| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903 |
- using BizCom;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using NHibernate.Linq;
- using NHibernate.Mapping;
- using NPOI.OpenXmlFormats.Dml.Diagram;
- using NPOI.OpenXmlFormats.Shared;
- using NPOI.SS.Formula.Eval;
- using NPOI.SS.Formula.Functions;
- using NPOI.SS.Formula.Udf;
- using SiteCore.Redis;
- using SiteCore.taobao;
- using SiteCore.taoObj;
- using SQLData;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel.Design;
- using System.Data;
- using System.Data.SqlClient;
- using System.Data.SqlTypes;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Security;
- using System.Reflection.Emit;
- using System.Security.Cryptography;
- using System.Security.Cryptography.X509Certificates;
- using System.Security.Policy;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Web.UI;
- using System.Web;
- using System.Web.UI.WebControls;
- using Utils;
- using Utils.Serialization;
- using static NHibernate.Linq.Visitors.LeftJoinDetector;
- using static SiteCore.taoObj.Api_trade_info;
- using static SiteCore.taoObj.Api_waybill_code_response_Obj;
- using static SiteCore.taoObj.work_core_vo;
- using static System.Net.Mime.MediaTypeNames;
- using System.Runtime.Remoting.Metadata.W3cXsd2001;
- using NPOI.Util;
- using static NPOI.HSSF.Util.HSSFColor;
- using BizCom.Enum;
- namespace SiteCore.Handler
- {
- public partial class sync
- {
- public void get_erp_orderlist()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- DataStruct dStruct = GetPostStruct();
- //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
- //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\水标售价(1).xlsx");
- //apiHelper.Api_SyncOrderByTime("598825");
- //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
- //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
- //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
- //banniuApiHelper.sendLogisticsInfo(null);
- //commonHelper.setOrderDummyDelivery("4055992920657411904");
- //commonHelper.checkOrderListDesignInfo("1111122222333338841");
- //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
- //int sid = commonHelper.autoDistributeToSupplier(entity);
- // string a = apiHelper.API_GetPrintData("YT8951457355085");
- //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1752654175000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1752826970000,\"lines\":[{\"latestDeliveryTime\":1752826970000,\"mark2\":[],\"num\":23,\"outerId\":\"DGCP\",\"payment\":460.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2200806677467/O1CN01Wlpmej251wOGAuYd2_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":20.0,\"refOlId\":\"4634728491992436446\",\"refSkuId\":\"0\",\"refSpuId\":\"617207822351\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":20.0,\"singleFee\":20.0,\"spuOuterId\":\"DGCP\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"蛋糕logo插牌定制烘焙店插卡插排生日小卡片装饰甜品标签插件设计\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1752658857000,\"openBuyerId\":\"AAHqRHraABkUZRPgSx1P9I8b\",\"openBuyerNick\":\"b**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1752654168000,\"payTime\":1752654170000,\"payment\":460.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"佛山市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"禅城区\",\"receiverId\":\"882d7aaecddc7a9698cc36e36a46ba24$\",\"receiverState\":\"广东省\",\"receiverTown\":\"石湾镇街道\",\"refOid\":\"4634728491992436446\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"60x12mm-2款各500张-插卡-350克铜板纸-直角单面烫金模切-bowie_s-英子-240元-(纯烫金)-老客户204.02.20,40x40mm-2000张-插卡-350克铜板纸-方形直角裁切-bowie_s-英子-220元--老客户2024.02.20\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0,\"type\":\"SALE\"}}");
- //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}}");
- //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
- //commonHelper.loginGetOrder(2152);
- //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
- //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- //12-1 修改
- string urgent = GetPostString("urgent");
- string back = GetPostString("back");
- string offlineSearch = GetPostString("offlineSearch");
- int paramsCount = 0;
- if (!string.IsNullOrWhiteSpace(urgent))
- {
- if (urgent.Equals("true"))
- {
- lw.Add(string.Format("(IsUrgency='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(back))
- {
- if (back.Equals("true"))
- {
- lw.Add(string.Format("(IsReturn='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(offlineSearch))
- {
- if (offlineSearch.Equals("true"))
- {
- lw.Add(string.Format("(ctid like '{0}%')", "N"));
- }
- }
- //end
- string date2 = GetPostString("date2");
- string buyernick = GetPostString("buyer_nick");
- if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
- {
- if (tid.Length <= 0 && buyernick.Length <= 0)
- {
- return;
- }
- }
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
- if (ceErpTradeCell != null)
- {
- tid = ceErpTradeCell.tid;
- }
- List<string> select_tid = getTidByCtidMore(tid);
- lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
- }
- if (buyernick.Length > 0)
- {
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- }
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0)
- {
- lw.Add(dw);
- }
- if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
- {
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("ShopId in ({0})", usershop));
- }
- }
- else
- {
- if (ex_psize == 0)
- {
- lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
- }
- if (PKey != "admin" && poscode != "SysAdmin")
- {
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("ShopId in ({0})", usershop));
- paramsCount++;
- }
- }
- string uploaddate1 = GetPostString("uploaddate1");
- string uploaddate2 = GetPostString("uploaddate2");
- string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
- if (update.Length > 0) lw.Add(update);
- string deliverydate1 = GetPostString("deliverydate1");
- string deliverydate2 = GetPostString("deliverydate2");
- string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
- if (deliverydate.Length > 0)
- {
- lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
- };
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string addwechat = GetPostString("addwechat");
- if (addwechat.Length > 0)
- {
- int addWt = Convert.ToInt32(addwechat);
- if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
- else lw.Add(string.Format("IsAddWechat={0}", addWt));
- }
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string backReason = GetPostString("backReason");
- if (backReason.Length > 0)
- {
- lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
- }
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string isoldcustomer = GetPostString("isoldcus");
- string spudata = GetPostString("spudata");
- if ("0".Equals(spudata))
- {
- lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
- }
- if ("1".Equals(spudata))
- {
- lw.Add(string.Format("spu_id <> ''"));
- }
- string finishdate1 = GetPostString("finishdate1");
- string finishdate2 = GetPostString("finishdate2");
- string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
- bool isFinish = false;
- if (finishdate.Length > 0)
- {
- lw.Add(finishdate);
- isFinish = true;
- paramsCount++;
- }
- if (isoldcustomer.Length > 0)
- {
- if ("2".Equals(isoldcustomer))
- {
- lw.Add(string.Format("VipCustomer=1"));
- }
- else
- {
- lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
- }
- }
- if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- if (ex_psize > 0)
- {
- int UserID = CurrentUser.UserID;
- if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
- UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
- }
- dStruct.Order = "pay_time desc";
- }
- string isNew = GetPostString("isNew");
- if (isNew == "true")
- {
- lw.Add(string.Format("IsNew = {0}", 1));
- }
- string overtime = GetPostString("overtime");
- if (overtime == "1")
- {
- lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
- }
- String usePost = CurrentUser.UserPost.Post.Code;
- if (usePost.Equals("Operation") == true)
- {
- dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
- }
- else
- {
- dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
- }
- //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";
- if (dStruct.PageSize == 100000)
- {
- dStruct.Order = "";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- string tablename = "view_orderlist";
- if (isFinish)
- {
- tablename = "view_orderlist_end";
- }
- dt = WebCache.GetData(tablename, dStruct);
- if (dt != null && dt.Rows.Count > 0)
- {
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- if (dr["refund_fees"] != null)
- {
- decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
- decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
- decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
- if (payment == refund_fees)
- {
- dr["refund_fees"] = Math.Round(refund_fees, 2);
- }
- else if (refund_fees == total_fee)
- {
- dr["refund_fees"] = payment;
- }
- else
- {
- decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
- decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
- dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
- }
- }
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else if ("外协".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = 200;
- }
- else if ("内部".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = -1;
- }
- else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- // 处理空引用异常
- dr["refund_fees"] = "0.00";
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_orderlist_sumprice()
- {
- returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
- return;
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- if (tid.Length > 0 || date1.Length > 0)
- {
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string isoldcustomer = GetPostString("isoldcus");
- if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
- if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- if (PKey != "admin")
- {
- string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", usershop));
- }
- //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";
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
- DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
- DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
- decimal total = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
- }
- var res = new
- {
- data = total
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_CustomerServiceGather()
- {
- string userWhere = "", orderWhere = "";
- List<string> lw = new List<string>();
- string customer = GetPostString("customer");
- if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- orderWhere = string.Join(" and ", lw.ToArray());
- 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 " +
- "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
- "left join " +
- "( " +
- " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
- ") as b on a.ID = b.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
- ") as d on a.ID = d.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
- ") as e on a.ID = e.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, RefundCount, RefundSum from " +
- " ( " +
- " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
- " from CE_ErpTradeRefund a " +
- " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
- " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
- " group by CustomerUserId " +
- " ) as a " +
- ") as f on a.ID = f.CustomerUserId " +
- "where a.PostCode = 'CustomerService'",
- userWhere, orderWhere);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- //writeGridDataTableJson(dt.Rows.Count, dt);
- }
- //设计汇总
- public void get_erp_DesignerGather()
- {
- string userWhere = "", orderWhere = "";
- List<string> lw = new List<string>();
- string Designer = GetPostString("designer");
- int org = GetPostInt("org");
- if (Designer.Length > 0)
- {
- userWhere = string.Format(" where Name like '%{0}%'", Designer);
- if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
- }
- else if (org > 0)
- {
- userWhere = string.Format(" where OrgID ={0}", org);
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string state = GetPostString("state");
- if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string UpDate1 = GetPostString("UpDate1");
- string UpDate2 = GetPostString("UpDate2");
- dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
- if (dw.Length > 0) lw.Add(dw);
- orderWhere = string.Join(" and ", lw.ToArray());
- 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 (" +
- "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 " +
- "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
- "left join " +
- "( " +
- " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
- ") as b on a.ID = b.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as d on a.ID = d.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as e on a.ID = e.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as g on a.ID = g.DesignUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, RefundCount, RefundSum from " +
- " ( " +
- " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
- " from CE_ErpTradeRefund a " +
- " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
- " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
- " group by CustomerUserId " +
- " ) as a " +
- ") as f on a.ID = f.CustomerUserId " +
- "where a.PostCode = 'Designer') as z",
- userWhere, orderWhere);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- //删除tradecell的订单
- public void del_erp_cellorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell.DelByCtid(eid);
- LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
- returnSuccessMsg("删除成功");
- }
- }
- public void clear_erp_refundstate()
- {
- if (UrlPostParmsCheck("ids"))
- {
- string eids = GetPostString("ids");
- string[] ctidList = eids.Split(',');
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.IsRefund = 0;
- entity.Update();
- LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
- }
- else
- continue;
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("缺少必要参数");
- }
- public void set_erp_urgency()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- double prices = commonHelper.calculationPrice(entity);
- if (prices <= 100)
- {
- returnErrorMsg("此订单金额不足100元,无法加急。");
- return;
- }
- string utime = GetPostString("urgencytime");
- if (utime.Length > 0)
- {
- entity.UrgencyTime = Convert.ToDateTime(utime);
- }
- else
- {
- returnErrorMsg("请选择加急时间");
- return;
- }
- if (entity.OrderState <= 4)
- {
- //entity.seller_memo = entity.seller_memo + "-加急";
- string smemo = entity.seller_memo;
- int kindex = smemo.IndexOf(")");
- string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
- if (lastoneStr != "-")
- {
- smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
- }
- string prememo = smemo.Substring(0, kindex + 2);
- string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
- int lastkindex = lastmemo.IndexOf("(");
- DateTime urgtime = Convert.ToDateTime(utime);
- string newlastmemo = "";
- if (lastkindex == 0)
- {
- string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
- newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
- }
- else
- {
- newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
- }
- entity.seller_memo = prememo + newlastmemo;
- }
- entity.IsUrgency = true;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "changeDesign";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.remarkSign = 3;
- designHelper.API_WorkCore(apiVo); //changeDesign
- CeErpSukuraData.createInfo(entity.ctid, 7);
- LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
- returnSuccessMsg("设置成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void set_erp_reset()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
- {
- if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
- {
- returnErrorMsg("财务要求已下单已发货无法重置");
- return;
- }
- }
- entity.IsUrgency = false;
- entity.seller_memo = "";
- entity.OtherMemo = "";
- entity.OrderState = 0;
- entity.IsReturn = 0;
- //entity.IsRefund = 0;
- entity.MemoOpt = 0;
- entity.AfterSaleState = 0;
- entity.AfterSaleResponsible = "";
- entity.AfterSaleUserId = 0;
- entity.IsNeedBill = 0;
- entity.CustomerUserId = 0;
- entity.DesignUserId = 0;
- entity.SupplierId = 0;
- entity.PlaceUserId = 0;
- entity.ptid = "";
- entity.IsSample = 0;
- entity.IsXianHuo = 0;
- entity.isDianziOrder = 0;
- entity.DispatchSort = 0;
- entity.IsVerifyToSupplier = false;
- entity.FinishPlaceTime = null;
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- trade.seller_memo = "";
- trade.Update();
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
- returnSuccessMsg("重置成功!");
- CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
- if (desginBill != null)
- {
- desginBill.isDel = 1;
- desginBill.Update();
- LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "resetDesign";
- designHelper.API_WorkCore(apiVo);//resetDesign
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_sellermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- string memo = GetPostString("seller_memo");
- memo = memo.Replace(" ", "");
- if (memo.Contains("补差"))
- {
- returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
- return;
- }
- List<string> bitList = new List<string>
- {
- "\\","/",":","*","?", "\"","<" ,">","|"
- };
- bool isIn = false;
- foreach (string bit in bitList)
- {
- if (memo.Contains(bit))
- {
- isIn = true;
- }
- }
- if (isIn)
- {
- returnErrorMsg("不能使用 一些符合作为文件名");
- return;
- }
- if (entity.seller_memo != memo)
- {
- if (entity.IsSample == 2)
- {
- returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
- return;
- }
- if (CurrentUser.UserPost.Post.Code != "SysAdmin")
- {
- if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
- {
- returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
- return;
- }
- /*if (CurrentUser.UserPost.Post.Code != "Place")
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
- {
- returnErrorMsg("售前系统订单无法再此修改!");
- return;
- }
- }*/
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
- }
- commonHelper.getCytPrice(entity);
- int memoopt = GetPostInt("MemoOpt");
- Boolean ismemoopt = false;
- if (memoopt > 0)
- {
- string stropt = "";
- if (memoopt == 1)
- {
- stropt = "“改稿”";
- ismemoopt = true;
- }
- else if (memoopt == 2)
- {
- stropt = "“定稿”";
- }
- else if (memoopt == 3)
- {
- stropt = "“查货”";
- CeErpSukuraData.createInfo(entity.ctid, 6);
- }
- entity.MemoOpt = Convert.ToInt32(memoopt);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
- }
- if (entity.OrderState < 5)
- {
- memo = memo.Replace("(", "(");
- memo = memo.Replace(")", ")");
- }
- if (entity.OrderState < 3)
- {
- entity.DispatchSort = 0;
- }
- entity.seller_memo = memo;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
- apiVo.orderRemarks = memo;
- apiVo.remarkSign = memoopt;
- designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
- {
- dataHelper.api_orderBack(entity.ctid, "0", "");
- }
- if (entity.seller_memo.Contains("改稿"))
- {
- commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
- }
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_checkorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if (entity.OrderState < 6)
- {
- returnErrorMsg("下单完成后才可查货");
- return;
- }
- /*if (entity.OrderState > 6)
- {
- returnErrorMsg("订单已发货");
- return;
- }*/
- if (entity.FinishPlaceTime != null)
- {
- if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
- {
- returnErrorMsg("下单时间不足,无法查货");
- return;
- }
- }
- entity.MemoOpt = 3;
- entity.CheckOrderTime = DateTime.Now;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 6);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_othermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.OtherMemo = GetPostString("otherMemo");
- if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
- {
- //品类一直
- entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
- CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
- if (ceErpSampleCustomer == null)
- {
- ceErpSampleCustomer = new CeErpSampleCustomer();
- ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
- ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
- ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
- ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
- ceErpSampleCustomer.shopId = entity.ShopId;
- }
- ceErpSampleCustomer.lastbuy_time = entity.pay_time;
- ceErpSampleCustomer.lastTid = entity.tid;
- if (ceErpSampleCustomer.ID > 0)
- {
- ceErpSampleCustomer.Update();
- }
- else
- {
- ceErpSampleCustomer.Create();
- }
- }
- }
- }
- }
- //if (entity.IsOldCustomer == 1)
- //{
- //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
- //{
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
- //}
- //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
- //{
- // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
- // {
- // if (entity.OtherMemo.IndexOf("改稿") > -1)
- // {
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
- // }
- // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
- // {
- // entity.OrderState = 2;
- // entity.DesignUserId = 0;
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
- // }
- // else
- // {
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
- // }
- // }
- //}
- //}
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("保存成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (entity.OtherMemo.Contains("改稿"))
- {
- commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
- }
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_customermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.UpdateTime = DateTime.Now;
- entity.CustomerMemo = GetPostString("CustomerMemo");
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "followRemarks";
- apiVo.orderRemarks = entity.CustomerMemo;
- designHelper.API_WorkCore(apiVo);//followRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_addmemotag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- string sfTagstr = GetPostString("memotag");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- ApiVo apiVo = new ApiVo();
- if (entity.OrderState == 0)
- {
- returnErrorMsg("请先领单");
- return;
- }
- //撤销顺丰
- if (sfTagstr == "撤销顺丰")
- {
- entity.IsSF = 0;
- string reMsg = "";
- string oldmemo = entity.seller_memo;
- if (entity.OrderState < 5)
- {
- oldmemo = oldmemo.Replace("顺丰到付", "");
- oldmemo = oldmemo.Replace("顺丰寄付", "");
- entity.seller_memo = oldmemo;
- }
- else
- {
- if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
- {
- reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
- }
- }
- entity.Update();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "orderRemarks";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.isSf = entity.IsSF.ToString();
- designHelper.API_WorkCore(apiVo);//orderRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
- returnSuccessMsg("撤销成功!" + reMsg);
- return;
- }
- if (entity.OrderState < 5 || entity.IsXianHuo == 1)
- {
- //string oldmemo = entity.seller_memo;
- //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
- string sfStr = GetPostString("memotag");
- string smemo = entity.seller_memo;
- int kindex = smemo.IndexOf(")");
- string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
- if (lastoneStr != "-")
- {
- smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
- }
- string prememo = smemo.Substring(0, kindex + 2);
- string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
- int lastkindex = lastmemo.IndexOf("(");
- string newlastmemo = "";
- if (lastkindex == 0)
- {
- string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
- newlastmemo = "(" + sfStr + "." + useLastmemo;
- }
- else
- {
- newlastmemo = "(" + sfStr + ")-" + lastmemo;
- }
- entity.seller_memo = prememo + newlastmemo;
- }
- string sfTagMSg = "";
- if (sfTagstr == "顺丰寄付")
- {
- entity.IsSF = 1;
- sfTagMSg = "顺丰寄付";
- }
- else if (sfTagstr == "顺丰到付")
- {
- entity.IsSF = 2;
- sfTagMSg = "顺丰到付";
- }
- entity.Update();
- apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "orderRemarks";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.isSf = entity.IsSF.ToString();
- designHelper.API_WorkCore(apiVo);//orderRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_ordertag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- int tag = GetPostInt("wechattag");
- //if(tag==4 && entity.IsSample == 2)
- //{
- // returnErrorMsg("补差价单不能标记微信单");
- // return;
- //}
- entity.wechatTag = tag;
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (tag == 1)
- {
- CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
- if (cash == null)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- cash = new CeErpReturnCash();
- cash.tid = entity.tid;
- cash.seller_nick = main.seller_nick;
- cash.payment = trade.payment;
- cash.buyer_nick = main.buyer_nick;
- cash.cashstate = 0;
- cash.rtype = "微信返现";
- cash.returnprice = 0;
- cash.created = DateTime.Now;
- cash.con = "订单标记微信单";
- cash.img = "";
- cash.applyuserid = CurrentUser.UserID;
- cash.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
- }
- else
- {
- cash.cashstate = 0;
- cash.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 9);
- }
- else if (tag == 2)
- {
- CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
- if (cash == null)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- cash = new CeErpReturnCash();
- cash.tid = entity.tid;
- cash.seller_nick = main.seller_nick;
- cash.payment = trade.payment;
- cash.buyer_nick = main.buyer_nick;
- cash.cashstate = 0;
- cash.rtype = "推购返现";
- cash.returnprice = 5;
- cash.created = DateTime.Now;
- cash.con = "订单标记推购单";
- cash.img = "";
- cash.applyuserid = CurrentUser.UserID;
- cash.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
- }
- else
- {
- cash.cashstate = 0;
- cash.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 9);
- }
- else if (tag == 3)
- {
- CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
- if (pers == null)
- {
- pers = new CeErpPersuade();
- pers.ctid = entity.ctid;
- pers.pstate = 0;
- pers.created = DateTime.Now;
- pers.applyuserid = CurrentUser.UserID;
- pers.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
- }
- else
- {
- pers.pstate = 0;
- pers.Update();
- }
- }
- else if (tag == 4 || tag == 5)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
- if (pers == null)
- {
- pers = CeErpStayGoods.GetByTid(entity.tid);
- }
- if (pers == null)
- {
- pers = new CeErpStayGoods();
- pers.t_id = entity.tid;
- pers.ctid = entity.ctid;
- pers.status = "待审核";
- pers.audit_type = 0;
- if (tag == 4)
- {
- pers.stay_type = "微信推购";
- }
- else
- {
- pers.stay_type = "旺旺推购";
- }
- if (entity.IsXianHuo == 0)
- {
- pers.product_id = entity.ProductId;
- }
- pers.wangwang = main.buyer_nick;
- pers.shop_name = main.seller_nick;
- pers.creata_time = DateTime.Now;
- pers.create_u_id = CurrentUser.UserID;
- pers.create_u_name = CurrentUser.UserName;
- pers.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
- }
- else
- {
- pers.ctid = entity.ctid;
- pers.audit_type = 0;
- pers.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 10);
- }
- //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_ordertag_cancel()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.wechatTag = 0;
- entity.Update();
- CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
- if (pers != null)
- {
- pers.status = "取消推购";
- pers.audit_type = 3;
- pers.Update();
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_addweichattag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsAddWechat > 0)
- {
- returnErrorMsg("此单已经标记过了");
- return;
- }
- 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);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- entity.IsAddWechat = 2;
- }
- else
- {
- entity.IsAddWechat = 1;
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_getmyorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- CeErpTrade father = CeErpTrade.Get(entity.tid);
- if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
- {
- returnErrorMsg("台湾客户需填写身份证号!");
- return;
- }
- if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
- {
- returnErrorMsg("偏远地区需要填写物流费!");
- return;
- }
- if (entity != null)
- {
- if (entity.ctid.IndexOf("C") != -1)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- decimal total = 0;
- foreach (DataRow dr in dt.Rows)
- {
- total += Convert.ToDecimal(dr["payment"]);
- }
- decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
- if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
- {
- returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
- return;
- }
- }
- }
- if (entity.OrderState == -1)
- {
- returnErrorMsg("待审核订单无法领取!");
- return;
- }
- entity.CustomerUserId = CurrentUser.UserID;
- if (entity.OrderState < 2)
- {
- entity.OrderState = 2;
- if (entity.ShopId != 0)
- {
- entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
- }
- }
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
- {
- dataHelper.api_orderBack(entity.ctid, "0", "");
- }
- returnSuccessMsg("领单成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void getmyorder_from_init()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string sellerMemo = GetPostString("sellerMemo");
- if (sellerMemo.Length > 0)
- {
- entity.seller_memo = sellerMemo;
- }
- string oterhMemo = GetPostString("otherMemo");
- if (oterhMemo.Length > 0)
- {
- entity.OtherMemo = oterhMemo;
- }
- int urg = GetPostInt("urgency");
- entity.IsUrgency = (urg == 1 ? true : false);
- int wechat = GetPostInt("wechat");
- int command = GetPostInt("command");
- if (wechat == 1)
- {
- entity.wechatTag = 1;
- }
- if (command == 1)
- {
- entity.wechatTag = 2;
- }
- string pPro = GetPostString("pprofession");
- if (pPro.Length > 0)
- {
- entity.ParentProfessionId = Convert.ToInt32(pPro);
- string spro = GetPostString("profession");
- if (spro.Length > 0)
- {
- entity.ProfessionId = Convert.ToInt32(spro);
- }
- }
- string proId = GetPostString("productId");
- if (proId.Length > 0)
- {
- entity.ProductId = Convert.ToInt32(proId);
- }
- entity.Material = GetPostString("material");
- entity.Craft = GetPostString("craft");
- entity.CustomerUserId = CurrentUser.UserID;
- if (entity.OrderState < 2)
- {
- entity.OrderState = 2;
- if (entity.ShopId != 0)
- {
- entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
- returnSuccessMsg("领单成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_setrelationorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- string ftid = GetPostString("ftid");
- CeErpTradeCell entity = null;
- CeErpTradeCell fentity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
- if (fentity == null)
- {
- returnErrorMsg("找不到关联的主订单");
- return;
- }
- if (entity != null)
- {
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("本单已经设计完成无法关联");
- return;
- }
- if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
- {
- returnErrorMsg("线下单续审核后才能关联!");
- return;
- }
- entity.ptid = ftid;
- entity.OrderState = fentity.OrderState;
- //entity.status = fentity.status;
- entity.CustomerUserId = fentity.CustomerUserId;
- entity.DesignUserId = fentity.DesignUserId;
- entity.seller_memo = "补差价单:" + ftid;
- entity.IsSample = 2;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ftid;
- apiVo.payment = entity.payment;
- apiVo.actionName = "repairDesign";
- designHelper.API_WorkCore(apiVo);//repairDesign
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
- returnSuccessMsg("关联成功!");
- return;
- }
- else
- returnErrorMsg("找不到记录");
- }
- }
- public void download_erp_neworder()
- {
- string seller = GetPostString("seller_nick");
- string tid = GetPostString("tid");
- if (seller.Length <= 0 || tid.Length <= 0)
- {
- returnErrorMsg("数据错误");
- }
- //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
- //{
- // returnErrorMsg("找不到店铺Sessionkey");
- //}
- //string sessionkey = taobaoHelper.ShopKeyDics[seller];
- //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
- string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
- if (res.IndexOf("refOid") == -1)
- {
- returnErrorMsg("下载订单数据失败");
- return;
- }
- tmcHelper.Api_Tmc_CreateNewOrder(res);
- returnSuccessMsg("下载完成");
- //tmcHelper.createNewOrder(res);
- //CeErpTrade entr = null;
- //entr = CeErpTrade.Get(tid);
- //if (entr != null)
- //{
- // returnSuccess("下载成功");
- // //下载成功之后,Cell表生成对应的订单;
- // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
- //}
- //else
- //{
- // returnErrorMsg("下载失败或者创建订单失败");
- //}
- }
- public void set_erp_atersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("AfterSaleReason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
- {
- returnErrorMsg("此订单已经在售后");
- return;
- }
- entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
- entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
- entity.AfterSaleTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
- returnSuccessMsg("转售后成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void set_erp_withdraw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- try
- {
- string eid = GetPostString("ctid");//商品id
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
- CeWithdraw ceWithdrawSelect = null;
- ceWithdrawSelect = CeWithdraw.GetByTid(eid);
- if (ceWithdrawSelect != null)
- {
- if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
- {
- ceWithdrawSelect.status = -1;
- ceWithdrawSelect.Update();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
- returnSuccessMsg("重新发起审核成功");
- return;
- }
- else
- {
- returnSuccessMsg("请勿重复申请!");
- return;
- }
- }
- else
- {
- string CustomerUserId = GetPostString("CustomerUserId");//供应商id
- if (string.IsNullOrEmpty(CustomerUserId))
- {
- CustomerUserId = "-1";
- }
- int Userid = CurrentUser.UserID;//用户id
- CeWithdraw ceWithdraw = new CeWithdraw();
- ceWithdraw.tid = eid;
- ceWithdraw.userid = Userid;
- ceWithdraw.providerid = CustomerUserId;
- ceWithdraw.status = 3;
- ceWithdraw.creationtime = DateTime.Now;
- ceWithdraw.Create();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
- returnSuccessMsg("申请撤回订单成功,待车间确认");
- return;
- }
- }
- catch
- {
- returnErrorMsg("申请撤回订单失败");
- return;
- }
- }
- }
- public void ins_erp_billinfo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpBill bill = CeErpBill.GetByTid(eid);
- bool isHave = false;
- if (bill != null)
- {
- isHave = true;
- if (bill.state != 4)
- {
- returnErrorMsg("此单已经申请过发票了");
- return;
- }
- }
- if (entity.IsNeedBill == 0)
- {
- entity.IsNeedBill = 1;
- }
- entity.Update();
- string errjson = "";
- try
- {
- CeErpBill bill_entity = new CeErpBill();
- bill_entity.tid = entity.tid;
- bill_entity.title = GetPostString("title");
- string taxstr = GetPostString("tax");
- taxstr = taxstr.Replace(" ", "");
- bill_entity.tax = taxstr;
- bill_entity.bank = GetPostString("bank");
- string bankacstr = GetPostString("bankac");
- bankacstr = bankacstr.Replace(" ", "");
- bill_entity.bankac = bankacstr;
- bill_entity.address = GetPostString("address");
- bill_entity.phone = GetPostString("phone");
- bill_entity.price = GetPostString("price");
- int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
- if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
- {
- billCount += 1;
- }
- string prebill = "ltb";
- for (int idx = 1; idx <= billCount; idx++)
- {
- string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
- string billoid = prebill + idx + dtstr;
- bill_entity.billOrderId += billoid;
- if (idx < billCount)
- {
- bill_entity.billOrderId += ",";
- }
- }
- bill_entity.productId = GetPostInt("ProductName");
- bill_entity.num = GetPostInt("num");
- bill_entity.unit = GetPostString("unit");
- bill_entity.type = GetPostString("type");
- bill_entity.sendType = GetPostString("SendType");
- bill_entity.email = GetPostString("email");
- bill_entity.buyer_nick = GetPostString("buyer_nick");
- bill_entity.shopName = GetPostString("ShopName");
- bill_entity.applymemo = GetPostString("applyMemo");
- bill_entity.createTime = DateTime.Now;
- bill_entity.state = 0;
- bill_entity.userId = CurrentUser.UserID;
- errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
- bill_entity.Create();
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
- returnErrorMsg("创建发票出错!");
- return;
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
- returnSuccessMsg("发票申请成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_neworder()
- {
- if (UrlPostParmsCheck("receiver_name"))
- {
- CeErpTrade entity = new CeErpTrade();
- string plat_form = GetPostString("platform");
- string preStr = "N_";
- if (plat_form == "拼多多")
- {
- preStr = "P_";
- }
- else if (plat_form == "阿里巴巴")
- {
- preStr = "A_";
- }
- entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
- entity.seller_nick = GetPostString("seller_nick");
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.payment = Convert.ToDouble(GetPostString("payment"));
- entity.total_fee = entity.payment;
- entity.pay_time = DateTime.Now;
- entity.status = "NOT_SHIPPED";
- entity.receiver_name = GetPostString("receiver_name");
- entity.receiver_mobile = GetPostString("receiver_mobile");
- entity.receiver_state = GetPostString("receiver_state");
- entity.receiver_city = GetPostString("receiver_city");
- entity.receiver_district = GetPostString("receiver_district");
- entity.receiver_address = GetPostString("receiver_address");
- if (entity.receiver_state == "" || entity.receiver_city == "")
- {
- returnErrorMsg("收件地址不能为空");
- return;
- }
- int shopId = 0;
- CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
- if (nShop != null)
- {
- shopId = nShop.ID;
- }
- if (shopId != 34 && entity.payment == 0)
- {
- returnErrorMsg("公司自用的单金额才能为0");
- return;
- }
- entity.Create();
- CeErpTradeCell entitycell = new CeErpTradeCell();
- entitycell.ctid = entity.tid;
- entitycell.tid = entity.tid;
- entitycell.ShopId = shopId;
- entitycell.payment = Convert.ToDouble(GetPostString("payment"));
- entitycell.OrderState = 0;
- entitycell.pay_time = entity.pay_time;
- entitycell.IsOffLineOrder = 1;
- entitycell.Create();
- returnSuccessMsg("订单已生成!单号:" + entity.tid);
- LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
- return;
- }
- }
- public void ins_erp_neworder2()
- {
- if (UrlPostParmsCheck("receiver_name"))
- {
- //string plat_form = GetPostString("platform");
- string preStr = "X_";
- string memo = GetPostString("memo");
- string productId = GetPostString("productId");
- string primg = GetPostString("proofimg");
- string sellerNick = GetPostString("seller_nick");
- string addFrom = GetPostString("addfrom");
- if (addFrom == "1")
- {
- preStr = "N_";
- }
- int shopId = 0;
- CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
- if (nShop != null)
- {
- shopId = nShop.ID;
- }
- else
- {
- returnErrorMsg("找不到对应店铺");
- return;
- }
- if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
- {
- returnErrorMsg("必须上传付款凭证");
- return;
- }
- CeErpTrade entity = new CeErpTrade();
- entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
- entity.seller_nick = sellerNick;
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.payment = Convert.ToDouble(GetPostString("payment"));
- entity.total_fee = entity.payment;
- entity.pay_time = DateTime.Now;
- entity.status = "NOT_SHIPPED";
- entity.receiver_name = GetPostString("receiver_name");
- entity.receiver_mobile = GetPostString("receiver_mobile");
- entity.receiver_state = GetPostString("receiver_state");
- entity.receiver_city = GetPostString("receiver_city");
- entity.receiver_district = GetPostString("receiver_district");
- entity.receiver_address = GetPostString("receiver_address");
- entity.seller_memo = memo;
- entity.orderFrom = 20;
- entity.orderType = 15;
- if (entity.receiver_state == "" || entity.receiver_city == "")
- {
- returnErrorMsg("收件地址不能为空");
- return;
- }
- if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
- {
- returnErrorMsg("公司自用的单金额才能为0");
- return;
- }
- entity.Create();
- string toWhere = GetPostString("towhere");
- CeErpTradeCell entitycell = new CeErpTradeCell();
- entitycell.ctid = entity.tid;
- //唯一标识
- entitycell.OrderSn = entity.tid;
- string orderSn = dataHelper.getSaleOrderSn();
- if (orderSn != "")
- {
- entitycell.OrderSn = orderSn;
- }
- entitycell.tid = entity.tid;
- //if (preStr == "X_")
- //{
- entitycell.IsOffLineOrder = 1;
- //}
- entitycell.CustomerUserId = CurrentUser.UserID;
- entitycell.PayProofImg = primg;
- entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
- entitycell.ProductId = Convert.ToInt32(productId);
- entitycell.ShopId = shopId;
- entitycell.UpdateTime = DateTime.Now;
- entitycell.payment = Convert.ToDouble(GetPostString("payment"));
- if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
- {
- entitycell.IsXianHuo = 1;
- }
- entitycell.pay_time = entity.pay_time;
- if (toWhere == "1")
- {
- entitycell.OrderState = 2;
- }
- else
- {
- entitycell.OrderState = 6;
- entitycell.FinishPlaceTime = entitycell.pay_time;
- }
- if (shopId == 94)
- {
- entitycell.OrderState = 4;
- entitycell.WaitDesignTime = entitycell.pay_time;
- entitycell.StartDesignTime = entitycell.pay_time;
- entitycell.DesignUserId = 218;
- }
- if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
- {
- entitycell.OrderState = -1;//修改12-5
- CeWithdraw ceWithdraw = new CeWithdraw();
- ceWithdraw.tid = entity.tid;
- ceWithdraw.providerid = "-1";
- ceWithdraw.status = -1;
- ceWithdraw.creationtime = DateTime.Now;
- ceWithdraw.userid = 1337;
- ceWithdraw.Create();
- }
- entitycell.Create();
- CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
- if (shopId == 34 && entity.buyer_nick == "现货手提袋")
- {
- addPlaceRegist(entitycell, CurrentUser.UserID);
- }
- returnSuccessMsg("订单已生成!单号:" + entity.tid);
- LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
- return;
- }
- }
- public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
- {
- CeErpPlaceRegister entity = new CeErpPlaceRegister();
- entity.PlactTime = tradecell.pay_time;
- entity.AddUserId = userid;
- entity.FileName = tradecell.seller_memo;
- entity.Supplier = 24;
- entity.CreateTime = DateTime.Now;
- entity.Did = tradecell.ctid;
- entity.tid = tradecell.tid;
- entity.splitTag = tradecell.SplitTag;
- entity.CurState = "未完成";
- entity.Create();
- }
- public void get_erp_offlinelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- if (tid.Length > 0 || date1.Length > 0)
- {
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //if (PKey != "admin")
- //{
- // string usershop = CurrentUser.User.pemShop;
- // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
- //}
- //if (ex_psize > 0)
- //{
- dStruct.Order = "pay_time desc";
- //}
- //else
- // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
- lw.Add(string.Format("IsOffLineOrder=1"));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_returncashrecord()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("tid like '%{0}%'", tid));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
- //writeGridDataTableJson(dStruct.TotalCount, dt);
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- return;
- }
- returnErrorMsg("id数据错误!");
- }
- public void ins_erp_returncashrecord()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string tid = GetPostString("tid");
- string retype = GetPostString("type");
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnErrorMsg("相同返现类型记录已存在");
- return;
- }
- CeErpReturnCash entity = new CeErpReturnCash();
- entity.tid = tid;
- entity.seller_nick = GetPostString("seller_nick");
- string pment = GetPostString("payment");
- if (pment.Length > 0)
- {
- entity.payment = Convert.ToDouble(pment);
- }
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.cashstate = 0;
- entity.rtype = retype;
- string rPrice = GetPostString("returnprice");
- if (rPrice.Length > 0)
- {
- entity.returnprice = Convert.ToDouble(rPrice);
- }
- entity.created = DateTime.Now;
- entity.con = GetPostString("con");
- entity.img = GetPostString("img");
- entity.applyuserid = CurrentUser.UserID;
- entity.Create();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void set_erp_predelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
- //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
- //{
- // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
- // return;
- //}
- entity.IsPreDelivery = 1;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
- returnSuccessMsg("预发货成功!");
- return;
- //string shop = GetPostString("seller_nick");
- ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
- //string comName = GetPostString("comName");
- //string comCode = GetPostString("comCode");
- //string outSid = GetPostString("outSid");//运单号
- //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
- //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
- ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
- //string apires = "";
- //if (deliveryType == "虚拟发货")
- //{
- // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
- //}
- //else
- //{
- // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
- //}
- ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
- ////{
- //if (apires.IndexOf("发货成功") != -1)
- //{
- // if (deliveryType != "虚拟发货")
- // {
- // //还要插入快递信息到 快递信息表
- // CeErpExpressInfo exinfo = new CeErpExpressInfo();
- // exinfo.tid = eid;
- // exinfo.out_sid = outSid;
- // exinfo.company_code = comCode;
- // exinfo.company_name = comName;
- // exinfo.delivery_memo = deliveryMemo;
- // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- // exinfo.deliveryType = deliveryType;
- // exinfo.Create();
- // }
- // returnSuccessMsg("发货成功!");
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
- //}
- //else
- //{
- // returnErrorMsg("淘宝发货失败!!");
- //}
- //return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_unusuallist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string ResponsibleMan = GetPostString("responsible");
- if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("UnusualTag > 0"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_unusualtonomal()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.UnusualTag = -1;
- entity.Update();
- returnSuccessMsg("忽略成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_unusualreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.MemoOpt = 4;
- entity.UnusualCon = GetPostString("con");
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
- }
- //查货是否超时
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = entity.ctid;
- }
- if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
- {
- ceErpTradeCellExtend.CheckOut += 1;
- }
- ceErpTradeCellExtend.CheckTime = DateTime.Now;
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Create();
- }
- CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_sampleorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string[] eArr = eid.Split(',');
- if (eArr.Length > 1)
- {
- List<string> eLst = new List<string>();
- for (int i = 0; i < eArr.Length; i++)
- {
- eLst.Add("'" + eArr[i] + "'");
- }
- eid = string.Join(",", eLst.ToArray());
- }
- else
- {
- eid = "'" + eid + "'";
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
- if (dt.Rows.Count > 0)
- {
- string errmsg = "";
- foreach (DataRow dr in dt.Rows)
- {
- StringBuilder sqlsb = new StringBuilder();
- sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
- sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
- string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
- if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
- {
- continue;
- }
- else
- {
- string emsg = commonHelper.KeepChinese(apires);
- errmsg += emsg;
- }
- }
- if (errmsg.Length > 0)
- {
- returnErrorMsg(errmsg);
- return;
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_transcustomer()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int userid = GetPostInt("CustomerUserId");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //string[] mlist = entity.seller_memo.Split('-');
- //string sql = "select * from view_erpuser where id=" + userid;
- //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //if (dt != null && dt.Rows.Count > 0)
- //{
- // string nmemo = "";
- // for(int i = 0; i < mlist.Length - 1; i++)
- // {
- // nmemo += mlist[i];
- // nmemo += "-";
- // }
- // nmemo+= dt.Rows[0]["Tb"].ToString();
- // entity.seller_memo = nmemo;
- //}
- entity.CustomerUserId = userid;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_transdesigner()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string[] ctidList = eids.Split(',');
- int userid = GetPostInt("DesignUserId");
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- entitys = CeErpDesignerBill.GetByTid(ctid);
- if (entity != null)
- {
- if (entity.OrderState > 4)
- {
- continue;
- }
- //存在退款不能流转
- if (entity.IsRefund > 0)
- {
- continue;
- }
- entity.DesignUserId = userid;
- entity.WaitDesignTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- }
- }
- public void upd_erp_distributedesigner()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int userid = GetPostInt("DesignUserId");
- string[] idlist = eid.Split(',');
- if (idlist.Length <= 0)
- {
- returnErrorMsg("订单不能为空");
- return;
- }
- foreach (string ctid in idlist)
- {
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- else continue;
- if (entity != null)
- {
- if (userid == 2125 || userid == 3542)
- { }
- if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
- {
- returnErrorMsg("金额错误的订单无法指派");
- return;
- }
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("已经设计完成无法指派");
- return;
- }
- if (entity.OrderState == -1)
- {
- returnErrorMsg("审核中的订单无法指派");
- return;
- }
- if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
- {
- returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
- return;
- }
- //157赖橙帆 159林晨 73 静之颖
- if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
- {
- returnErrorMsg("指派设计共创无法再次指派!");
- return;
- }
- entity.OrderState = 3;
- if (entity.SupplierId == 0)
- {
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- if (userid == 2125 && entity.seller_memo != "")
- {
- apiDesign.API_GetPrintData_CreateOrder(entity);
- }
- if (userid == 3542 && entity.seller_memo != "")
- {
- string userPost = CurrentUser.UserPost.Post.Code;
- if (CurrentUser.UserID == 73)
- {
- userPost = "SysAdmin";
- }
- designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
- LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
- if (response.msg != "设计共创:成功")
- {
- returnErrorMsg(response.msg);
- return;
- }
- entity.DispatchSort = 2;
- }
- else
- {
- if (entity.DispatchSort == 2)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.actionName = "closeDesign";
- apiVo.orderNumber = entity.ctid;
- designHelper.API_WorkCore(apiVo);//closeDesign
- }
- entity.DispatchSort = 0;
- }
- entity.DesignUserId = userid;
- entity.WaitDesignTime = DateTime.Now;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- string name = commonHelper.getUserNameById(userid);
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public string getTidByCtid(string ctid)
- {
- string tid = "";
- string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
- DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dataTable != null && dataTable.Rows.Count > 0)
- {
- tid = dataTable.Rows[0]["tid"].ToString();
- }
- return tid;
- }
- public List<string> getTidByCtidMore(string ctid)
- {
- string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
- DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- List<string> list = new List<string>();
- if (dataTable != null && dataTable.Rows.Count > 0)
- {
- foreach (DataRow item in dataTable.Rows)
- {
- list.Add("'" + item["tid"].ToString() + "'");
- }
- }
- return list;
- }
- public List<string> getTidByCtidLike(string ctid)
- {
- string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
- DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- List<string> list = new List<string>();
- if (dataTable != null && dataTable.Rows.Count > 0)
- {
- foreach (DataRow item in dataTable.Rows)
- {
- list.Add("'" + item["tid"].ToString() + "'");
- }
- }
- return list;
- }
- public List<string> getReceiverIdByCtidLike(List<string> tids)
- {
- string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
- DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- List<string> list = new List<string>();
- if (dataTable != null && dataTable.Rows.Count > 0)
- {
- foreach (DataRow item in dataTable.Rows)
- {
- if (string.IsNullOrEmpty(item["receiverId"].ToString()))
- {
- continue;
- }
- list.Add("'" + item["receiverId"].ToString() + "'");
- }
- }
- return list;
- }
- public void get_erp_myorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
- }
- //12-1 修改
- string urgent = GetPostString("urgent");
- string back = GetPostString("back");
- string offlineSearch = GetPostString("offlineSearch");
- if (!string.IsNullOrWhiteSpace(urgent))
- {
- if (urgent.Equals("true"))
- {
- lw.Add(string.Format("(IsUrgency='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(back))
- {
- if (back.Equals("true"))
- {
- lw.Add(string.Format("(IsReturn='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(offlineSearch))
- {
- if (offlineSearch.Equals("true"))
- {
- lw.Add(string.Format("(ctid like '{0}%')", "N"));
- }
- }
- //end
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string urgency = GetPostString("urgency");
- if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
- string after = GetPostString("after");
- if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
- lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else if ("外协".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = 200;
- }
- else if ("内部".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = -1;
- }
- else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_myreturnorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (CurrentUser.UserPost.Post.Code == "SysAdmin")
- {
- lw.Add(string.Format("CusOrgID = 94"));
- }
- else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
- {
- lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
- }
- else
- {
- lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
- }
- lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else if ("外协".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = 200;
- }
- else if ("内部".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = -1;
- }
- else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- // 处理空引用异常
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_myorderlist_pregather()
- {
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- int userId = CurrentUser.UserID; //客服id
- string orderWhere = "";
- List<string> lw = new List<string>();
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- lw.Add(string.Format("CustomerUserId={0}", userId));
- lw.Add(string.Format("OrderState<9"));
- orderWhere = string.Join(" and ", lw.ToArray());
- string orderWhere2 = "";
- List<string> lw2 = new List<string>();
- string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw2.Length > 0) lw2.Add(dw2);
- lw2.Add(string.Format("CustomerUserId={0}", userId));
- orderWhere2 = string.Join(" and ", lw2.ToArray());
- string sql = string.Format("select *" +
- "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
- "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 " +
- "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 " +
- "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");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //writeGridDataTableJson(dt.Rows.Count, dt);
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void upd_erp_publishorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 0; //发布后,变为待抢单
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
- returnSuccessMsg("发布成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_my_tiporder()
- {
- StringBuilder sql = new StringBuilder();
- int userId = 0;
- if (CurrentUser != null) userId = CurrentUser.UserID;
- string posCode = CurrentUser.UserPost.Post.Code;
- string isTipedAfterSaleVerify = GetPostString("af");
- DataTable dt = new DataTable();
- if (posCode != "Supplier")
- {
- if (posCode == "CustomerService" || posCode == "Director")
- {
- sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
- }
- else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
- {
- sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
- }
- else
- {
- string teamIds = CurrentUser.User.TeamIds;
- if (teamIds == "")
- {
- teamIds = "0";
- }
- 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);
- }
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- if (dt.Rows.Count <= 0)
- {
- string key = "aftersale_order_" + userId;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- dt.Columns.Add("ctid", typeof(string));
- dt.Columns.Add("IsReadTag", typeof(int));
- foreach (var i in list)
- {
- DataRow data = dt.NewRow();
- data["ctid"] = i;
- data["IsReadTag"] = 4;
- dt.Rows.Add(data);
- }
- RedisHelper.StringDelete(key);
- }
- }
- if (dt.Rows.Count <= 0)
- {
- sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- if (posCode == "Supplier")
- {
- string ids = CurrentUser.User.pemVend;
- if (ids != null && ids.Length > 0)
- {
- string[] ids_list = ids.Split(',');
- foreach (var item in ids_list)
- {
- string key = "return_order_" + item;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- dt.Columns.Add("ctid", typeof(string));
- dt.Columns.Add("IsReadTag", typeof(int));
- foreach (var i in list)
- {
- DataRow data = dt.NewRow();
- data["ctid"] = i;
- data["IsReadTag"] = 1;
- dt.Rows.Add(data);
- }
- RedisHelper.StringDelete(key);
- }
- }
- }
- if (dt.Rows.Count <= 0)
- {
- sql = new StringBuilder();
- 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);
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void reset_erp_tiporder()
- {
- string ids = GetPostString("ids");
- string[] ctidList = ids.Split(',');
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
- if (enty != null)
- {
- enty.IsReadTag = 0;
- enty.Update();
- }
- }
- returnSuccessMsg("成功!");
- return;
- }
- public void get_erp_designlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
- lw.Add(string.Format("OrderState<6"));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string designTime = GetPostString("designtime");
- if (designTime.Length > 0)
- {
- lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
- }
- string usershop = CurrentUser.User.pemShop;
- if (usershop.Length > 0)
- {
- lw.Add(string.Format("shopId in ({0})", usershop));
- }
- int myOrgid = CurrentUser.UserPost.OrgID;
- string myOrgCode = CurrentUser.UserPost.Post.Code;
- if (myOrgCode.IndexOf("Designer") != -1)
- {
- if (CurrentUser.User.ManageOrgIds.Length > 0)
- {
- lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
- }
- else
- {
- lw.Add(string.Format("DesOrgID = {0}", myOrgid));
- }
- }
- else
- {
- string orgId = GetPostString("designerhd");
- if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
- }
- if (tid.Length > 0 || buyernick.Length > 0)
- {
- lw.Add(string.Format("OrderState >= 3"));
- }
- else
- lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else if ("外协".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = 200;
- }
- else if ("内部".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = -1;
- }
- else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_mydesignlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
- //lw.Add(string.Format("OrderState<6"));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string olddownload = GetPostString("olddown");
- if (olddownload == "1")
- {
- lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
- }
- else if (olddownload == "2")
- {
- lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
- }
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
- if (CurrentUser.UserPost.Post.Code != "SysAdmin")
- {
- if (CurrentUser.User.TeamIds.Length > 0)
- {
- if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
- lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
- else
- lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
- }
- else
- {
- lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
- }
- }
- if (tid.Length <= 0)
- {
- lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
- }
- lw.Add(string.Format("IsReturn!=3"));
- dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- string teamids = CurrentUser.User.TeamIds.ToString();
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else if ("外协".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = 200;
- }
- else if ("内部".Equals(dr["ToType"].ToString()))
- {
- dr["gongchuang"] = -1;
- }
- else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_startdesign()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState != 3)
- {
- returnErrorMsg("请刷新,订单已经设计了");
- return;
- }
- entity.StartDesignTime = DateTime.Now;
- entity.OrderState = 4;
- if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
- {
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- entity.UpdateTime = DateTime.Now;
- //entity.MakeSupplier = suname;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
- commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
- commonHelper.getCytPrice(entity);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_designselfmemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string con = GetPostString("con");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.DesignSelfMemo = con;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_designprice()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int uid = CurrentUser.UserID;
- string userName = CurrentUser.UserName;
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entitys == null)
- {
- entitys = new CeErpDesignerBill();
- }
- if (entity != null)
- {
- entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
- //entity.Number = Convert.ToInt32(GetPostString("number"));
- entity.StartDesignTime = DateTime.Now;
- entity.OrderState = 4;
- string suname = "";
- if (entity.SupplierId == 0)
- {
- int sid = commonHelper.autoDistributeToSupplier(entity);
- entity.SupplierId = sid;
- suname = commonHelper.getSupplierNameById(entity.SupplierId);
- }
- entity.Update();
- CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
- if (ceErpUserPost != null)
- {
- CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
- if (ceErpPost != null)
- {
- if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
- {
- entitys.tid = entity.ctid;
- entitys.oid = entity.tid;
- entitys.uid = uid;
- entitys.userName = userName;
- entitys.designerType = 1;
- entitys.designerTypeText = "内部设计师";
- entitys.price = Convert.ToDouble(GetPostString("price"));
- entitys.designNum = GetPostInt("designNum");
- entitys.modifyNum = GetPostInt("modifyNum");
- entitys.designSize = GetPostString("designSize");
- entitys.modifySize = GetPostString("modifySize");
- if (CeErpDesignerBill.GetByTid("ctid") == null)
- {
- entitys.create_time = DateTime.Now;
- entitys.create_u_id = uid;
- entitys.create_u_name = userName;
- entitys.Save();
- }
- else
- {
- entitys.update_time = DateTime.Now;
- entitys.update_u_id = uid;
- entitys.update_u_name = userName;
- entitys.Update();
- }
- }
- }
- }
- commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
- LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
- if (suname != "")
- {
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- commonHelper.getCytPrice(entity);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upload_erp_filecomplete()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 5; //设计完成
- entity.Update();
- returnSuccessMsg(eid + "上传成功,设计完成!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_designovertimelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string ResponsibleMan = GetPostString("responsible");
- if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("UnusualTag=3"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "WaitDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //设计管理 获取抢单大厅列表
- public void get_erp_grabinglist()
- {
- int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
- DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
- bool oldOrder = false;
- if (org != null)
- {
- oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
- }
- string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
- sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
- //先处理订单数据
- if (dt.Rows.Count > 0)
- {
- Dictionary<string, int> design = null;
- int count = 0;
- foreach (DataRow row in dt.Rows)
- {
- if (map.ContainsKey(row["ShopId"].ToString()))
- {
- map.TryGetValue(row["ShopId"].ToString(), out design);
- }
- else
- {
- design = new Dictionary<string, int>();
- }
- if (design.ContainsKey(row["ProductId"].ToString()))
- {
- design.TryGetValue(row["ProductId"].ToString(), out count);
- }
- count++;
- design[row["ProductId"].ToString()] = count;
- map[row["ShopId"].ToString()] = design;
- }
- }
- sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
- DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //把店铺排序和技能排序分类
- Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
- Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
- if (design_dt.Rows.Count > 0)
- {
- Dictionary<string, string> design = null;
- List<string> shopIds = null;
- foreach (DataRow row in design_dt.Rows)
- {
- if ("0".Equals(row["designId"].ToString()))
- {
- if (shop_orders.ContainsKey(row["orders"].ToString()))
- {
- shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
- }
- else
- {
- shopIds = new List<string>();
- }
- shopIds.Add(row["shopId"].ToString());
- shop_orders[row["orders"].ToString()] = shopIds;
- }
- else
- {
- if (design_orders.ContainsKey(row["shopId"].ToString()))
- {
- design_orders.TryGetValue(row["shopId"].ToString(), out design);
- }
- else
- {
- design = new Dictionary<string, string>();
- }
- design[row["orders"].ToString()] = row["designId"].ToString();
- design_orders[row["shopId"].ToString()] = design;
- }
- }
- //处理成key value后根据key排序
- shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- foreach (List<string> val in shop_orders.Values)
- {
- if (val != null)
- {
- foreach (string key in val)
- {
- if (design_orders.ContainsKey(key.ToString()))
- {
- design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- }
- }
- }
- }
- }
- //校验哪个优先级有订单
- Dictionary<string, string> designIds = new Dictionary<string, string>();
- foreach (string key in shop_orders.Keys)
- {
- List<string> ids = null;
- shop_orders.TryGetValue(key, out ids);
- //id为shopid
- foreach (string id in ids)
- {
- Dictionary<string, int> list = null;
- Dictionary<string, string> desing = null;
- map.TryGetValue(id, out list);
- design_orders.TryGetValue(id, out desing);
- if (list != null && desing != null)
- {
- foreach (var item in desing)
- {
- int count = 0;
- if (list.ContainsKey(item.Value))
- {
- list.TryGetValue(item.Value, out count);
- if (count > 0)
- {
- designIds[id] = item.Value;
- break;
- }
- }
- }
- }
- }
- if (designIds.Count > 0)
- {
- break;
- }
- }
- DataTable table = new DataTable();
- table.Columns.Add("tid", typeof(string));
- table.Columns.Add("ctid", typeof(string));
- table.Columns.Add("seller_nick", typeof(string));
- table.Columns.Add("productName", typeof(string));
- table.Columns.Add("pay_time", typeof(string));
- table.Columns.Add("seller_memo", typeof(string));
- if (designIds.Count > 0)
- {
- string shopId = "";
- string productId = "";
- foreach (var designInfo in designIds)
- {
- shopId = designInfo.Key;
- productId = designInfo.Value;
- CeErpShop ceErpShop = CeErpShop.Get(shopId);
- CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow row in dt.Rows)
- {
- if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
- {
- DataRow data = table.NewRow();
- data["ctid"] = row["ctid"].ToString();
- data["tid"] = row["tid"].ToString();
- data["seller_nick"] = ceErpShop.ShopName;
- data["pay_time"] = row["pay_time"].ToString();
- data["seller_memo"] = row["seller_memo"].ToString();
- data["productName"] = ceErpProduct.PType;
- table.Rows.Add(data);
- }
- }
- }
- }
- }
- writeGridDataTableJson(table.Rows.Count, table);
- }
- private object rushLockObject = new object();
- public void set_erp_grabingorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- int total = CurrentUser.User.Person.Total;
- int userId = CurrentUser.User.ID;
- int noFinish = CurrentUser.User.Person.NoFinish;
- int finalization = CurrentUser.User.Person.Finalization;
- string eids = GetPostString("ctid");
- string key = "RushKey_" + userId;
- int count = 0;
- if (erpRedis.RedisHelper.KeyExists(key))
- {
- string redisCount = erpRedis.RedisHelper.StringGet(key);
- if (redisCount != null)
- {
- count = Convert.ToInt32(redisCount);
- }
- }
- if (count >= total)
- {
- returnErrorMsg("半小时内已经抢" + total + "单");
- return;
- }
- string[] ctidlist = eids.Split(',');
- if (count + ctidlist.Length > total)
- {
- returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
- return;
- }
- int itag = 0;
- lock (rushLockObject)
- {
- if (ctidlist.Length > 0)
- {
- string[] dtList = new string[ctidlist.Length];
- for (int i = 0; i < ctidlist.Length; i++)
- {
- dtList[i] = "'" + ctidlist[i] + "'";
- }
- 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"));
- DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
- if (dt_user.Rows.Count > 0)
- {
- int doing = 0;//未定稿
- int finish = 0;//已完成
- foreach (DataRow dr in dt_user.Rows)
- {
- if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
- {
- doing++;
- }
- else
- {
- finish++;
- }
- }
- if (doing >= noFinish)
- {
- returnErrorMsg(doing + "未定稿数量,无法继续抢单");
- return;
- }
- if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
- {
- returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
- return;
- }
- }
- //校验选择单子状态
- string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- List<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- if (Convert.ToInt32(dr["OrderState"]) != 2)
- {
- list.Add(dr["ctid"].ToString());
- }
- }
- if (list.Count > 0)
- {
- returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
- return;
- }
- }
- foreach (string ctid in ctidlist)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.OrderState = 3;
- entity.DesignUserId = CurrentUser.UserID;
- entity.WaitDesignTime = DateTime.Now;
- entity.StartDesignTime = DateTime.Now;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
- itag++;
- }
- }
- }
- }
- count += ctidlist.Length;
- erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
- if (itag == 0)
- returnErrorMsg("没有找到相关订单");
- else
- returnSuccessMsg("抢单成功!");
- return;
- }
- }
- public void get_erp_waitorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string address = GetPostString("address");
- 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));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("OrderState = 5 "));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- string pagesize = GetPostString("pagesize");
- if (pagesize != null)
- {
- dStruct.PageSize = 200;
- }
- DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
- List<string> tids = new List<string>();
- if (dt != null)
- {
- dt.Columns.Add("compenPrice", typeof(double));
- foreach (DataRow dr in dt.Rows)
- {
- if (Convert.IsDBNull(dr["compenPrice"]))
- {
- dr["compenPrice"] = 0;
- }
- tids.Add("'" + dr["tid"].ToString() + "'");
- 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();
- if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- entity.Update();
- }
- }
- }
- if (tids.Count > 0)
- {
- string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
- DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt_price != null && dt_price.Rows.Count > 0)
- {
- foreach (DataRow dr in dt_price.Rows)
- {
- foreach (DataRow row in dt.Rows)
- {
- if (row["tid"].Equals(dr["ptid"]))
- {
- row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
- break;
- }
- }
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_supplierwaitorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- lw.Add(string.Format("OrderState = 5 "));
- lw.Add(string.Format("IsVerifyToSupplier=1"));
- if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- string supplier = GetPostString("supplier");
- if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
- {
- lw.Add(string.Format("SupplierName = '{0}'", supplier));
- }
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_verifytosupplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- CeErpTradeCell entity = null;
- string[] eidsList = eids.Split(',');
- if (eidsList.Length <= 0)
- {
- returnErrorMsg("订单号不能空");
- return;
- }
- List<string> tLst = new List<string>();
- foreach (string ctidstr in eidsList)
- {
- tLst.Add("'" + ctidstr + "'");
- CeErpDataSendOrderInfo.createObject(ctidstr);
- }
- string needtids = string.Join(",", tLst.ToArray());
- StringBuilder sql = new StringBuilder();
- //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
- sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
- sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("操作成功!");
- return;
- /**foreach (string ctidstr in eidsList)
- {
- entity = CeErpTradeCell.GetByCtid(ctidstr);
- if (entity != null)
- {
- if (entity.SupplierId == 0)
- {
- continue;
- }
- entity.IsVerifyToSupplier = true;
- if (entity.IsReturn == 1) //1是供应商打回
- {
- entity.IsReturn = 0;
- }
- entity.FinishPlaceTime = DateTime.Now;
- entity.PlaceUserId = CurrentUser.UserID;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;**/
- }
- }
- public void upd_erp_supplierback()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string message = "操作成功!";
- string isDown = "";
- if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
- {
- message = "订单有被点击下载。请注意沟通是否已下载完!";
- isDown = "被点击下载";
- }
- if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
- {
- string key = "return_order_" + entity.SupplierId;
- List<string> list = new List<string>();
- if (RedisHelper.HasKey(key))
- {
- object data = RedisHelper.StringGet(key);
- list = Convert.ToString(data).Split(',').ToList();
- }
- list.Add(eid);
- RedisHelper.StringSet(key, string.Join(",", list));
- }
- entity.IsVerifyToSupplier = false;
- entity.IsReturn = 1;
- entity.IsHaveNewOrder = 0;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- if (entity.OrderState == 6)
- {
- entity.OrderState = 5;
- }
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
- returnSuccessMsg(message);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_toaftersaleorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.isAfterSaleOrder != 1)
- {
- returnErrorMsg("带S的售后单才能打回给售后");
- return;
- }
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("已经设计完成了不能打回给售后");
- return;
- }
- entity.OrderState = 0;
- entity.IsReturn = 3;
- entity.ReturnTime = DateTime.Now;
- entity.UpdateTime = DateTime.Now;
- entity.ReturnReason = reason;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_aftersaletodesign()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 3;
- entity.IsReturn = 0;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void assign_erp_supplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- int sid = GetPostInt("SupplierName");
- string fromTag = GetPostString("tag");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("指派不能为空");
- return;
- }
- string errMsg = "";
- string suname = commonHelper.getSupplierNameById(sid);
- foreach (string ctid in eidList)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if (fromTag == "waitingorder" && entity.OrderState >= 6)
- {
- errMsg += (ctid + "指派失败!!!");
- continue;
- }
- entity.SupplierId = sid;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
- if (entity.OrderState >= 6)
- {
- //if (entity.MakeSupplier.IndexOf(",") != -1)
- //{
- // string msl = entity.MakeSupplier;
- // string[] mslist = msl.Split(',');
- // 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);
- // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- //}
- //else
- //{
- StringBuilder sql = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- //}
- }
- }
- else
- {
- continue;
- }
- }
- if (errMsg.Length > 0)
- {
- returnErrorMsg(errMsg);
- return;
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void assign_erp_makesupplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string sname = GetPostString("SupplierName");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("指派不能为空");
- return;
- }
- List<string> tLst = new List<string>();
- foreach (string ctid in eidList)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.MakeSupplier = sname;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
- tLst.Add("'" + ctid + "'");
- }
- else
- {
- continue;
- }
- }
- string ctids = string.Join(",", tLst.ToArray());
- StringBuilder sql2 = new StringBuilder();
- sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void ins_erp_returnreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- string userpost = CurrentUser.UserPost.Post.Code;
- if (entity != null)
- {
- bool isPlace = false;
- if (entity.OrderState > 6)
- {
- returnErrorMsg("已发货无法打回!");
- return;
- }
- if (entity.OrderState == 6)
- {
- isPlace = true;
- }
- bool isNeedUpdateCell2 = false;
- if (entity.OrderState >= 6)
- {
- isNeedUpdateCell2 = true;
- }
- int returnTag = 2;
- if (userpost == "Supplier")
- {
- returnTag = 1;
- }
- int toType = GetPostInt("totype");
- string fromType = "3";
- if (entity.OrderState < 5)
- {
- fromType = "3";
- }
- else
- {
- fromType = "4";
- }
- if (entity.IsXianHuo == 0)
- {
- if (returnTag == 2)
- {
- if (toType == 1)
- {
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- string clearman = GetPostString("clearman");
- if (!string.IsNullOrEmpty(clearman))
- {
- entity.DesignUserId = 0;
- }
- }
- else
- {
- entity.OrderState = 3;
- entity.ReturnUserType = 2;
- }
- entity.IsReadTag = 1;
- }
- else if (returnTag == 1)
- {
- entity.OrderState = 5;
- }
- entity.IsVerifyToSupplier = false;
- }
- if (entity.IsXianHuo == 1)
- {
- entity.OrderState = 5;
- }
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = returnTag;
- entity.ReturnTime = DateTime.Now;
- entity.UpdateTime = DateTime.Now;
- entity.ReturnReason = GetPostString("returnreason");
- entity.Update();
- if (entity.OrderState == 3)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "rebutDesign";
- apiVo.orderRemarks = entity.ReturnReason;
- designHelper.API_WorkCore(apiVo);//rebutDesign
- }
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
- {
- dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
- }
- CeErpSukuraData.createInfo(entity.ctid, 5);
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
- if (isPlace)
- {
- string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dth != null && dth.Rows.Count > 0)
- {
- dataSendOrderBean dataSendOrderBean = null;
- foreach (DataRow item in dth.Rows)
- {
- try
- {
- dataSendOrderBean = new dataSendOrderBean();
- dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
- dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
- dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
- dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
- dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
- dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
- dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
- dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
- dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
- dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
- dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
- dataSendOrderBean.Radio1723534706288 = "打回";
- dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
- if (result != null)
- {
- if ("0".Equals(result.errcode))
- {
- CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
- }
- else
- {
- CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
- if (isNeedUpdateCell2)
- {
- if (entity.MakeSupplier.IndexOf(",") != -1)
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- else
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void cyt_erp_returnreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- string userpost = CurrentUser.UserPost.Post.Code;
- if (entity != null)
- {
- if (entity.OrderState > 6)
- {
- returnErrorMsg("已发货无法打回!");
- return;
- }
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "Pwd", "lt666888" },
- { "LTOrderId",eid }
- };
- string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg != "取消成功")
- {
- returnErrorMsg(msg);
- return;
- }
- bool isNeedUpdateCell2 = false;
- if (entity.OrderState >= 6)
- {
- isNeedUpdateCell2 = true;
- }
- int returnTag = 2;
- if (userpost == "Supplier")
- {
- returnTag = 1;
- }
- if (entity.IsXianHuo == 0)
- {
- if (returnTag == 2)
- {
- int toType = GetPostInt("totype");
- if (toType == 1)
- {
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- }
- else
- {
- entity.OrderState = 4;
- entity.ReturnUserType = 2;
- }
- entity.IsReadTag = 1;
- }
- else if (returnTag == 1)
- {
- entity.OrderState = 5;
- }
- entity.IsVerifyToSupplier = false;
- }
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = returnTag;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = GetPostString("returnreason");
- entity.Update();
- if (entity.OrderState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "rebutDesign";
- apiVo.orderRemarks = entity.ReturnReason;
- designHelper.API_WorkCore(apiVo);//rebutDesign
- }
- CeErpSukuraData.createInfo(entity.ctid, 5);
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
- if (isNeedUpdateCell2)
- {
- if (entity.MakeSupplier.IndexOf(",") != -1)
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- else
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_xianhuoreturntag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string[] ctids = eids.Split(',');
- foreach (string ctid in ctids)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.IsReturn = 0;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_waitdeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
- if (tid.Length > 5)
- {
- List<string> tids = getTidByCtidLike(tid);
- if (tids.Count > 0 && tids.Count < 10)
- {
- tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
- /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
- if (receiverIds.Count > 0 && receiverIds.Count < 10)
- {
- tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
- }*/
- }
- }
- lw.Add(tid_sql);
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
- lw.Add(string.Format("type != 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_changedeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
- if (tid.Length > 5)
- {
- List<string> tids = getTidByCtidLike(tid);
- if (tids.Count > 0 && tids.Count < 10)
- {
- tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
- }
- }
- lw.Add(tid_sql);
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.RemoveAt(0);
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_pddderiving()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
- if (tid.Length > 5)
- {
- List<string> tids = getTidByCtidLike(tid);
- if (tids.Count > 0 && tids.Count < 10)
- {
- tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
- /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
- if (receiverIds.Count > 0 && receiverIds.Count < 10)
- {
- tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
- }*/
- }
- }
- lw.Add(tid_sql);
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
- lw.Add(string.Format("type = 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.RemoveAt(0);
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_jdderiving()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("type = 'JD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_demoorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- //lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("IsSample={0}", 3));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void save_erp_checkmemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.CheckMemo = GetPostString("CheckMemo");
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_returnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsReturn>0"));
- lw.Add(string.Format("IsXianHuo=0"));
- lw.Add(string.Format("IsReturn!=3"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_today_sumreturn()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string bdate1 = GetPostString("returnTimeS");
- string bdate2 = GetPostString("returnTimeE");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- lw.Add(string.Format("IsReturn=0"));
- lw.Add(string.Format("IsXianHuo=0"));
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "";
- if (dw_back.Length > 0)
- {
- sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
- }
- else
- {
- 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 + "'";
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- decimal total = 0, today_finish = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["total"]);
- }
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
- {
- today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
- }
- var res = new
- {
- data = total,
- data1 = today_finish,
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_allreturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string backreason = GetPostString("backreason");
- if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
- lw.Add(string.Format("IsXianHuo=0"));
- lw.Add(string.Format("ReturnTime != ''"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_aftersalereturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsReturn=3"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- string backreason = GetPostString("backreason");
- if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
- dStruct.Order = "ReturnTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_xianhuoreturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState=6 "));
- lw.Add(string.Format("IsXianHuo=1 "));
- lw.Add(string.Format("IsReturn>0 "));
- lw.Add(string.Format("IsReturn!=3"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_orderdelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState >= 7)
- {
- returnErrorMsg("此单已发货,无需重复发货");
- return;
- }
- if (entity.OrderState != 6)
- {
- returnErrorMsg("此单状态为非【下单完成】,无法发货");
- return;
- }
- string shop = GetPostString("seller_nick");
- //string sessionkey = taobaoHelper.ShopKeyDics[shop];
- string comName = GetPostString("comName");
- string comCode = GetPostString("comCode");
- string outSid = GetPostString("outSid");
- string deliveryType = GetPostString("deliveryType");
- string deliveryMemo = GetPostString("deliveryMemo");
- outSid = outSid.Trim();
- CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
- if (mainEn == null)
- {
- returnErrorMsg("找不到原始订单记录");
- return;
- }
- bool isInitOrderDeliv = false;
- if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
- {
- isInitOrderDeliv = true;
- }
- string apires = "";
- string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
- 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)
- {
- apires = "发货成功true";
- }
- else
- {
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
- apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
- }
- if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
- {
- entity.OrderState = 7;//发货后订单已发货
- entity.OutSid = outSid;
- entity.MemoOpt = 0;
- entity.UpdateTime = DateTime.Now;
- entity.FinishDeliveryTime = DateTime.Now;
- entity.Update();
- commonHelper.aftersaleSend(entity.ctid, comName, outSid);
- commonHelper.UpdateRelationOrder(entity.ctid);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = eid;
- exinfo.out_sid = outSid;
- exinfo.company_code = comCode;
- exinfo.company_name = comName;
- exinfo.delivery_memo = deliveryMemo;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = deliveryType;
- exinfo.Create();
- returnSuccessMsg("发货操作成功!");
- commonHelper.UpdateRelationOrder(entity.ctid);
- commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
- CeErpSukuraData.createInfo(entity.ctid, 4);
- if (entity.SupplierId == 64 || entity.SupplierId == 80)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
- }
- else
- {
- string errmsg = commonHelper.KeepChinese(apires);
- returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
- XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
- }
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void set_erp_multidelivery()
- {
- string eids = GetPostString("tids");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("发货不能为空");
- return;
- }
- foreach (string ctid in eidList)
- {
- if (ctid.Length <= 0) continue;
- CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
- if (expInfo != null)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
- {
- expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
- expInfo.state = "异常";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- continue;
- }
- if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
- {
- expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
- expInfo.state = "异常";
- expInfo.Update();
- continue;
- }
- //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
- bool isInitOrderDeliv = false;
- if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
- {
- isInitOrderDeliv = true;
- expInfo.isMultiDelivery = 1;
- }
- if (ctid.IndexOf("N") != -1)
- {
- StringBuilder sqlbucha = new StringBuilder();
- sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
- CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
- LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
- commonHelper.UpdateRelationOrder(ctid);
- expInfo.delivery_memo = "发货成功";
- expInfo.state = "发货成功";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- }
- else
- {
- string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
- string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
- if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
- {
- expInfo.delivery_memo = "发货成功";
- expInfo.state = "发货成功";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- commonHelper.UpdateRelationOrder(ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
- LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
- }
- else
- {
- expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
- expInfo.state = "异常";
- expInfo.Update();
- }
- }
- }
- }
- }
- returnSuccessMsg("操作完成");
- }
- public void reset_erp_memoopt()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string stropt = "";
- if (entity.MemoOpt == 1)
- {
- stropt = "“改稿”";
- }
- else if (entity.MemoOpt == 2)
- {
- stropt = "“定稿”";
- }
- else if (entity.MemoOpt == 3)
- {
- stropt = "“完成查货”";
- CeErpSukuraData.createInfo(entity.ctid, 6);
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
- entity.UpdateTime = DateTime.Now;
- entity.MemoOpt = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_deliveryunusual()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6"));
- lw.Add(string.Format("UnusualTag = 5"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_deliveryedlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string logistics = GetPostString("logistics");
- if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- {
- string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
- if (tid.Length > 5)
- {
- List<string> tids = getTidByCtidLike(tid);
- if (tids.Count > 0 && tids.Count < 10)
- {
- tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
- }
- }
- lw.Add(tid_sql);
- }
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format(" OrderState IN (7, 8)"));
- lw.Add(string.Format("type != 'PDD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_pdddeliveryed()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string logistics = GetPostString("logistics");
- if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- {
- string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
- if (tid.Length > 5)
- {
- List<string> tids = getTidByCtidLike(tid);
- if (tids.Count > 0 && tids.Count < 10)
- {
- tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
- }
- }
- lw.Add(tid_sql);
- }
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("type = 'PDD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /* if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_jddeliveryed()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("type = 'JD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_allplacelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string pldate1 = GetPostString("placedate1");
- string pldate2 = GetPostString("placedate2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
- {
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- }
- else
- {
- if (ex_psize <= 0) //非导出的时候 显示3个月数据
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState >= 6"));
- lw.Add(string.Format("IsSample != 2 "));
- //lw.Add(string.Format("isDianziOrder = 0 "));
- lw.Add(string.Format("SupplierId > 0 "));
- //lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_financeallplacelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string pldate1 = GetPostString("placedate1");
- string pldate2 = GetPostString("placedate2");
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
- {
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- }
- else
- {
- if (ex_psize <= 0) //非导出的时候 显示3个月数据
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- //lw.Add(string.Format("OrderState >= 6"));
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("isDianziOrder = 0 "));
- //lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_expresslist()
- {
- int listtype = GetInt("ltype");
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string outsid = GetPostString("out_sid");
- if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
- string importer = GetPostString("ImportUserName");
- if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
- string file = GetPostString("import_file");
- if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
- string printman = GetPostString("printman");
- if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string fdate1 = GetPostString("finishdate1");
- string fdate2 = GetPostString("finishdate2");
- string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string supplierId = GetPostString("supplierId");
- if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
- if (listtype == 1)
- {
- lw.Add(string.Format("importUserId !=0"));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- if (dStruct.PageSize != 100000)
- {
- dStruct.Order = "isMultiDelivery asc, import_time desc";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_buchaorderdelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSample != 2)
- {
- returnErrorMsg("补差价单才能标记为已发货");
- return;
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
- entity.OrderState = 7;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_stdtemplates()
- {
- //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
- //string res = taobaoHelper.test();
- string res = apiHelper.API_PrintTemplate();
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
- {
- int sidx = res.IndexOf("error_code");
- int eidx = res.IndexOf("success");
- string msg = res.Substring(sidx, eidx - sidx);
- returnErrorMsg(msg);
- return;
- }
- if (res.Length <= 0)
- {
- returnErrorMsg("模板数据为空!");
- return;
- }
- ReturnSuccess(res);
- }
- public void cancel_print_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- string res = "";
- string code = entity.LastBillWaybillCode;
- if (code == "")
- {
- code = entity.OutSid;
- }
- res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
- XLog.SaveLog(0, "取消面单" + res);
- }
- }
- }
- public void set_erp_printwaybill()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
- string cpName = GetPostString("cpname");
- string isTogether = GetPostString("together");
- string printType = GetPostString("printType");
- //var res_obj = new
- //{
- // restype = 1,
- // 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\"}"
- //};
- //string ro_json = JsonConvert.SerializeObject(res_obj);
- //ReturnSuccess(ro_json);
- //return;
- bool isUseLastWayBillCode = false;
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
- {
- isUseLastWayBillCode = true;
- }
- if (entity.OrderState == 7 && "delivering".Equals(printType))
- {
- ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
- return;
- }
- if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
- {
- returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
- return;
- }
- if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
- {
- returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
- return;
- }
- }
- string res = "";
- Api_waybill_code_response_Obj fullObj = null;
- string pData_str = "";
- string curUseWayBillCode = "";
- if (isUseLastWayBillCode == false)
- {
- res = apiHelper.API_GetWaybill(cpCode, ctid);
- //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
- if (res.IndexOf("failure") != -1)
- {
- //int idx = res.IndexOf("sub_message");
- //int idx2 = res.IndexOf("flag");
- //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
- string errMsgNeed = commonHelper.KeepChinese(res);
- var res_objd = new
- {
- restype = 0,
- data = "获取面单失败" + errMsgNeed
- };
- string ro_jsond = JsonConvert.SerializeObject(res_objd);
- returnSuccess(ro_jsond);
- if (res.IndexOf("停发") != -1)
- {
- entity.UnusualCon = "物流停发";
- entity.Update();
- }
- //returnErrorMsg("获取面单失败,"+emsg);
- XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
- return;
- }
- else if (res.IndexOf("errorMsg") != -1)
- {
- //int idx = res.IndexOf("errorMsg");
- //int idx2 = res.IndexOf("}]}");
- //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
- string errMsgNeed = commonHelper.KeepChinese(res);
- var res_objf = new
- {
- restype = 0,
- data = "获取面单失败2" + errMsgNeed
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- if (res.IndexOf("停发") != -1)
- {
- entity.UnusualCon = "物流停发";
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
- }
- }
- returnSuccess(ro_jsonf);
- //returnErrorMsg("获取面单失败," + emsg);
- XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
- return;
- }
- try
- {
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- //res = res.Replace(" ", "");
- fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "生成fullObj" + res);
- var res_objf = new
- {
- restype = 0,
- data = "生成fullObj发生错误" + ex.Message
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- returnSuccess(ro_jsonf);
- return;
- }
- if (fullObj.response.data.content.Count > 0)
- {
- ContentItem codeObj = fullObj.response.data.content[0];
- if (cpCode.IndexOf("SFFQ-") != -1)
- {
- pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
- }
- else
- pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
- curUseWayBillCode = codeObj.waybillCode;
- }
- else
- {
- XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
- var res_objf = new
- {
- restype = 0,
- data = "生成fullObj找不到快递单号waybillCode"
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- returnSuccess(ro_jsonf);
- return;
- }
- }
- else
- {
- //使用上次打印的快递单号
- if (cpCode == "SFFQ-LY")
- {
- pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
- }
- else
- pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
- curUseWayBillCode = entity.LastBillWaybillCode;
- }
- if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
- {
- var res_obje = new
- {
- restype = 0,
- data = "获取加密打印数据失败"
- };
- string ro_jsone = JsonConvert.SerializeObject(res_obje);
- returnSuccess(ro_jsone);
- entity.LastBillCpCode = cpCode;
- entity.LastBillWaybillCode = curUseWayBillCode;
- entity.Update();
- XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
- //returnErrorMsg("获取加密打印数据失败");
- return;
- }
- //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
- //string msg = "{\"data\":\""+pageUrl+"\"}";
- string btnType = "";
- string errorMsg = "";
- if (entity != null)
- {
- CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
- //cpcode是 YTO-CAINIAO
- //string comCode = cpCode.Split('-')[0].ToString();
- string apires = "";
- string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
- //isTogether=2是新的合包弹窗
- if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
- {
- if (ctid.IndexOf("N") != -1)
- {
- apires = "发货成功";
- }
- else
- {
- apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
- }
- //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
- //打单后发货
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
- if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
- {
- sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
- }
- else
- {
- sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- foreach (DataRow row in dt.Rows)
- {
- entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
- if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
- {
- try
- {
- btnType = "待发货";
- entity.OutSid = curUseWayBillCode;
- entity.OrderState = 7;
- entity.IsUrgency = false;
- entity.LastBillCpCode = "";
- entity.LastBillWaybillCode = "";
- entity.FinishDeliveryTime = DateTime.Now;
- entity.IsReturn = 0;
- entity.MemoOpt = 0;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = curUseWayBillCode;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = supplierName;
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.postData = pData_str;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(entity.ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
- if (entity.SupplierId == 64 || entity.SupplierId == 80)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
- }
- }
- else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
- {
- entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
- if (entity.OrderState == 6)
- {
- entity.OrderState = 7;
- }
- entity.UpdateTime = DateTime.Now;
- entity.FinishDeliveryTime = DateTime.Now;
- btnType = "已发货";
- entity.Update();
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = curUseWayBillCode;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = supplierName;
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.postData = pData_str;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(entity.ctid);
- CeErpSukuraData.createInfo(entity.ctid, 4);
- if (entity.SupplierId == 64 || entity.SupplierId == 80)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //不处理
- }
- else
- {
- entity.UpdateTime = DateTime.Now;
- entity.LastBillCpCode = cpCode;
- entity.LastBillWaybillCode = curUseWayBillCode;
- entity.Update();
- string errmsg = commonHelper.KeepChinese(apires);
- var res_objz = new
- {
- restype = 0,
- data = "打单后发货失败"
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
- XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
- return;
- }
- }
- }
- else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
- {
- string ctids = GetPostString("ctids");
- DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
- List<string> list = new List<string>();
- List<string> send_list = new List<string>();
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- CeErpTrade ceErpTrade = new CeErpTrade();
- //可合包的合并一起发货
- if (dt == null && string.IsNullOrEmpty(ctids))
- {
- var res_objz = new
- {
- restype = 0,
- data = "打单后发货失败"
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- return;
- }
- if (!string.IsNullOrEmpty(ctids))
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- foreach (DataRow row in dt.Rows)
- {
- list.Add("'" + row["ctid"] + "'");
- ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
- ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- if (ctid.IndexOf("N") != -1)
- {
- apires = "发货成功";
- }
- else
- {
- if (!send_list.Contains(ceErpTrade.tid))
- {
- apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
- }
- else
- {
- apires = "发货成功";
- }
- }
- if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
- {
- send_list.Add(ceErpTrade.tid);
- try
- {
- btnType = "待发货";
- ceErpTradeCell.OutSid = curUseWayBillCode;
- ceErpTradeCell.OrderState = 7;
- ceErpTradeCell.IsUrgency = false;
- ceErpTradeCell.LastBillCpCode = "";
- ceErpTradeCell.LastBillWaybillCode = "";
- ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
- ceErpTradeCell.IsReturn = 0;
- ceErpTradeCell.MemoOpt = 0;
- ceErpTradeCell.UpdateTime = DateTime.Now;
- ceErpTradeCell.Update();
- commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = ceErpTradeCell.ctid;
- exinfo.out_sid = curUseWayBillCode;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = supplierName;
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.postData = pData_str;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
- if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
- }
- }
- else
- {
- ceErpTradeCell.UpdateTime = DateTime.Now;
- ceErpTradeCell.LastBillCpCode = cpCode;
- ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
- ceErpTradeCell.Update();
- string errmsg = commonHelper.KeepChinese(apires);
- XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
- errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
- }
- }
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
- }
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
- var res_obj = new
- {
- restype = 1,
- data = pData_str,
- errorMsg
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- ReturnSuccess(ro_json);
- return;
- }
- }
- private string GetUTF8String(byte[] vs)
- {
- throw new NotImplementedException();
- }
- public void set_erp_printwaybill_cn()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string cpCode = GetPostString("cpcode");
- string cpName = GetPostString("cpname");
- string tempUrl = GetPostString("tempurl");
- //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
- string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
- //string res = taobaoHelper.test();
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
- {
- int sidx = res.IndexOf("errorMsg");
- int eidx = res.IndexOf("}");
- string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
- var res_objzxx = new
- {
- restype = 0,
- data = msg
- };
- string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
- returnSuccess(ro_jsonzxx);
- //returnErrorMsg(msg);
- return;
- }
- int idx = res.IndexOf("waybillCode");
- int idx2 = res.IndexOf("printData");
- string outsid = res.Substring(idx + 14, idx2 - idx - 17);
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string osid = entity.OutSid;
- entity.OutSid = osid + "," + outsid;
- entity.FinishDeliveryTime = DateTime.Now;
- entity.OrderState = 7;
- entity.UpdateTime = DateTime.Now;
- entity.IsReturn = 0;
- entity.Update();
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = outsid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- if (entity.SupplierId == 64 || entity.SupplierId == 80)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
- var res_objz = new
- {
- restype = 1,
- data = res
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- //ReturnSuccess(res);
- }
- }
- ////打单,打印面单 获取面单号
- //public void set_erp_printwaybill()
- //{
- // if (UrlPostParmsCheck("ctid"))
- // {
- // string ctid = GetPostString("ctid");
- // string cpCode = GetPostString("cpcode");
- // string tempUrl = GetPostString("tempurl");
- // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
- // //string res = taobaoHelper.test();
- // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- // if (res.IndexOf("error_response") != -1)
- // {
- // int sidx = res.IndexOf("sub_msg");
- // int eidx = res.IndexOf("request_id");
- // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
- // returnErrorMsg(msg);
- // return;
- // }
- // int idx = res.IndexOf("waybill_code");
- // int idx2 = res.IndexOf("}]}");
- // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
- // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
- // ReturnSuccess(res);
- // }
- //}
- public void cancel_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //有过处理的售后,取消也不能删除 售 字,保留
- if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
- {
- entity.AfterSaleState = 4;
- }
- else
- entity.AfterSaleState = 0;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_aftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = GetInt("st");
- string tid = GetPostString("ctid");
- if (st == 3)
- {
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- }
- else
- {
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string posCode = CurrentUser.UserPost.Post.Code;
- //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
- //{
- // string vstate = GetPostString("vstate");
- // if (vstate.Length > 0)
- // {
- // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- // }
- // if (posCode == "Supplier")
- // {
- // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- // }
- // else
- // {
- // lw.Add(string.Format("AfterSaleState = {0}", st));
- // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
- // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
- // {
- // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
- // }
- // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
- // {
- // int orgid = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
- // }
- // else if (CurrentUser.UserPost.Post.Code == "Director")
- // {
- // string shopid = CurrentUser.User.pemShop;
- // lw.Add(string.Format("shopId in ({0})", shopid));
- // }
- // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
- // //{
- // // int org_id = CurrentUser.UserPost.OrgID;
- // // lw.Add(string.Format("OrgID={0}", org_id));
- // //}
- // dStruct.Order = "IsArbitrate desc, createdTime desc";
- // }
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- if (st == 5)
- {
- if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
- {
- if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
- {
- int mrOrgid = CurrentUser.UserPost.OrgID;
- lw.Add(string.Format("DesOrgID={0}", mrOrgid));
- lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
- }
- //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
- //{
- // int mrOrgid = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
- //}
- else
- {
- string userIdStr = "";
- if (posCode == "CustomerService")
- {
- userIdStr = CurrentUser.UserID + "_k";
- }
- else if (posCode == "Designer" || posCode == "wxDesigner")
- {
- userIdStr = CurrentUser.UserID + "_s";
- }
- else if (posCode == "Place")
- {
- userIdStr = CurrentUser.UserID + "_x";
- }
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
- }
- }
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (dwplace.Length > 0) lw.Add(dwplace);
- string supState = GetPostString("supState");
- if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
- string searchType = GetPostString("searchType");
- if (searchType.Length > 0 && "moreBack".Equals(searchType))
- {
- lw.Add(string.Format("BackNum>1"));
- }
- lw.Add(string.Format("AfterSaleState>0"));
- if (ex_psize > 0)
- {
- if (CurrentUser.UserPost.Post.Code == "Finance")
- dStruct.Order = "pay_time desc";
- else
- dStruct.Order = "HandleTime desc";
- }
- else
- dStruct.Order = "HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_test", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
- //{
- // lw.Add(string.Format("AfterSaleState=4"));
- // string code = CurrentUser.UserPost.Post.Code;
- // if (code == "CustomerService")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
- // }
- // else if (code == "Designer" || code == "DesignerMr")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
- // }
- // else if (code == "Place" || code == "PlaceMr")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
- // }
- // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- //else //处理中的售后,待处理和处理中合并
- //{
- // if (afterState.Length <= 0)
- // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- }
- public void get_erp_disagreeftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string backdate1 = GetPostString("backdate1");
- string backdate2 = GetPostString("backdate2");
- string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
- if (backDate.Length > 0) lw.Add(backDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string aftersakereason = GetPostString("aftersakereason");
- if (aftersakereason.Length > 0)
- {
- if (aftersakereason == "1")
- {
- lw.Add(string.Format("AfterSaleResSupId > 0"));
- }
- if (aftersakereason == "2")
- {
- lw.Add(string.Format("AfterSaleResSupId = 0"));
- }
- }
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- string searchType = GetPostString("searchType");
- if (searchType == "wait")
- {
- lw.Add(string.Format("HandleTime is null"));
- }
- if (searchType == "handling")
- {
- lw.Add(string.Format("HandleTime is not null "));
- }
- if (searchType == "back" || searchType == "puBack")
- {
- lw.Add(string.Format("AfterSaleBackReason != ''"));
- }
- if (searchType == "reBack")
- {
- lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
- }
- if (searchType == "moreBack")
- {
- lw.Add(string.Format("backNum > 1"));
- }
- lw.Add(string.Format("(AfterSaleState=5)"));
- dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_handlingaftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string afterresult = GetPostString("afterresult");
- if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- string searchType = GetPostString("searchType");
- if (searchType == "wait")
- {
- lw.Add(string.Format("HandleTime is null"));
- }
- if (searchType == "documentary")
- {
- lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
- }
- if (searchType == "handling")
- {
- lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
- }
- if (searchType == "back" || searchType == "puBack")
- {
- lw.Add(string.Format("AfterSaleBackReason != ''"));
- }
- if (searchType == "reBack")
- {
- lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
- }
- if (afterState.Length <= 0)
- {
- lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- }
- dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
- //public void get_erp_back_handlingaftersalelist()
- //{
- // DataStruct dStruct = GetPostStruct();
- // List<string> lw = new List<string>();
- // string tid = GetPostString("ctid");
- // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- // string shopname = GetPostString("shopname");
- // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- // string buyernick = GetPostString("buyer_nick");
- // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- // string sellermemo = GetPostString("seller_memo");
- // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- // string orderState = GetPostString("orderState");
- // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- // string afterState = GetPostString("afterstate");
- // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- // string date1 = GetPostString("date1");
- // string date2 = GetPostString("date2");
- // string dw = GetDateMinuteWhere("pay_time", date1, date2);
- // if (dw.Length > 0) lw.Add(dw);
- // string price1 = GetPostString("price1");
- // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- // string price2 = GetPostString("price2");
- // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- // //lw.Add(string.Format("IsRefund!={0}", 1));
- // string reason = GetPostString("reason");
- // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- // string method = GetPostString("method");
- // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- // string handler = GetPostString("handler");
- // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- // string handledate1 = GetPostString("handledate1");
- // string handledate2 = GetPostString("handledate2");
- // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- // string afterdate1 = GetPostString("afterdate1");
- // string afterdate2 = GetPostString("afterdate2");
- // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- // if (afterDate.Length > 0) lw.Add(afterDate);
- // string supplier = GetPostString("supplier");
- // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- // string responsible = GetPostString("responsibleman");
- // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- // string customer = GetPostString("customer");
- // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- // string design = GetPostString("design");
- // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- // string afterMemoType = GetPostString("aftermemotype");
- // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
- // if (afterState.Length <= 0)
- // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- public void get_erp_aftersaleverifylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("otid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string posCode = CurrentUser.UserPost.Post.Code;
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- if (posCode == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- lw.Add(string.Format("VerifyState = 0"));
- lw.Add("type = 1");
- lw.Add(string.Format("AfterSaleState={0}", 3));
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- else if (posCode == "logistics")
- {
- lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
- lw.Add(string.Format("VerifyState = 0"));
- lw.Add("type = 2");
- lw.Add(string.Format("AfterSaleState={0}", 3));
- dStruct.Order = "AfterSaleState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- else
- {
- lw.Add(string.Format("(AfterSaleState = 3)"));
- lw.Add("type = 0");
- string reasonState = GetPostString("reasonState");
- if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
- {
- if (reasonState == "2")
- {
- lw.Add("VerifyState = 3");
- }
- else if (reasonState == "1")
- {
- lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
- }
- else
- {
- lw.Add("VerifyState in (0,3)");
- }
- //不加条件,可以看全部
- }
- 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")
- {
- int orgid = CurrentUser.UserPost.OrgID;
- string manageOrgId = CurrentUser.User.ManageOrgIds;
- if (string.IsNullOrEmpty(manageOrgId))
- {
- lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
- }
- if (reasonState == "1")
- {
- lw.Add("VerifyState = 3");
- }
- else if (reasonState == "2")
- {
- lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
- }
- else
- {
- }
- }
- else
- {
- lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
- }
- //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
- //{
- // int org_id = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("OrgID={0}", org_id));
- //}
- dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- }
- public void get_erp_finishaftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 4;
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("otid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- if ("3".Equals(vstate))
- {
- lw.Add(string.Format("IsTem=1"));
- }
- else
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- }
- lw.Add(string.Format("AfterSaleState=4"));
- string code = CurrentUser.UserPost.Post.Code;
- if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
- {
- //不加条件,可以看全部
- }
- else if (code == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- lw.Add("type = 1");
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- }
- else if (code == "logistics")
- {
- lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
- lw.Add("type = 2");
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- }
- 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")
- {
- lw.Add("type = 0");
- int orgid = CurrentUser.UserPost.OrgID;
- string manageOrgIds = CurrentUser.User.ManageOrgIds;
- if (string.IsNullOrEmpty(manageOrgIds))
- {
- lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
- }
- }
- else
- {
- lw.Add("type = 0");
- lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
- }
- dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void handle_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string responStr = GetPostString("AfterSaleResponsible");
- if (responStr.Length <= 0)
- {
- returnErrorMsg("售后责任人不能为空");
- return;
- }
- bool isDesign = false;
- double designFree = 0.00;
- int responsibleId = 0;
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- int isNeedNewOrder = GetPostInt("IsNewOrder");
- string afterMethod = GetPostString("AfterSaleMethod");
- if (isNeedNewOrder == 1)
- {
- CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
- bool ishav = true;
- if (newentity == null)
- {
- newentity = entity.Clone() as CeErpTradeCell;
- ishav = false;
- newentity.ctid = "S_" + entity.ctid;
- newentity.OrderState = 0;
- //唯一标识
- newentity.OrderSn = newentity.ctid;
- string orderSn = dataHelper.getSaleOrderSn();
- if (orderSn != "")
- {
- newentity.OrderSn = orderSn;
- }
- }
- newentity.UpdateTime = DateTime.Now;
- newentity.AfterSaleState = 0;
- newentity.AfterSaleMethod = afterMethod;
- if (!ishav)
- {
- string memo_str = newentity.seller_memo;
- memo_str = memo_str.Replace("(", "(");
- memo_str = memo_str.Replace(")", ")");
- int sIndex = memo_str.IndexOf("(");
- int eIndex = memo_str.IndexOf(")");
- if (sIndex == -1 || eIndex == -1)
- {
- returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
- return;
- }
- string first = memo_str.Substring(0, sIndex + 1);
- string memoCtid = newentity.OrderSn;
- //if (memoCtid.IndexOf("C") != -1)
- //{
- //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
- //if (CIdx.IndexOf("+") != -1)
- //{
- //CIdx = "C" + CIdx.Split('+')[1];
- //}
- //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
- //}
- string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
- //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
- string newMemo = first + memoCtid + last;
- newentity.seller_memo = newMemo;
- newentity.FinishPlaceTime = null;
- newentity.UnusualTag = 0;
- newentity.UnusualCon = "";
- newentity.UnusualTime = null;
- newentity.AfterSaleMemo = "";
- newentity.AfterSaleMethod = afterMethod;
- newentity.AfterSalePreTime = null;
- newentity.AfterSaleReason = "";
- newentity.AfterSaleResponsible = "";
- newentity.AfterSaleState = 0;
- newentity.AfterSaleTime = null;
- newentity.AfterSaleUserId = 0;
- newentity.AfterSaleSupplierState = 0;
- newentity.LastBillWaybillCode = "";
- newentity.LastBillCpCode = "";
- newentity.FinishAfterSaleTime = null;
- newentity.HandleTime = null;
- newentity.IsSF = 0;
- newentity.IsOldCustomer = 0;
- newentity.UrgencyTime = null;
- newentity.ResponsibleUserId = "";
- newentity.IsVerifyToSupplier = false;
- newentity.payment = 0;
- newentity.CheckMemo = "";
- newentity.OutSid = "";
- newentity.CheckOrderTime = null;
- newentity.MemoOpt = 0;
- LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
- }
- newentity.isAfterSaleOrder = 1;
- newentity.IsRefund = 0;
- string receiveMobile = GetPostString("receiver_mobile");
- if (receiveMobile.Length > 0)
- {
- CeErpTrade trade = CeErpTrade.Get(newentity.tid);
- if (trade != null)
- {
- trade.receiver_name = GetPostString("receiver_name");
- trade.receiver_mobile = receiveMobile;
- trade.receiver_state = GetPostString("receiver_state");
- trade.receiver_city = GetPostString("receiver_city");
- trade.receiver_district = GetPostString("receiver_district");
- trade.receiver_address = GetPostString("receiver_address");
- newentity.IsOffLineOrder = 1;
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
- }
- }
- string st = GetPostString("ToState");
- if (st.Length > 0)
- {
- if (newentity.OrderState <= 3)
- {
- newentity.WaitDesignTime = DateTime.Now;
- newentity.StartDesignTime = null;
- newentity.FinishDesignTime = null;
- newentity.OrderState = 3;
- if (st == "下单员")
- {
- newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
- if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
- {
- newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
- }
- }
- else
- {
- newentity.WaitDesignTime = DateTime.Now;
- string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
- DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
- {
- DataRow user = dt1.Rows[0];
- //找主管
- string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
- newentity.DesignUserId = designMr;
- string key = "aftersale_order_" + designMr;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- list.Add(newentity.ctid);
- RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
- }
- }
- //账号正常
- if (user["State"].ToString() == "0")
- {
- newentity.DesignUserId = entity.DesignUserId;
- string key = "aftersale_order_" + entity.DesignUserId;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- list.Add(newentity.ctid);
- RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
- }
- }
- }
- }
- }
- if (entity.IsXianHuo == 1)
- {
- newentity.OrderState = 6;
- entity.FinishPlaceTime = DateTime.Now;
- }
- }
- if (ishav)
- {
- newentity.Update();
- }
- else
- {
- newentity.Create();
- CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
- newCellExtend.ctid = newentity.ctid;
- newCellExtend.orderFrom = 20;
- newCellExtend.orderType = 30;
- if (st == "下单员")
- {
- }
- else
- {
- newCellExtend.ReprintTime = DateTime.Now;
- }
- newCellExtend.Create();
- }
- if (st != "下单员")
- {
- if (entity.DispatchSort == 2)
- {
- designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
- LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
- }
- }
- }
- //处理售后扩展
- string resIdStr = GetPostString("ResponsibleUserId");
- string refundFees = GetPostString("refundFrees");
- int IsComplain = GetPostInt("isComplain");
- int IsBad = GetPostInt("isBad");
- string IsOriginal = GetPostString("isOriginal");
- double diffResultPrice = GetPostDouble("diffResultPrice");
- string textResult = GetPostString("textResult");
- string supplierResponsible = GetPostString("supplierResponsible");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
- if (ceErpTradeAfterSaleExtend == null)
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = eid;
- ceErpTradeAfterSaleExtend.RefundFees = refundFees;
- ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
- ceErpTradeAfterSaleExtend.IsBad = IsBad;
- ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
- ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
- ceErpTradeAfterSaleExtend.TextResult = textResult;
- ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
- ceErpTradeAfterSaleExtend.Create();
- }
- else
- {
- if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
- {
- ceErpTradeAfterSaleExtend.ChangeNum += 1;
- }
- ceErpTradeAfterSaleExtend.RefundFees = refundFees;
- ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
- ceErpTradeAfterSaleExtend.TextResult = textResult;
- ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
- ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
- ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
- ceErpTradeAfterSaleExtend.IsBad = IsBad;
- ceErpTradeAfterSaleExtend.Update();
- }
- int gysid = GetPostInt("ResponsibleSupId");
- if (entity.AfterSaleUserId == 0)
- {
- entity.AfterSaleUserId = CurrentUser.UserID;
- }
- entity.ResponsibleUserId = resIdStr;
- entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
- entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
- if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
- {
- CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
- int backNum = 0;
- if (number != null)
- {
- backNum = number.BackNum;
- }
- char[] separator = { ',' };
- string[] sArray = resIdStr.Split(separator);
- string[] refundFreeList = { };
- if (refundFees.Length > 0)
- {
- refundFreeList = refundFees.Split(separator);
- }
- int index = -1;
- List<int> responsibleIds = new List<int>();
- foreach (string i in sArray)
- {
- index++;
- if (i.Length <= 0) continue;
- char[] separator2 = { '_' };
- string idstr = i.Split(separator2)[0];
- string idtype = i.Split(separator2)[1];
- double refudFree = 0;
- if (refundFreeList.Length > 0)
- {
- refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
- }
- if (idtype == "s")
- {
- isDesign = true;
- designFree = refudFree;
- }
- int userId = Convert.ToInt32(idstr);
- int type = 0;
- if (idtype == "g")
- {
- type = 1;
- }
- if (idtype == "w")
- {
- type = 2;
- }
- if (idtype == "t")
- {
- type = 3;
- }
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
- if (ceErpTradeResponsible == null)
- {
- ceErpTradeResponsible = new CeErpTradeResponsible();
- ceErpTradeResponsible.tid = eid;
- ceErpTradeResponsible.UserId = userId;
- ceErpTradeResponsible.createdTime = DateTime.Now;
- ceErpTradeResponsible.type = type;
- if (type == 1)
- {
- ceErpTradeResponsible.IsSup = 1;
- }
- if (type == 2)
- {
- ceErpTradeResponsible.IsFlow = 1;
- }
- }
- int state = 0;
- //已认可的不需要再次认可
- if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
- {
- state = 1;
- }
- ceErpTradeResponsible.RefundFee = refudFree;
- ceErpTradeResponsible.VerifyState = state;
- if (userId == 2125 || idtype == "w")
- {
- ceErpTradeResponsible.VerifyState = 1;
- }
- if (idtype == "w" && userId == 101)
- {
- ceErpTradeResponsible.VerifyState = state;
- }
- if (ceErpTradeResponsible.ID > 0)
- {
- ceErpTradeResponsible.Update();
- }
- else
- {
- ceErpTradeResponsible.Create();
- }
- if (isDesign)
- {
- responsibleId = ceErpTradeResponsible.ID;
- }
- responsibleIds.Add(ceErpTradeResponsible.ID);
- }
- CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
- CeErpTradeResponsible.NumByTid(backNum, eid);
- }
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null)
- {
- ceErpTradeCellExtend.returnVisit = 0;
- ceErpTradeCellExtend.Update();
- }
- if (entity.HandleTime != null)
- {
- if (entity.AfterSaleState == 1)
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
- }
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
- entity.HandleTime = DateTime.Now;
- }
- bool isCompale = false;
- if (entity.AfterSaleState == 5)
- {
- isCompale = true;
- entity.AfterSaleState = 3;
- }
- entity.AfterSaleSupplierState = 0;
- if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
- }
- string sImgs = GetPostString("img");
- entity.AfterSaleSupplierImg = sImgs;
- entity.supRefundType = GetPostString("supRefundType");
- entity.AfterSaleReason = GetPostString("AfterSaleReason");
- entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
- entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
- entity.AfterSaleMemoType = GetPostString("MemoType");
- if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
- {
- //entity.AfterSaleSupplierState = 2;
- }
- string df = GetPostString("DeductFee");
- if (df == "")
- {
- df = "0";
- }
- string rf = GetPostString("RefundFee");
- if (rf == "")
- {
- rf = "0";
- }
- string pm = GetPostString("AfterSalePayment");
- if (pm == "")
- {
- pm = "0";
- }
- entity.AfterSalePayment = Convert.ToDouble(pm);
- entity.DeductFee = Convert.ToDouble(df);
- entity.RefundFee = Convert.ToDouble(rf);
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- string toState = GetPostString("ToState");
- string original = GetPostString("isOriginal");
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterDesign";
- apiVo.orderRemarks = entity.AfterSaleMethod;
- apiVo.reasonRemarks = entity.AfterSaleReason;
- apiVo.isDesign = isDesign;
- apiVo.designFree = designFree;
- apiVo.responsibleId = responsibleId;
- apiVo.afterFiles = entity.AfterSaleSupplierImg;
- if (toState == "设计师")
- {
- apiVo.isOriginal = Convert.ToBoolean(original);
- }
- designHelper.API_WorkCore(apiVo);//afterDesign
- CeErpMethod methodSql = new CeErpMethod();
- methodSql.con = entity.AfterSaleMethod;
- methodSql.addTime = DateTime.Now;
- methodSql.Create();
- string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
- CeErpMethod.ExecuteNonQuery(delsql);
- if (isCompale)
- {
- aftersale_data_change(entity.ctid);
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void ins_erp_toresponsible()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
- {
- returnErrorMsg("客户售后结果不能为空或不能为待处理!");
- return;
- }
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (entity.AfterSalePreTime == null)
- {
- if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
- {
- ceErpTradeAfterSaleExtend.PreTimeOut += 1;
- }
- }
- entity.AfterSalePreTime = DateTime.Now;
- //预完成给售后主管审核客户问题直接完成
- if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
- {
- if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
- {
- ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
- }
- }
- ceErpTradeAfterSaleExtend.Update();
- entity.AfterSaleState = 2;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
- aftersale_data_change(entity.ctid);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void cancel_erp_aftersaleanddelnew()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.AfterSaleState = 0;
- entity.AfterSaleReason = "";
- entity.AfterSaleMethod = "";
- entity.AfterSaleMemo = "";
- entity.AfterSaleResponsible = "";
- entity.ResponsibleUserId = "";
- entity.DeductFee = 0;
- entity.RefundFee = 0;
- entity.IsArbitrate = 0;
- CeErpTradeResponsible.DelByTid(eid, -1);
- entity.Update();
- CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
- if (after != null)
- {
- if (after.OrderState < 5)
- CeErpTradeCell.DelByCtid("S_" + eid);
- }
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_aftersale_pregather()
- {
- List<string> lw = new List<string>();
- int st = GetInt("st");
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterresult = GetPostString("afterresult");
- if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- var mainwhere = string.Join(" and ", lw.ToArray());
- string ro_json = "";
- string type = GetPostString("gather_type");
- int number = 0;
- if (poscode == "AfterSale")
- {
- //处理中
- if (type == "Handling")
- {
- 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) : ""));
- DataTable dt = null;
- try
- {
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- number = Convert.ToInt32(dt.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
- return;
- }
- if (type == "Wait")
- {
- //待处理
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- number = Convert.ToInt32(dt1.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
- return;
- }
- if (type == "back")
- {
- //打回
- string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt2 = null;
- try
- {
- dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
- number = Convert.ToInt32(dt2.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt2 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { back = number }));
- return;
- }
- if (type == "preCompletion")
- {
- //预完成
- string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt3 = null;
- try
- {
- dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
- number = Convert.ToInt32(dt3.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt3 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
- return;
- }
- if (type == "documentary")
- {
- //跟单中
- 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) : ""));
- DataTable dt4 = null;
- try
- {
- dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
- number = Convert.ToInt32(dt4.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt4 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
- return;
- }
- if (type == "reBack")
- {
- //被打回
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- number = Convert.ToInt32(dt1.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
- return;
- }
- }
- if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
- {
- if (type == "puBack")
- {
- //退回
- string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt = null;
- try
- {
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- number = Convert.ToInt32(dt.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
- return;
- }
- if (type == "reBack")
- {
- //打回
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- number = Convert.ToInt32(dt1.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
- return;
- }
- if (type == "examEd")
- {
- //已审核
- string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt2 = null;
- try
- {
- dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
- number = Convert.ToInt32(dt2.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt2 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
- return;
- }
- if (type == "waitExam")
- {
- //待审核
- string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt3 = null;
- try
- {
- dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
- number = Convert.ToInt32(dt3.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt3 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
- return;
- }
- if (type == "Handling")
- {
- //处理中
- 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) : ""));
- DataTable dt4 = null;
- try
- {
- dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
- number = Convert.ToInt32(dt4.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt4 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
- return;
- }
- if (type == "Wait")
- {
- //待处理
- string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt5 = null;
- try
- {
- dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
- number = Convert.ToInt32(dt5.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt5 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
- return;
- }
- if (type == "documentary")
- {
- //跟单中
- 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) : ""));
- DataTable dt6 = null;
- try
- {
- dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
- number = Convert.ToInt32(dt6.Rows[0]["number"]);
- }
- catch (Exception e)
- {
- dt6 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
- return;
- }
- }
- returnSuccess(ro_json);
- }
- public void end_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string stype = GetPostString("stype");
- string typeStr = stype;
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
- DbHelper.DbConn.ExecuteNonQuery(sqlupd);
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void ins_erp_finishaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpTradeResponsible entity = null;
- if (eid != "") entity = CeErpTradeResponsible.Get(eid);
- if (entity != null)
- {
- entity.VerifyState = 1;
- entity.VerifyTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
- string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
- if (dt.Rows.Count <= 0)
- {
- string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
- DbHelper.DbConn.ExecuteNonQuery(sqlupd);
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
- CeErpSukuraData.createInfo(entity.tid, 8);
- if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
- {
- CeErpDesignerBill.Del(entity.tid);
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_arbitrateaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpTradeResponsible entity = null;
- if (eid != "") entity = CeErpTradeResponsible.Get(eid);
- if (entity != null)
- {
- entity.IsArbitrate = 1;
- entity.ArbitradeMemo = GetPostString("reason");
- entity.VerifyState = 2;
- entity.Update();
- CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
- if (tradecell != null)
- {
- tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
- tradecell.IsArbitrate = 1;
- tradecell.Update();
- }
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_backaftersale()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string eid = GetPostString("tid");
- CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
- int backNum = 0;
- if (number != null)
- {
- backNum = number.BackNum;
- }
- CeErpTradeResponsible.NumByTid(backNum + 1, eid);
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.AfterSaleBackReason = GetPostString("backreason");
- entity.AfterSaleState = 1;
- entity.AfterSaleSupplierState = 0;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_supplieraftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- lw.Add(string.Format("AfterSaleState>={0}", 2));
- string supplier = GetPostString("supplier");
- int supid = commonHelper.getSupplierIDByName(supplier);
- if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
- string posCode = CurrentUser.UserPost.Post.Code;
- if (posCode == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- }
- else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("AfterSaleResSupId != 0"));
- }
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_supverifyaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- CeErpTradeCell entity = null;
- if (ceErpTradeResponsible != null)
- {
- entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- }
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- if (entity != null)
- {
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- ceErpTradeResponsible.VerifyState = 1;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (num <= 1)
- {
- entity.AfterSaleState = 1;
- }
- else
- {
- entity.AfterSaleState = 5;
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Create();
- }
- }
- if (entity.AfterSaleState == 4)
- {
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
- if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
- {
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_masteraftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- string textResult = GetPostString("textResult");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- if (ceErpTradeResponsible != null)
- {
- ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (entity != null)
- {
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- //退回到售后
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (num <= 1)
- {
- entity.AfterSaleState = 1;
- }
- else
- {
- entity.AfterSaleState = 5;
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Create();
- }
- }
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_personaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- //林小连
- if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
- {
- upd_erp_masteraftersale();
- return;
- }
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- if (ceErpTradeResponsible != null)
- {
- ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (entity != null)
- {
- entity.AfterSaleSupplierMemo = afmemo;
- entity.AfterSaleSupplierState = st;
- if (st == 1)
- {
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.Create();
- }
- //退回到主管
- //entity.AfterSaleState = 2;
- }
- if (entity.AfterSaleState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void set_erp_supplierrefundtag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.IsSupplierRefund = GetPostInt("tag");
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_refundlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- //string rid = GetPostString("refund_id");
- //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- //string date1 = GetPostString("date1");
- //string date2 = GetPostString("date2");
- //string dateType = GetPostString("dateType");
- //if (dateType.Length > 0)
- //{
- // if (dateType == "1001") dateType = "0";
- // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
- // if (searchDT.Count == 2)
- // {
- // date1 = searchDT[0].ToString();
- // date2 = searchDT[1].ToString();
- // }
- //}
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string redate1 = GetPostString("refunddate1");
- string redate2 = GetPostString("refunddate2");
- string dwdate = GetDateMinuteWhere("created", redate1, redate2);
- if (dwdate.Length > 0) lw.Add(dwdate);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string ispartrefund = GetPostString("ispartrefund");
- if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
- string refundState = GetPostString("refundvstate");
- if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
- int st = GetInt("st");
- if (st == 2) //待确认列表中,把state=3已确认的也显示
- {
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- lw.Add(string.Format("RefundState>={0}", st));
- string code = CurrentUser.UserPost.Post.Code;
- if (code == "CustomerService")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
- }
- else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
- }
- else if (code == "Place" || code == "PlaceMr")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
- }
- dStruct.Order = "RefundState asc,created desc";
- }
- else if (st == 10)
- {
- string responsible = GetPostString("responsibleman");
- if (responsible == "空白")
- {
- lw.Add(string.Format("ResponsibleUserName = ''"));
- }
- else if (responsible.Length > 0)
- {
- lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- }
- lw.Add(string.Format("RefundState>=0"));
- dStruct.Order = "created desc";
- }
- else
- {
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- lw.Add(string.Format("RefundState={0}", st));
- dStruct.Order = "created desc";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
- dt.Columns.Add("refund_fees");
- foreach (DataRow dr in dt.Rows)
- {
- String status = dr["status"].ToString();
- if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
- {
- dr["refund_fees"] = dr["refund_fee"];
- }
- else
- {
- dr["refund_fees"] = "0.0";
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_refunddesignlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string redate1 = GetPostString("refunddate1");
- string redate2 = GetPostString("refunddate2");
- string dwdate = GetDateMinuteWhere("created", redate1, redate2);
- if (dwdate.Length > 0) lw.Add(dwdate);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string ispartrefund = GetPostString("ispartrefund");
- if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
- string designerorg = GetPostString("designerorg");
- if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
- string refundState = GetPostString("refundState");
- if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
- int myOrgid = CurrentUser.UserPost.OrgID;
- string myOrgCode = CurrentUser.UserPost.Post.Code;
- if ("Designer".Equals(myOrgCode))//设计师能看到的
- {
- if (CurrentUser.User.TeamIds.Length > 0)
- {
- lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
- }
- else
- {
- lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
- }
- }
- else if ("SysAdmin".Equals(myOrgCode))
- {
- }
- else
- {
- if (CurrentUser.User.ManageOrgIds.Length > 0)
- {
- lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
- }
- else
- {
- lw.Add(string.Format("DesOrgID = {0}", myOrgid));
- }
- }
- lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
- dt.Columns.Add("refund_fees");
- foreach (DataRow dr in dt.Rows)
- {
- String status = dr["status"].ToString();
- if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
- {
- dr["refund_fees"] = dr["refund_fee"];
- }
- else
- {
- dr["refund_fees"] = "0.0";
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void handle_erp_refundtag()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- string respMan = GetPostString("ResponsibleName");
- if (respMan.Length <= 0)
- {
- returnErrorMsg("责任人不能为空");
- return;
- }
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- entity.ResponsibleUserName = respMan;
- string userid = GetPostString("ResponsibleUserId");
- if (userid.Length > 0)
- {
- entity.ResponsibleUserId = userid;
- }
- entity.Memo = GetPostString("Memo");
- if (respMan.IndexOf("客服") != -1 ||
- respMan.IndexOf("设计师") != -1 ||
- respMan.IndexOf("下单员") != -1)
- {
- entity.RefundState = 2;
- }
- else
- {
- entity.RefundState = 3;
- }
- entity.modified = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void handle_erp_designrefundtag()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = eid;
- }
- ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Create();
- }
- LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- public void upd_erp_refundverify()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
- entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
- entity.ResponsibleUserName.IndexOf("下单员") != -1)
- {
- entity.RefundState = 2;
- }
- else
- {
- entity.RefundState = 3;
- }
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_refundapprove()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- int apr = GetPostInt("approve");
- if (apr == 0)
- {
- entity.RefundState = 1;
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
- }
- else if (apr == 1)
- {
- entity.RefundState = 3;
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
- }
- entity.modified = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_billlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string title = GetPostString("title");
- if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
- string tid = GetPostString("tid");
- string tids = GetPostString("tids");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- if (tids.Length > 0)
- {
- tids = "'" + tids + "'";
- tids = tids.Replace(",", "','");
- lw.Add(string.Format("tid in ({0})", tids));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
- if (dw1.Length > 0) lw.Add(dw1);
- string billtype = GetPostString("billtype");
- if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
- string billstate = GetPostString("billstate");
- if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
- dStruct.Order = "createTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
- //foreach (DataRow dr in dt.Rows)
- //{
- // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
- //}
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void modify_erp_billinfo()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpBill bill_entity = null;
- if (eid != "") bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.tid = GetPostString("tid");
- bill_entity.title = GetPostString("title");
- bill_entity.tax = GetPostString("tax");
- bill_entity.bank = GetPostString("bank");
- bill_entity.bankac = GetPostString("bankac");
- bill_entity.address = GetPostString("address");
- bill_entity.phone = GetPostString("phone");
- bill_entity.price = GetPostString("price");
- bill_entity.productId = GetPostInt("ProductName");
- bill_entity.num = GetPostInt("num");
- bill_entity.unit = GetPostString("unit");
- bill_entity.type = GetPostString("type");
- bill_entity.sendType = GetPostString("SendType");
- bill_entity.email = GetPostString("email");
- bill_entity.buyer_nick = GetPostString("buyer_nick");
- bill_entity.shopName = GetPostString("ShopName");
- bill_entity.applymemo = GetPostString("applymemo");
- bill_entity.modifyTime = DateTime.Now;
- bill_entity.createTime = DateTime.Now;
- bill_entity.state = 0;
- bill_entity.Update();
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
- returnSuccessMsg("发票修改成功!");
- return;
- }
- returnErrorMsg("找不到对应记录");
- }
- }
- public void set_erp_invoicing()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string eid = GetPostString("id");
- CeErpBill bill_entity = null;
- if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- int ComId = GetPostInt("ComId");
- //string memo = GetPostString("Memo");
- int allInfo = GetPostInt("allinfo");
- string clert = CurrentUser.User.Name;
- //string detailValue = GetPostString("detailvalue");
- string billId = bill_entity.billOrderId;
- string[] billIdList = billId.Split(',');
- CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
- int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
- if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
- {
- billCount += 1;
- }
- if (billId.Length <= 0 || billIdList.Length != billCount)
- {
- bill_entity.billOrderId = "";
- string prebill = "ltb";
- for (int idx = 1; idx <= billCount; idx++)
- {
- string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
- string billoid = prebill + idx + dtstr;
- bill_entity.billOrderId += billoid;
- if (idx < billCount)
- {
- bill_entity.billOrderId += ",";
- }
- }
- }
- string[] billOrderList = bill_entity.billOrderId.Split(',');
- if (bill_entity.state == 5)
- {
- string errMsg = bill_entity.failerror;
- string[] errlist = errMsg.Split('|');
- string[] errTags = new string[errlist.Length];
- for (int itag = 0; itag < errlist.Length; itag++)
- {
- if (errlist[itag].Length <= 0) continue;
- errTags[itag] = errlist[itag].Split('&')[0];
- }
- for (int iii = 0; iii < errTags.Length; iii++)
- {
- if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
- int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
- if (billOrderList.Length >= erroBillOrderTag)
- {
- string needModifyBillId = billOrderList[erroBillOrderTag - 1];
- if (needModifyBillId.Length <= 19)
- {
- needModifyBillId = needModifyBillId + "1";
- }
- else
- {
- int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
- last = last + 1;
- needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
- }
- billOrderList[erroBillOrderTag - 1] = needModifyBillId;
- }
- }
- }
- bool isHaveBillSucces = false;
- string totalRes = "";
- bill_entity.failerror = "";
- for (int ii = 1; ii <= billOrderList.Length; ii++)
- {
- string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
- totalRes += res;
- if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
- {
- isHaveBillSucces = true;
- bill_entity.comId = ComId;
- bill_entity.state = 1;
- bill_entity.executeTime = DateTime.Now;
- bill_entity.executeUser = clert;
- }
- else
- {
- bill_entity.state = 5;
- bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
- }
- }
- bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
- bill_entity.Update();
- if (isHaveBillSucces)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
- if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
- {
- returnErrorMsg("开票失败");
- }
- else
- returnSuccessMsg("发票开具中,稍后刷新查看!");
- return;
- }
- returnErrorMsg("找不到对应记录");
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
- returnErrorMsg("操作失败");
- }
- }
- }
- public void get_erp_invoicing_back()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string id = GetPostString("id");
- CeErpBill entiy = CeErpBill.Get(id);
- if (entiy != null)
- {
- if (entiy.state == 0)
- {
- returnErrorMsg("发票还未开具");
- return;
- }
- string[] billOrderList = entiy.billOrderId.Split(',');
- int iTag = 0;
- entiy.fplsh = "";
- entiy.fpdm = "";
- entiy.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- string res = taobaoHelper.get_invoicing(id, billOrderId);
- if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
- {
- //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
- try
- {
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
- if (iObj != null)
- {
- entiy.state = 2;
- entiy.fplsh += iObj.list[0].c_fpqqlsh;
- entiy.fpdm += iObj.list[0].c_fpdm;
- entiy.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- entiy.fplsh += ",";
- entiy.fpdm += ",";
- entiy.fphm += ",";
- }
- entiy.Update();
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("开票成功");
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
- }
- return;
- }
- else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
- {
- var res_obj = new
- {
- data = "开票中"
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- return;
- }
- else
- {
- int eidx = res.IndexOf("c_resultmsg");
- int lidx = res.IndexOf("c_status");
- string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
- entiy.state = 5;
- entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
- entiy.Update();
- returnErrorMsg("开票失败");
- return;
- }
- }
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
- }
- return;
- }
- }
- public void get_erp_invoicing()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string id = GetPostString("id");
- CeErpBill entiy = CeErpBill.Get(id);
- if (entiy != null)
- {
- if (entiy.state == 0)
- {
- returnErrorMsg("发票还未开具");
- return;
- }
- if (entiy.sendType == "纸质发票")
- {
- if (entiy.img.Length <= 0)
- {
- returnErrorMsg("查无纸质发票");
- return;
- }
- string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
- returnSuccess(returnres);
- return;
- }
- string[] billOrderList = entiy.billOrderId.Split(',');
- int iTag = 0;
- string fpUrl = "";
- entiy.fplsh = "";
- entiy.fpdm = "";
- entiy.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- string res = taobaoHelper.get_invoicing(id, billOrderId);
- if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
- {
- //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
- if (iObj != null)
- {
- //entiy.state = 2;
- entiy.fplsh += iObj.list[0].c_fpqqlsh;
- entiy.fpdm += iObj.list[0].c_fpdm;
- entiy.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- entiy.fplsh += ",";
- entiy.fpdm += ",";
- entiy.fphm += ",";
- }
- entiy.Update();
- fpUrl += iObj.list[0].c_url + ",";
- }
- //returnSuccess(res);
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- else
- {
- int eidx = res.IndexOf("c_resultmsg");
- //int lidx = res.IndexOf("c_status");
- string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
- //开票失败
- entiy.state = 5;
- entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
- entiy.Update();
- returnErrorMsg("开票失败");
- return;
- }
- }
- var returnObj = new
- {
- data = fpUrl
- };
- string ro_json = JsonConvert.SerializeObject(returnObj);
- returnSuccess(ro_json);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
- }
- return;
- }
- }
- public void save_erp_billimg()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpBill bill_entity = null;
- if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.img = GetPostString("img");
- bill_entity.executeTime = DateTime.Now;
- bill_entity.state = 2;
- bill_entity.Update();
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
- returnSuccessMsg("保存成功");
- }
- return;
- }
- }
- public void upd_erp_billreturnback()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpBill bill_entity = null;
- if (eid != 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.state = 3;
- bill_entity.returnReason = GetPostString("reason");
- bill_entity.Update();
- returnSuccessMsg("驳回成功!");
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
- }
- return;
- }
- }
- public void cancel_erp_bill()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- int detailValue = GetPostInt("detailvalue");
- CeErpBill bill_entity = null;
- if (eid != 0) bill_entity = CeErpBill.Get(eid);
- string cres = "";
- string gres = "";
- if (bill_entity != null)
- {
- string[] billOrderList = bill_entity.billOrderId.Split(',');
- if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
- {
- int iTag = 0;
- bill_entity.fplsh = "";
- bill_entity.fpdm = "";
- bill_entity.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
- if (gres.IndexOf("success") != -1)
- {
- //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
- if (iObj != null)
- {
- bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
- bill_entity.fpdm += iObj.list[0].c_fpdm;
- bill_entity.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- bill_entity.fplsh += ",";
- bill_entity.fpdm += ",";
- bill_entity.fphm += ",";
- }
- bill_entity.Update();
- }
- }
- else
- {
- returnErrorMsg(gres);
- return;
- }
- }
- }
- if (bill_entity.sendType == "纸质发票")
- {
- //作废
- //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
- //if (DateTime.Now.Month == extime.Month)
- //{
- //cres = taobaoHelper.cancel_invoicing(eid);
- //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
- //{
- bill_entity.state = 4;//已作废
- bill_entity.Update();
- returnSuccessMsg("发票已作废");
- return;
- //}
- //else
- //{
- // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
- // bill_entity.Update();
- // returnErrorMsg(cres);
- // return;
- //}
- //}
- //else
- //{
- // returnErrorMsg("纸质发票只能作废本月的发票");
- // return;
- //}
- }
- //红冲
- int redTag = 0;
- string[] fpdmList = bill_entity.fpdm.Split(',');
- string[] fphmList = bill_entity.fphm.Split(',');
- if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
- {
- returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
- return;
- }
- foreach (string billOrderId in billOrderList)
- {
- redTag++;
- string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
- cres += onecres;
- cres += ",";
- if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
- {
- bill_entity.state = 4;//已作废
- //bill_entity.Update();
- //returnSuccessMsg("发票已红冲");
- }
- else if (onecres.IndexOf("重复冲红") != -1)
- {
- bill_entity.state = 4;//已作废
- //bill_entity.Update();
- //returnSuccessMsg("发票已红冲");
- }
- else
- {
- string errmsg = commonHelper.KeepChinese(onecres);
- bill_entity.failerror += redTag + "&" + errmsg + "|";
- }
- }
- bill_entity.Update();
- if (cres.IndexOf("失败") != -1)
- returnErrorMsg("红冲失败");
- else
- returnSuccessMsg("发票已红冲");
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
- return;
- }
- return;
- }
- }
- public void del_erp_billorder()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpBill.Del(eid);
- CeErpBill bill = CeErpBill.Get(eid);
- if (bill != null)
- {
- LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
- }
- returnSuccessMsg("删除成功");
- }
- }
- public void finish_erp_bill()
- {
- if (UrlPostParmsCheck("ids"))
- {
- string eids = GetPostString("ids");
- string[] list = eids.Split(',');
- foreach (string eid in list)
- {
- CeErpBill bill = CeErpBill.Get(eid);
- if (bill != null)
- {
- bill.state = 2;
- bill.Update();
- LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
- }
- }
- returnSuccessMsg("操作成功");
- }
- }
- public void get_erp_returncash()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string returntype = GetPostString("returntype");
- if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_staygoods()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
- string wangwang = GetPostString("wangwang");
- if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
- string persuadetype = GetPostString("persuadetype");
- if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
- string customerOrg = GetPostString("customerOrg");
- if (customerOrg.Length > 0)
- {
- lw.Add(string.Format("OrgID = {0}", customerOrg));
- }
- dStruct.Order = "creata_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_staygoods()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpStayGoods entity = null;
- if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
- if (entity != null)
- {
- entity.audit_type = 1;
- entity.audit_time = DateTime.Now;
- entity.audit_u_id = CurrentUser.UserID;
- entity.audit_u_name = CurrentUser.UserName;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_stayGoodsback()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpStayGoods entity = null;
- if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
- if (entity != null)
- {
- entity.audit_text = GetPostString("reason");
- entity.audit_type = 2;
- entity.audit_time = DateTime.Now;
- entity.audit_u_id = CurrentUser.UserID;
- entity.audit_u_name = CurrentUser.UserName;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returncashverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- entity.cashstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_all_erp_returncashverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- String[] list = GetPostString("ID").Split(',');
- CeErpReturnCash entity = null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
- if (entity != null)
- {
- if (entity.cashstate == 1)
- {
- returnErrorMsg("已审核过的订单不需要在审核!");
- return;
- }
- entity.cashstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- }
- }
- returnSuccessMsg("审核成功!");
- return;
- }
- }
- public void upd_erp_returncashback()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- entity.backreason = GetPostString("reason");
- entity.cashstate = 2;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returnprice()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- if (entity.cashstate == 1)
- {
- returnErrorMsg("审核通过了不能改");
- return;
- }
- entity.returnprice = GetPostDouble("returnprice");
- entity.Update();
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void del_erp_returncash()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash.Del(eid);
- returnSuccessMsg("操作成功");
- return;
- }
- }
- public void test_for_do_sql()
- {
- string sql = GetPostString("sqlstr");
- if (sql.Length > 0)
- {
- try
- {
- DbHelper.DbConn.ExecuteNonQuery(sql);
- var res_obj = new
- {
- data = "成功",
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- catch (Exception ex)
- {
- var res_obj = new
- {
- data = ex.Message,
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- }
- }
- public void get_user_info()
- {
- DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
- }
- public void get_total_data()
- {
- int userId = CurrentUser.UserID;
- string sql = "";
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- 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);
- }
- else
- {
- 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 " +
- "(select ID from CE_ErpUser where ID = {0}) d " +
- "left join " +
- "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
- ") a on d.ID = a.id left join " +
- "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
- ") b on a.id = b.id1 left join" +
- "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
- ") c on a.id = c.id2;", userId);
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_date_area_total_data2()
- {
- int userId = CurrentUser.UserID;
- string date_type = GetPostString("timetype");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = "";
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
- "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
- "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
- "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
- "(select ID from CE_ErpUser where ID = {0}) e left join " +
- "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
- " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") a on e.ID = a.id left join " +
- "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
- " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") b on a.id = b.id1 " +
- "left join " +
- "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
- " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") c on a.id = c.id2 " +
- "left join " +
- "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
- " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
- ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
- }
- else
- {
- sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
- "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
- "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
- "(select ID from CE_ErpUser where ID = {0}) e left join " +
- "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
- " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
- ") a on e.ID = a.id left join " +
- "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
- " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
- ") c on a.id = c.id2 " +
- "left join " +
- "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
- " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
- ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_date_area_total_data()
- {
- int userId = CurrentUser.UserID;
- string date_type = GetPostString("timetype");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string date1 = searchDT[0].ToString();
- string date2 = searchDT[1].ToString();
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- SqlParameter[] sqlParameter ={
- new SqlParameter("@userId", SqlDbType.Int,4),
- new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@res", SqlDbType.VarChar, 4000)
- };
- sqlParameter[0].Value = userId;
- sqlParameter[1].Value = date1;
- sqlParameter[2].Value = date2;
- sqlParameter[3].Direction = ParameterDirection.Output;
- DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
- string res = sqlParameter[3].Value.ToString();
- var res_obj = new
- {
- data = res
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- else
- {
- SqlParameter[] sqlParameter ={
- new SqlParameter("@userId", SqlDbType.Int,4),
- new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@res", SqlDbType.VarChar, 4000)
- };
- sqlParameter[0].Value = userId;
- sqlParameter[1].Value = date1;
- sqlParameter[2].Value = date2;
- sqlParameter[3].Direction = ParameterDirection.Output;
- DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
- string res = sqlParameter[3].Value.ToString();
- var res_obj = new
- {
- data = res
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- //writeGridDataViewJson(dt.Rows.Count, dv);
- }
- public void get_order_list()
- {
- string strFields = GetPostString("paraFields");
- string strOrder = GetPostString("paraOrder");
- string strWhere = GetPostString("paraWhere");
- string strPageSize = GetPostString("paraPageSize");
- DataStruct dStruct = GetPostStruct();
- dStruct.PageSize = int.Parse(strPageSize);
- dStruct.Fileds = strFields;
- dStruct.Order = strOrder;
- dStruct.MainWhere = strWhere;
- DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- ////获取待开始订单列表
- //public void get_wait_design_order_list()
- //{
- // string date_type = GetPostString("date_type");
- // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- // DataStruct dStruct = GetPostStruct();
- // dStruct.PageSize = 1000;
- // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
- // List<string> lw = new List<string>();
- // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
- // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
- // dStruct.Order = "WaitDesignTime asc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- //获取完成单量排名
- public void get_finish_order_count_ranking()
- {
- /* string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
- "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
- "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
- writeGridDataTableJson(0, new DataTable());
- }
- public void get_finish_order_amount_ranking()
- {
- /*string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
- "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
- "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
- writeGridDataTableJson(0, new DataTable());
- }
- public void get_finish_refund_count_ranking()
- {
- string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
- "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
- "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- public void get_finish_refund_amount_ranking()
- {
- string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
- "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
- "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- public void set_erp_finishorder_director()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 8;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_placeregistlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string outsid = GetPostString("outsid");
- if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
- string memo = GetPostString("memo");
- if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
- string filename = GetPostString("filename");
- if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
- string islate = GetPostString("islate");
- if (islate.Length > 0)
- {
- if (islate == "1")
- lw.Add(string.Format("OutLate>0"));
- else
- lw.Add(string.Format("OutLate=0"));
- }
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
- if (dw.Length > 0) lw.Add(dw);
- string deliveryDate1 = GetPostString("deliverydate1");
- string deliveryDate2 = GetPostString("deliverydate2");
- string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
- if (dw_deli.Length > 0) lw.Add(dw_deli);
- dStruct.Order = "ID desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void ins_erp_placeregist()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpPlaceRegister entity = null;
- if (eid == "0")//新增
- {
- entity = new CeErpPlaceRegister();
- string xdTime = GetPostString("placeTime");
- if (xdTime.Length > 0)
- {
- entity.PlactTime = Convert.ToDateTime(xdTime);
- }
- string fhTime = GetPostString("deliveryTime");
- if (fhTime.Length > 0)
- {
- entity.DeliveryTime = Convert.ToDateTime(fhTime);
- }
- string preTime = GetPostString("preOutTime");
- if (preTime.Length > 0)
- {
- entity.PreOutTime = Convert.ToDateTime(preTime);
- }
- entity.DeliveryCount = GetPostInt("deliveryCount");
- entity.ReceiveCount = GetPostInt("receiveCount");
- entity.OutSid = GetPostString("outSid");
- entity.FileName = GetPostString("fileName");
- entity.Memo = GetPostString("memo");
- entity.AddUserId = CurrentUser.UserID;
- entity.CreateTime = DateTime.Now;
- entity.Img = GetPostString("img");
- entity.Supplier = GetPostInt("supplier");
- entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
- if (entity.PreOutTime != null && entity.DeliveryTime != null)
- {
- DateTime dt1 = (DateTime)entity.DeliveryTime;
- DateTime dt2 = (DateTime)entity.PreOutTime;
- TimeSpan span = dt1.Subtract(dt2);
- if (span.Days > 0)
- {
- entity.OutLate = span.Days;
- }
- }
- entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
- entity.Create();
- returnSuccessMsg("添加成功!");
- return;
- }
- else //修改
- {
- entity = CeErpPlaceRegister.Get(eid);
- if (entity != null)
- {
- string xdTime = GetPostString("placeTime");
- if (xdTime.Length > 0)
- {
- entity.PlactTime = Convert.ToDateTime(xdTime);
- }
- string fhTime = GetPostString("deliveryTime");
- if (fhTime.Length > 0)
- {
- entity.DeliveryTime = Convert.ToDateTime(fhTime);
- }
- string preTime = GetPostString("preOutTime");
- if (preTime.Length > 0)
- {
- entity.PreOutTime = Convert.ToDateTime(preTime);
- }
- entity.DeliveryCount = GetPostInt("deliveryCount");
- entity.ReceiveCount = GetPostInt("receiveCount");
- if (entity.DeliveryCount == entity.ReceiveCount)
- {
- entity.CurState = "已完成";
- }
- else
- {
- entity.CurState = "未完成";
- }
- entity.OutSid = GetPostString("outSid");
- entity.FileName = GetPostString("fileName");
- entity.Memo = GetPostString("memo");
- entity.Img = GetPostString("img");
- entity.Supplier = GetPostInt("supplier");
- //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
- if (entity.PreOutTime != null && entity.DeliveryTime != null)
- {
- DateTime dt1 = (DateTime)entity.DeliveryTime;
- DateTime dt2 = (DateTime)entity.PreOutTime;
- TimeSpan span = dt1.Subtract(dt2);
- if (span.Days > 0)
- {
- entity.OutLate = span.Days;
- }
- }
- entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
- entity.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("找不到对应的记录");
- return;
- }
- }
- returnErrorMsg("缺少必要参数");
- }
- public void del_erp_placeregist()
- {
- string eid = GetPostString("id");
- CeErpPlaceRegister.Del(eid);
- returnSuccessMsg("删除成功!");
- return;
- }
- public void ins_erp_placeregistbyorder()
- {
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- CeErpPlaceRegister entity = new CeErpPlaceRegister();
- entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
- entity.AddUserId = CurrentUser.UserID;
- entity.tid = dr["tid"].ToString();
- entity.Did = Convert.ToString(dr["ctid"]);
- entity.splitTag = dr["SplitTag"].ToString();
- string sellmemo = Convert.ToString(dr["seller_memo"]);
- string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
- if (pre_ctid.Length > 0)
- {
- sellmemo = sellmemo.Replace(pre_ctid, "");
- }
- sellmemo = sellmemo.Replace("[", "");
- sellmemo = sellmemo.Replace("]", "");
- entity.FileName = sellmemo;
- string count = dr["ProductCount"].ToString();
- int usecount = commonHelper.getIntCountFromString(count);
- entity.DeliveryCount = usecount;
- entity.CurState = "未完成";
- if (Convert.ToInt32(dr["SupplierId"]) == 0)
- {
- entity.Supplier = 24;//dl手提袋定制
- }
- else
- entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
- entity.CreateTime = DateTime.Now;
- entity.Create();
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("没有找到对应订单");
- return;
- }
- returnErrorMsg("缺少订单编号");
- return;
- }
- public void get_erp_persuadelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string persuadetype = GetPostString("persuadetype");
- if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_returnpersuadeback()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpPersuade entity = null;
- if (eid != 0) entity = CeErpPersuade.Get(eid);
- if (entity != null)
- {
- entity.backreason = GetPostString("reason");
- entity.pstate = 2;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returnpersuadeverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- if (CurrentUser.UserPost.Post.Code != "Summarize")
- {
- returnErrorMsg("暂无权限审核");
- return;
- }
- int eid = GetPostInt("ID");
- CeErpPersuade entity = null;
- if (eid != 0) entity = CeErpPersuade.Get(eid);
- if (entity != null)
- {
- entity.pstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void del_erp_persuade()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpPersuade.Del(eid);
- returnSuccessMsg("操作成功");
- return;
- }
- }
- public void get_erp_oldcustoupload()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0)
- {
- lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- }
- else
- return;
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_checkorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (CurrentUser.UserPost.Post.Code == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string checkst = GetPostString("checkstate");
- if (checkst.Length > 0 && "10".Equals(checkst))
- {
- lw.Add(string.Format("CheckOut>0"));
- }
- else
- {
- if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
- lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
- }
- if (CurrentUser.UserPost.Post.Code == "AfterSale")
- {
- lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
- }
- dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void ins_erp_startCheck()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.MemoOpt = 4;
- entity.UpdateTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
- CeErpSukuraData.createInfo(entity.ctid, 6);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_sendXlw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSendGift == 1)
- {
- returnErrorMsg("请勿重复标记");
- return;
- }
- entity.IsSendGift = 1;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void cancel_sendXlw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSendGift == 0)
- {
- returnErrorMsg("未标记小礼物");
- return;
- }
- entity.IsSendGift = 0;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_designbill()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int isMy = GetInt("my");
- if (isMy == 1)
- {
- lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
- }
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string userName = GetPostString("design");
- if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
- string rePrice1 = GetPostString("rePrice1");
- if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
- string rePrice2 = GetPostString("rePrice2");
- if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
- string designerType = GetPostString("designerType");
- if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string endTime1 = GetPostString("endTime1");
- string endTime2 = GetPostString("endTime2");
- string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
- if (dw.Length > 0) lw.Add(dw);
- string isDk = GetPostString("isDk");
- if (isDk == "1")
- {
- lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
- }
- else if (isDk == "0")
- {
- lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
- }
- dStruct.Order = "oid, create_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_designerbill()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpDesignerBill entity = null;
- if (eid != "") entity = CeErpDesignerBill.Get(eid);
- if (entity != null)
- {
- if (GetPostDouble("designerpirce") > 0)
- {
- entity.realPrice = GetPostDouble("designerpirce");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- else
- {
- entity.price = GetPostDouble("price");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void audit_erp_designerbill()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpDesignerBill entity = null;
- if (eid != "") entity = CeErpDesignerBill.Get(eid);
- CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.realPrice = GetPostDouble("designerpirce");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- entity.isAudit = 1;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
- entity.Update();
- if (orderEntity != null)
- {
- orderEntity.IsReadTag = 3;
- orderEntity.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void all_audit_erp_designerbill()
- {
- if (UrlPostParmsCheck("idList"))
- {
- string[] list = GetPostString("idList").Split(',');
- CeErpDesignerBill entity = null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
- if (entity == null) return;
- CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
- if (orderEntity == null) return;
- if (entity.realPrice == 0) entity.realPrice = entity.price;
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- entity.isAudit = 1;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
- entity.Update();
- orderEntity.IsReadTag = 3;
- orderEntity.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_sameorders()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- var res = new
- {
- data = dt.Rows.Count
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- returnErrorMsg("未找到订单");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void get_erp_islasthavesameorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string[] ctidList = eid.Split(',');
- StringBuilder sql = new StringBuilder();
- string tisCtid = "";
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- sql = new StringBuilder();
- sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dth.Rows.Count > 0)
- {
- tisCtid += entity.ctid;
- tisCtid += ",";
- }
- }
- }
- if (tisCtid.Length > 0)
- {
- var res = new
- {
- data = tisCtid
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- }
- else
- {
- var res = new
- {
- data = ""
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- }
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void file_client_down_url()
- {
- if (!UrlPostParmsCheck("userId"))
- {
- returnErrorMsg("缺少必要的参数");
- }
- returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
- }
- public void checkout_form_data()
- {
- if (!UrlPostParmsCheck("tid"))
- {
- returnErrorMsg("缺少必要的参数");
- }
- string tid = GetPostString("tid");
- CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
- if (ceErpOrderFormData != null)
- {
- string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
- returnSuccess(ro_jsond);
- return;
- }
- returnErrorMsg("尚未有文件!");
- }
- public void back_supplier_audit()
- {
- int userId = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- 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);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- }
- public void back_supplier_query()
- {
- string eid = GetPostString("ctid");
- if (eid != "")
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnErrorMsg("找不到订单记录");
- return;
- }
- }
- public void verified_to_order()
- {
- int userId = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- }
- public void upd_supplier_audit()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- CeWithdraw withdraw = null;
- withdraw = CeWithdraw.GetByTid(eid);
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
- {
- if (withdraw != null)
- {
- if (!withdraw.userid.Equals(CurrentUser.UserID))
- {
- returnSuccessMsg("您没有权限操作!");
- return;
- }
- else
- {
- if (reason.Equals("1"))
- {
- if (entity.OrderState == -1)
- {
- if (entity.FinishPlaceTime == null)
- {
- entity.OrderState = 2;
- }
- else
- {
- entity.OrderState = 6;
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("查看详细请点击线下订单查询");
- return;
- }
- }
- }
- // 第一个字符是 'N'
- }
- if (eid[0] != 'N')
- {
- }
- if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
- {
- entity.IsVerifyToSupplier = false;
- entity.IsReturn = 1;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- if (entity.OrderState == 6)
- {
- entity.OrderState = 5;
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else if (int.Parse(reason) == 2 && entity.OrderState > 2)
- {
- ;
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("供应商取消撤回!");
- return;
- }
- }
- else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
- {
- if (entity.OrderState == -1)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
- {
- returnErrorMsg("台湾客户需填写身份证!");
- return;
- }
- if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0)
- {
- returnErrorMsg("偏远地区需要填写物流费!");
- return;
- }
- if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
- {
- returnErrorMsg("订单spu没有确认无法通过审核!");
- return;
- }
- if (entity.FinishPlaceTime == null)
- {
- entity.OrderState = 2;
- }
- else
- {
- entity.OrderState = 3;
- }
- commonHelper.getCytPrice(entity);
- tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else if (int.Parse(reason) == 2 && entity.OrderState < 0)
- {
- if (withdraw == null)
- {
- returnSuccessMsg("驳回操作成功!可重新发起审核!");
- return;
- }
- }
- else if (int.Parse(reason) == 4 && entity.OrderState < 0)
- {
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("查看详细请点击线下订单查询");
- return;
- }
- }
- return;
- }
- }
- //校验报价
- public void refund_order_tip()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- List<string> ids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- ids.Add(dr["ID"].ToString());
- }
- try
- {
- /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
- }
- catch (Exception ex)
- {
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void refund_order_Design()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- List<string> ids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- ids.Add(dr["ID"].ToString());
- }
- try
- {
- string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- }
- catch (Exception ex)
- {
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void change_order_info()
- {
- int userid = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- 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);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void change_win_mome()
- {
- if (UrlPostParmsCheck("id,ctid"))
- {
- string id = GetPostString("id");
- string ctid = GetPostString("ctid");
- CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
- CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
- if (ce == null || ceErpMessageTip == null)
- {
- returnSuccessMsg("未找到对应的订单!");
- return;
- }
- if (ce.OrderState >= 5)
- {
- ceErpMessageTip.isVisit = true;
- ceErpMessageTip.Update();
- returnSuccessMsg("已上传文件无法修改!");
- return;
- }
- int type = GetPostInt("type");
- string content = GetPostString("content");
- if (type == 0)
- {
- content = content.Replace("(", "(");
- content = content.Replace(")", ")");
- string check = MidStrEx(content, "(", ")").Trim();
- if (string.IsNullOrEmpty(check))
- {
- returnSuccessMsg("文件名格式不正确");
- return;
- }
- }
- ce.seller_memo = content;
- ce.Update();
- ceErpMessageTip.isVisit = true;
- ceErpMessageTip.Update();
- string text = type == 0 ? "同意修改:" + content : "不同意修改";
- LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ce.ctid;
- apiVo.actionName = "demandDesign";
- apiVo.orderRemarks = content;
- apiVo.demandExamine = type + 1;
- designHelper.API_WorkCore(apiVo);//demandDesign
- returnSuccessMsg("修改成功!");
- }
- }
- public static string MidStrEx(string sourse, string startstr, string endstr)
- {
- string result = string.Empty;
- int startindex, endindex;
- try
- {
- startindex = sourse.IndexOf(startstr);
- if (startindex == -1)
- return result;
- string tmpstr = sourse.Substring(startindex + startstr.Length);
- endindex = tmpstr.IndexOf(endstr);
- if (endindex == -1)
- return result;
- result = tmpstr.Remove(endindex);
- }
- catch (Exception ex)
- {
- Console.WriteLine("MidStrEx Err:" + ex.Message);
- }
- return result;
- }
- public void refund_order_list()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- DataStruct dStruct = GetPostStruct();
- DataTable dt = null;
- List<string> ids = new List<string>();
- List<string> tids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- tids.Add("'" + dr["tid"].ToString() + "'");
- ids.Add(dr["id"].ToString());
- }
- try
- {
- string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- List<string> lw = new List<string>();
- lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_orderlist", dStruct);
- }
- catch (Exception ex)
- {
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
- }
- //新增
- public void order_batch_downloads()
- {
- string ceid = GetPostString("tid");
- String[] tid = ceid.Split(',');
- order_batch_caiyingtong(tid);
- /* (string success, string errors) = UploadFiles(tid);
- returnSuccessMsg(success + errors);*/
- return;
- }
- //报价接口
- public void Get_To_Quote()
- {
- string ceid = GetPostString("ctid");
- if (ceid != null)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
- if (entity != null)
- {
- if (entity.seller_memo.IndexOf("种子纸") > -1)
- {
- return;
- }
- CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
- double price = 0;
- if (cp == null)
- {
- JObject jsonObject12 = new JObject
- {
- { "UserId", "77886" },
- { "Pwd", "lt666888" },
- { "Filename", entity.seller_memo }
- };
- string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
- JObject jsonObjects1 = JObject.Parse(response1);
- string ms1g = (string)jsonObjects1["msg"];
- if (ms1g == "报价成功")
- {
- JObject jsonObject1 = (JObject)jsonObjects1["data"];
- string data = (string)jsonObject1["price"];
- 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 + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- returnSuccessMsg("获取报价成功:" + data);
- price = Convert.ToDouble(data);
- }
- else
- {
- returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
- return;
- }
- }
- String[] beizhu = entity.seller_memo.Split('-');
- String chanp = "";
- if (beizhu.Length > 0)
- {
- chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
- }
- else
- {
- chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
- }
- JObject jsonObject = new JObject
- {
- { "UserId", "77886" },
- { "Pwd", "lt666888" },
- { "Filename", chanp }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- JObject jsonObject1 = (JObject)jsonObjects["data"];
- string data = (string)jsonObject1["price"];
- 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 + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- returnSuccessMsg("获取报价成功:" + data);
- price = Convert.ToDouble(data);
- }
- else
- {
- returnErrorMsg("获取报价失败,检查备注格式" + msg);
- return;
- }
- if (price > 0)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = entity.ctid;
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Update();
- }
- }
- return;
- }
- }
- else
- {
- returnErrorMsg("请至少选择一条数据");
- return;
- }
- }
- //新增
- public void order_To_Supplier()
- {
- string ceid = GetPostString("tid");
- String[] tid = ceid.Split(',');
- if (tid.Length > 0)
- {
- try
- {
- for (int i = 0; i < tid.Length; i++)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- entity.Update();
- }
- }
- catch (Exception ex)
- {
- returnErrorMsg("自动匹配供应商失败");
- return;
- }
- }
- else
- {
- returnErrorMsg("请至少选择一条数据");
- return;
- }
- returnSuccessMsg("自动匹配供应商成功");
- return;
- }
- public (string, string) UploadFiles(string[] urls)
- {
- string success = "";
- string errors = "";
- int userid = CurrentUser.UserID;
- foreach (string url in urls)
- {
- String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
- (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
- if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
- {
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "cyt86435015" },
- { "content", base64FileContent },
- { "ext", Path.GetExtension(fileName) }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg.Equals("上传成功"))
- {
- success += url + " 上传成功";
- }
- else
- {
- errors += url + " 上传失败";
- }
- }
- else
- {
- errors += url + " 格式出现问题";
- }
- }
- if (urls.Length == 0)
- {
- return (success, errors);
- }
- return (success, errors);
- }
- private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
- {
- return true; //总是接受
- }
- public static string HttpPost(string url, string param = null)
- {
- HttpWebRequest request;
- //如果是发送HTTPS请求
- if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
- {
- ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
- request = WebRequest.Create(url) as HttpWebRequest;
- request.ProtocolVersion = HttpVersion.Version10;
- }
- else
- {
- request = WebRequest.Create(url) as HttpWebRequest;
- }
- request.Method = "POST";
- request.ContentType = "application/json";
- request.Accept = "*/*";
- request.Timeout = 120000;
- request.AllowAutoRedirect = false;
- StreamWriter requestStream = null;
- WebResponse response = null;
- string responseStr = null;
- try
- {
- requestStream = new StreamWriter(request.GetRequestStream());
- requestStream.Write(param);
- requestStream.Close();
- response = request.GetResponse();
- if (response != null)
- {
- StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
- responseStr = reader.ReadToEnd();
- reader.Close();
- }
- }
- catch (Exception ex)
- {
- return ex.Message;
- }
- finally
- {
- request = null;
- requestStream = null;
- response = null;
- }
- return responseStr;
- }
- public (string, string) DownloadAndConvertToBase64(string downloadUrl)
- {
- string base64FileContent;
- string fileName;
- using (WebClient webClient = new WebClient())
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
- using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
- {
- using (Stream stream = response.GetResponseStream())
- {
- using (MemoryStream memoryStream = new MemoryStream())
- {
- stream.CopyTo(memoryStream);
- byte[] fileBytes = memoryStream.ToArray();
- base64FileContent = Convert.ToBase64String(fileBytes);
- fileName = response.Headers["Content-Disposition"];
- if (!string.IsNullOrEmpty(fileName))
- {
- int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
- if (index >= 0)
- {
- fileName = fileName.Substring(index + 9).Trim('\"');
- }
- }
- else
- {
- fileName = Path.GetFileName(downloadUrl);
- }
- }
- }
- }
- }
- return (fileName, base64FileContent);
- }
- //新增
- public void order_batch_caiyingtong(string[] downloadUrls)
- {
- try
- {
- //遍历文件
- DataStruct dStruct = GetPostStruct();
- DataTable dt = null;
- int userid = CurrentUser.UserID;
- List<string> ids = new List<string>();//失败组
- List<string> tids = new List<string>();
- using (WebClient webClient = new WebClient())
- {
- foreach (var url in downloadUrls)
- {
- try
- {
- tids.Add("'" + url + "'");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
- if (entity != null)
- {
- CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
- if (cp == null)
- {
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "lt666888" },
- { "Filename",entity.seller_memo }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
- DownloadAndConvertToBase64(url1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
- }
- }
- else
- {
- String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "lt666888" },
- { "Filename",chanp }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
- DownloadAndConvertToBase64(url1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
- }
- }
- }
- // 上传文件到FTP
- }
- catch (Exception ex)
- {
- Console.WriteLine($"An error occurred: {ex.Message}");
- }
- }
- List<string> lw = new List<string>();
- lw.Add(string.Format("( OrderState < 6 )"));
- lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- ids.Add(dr["ctid"].ToString());
- }
- }
- String ErrorMsgs = "";
- foreach (String id in ids)
- {
- ErrorMsgs += id + ",";
- }
- if (ErrorMsgs.Length > 1)
- {
- ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
- }
- if (ErrorMsgs.Length < 1)
- {
- ErrorMsgs = "上传成功";
- returnSuccessMsg(ErrorMsgs);
- }
- else
- {
- returnErrorMsg("以下订单" + ErrorMsgs);
- }
- }
- // 删除文件夹及其内容
- /* Directory.Delete(localDirectory, true);*/
- }
- catch { }
- }
- public void get_center_data()
- {
- int userId = CurrentUser.UserID;
- string postCode = CurrentUser.UserPost.Post.Code;
- List<string> lw = new List<string>();
- List<string> ww = new List<string>();
- DateTime currentTime = DateTime.Now;
- string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
- string sql = " SELECT ";
- string startTime = "2023-10-01 11:22:31";
- //设计
- if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
- {
- lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
- 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));
- lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
- 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));
- }
- //客服
- else if (postCode == "CustomerService" || postCode == "Director")
- {
- lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
- 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));
- lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
- 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));
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
- 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));
- lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
- 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));
- }
- //售后
- else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
- 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));
- lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
- 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));
- }
- //下单部
- else if (postCode == "Place" || postCode == "PlaceMr")
- {
- lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
- 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));
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- }
- //车间
- else if (postCode == "Supplier")
- {
- lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
- 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));
- }
- DataTable dt = new DataTable();
- if (lw.Count > 0)
- {
- sql += string.Join(" , ", lw);
- sql += " FROM ";
- sql += string.Join(" , ", ww);
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_center_data_list()
- {
- int userId = CurrentUser.UserID;
- string postCode = CurrentUser.UserPost.Post.Code;
- string shopIds = CurrentUser.User.pemShop;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- DateTime currentTime = DateTime.Now;
- string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
- string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string startTime = "2023-10-01 11:22:31";
- int order_type = GetPostInt("order_type");
- if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
- {
- lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
- if (order_type == 0)
- {
- lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
- }
- else if (order_type == 3)
- {
- lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //客服
- if (postCode == "CustomerService" || postCode == "Director")
- {
- lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
- if (order_type == 0)
- {
- lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
- }
- else if (order_type == 1)
- {
- lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
- }
- else if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else if (order_type == 3)
- {
- lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
- }
- else if (order_type == 4)
- {
- lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //售后
- if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (shopIds != "")
- {
- lw.Add(string.Format("ShopId in ({0})", shopIds));
- }
- if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else if (order_type == 4)
- {
- lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
- }
- else if (order_type == 5)
- {
- lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //下单部
- if (postCode == "Place" || postCode == "PlaceMr")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (shopIds != "")
- {
- lw.Add(string.Format("ShopId in ({0})", shopIds));
- }
- else if (order_type == 1)
- {
- lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
- }
- else if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //车间
- if (postCode == "Supplier")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (order_type == 5)
- {
- lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Fileds = "tid,ctid";
- DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void aftersale_audit_master()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0)
- {
- bool result = aftersale_data_change(ctid);
- if (result)
- {
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- returnErrorMsg("找不到指定售后单对应的原始订单!");
- }
- }
- public void aftersale_batch_audit_master()
- {
- if (UrlPostParmsCheck("ctids"))
- {
- string ctids = GetPostString("ctids");
- if (ctids.Length > 0)
- {
- List<string> list = new List<string>();
- string[] ctid_list = ctids.Split(',');
- foreach (var item in ctid_list)
- {
- bool result = aftersale_data_change(item);
- if (!result)
- {
- list.Add(item);
- }
- }
- if (list.Count > 0)
- {
- returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
- return;
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到指定售后单对应的原始订单!");
- }
- }
- public bool aftersale_data_change(string ctid)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
- ceErpTradeCell.AfterSaleSupplierState = 0;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- CeErpTradeResponsible.DelByTid(ctid, 0);
- 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 == "不理赔")
- {
- CeErpTradeResponsible.DelByTid(ctid, 1);
- ceErpTradeCell.AfterSaleSupplierState = 1;
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- }
- else
- {
- ceErpTradeCell.AfterSaleState = 3;
- }
- bool needCyt = false;
- if (dt != null)
- {
- if (dt.Rows.Count == 1)
- {
- bool isEnd = false;
- foreach (DataRow dr in dt.Rows)
- {
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- isEnd = true;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- isEnd = true;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
- {
- needCyt = true;
- }
- }
- if (isEnd)
- {
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- ceErpTradeCell.AfterSaleSupplierState = 1;
- }
- }
- else
- {
- bool isAll = true;
- foreach (DataRow dr in dt.Rows)
- {
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- continue;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
- {
- string path = "";
- int OrgID = 0;
- if (!Convert.IsDBNull(dr["OrgPath"]))
- {
- path = dr["OrgPath"].ToString();
- }
- if (!Convert.IsDBNull(dr["OrgID"]))
- {
- OrgID = Convert.ToInt32(dr["OrgID"]);
- }
- if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- continue;
- }
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
- {
- needCyt = true;
- }
- isAll = false;
- }
- if (isAll)
- {
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- ceErpTradeCell.AfterSaleSupplierState = 1;
- }
- }
- }
- if (needCyt && ceErpTradeCell.AfterSaleState != 4)
- {
- commonHelper.sendCytAfterSale(ceErpTradeCell);
- }
- if (ceErpTradeCell.AfterSaleState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ceErpTradeCell.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- ceErpTradeCell.Update();
- CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
- CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
- return true;
- }
- return false;
- }
- public void get_erp_wechatorder()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- lw.Add(string.Format("rtype = '{0}'", "微信返现"));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_wechatlist_sumprice()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- lw.Add(string.Format("rtype = '{0}'", "微信返现"));
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
- DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
- DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
- decimal total = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
- }
- var res = new
- {
- data = total
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_qr_waitdeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- var res_objz = new
- {
- restype = 1,
- data = dt
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- }
- public void get_erp_yield_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_supYield", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void change_erp_sup_state()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- ceErpTradeCellExtend.SupState = 1;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.SupState = 1;
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
- returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
- return;
- }
- returnErrorMsg("找不到订单");
- }
- }
- public void supplier_all_downs()
- {
- if (UrlPostParmsCheck("tids"))
- {
- string tids = GetPostString("tids");
- if (tids != null && tids.Length > 0)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- sql = new StringBuilder();
- 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, "下载设计文件");
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- string[] list = tids.Split(',');
- foreach (string ctid in list)
- {
- CeErpSukuraData.createInfo(ctid, 3);
- }
- designHelper.api_approveDesign(tids); //approveDesign
- returnSuccessMsg("下载成功!");
- return;
- }
- returnErrorMsg("下载订单更新失败");
- }
- }
- public void uploaderFileSuccess()
- {
- if (UrlPostParmsCheck("fileName"))
- {
- string fileName = GetPostString("fileName");
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = fileName;
- apiVo.actionName = "finishDesign";
- designHelper.API_WorkCore(apiVo);//finishDesign
- returnSuccessMsg("");
- }
- }
- public void get_sample2_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
- DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
- double total = 0.0;
- double order_price = 0.0;
- if (dt_bu.Rows.Count > 0)
- {
- foreach (DataRow dr in dt_bu.Rows)
- {
- total += Convert.ToDouble(dr["payment"]);
- }
- }
- order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
- string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
- DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
- string tid = ctid.Replace("S_", "");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
- double paymant = 0.0;
- if (entity != null)
- {
- paymant = entity.payment;
- }
- string return_reason = "";
- if (dt_after != null && dt_after.Rows.Count > 0)
- {
- return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
- }
- returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
- }
- }
- public void get_erp_design_status()
- {
- string designName = GetPostString("designName");
- DataStruct dStruct = GetPostStruct();
- if (designName.Length > 0)
- {
- 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";
- sql_user += " and Name like '%" + designName + "%'";
- DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
- List<string> ids_list = new List<string>();
- if (user_table.Rows.Count > 0)
- {
- foreach (DataRow item in user_table.Rows)
- {
- ids_list.Add(item["id"].ToString());
- string ids_s = item["TeamIds"].ToString();
- if (ids_s.Length > 0)
- {
- ids_list.AddRange(ids_s.Split(','));
- }
- }
- }
- HashSet<string> set = new HashSet<string>(ids_list);
- ids_list = set.ToList();
- if (ids_list.Count > 0)
- {
- 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));
- dStruct.MainWhere = sql;
- DataTable dt = null;
- dt = WebCache.GetData("view_ErpUser", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- }
- }
- public void change_erp_order_price()
- {
- string ctid = GetPostString("ctid");
- double price = GetPostDouble("price");
- if (ctid.Length > 0)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Update();
- }
- CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
- if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
- {
- ceErpDataSendOrderInfo.isSync = false;
- ceErpDataSendOrderInfo.Update();
- }
- if (ceErpDataSendOrderInfo == null)
- {
- ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
- ceErpDataSendOrderInfo.isSync = false;
- ceErpDataSendOrderInfo.ctid = ctid;
- ceErpDataSendOrderInfo.Create();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
- string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
- {
- dataSendOrderBean dataSendOrderBean = null;
- foreach (DataRow item in dth.Rows)
- {
- try
- {
- dataSendOrderBean = new dataSendOrderBean();
- dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
- dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
- dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
- dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
- dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
- dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
- dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
- dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
- dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
- dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
- dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
- dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
- dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
- if (result != null)
- {
- if ("0".Equals(result.errcode))
- {
- CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
- }
- else
- {
- CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void find_he_together()
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- List<string> list = new List<string>();
- if (ceErpTradeCell != null)
- {
- if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
- {
- 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);
- DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (table != null && table.Rows.Count > 0)
- {
- foreach (TableRow row in table.Rows)
- {
- }
- }
- }
- }
- returnSuccess(JsonConvert.SerializeObject(new { list }));
- }
- Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
- {
- //chy----19
- {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
- //GD-CYT-----64
- {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
- //ZHX----3
- {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
- //JK----97
- {97, new Dictionary<string, string> {{"uv", "uv"}}},
- //ZT----70
- {70, new Dictionary<string, string> {{"uv", "uv"}}},
- //LHCY-----98
- {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
- //XD-----90
- {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
- //CYCY-----14
- {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
- };
- //其他改名
- Dictionary<int, string> suppliers = new Dictionary<int, string>()
- {
- {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
- {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
- {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
- {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
- {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
- {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
- {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
- {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
- };
- //不统计
- List<int> no_suppliers = new List<int>()
- {
- 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
- };
- //配件单
- Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
- {
- {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
- {"棉绳",new List<string>(){ "卡片", "吊牌" } },
- {"别针",new List<string>(){ "卡片", "吊牌" } },
- {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
- {"流苏",new List<string>(){ "卡片", "吊牌" } },
- {"旗杆",new List<string>(){ "班旗" } },
- {"牙签",new List<string>(){ "不干胶" } }
- };
- public void get_place_order_data()
- {
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
- DateTime start = DateTime.Parse(starttime);
- string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
- DateTime end = DateTime.Parse(endtime);
- if (date1 != null && date1.Length > 0)
- {
- DateTime dateTime = DateTime.Parse(date1);
- starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
- start = DateTime.Parse(starttime);
- endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
- end = DateTime.Parse(endtime);
- }
- if (date2 != null && date2.Length > 0)
- {
- DateTime dateTime = DateTime.Parse(date2);
- endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
- end = DateTime.Parse(endtime);
- }
- 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);
- DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //不干胶-----1,卡片-----29
- Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
- foreach (DataRow row in data.Rows)
- {
- int productId = Convert.ToInt32(row["ProductId"]);
- int supplierId = Convert.ToInt32(row["SupplierId"]);
- if (no_suppliers.Contains(supplierId))
- {
- continue;
- }
- string seller_memo = row["seller_memo"].ToString();
- bool ispj = false;//是否配件单
- bool isfirst = true;//第一个配
- maps.Keys.ForEach(key =>
- {
- //备注包含配件
- if (seller_memo.Contains(key) && isfirst)
- {
- List<string> list = maps[key];
- ispj = true;
- isfirst = false;
- for (int i = 0; i < list.Count; i++)
- {
- if (seller_memo.Contains(list[i]))
- {
- ispj = false;
- break;
- }
- }
- }
- });
- if (ispj)
- {
- continue;
- }
- seller_memo = seller_memo.Replace("UV", "uv");
- seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
- //吊牌归到卡片
- seller_memo = seller_memo.Replace("吊牌", "卡片");
- seller_memo = seller_memo.Replace("卡套", "卡片");
- seller_memo = seller_memo.Replace("封套", "卡片");
- seller_memo = seller_memo.Replace("吸管套", "卡片");
- seller_memo = seller_memo.Replace("腰封", "卡片");
- seller_memo = seller_memo.Replace("旗帜布", "条幅");
- seller_memo = seller_memo.Replace("手拉旗", "条幅");
- seller_memo = seller_memo.Replace("横幅", "条幅");
- seller_memo = seller_memo.Replace("锦旗", "条幅");
- string map_key = "";
- string type = "";
- if (supplierMap.ContainsKey(supplierId))
- {
- foreach (var kvp in supplierMap[supplierId])
- {
- if (seller_memo.Contains(kvp.Key))
- {
- map_key = kvp.Value;
- type = kvp.Value;
- break;
- }
- }
- }
- if (map_key == "")
- {
- type = "其他";
- map_key = "其他";
- }
- if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
- {
- map_key = suppliers[supplierId];
- }
- if (supplierId == 70)
- {
- supplierId = 70;
- }
- map_key += "_" + row["SupplierName"].ToString();
- Dictionary<string, int> map = null;
- if (other_map.ContainsKey(map_key))
- {
- other_map.TryGetValue(map_key, out map);
- }
- else
- {
- map = new Dictionary<string, int>();
- map.Add("dayDev", 0);//当天出货
- map.Add("dayTotal", 0);//下单总数
- map.Add("payTotal", 0);//500以上
- map.Add("today", 0);//当天出货数量
- map.Add("unusua", 0);//异常数
- other_map.Add(map_key, map);
- other_map.TryGetValue(map_key, out map);
- }
- DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
- DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
- DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
- DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
- if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
- {
- map["dayTotal"]++;
- if (supplierId == 97)
- {
- supplierId = 97;
- }
- }
- if (Convert.ToDecimal(row["payment"]) >= 500)
- {
- map["payTotal"]++;
- }
- if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
- {
- DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
- if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
- {
- if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
- {
- map["today"]++;
- }
- }
- else
- {
- if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
- {
- map["today"]++;
- }
- else
- {
- if (supplierId == 119)
- {
- Debug.WriteLine(row["seller_memo"].ToString());
- }
- }
- }
- }
- if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
- {
- map["unusua"]++;
- }
- DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
- //GD-CYT-----64
- DateTime two = palceTimeStart.AddHours(14);
- DateTime three = palceTimeStart.AddHours(15);
- DateTime four = palceTimeStart.AddHours(16);
- DateTime six = palceTimeStart.AddHours(18);
- if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
- {
- //下午四点前 500-1000
- string count = row["ProductCount"].ToString();
- if (count != null && count.Length > 0)
- {
- int productCount = commonHelper.getPlaceProductCount(count);
- if (productCount >= 500 && productCount <= 1000)
- {
- if (DateTime.Compare(FinishPlaceTime, four) < 0)
- {
- map["dayDev"]++;
- }
- }
- }
- }
- //UV
- else if ("uv".Equals(type))
- {
- //ZT----70
- //ZHX----3
- if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
- {
- map["dayDev"]++;
- }
- //JK----97
- //HZX----105
- if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
- {
- map["dayDev"]++;
- }
- }
- //帆布---52|条幅---27
- else if ("帆布".Equals(type) || "条幅".Equals(type))
- {
- //LHCY-----98
- if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
- {
- map["dayDev"]++;
- }
- }
- //条幅
- else if ("条幅".Equals(type))
- {
- //XD-----90
- if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
- {
- map["dayDev"]++;
- }
- }
- //桌布
- else if ("桌布".Equals(type))
- {
- //XD-----90
- if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
- {
- map["dayDev"]++;
- }
- }
- //DL---10
- //AYTW---119
- //FS-CYT-DY ----80
- //JK----97
- else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
- {
- if (DateTime.Compare(FinishPlaceTime, three) < 0)
- {
- map["dayDev"]++;
- }
- }
- // QC---121
- else if (supplierId == 121)
- {
- if (DateTime.Compare(FinishPlaceTime, six) < 0)
- {
- map["dayDev"]++;
- }
- }
- }
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
- dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
- dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
- dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
- dt.Columns.Add(new DataColumn("today", typeof(string)));
- dt.Columns.Add(new DataColumn("unusua", typeof(string)));
- dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
- dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
- other_map.Keys.ForEach(key =>
- {
- DataRow dr = dt.NewRow();
- Dictionary<string, int> map = other_map[key];
- string[] key_list = key.Split('_');
- dr[0] = key_list[0];
- dr[1] = key_list[1];
- if (key_list.Length > 2)
- {
- dr[1] += "(" + key_list[2] + ")";
- }
- dr[2] = map["dayTotal"];
- dr[3] = map["payTotal"];
- dr[4] = map["today"];
- dr[5] = map["unusua"];
- dr[6] = map["dayDev"];
- double rate = 0.00;
- if (map["dayDev"] > 0)
- {
- rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
- }
- dr[7] = rate.ToString();
- dt.Rows.Add(dr);
- });
- DataView dv = new DataView(dt);
- dv.Sort = "SupplierName";
- //dv.Sort = "AllOrder desc";
- DataTable dtNew = dv.ToTable();
- writeGridDataTableJson(dtNew.Rows.Count, dtNew);
- }
- public void check_order_desing_info()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
- returnSuccess(JsonConvert.SerializeObject(new { response }));
- return;
- }
- returnErrorMsg("找不到订单");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void get_timeout_detail()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string id = GetPostString("id");
- string pay_date1 = GetPostString("pay_date1");
- string pay_date2 = GetPostString("pay_date2");
- int type = GetPostInt("type");
- if (type == 0)
- {
- if (pay_date1.Length > 0)
- {
- lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
- }
- if (pay_date2.Length > 0)
- {
- lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
- }
- lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
- }
- if (type == 1)
- {
- if (pay_date1.Length > 0)
- {
- lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
- }
- if (pay_date2.Length > 0)
- {
- lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
- }
- lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_orderlist", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void saveUrgentChargePrice()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- double prices = commonHelper.calculationPrice(ceErpTradeCell);
- if (prices <= 100)
- {
- returnErrorMsg("此订单金额不足100元,无法加急。");
- return;
- }
- double price = GetPostDouble("price");
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
- }
- ceErpTradeCellExtend.urgentCharge = price;
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Save();
- }
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void finish_erp_order()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
- ceErpTradeCell.Update();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void get_trade_order_list()
- {
- string tid = GetPostString("tid");
- if (!string.IsNullOrEmpty(tid))
- {
- string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
- DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(data.Rows.Count, data);
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void save_cell_spu()
- {
- string ctid = GetPostString("ctid");
- string spu_id = GetPostString("spu_id");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.spu_id = spu_id;
- if (!string.IsNullOrEmpty(spu_id))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
- }
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void change_express_info()
- {
- string ctid = GetPostString("ctid");
- string transNo = GetPostString("transNo");
- string transCom = GetPostString("transCom");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.modExpressNo = transNo;
- ceErpTradeCellExtend.modExpressCom = transCom;
- ceErpTradeCellExtend.readMod = 2;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void get_change_express_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- lw.Add("readMod = 2");
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void deal_express_complete()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.readMod = 1;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void aftersale_return_visit()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.returnVisit = 1;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.TextResult = "";
- ceErpTradeAfterSaleExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void orderPlaceInfo()
- {
- string ctids = GetPostString("ctids");
- string[] list = ctids.Split(',');
- foreach (string ctid in list)
- {
- CeErpSukuraData.createInfo(ctid, 3);
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- designHelper.api_approveDesign(ctids); //approveDesign
- returnSuccessMsg("");
- }
- public void get_issue_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- string select_tid = getTidByCtid(tid);
- lw.Add(string.Format("tid='{0}'", select_tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
- {
- lw.Add("IssueState = 1");
- }
- else
- {
- string iisstate = GetPostString("iisstate");
- if ("1".Equals(iisstate))
- {
- lw.Add("IssueState =1");
- }
- else if ("2".Equals(iisstate))
- {
- lw.Add("IssueState = 2");
- }
- else
- {
- lw.Add("IssueState > 0");
- }
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void saveIssueContent()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- string content = GetPostString("content");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend == null)
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = ctid;
- }
- ceErpTradeAfterSaleExtend.IssueContent = content;
- ceErpTradeAfterSaleExtend.IssueState = 1;
- if (ceErpTradeAfterSaleExtend.ID > 0)
- {
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend.Create();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
- returnSuccessMsg("添加成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void dealIssueContent()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- string content = GetPostString("content");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.IssueState = 2;
- ceErpTradeAfterSaleExtend.Update();
- LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
- returnSuccessMsg("修改完成!");
- return;
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void set_tid_attachments()
- {
- string tid = GetPostString("tid");
- string atta = GetPostString("atta");
- if (!string.IsNullOrEmpty(tid))
- {
- if (string.IsNullOrEmpty(atta))
- {
- returnErrorMsg("文件地址为空");
- return;
- }
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- if (ceErpTradeCell != null)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- if (ceErpTrade == null)
- {
- returnErrorMsg("找不到订单");
- return;
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
- bool isSend = false;
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow row in dt.Rows)
- {
- if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
- {
- isSend = true;
- }
- }
- if (isSend)
- {
- returnErrorMsg("已发货无法修改");
- return;
- }
- ceErpTrade.Attachments = atta;
- ceErpTrade.Update();
- LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
- returnSuccessMsg("上传成功!");
- return;
- }
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void get_tid_attachments()
- {
- string tid = GetPostString("tid");
- if (!string.IsNullOrEmpty(tid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
- if (ceErpTradeCell != null)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- if (ceErpTrade == null)
- {
- returnErrorMsg("找不到订单");
- return;
- }
- returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
- return;
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void check_erp_sameorders()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
- CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
- if (entity != null && ceErpTrade != null)
- {
- if (entity.OrderState > 6)
- {
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
- return;
- }
- DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
- List<string> ids = new List<string>();
- if (dt != null && dt.Rows.Count > 1)
- {
- bool needhe = true;
- foreach (DataRow dr in dt.Rows)
- {
- ids.Add("'" + dr["ctid"] + "'");
- /* //备注有合包
- if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
- {
- needhe = true;
- }
- if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
- {
- needhe = true;
- }
- //顺丰快递
- if (Convert.ToInt32(dr["IsSF"]) > 0)
- {
- needhe = true;
- }*/
- }
- if (!needhe)
- {
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
- return;
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
- dt.Columns.Add(new DataColumn("dstate", typeof(int)));
- dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
- DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- dr["dstate"] = 0;
- dr["dnumber"] = 0;
- foreach (DataRow row in dt1.Rows)
- {
- if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
- {
- dr["dstate"] = 2;
- dr["default"] = 1;
- dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
- }
- }
- if (eid.Equals(dr["ctid"].ToString()))
- {
- dr["dstate"] = 1;
- dr["default"] = 1;
- }
- }
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
- return;
- }
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
- return;
- }
- returnErrorMsg("未找到订单");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void get_mark_number()
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
- CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
- int current = 1;
- if (ceErpDeliverMark == null)
- {
- DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
- List<string> ids = new List<string>();
- if (dt != null && dt.Rows.Count > 1)
- {
- foreach (DataRow dr in dt.Rows)
- {
- ids.Add("'" + dr["ctid"] + "'");
- }
- //查询已有的编号
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
- DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt1 == null || dt1.Rows.Count == 0)
- {
- DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
- List<int> list_number = new List<int>();
- foreach (DataRow row in numbers.Rows)
- {
- list_number.Add(Convert.ToInt32(row["markNumber"]));
- }
- //查询空余编号
- for (int i = 0; i < list_number.Count + 2; i++)
- {
- if (!list_number.Contains(current))
- {
- CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
- //防止查询过程中有新数据生成
- if (ceErpDeliverMark1 == null)
- {
- break;
- }
- }
- current++;
- }
- }
- else
- {
- foreach (DataRow row in dt1.Rows)
- {
- current = Convert.ToInt32(row["markNumber"]);
- }
- }
- ceErpDeliverMark = new CeErpDeliverMark();
- ceErpDeliverMark.ctid = eid;
- ceErpDeliverMark.createtime = DateTime.Now;
- if (ceErpTrade != null)
- {
- ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
- }
- ceErpDeliverMark.markNumber = current;
- ceErpDeliverMark.Create();
- }
- }
- else
- {
- current = ceErpDeliverMark.markNumber;
- }
- ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
- return;
- }
- }
- public void aftersaleCytSend()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- commonHelper.sendCytAfterSale(ceErpTradeCell);
- }
- returnSuccessMsg("推送成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void packOrderInfo()
- {
- string ctids = GetPostString("ctids");
- if (!string.IsNullOrEmpty(ctids))
- {
- string[] ctid_list = ctids.Split(',');
- if (ctid_list.Length > 20)
- {
- returnErrorMsg("单次下载次数不能超过20个");
- return;
- }
- string textCtids = "'" + ctids.Replace(",", "','") + "'";
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- int supplierId = 0;
- StringBuilder insterSql = new StringBuilder();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow row = dt.Rows[i];
- if (i == 0)
- {
- supplierId = Convert.ToInt32(row["SupplierId"]);
- }
- if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
- {
- returnErrorMsg("同车间的订单才能一起打包");
- return;
- }
- int orderState = Convert.ToInt32(row["OrderState"]);
- if (orderState != 5)
- {
- returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
- return;
- }
- insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
- }
- CeErpPackData ceErpPackData = new CeErpPackData();
- ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
- ceErpPackData.supplierId = supplierId;
- ceErpPackData.createtime = DateTime.Now;
- ceErpPackData.createBy = CurrentUser.UserID;
- ceErpPackData.createName = CurrentUser.UserName;
- ceErpPackData.Create();
- if (ceErpPackData.ID > 0)
- {
- string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
- DbHelper.DbConn.ExecuteNonQuery(inSql);
- }
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
- returnSuccessMsg("打包成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void rePackOrderInfo()
- {
- string id = GetPostString("id");
- if (!string.IsNullOrEmpty(id))
- {
- CeErpPackData ceErpPackData = CeErpPackData.Get(id);
- if (ceErpPackData == null)
- {
- returnSuccessMsg("查无数据");
- return;
- }
- ceErpPackData.upStatus = 0;
- ceErpPackData.message = "";
- ceErpPackData.Update();
- returnSuccessMsg("打包成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void backPackOrderInfo()
- {
- string id = GetPostString("id");
- if (!string.IsNullOrEmpty(id))
- {
- CeErpPackData ceErpPackData = CeErpPackData.Get(id);
- if (ceErpPackData == null)
- {
- returnSuccessMsg("查无数据");
- return;
- }
- ceErpPackData.upStatus = 4;
- ceErpPackData.Update();
- List<string> list = new List<string>();
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow row = dt.Rows[i];
- list.Add("'" + row["ctid"].ToString() + "'");
- }
- string textCtids = string.Join(",", list);
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
- DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
- returnSuccessMsg("退回成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void addPackDownNum()
- {
- string id = GetPostString("id");
- if (!string.IsNullOrEmpty(id))
- {
- DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
- returnSuccessMsg("下载成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void get_pack_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Order = "createtime desc";
- DataTable dt = WebCache.GetData("view_packCenter", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_pack_order_list()
- {
- string packId = GetPostString("packId");
- if (string.IsNullOrEmpty(packId))
- {
- returnErrorMsg("缺少必要的参数");
- return;
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt == null || dt.Rows.Count == 0)
- {
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
- return;
- }
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
- return;
- }
- public void get_supplier_product_time_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
- string posTag = CurrentUser.UserPost.Post.Code;
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void saveSupplierProductTime()
- {
- string productId = GetPostString("productId");
- if (string.IsNullOrEmpty(productId))
- {
- returnErrorMsg("缺少必要的参数");
- return;
- }
- string productName = GetPostString("productName");
- int supplierId = GetPostInt("supplierId");
- if (supplierId == 0)
- {
- returnErrorMsg("缺少必要的参数");
- return;
- }
- int quantity = GetPostInt("quantity");
- int sendDay = GetPostInt("sendTime");
- string supplierName = GetPostString("supplierName");
- string craft = GetPostString("craft");
- string deadLine = GetPostString("deadLine");
- string dayDeadLine = GetPostString("dayDeadLine");
- try
- {
- int eid = GetPostInt("eid");
- CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
- if (ceErpSupplierProductTime == null)
- {
- ceErpSupplierProductTime = new CeErpSupplierProductTime();
- }
- ceErpSupplierProductTime.productId = productId;
- ceErpSupplierProductTime.productName = productName;
- ceErpSupplierProductTime.supplierId = supplierId;
- ceErpSupplierProductTime.supplierName = supplierName;
- ceErpSupplierProductTime.craft = craft;
- ceErpSupplierProductTime.sendDay = sendDay;
- ceErpSupplierProductTime.quantity = quantity;
- if (!string.IsNullOrEmpty(deadLine))
- {
- ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
- }
- if (!string.IsNullOrEmpty(dayDeadLine))
- {
- ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
- }
- if (ceErpSupplierProductTime.ID == 0)
- {
- ceErpSupplierProductTime.Save();
- }
- else
- {
- ceErpSupplierProductTime.Update();
- }
- }
- catch (Exception e)
- {
- }
- returnSuccessMsg("保存成功");
- return;
- }
- public void delSupplierProductTime()
- {
- int eid = GetPostInt("eid");
- if (eid > 0)
- {
- CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
- if (ceErpSupplierProductTime == null)
- {
- returnErrorMsg("查无数据");
- return;
- }
- ceErpSupplierProductTime.Delete();
- returnSuccessMsg("保存成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void getExpressInfo()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- string outSid = ceErpTradeCell.OutSid;
- if (outSid.Length > 0)
- {
- string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
- return;
- }
- }
- returnErrorMsg("查无记录");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void getExpressPostData()
- {
- string express = GetPostString("express");
- if (!string.IsNullOrEmpty(express))
- {
- CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
- if (ceErpExpressInfo != null)
- {
- ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
- return;
- }
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void checkSupplierOrder()
- {
- string ctids = GetPostString("ctids");
- if (ctids != null)
- {
- List<string> list = new List<string>();
- string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataRow row = dt.Rows[i];
- if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
- {
- continue;
- }
- list.Add(row["seller_memo"].ToString());
- }
- if (list.Count > 0)
- {
- DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
- ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
- return;
- }
- }
- ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
- return;
- }
- public void addPersonId()
- {
- string tid = GetPostString("tid");
- string personId = GetPostString("personId");
- CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
- if (ceErpTrade != null)
- {
- ceErpTrade.receiver_zip = personId;
- ceErpTrade.Update();
- LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
- returnSuccessMsg("保存成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void addDeliveryPaymant()
- {
- string tid = GetPostString("tid");
- string paymant = GetPostString("paymant");
- CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
- if (ceErpTrade != null)
- {
- if (!string.IsNullOrEmpty(paymant))
- {
- ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
- }
- ceErpTrade.Update();
- LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
- returnSuccessMsg("保存成功");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- }
- }
|