sync.order.cs 603 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //apiHelper.Api_SyncOrderByTime("598825");
  55. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  56. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  57. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  58. //banniuApiHelper.sendLogisticsInfo(null);
  59. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  60. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  61. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  62. //int sid = commonHelper.autoDistributeToSupplier(entity);
  63. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  64. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1743037314000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1743210111000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":100.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2200806677467/O1CN01FNM4MW251wJNQ0RTV_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4279817918999398627\",\"refSkuId\":\"0\",\"refSpuId\":\"743796792540\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":50.0,\"singleFee\":50.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【活动价】镜子贴纸定制婚礼迎宾牌装饰静电贴镜面玻璃窗户字母转印贴画墙贴\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1743040267000,\"openBuyerId\":\"AAEXRHraABkUZRPgSx1Mbz6h\",\"openBuyerNick\":\"天**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1743037310000,\"payTime\":1743037311000,\"payment\":100.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"齐齐哈尔市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"建华区\",\"receiverId\":\"82f9bfecd2ef7df766b42edd73faa2f3$\",\"receiverState\":\"黑龙江省\",\"receiverTown\":\"文化街道\",\"refOid\":\"4279817918999398627\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"500x640mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50,580x585mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0,\"type\":\"SALE\"}}");
  65. //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}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. string select_tid = getTidByCtid(tid);
  110. lw.Add(string.Format("tid='{0}'", select_tid));
  111. }
  112. if (buyernick.Length > 0)
  113. {
  114. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  115. }
  116. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  117. if (dw.Length > 0)
  118. {
  119. lw.Add(dw);
  120. }
  121. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  122. {
  123. string usershop = CurrentUser.User.pemShop;
  124. lw.Add(string.Format("ShopId in ({0})", usershop));
  125. }
  126. }
  127. else
  128. {
  129. if (ex_psize == 0)
  130. {
  131. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  132. }
  133. if (PKey != "admin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. paramsCount++;
  138. }
  139. }
  140. string uploaddate1 = GetPostString("uploaddate1");
  141. string uploaddate2 = GetPostString("uploaddate2");
  142. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  143. if (update.Length > 0) lw.Add(update);
  144. string deliverydate1 = GetPostString("deliverydate1");
  145. string deliverydate2 = GetPostString("deliverydate2");
  146. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  147. if (deliverydate.Length > 0)
  148. {
  149. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  150. };
  151. string shopname = GetPostString("shopname");
  152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  153. string addwechat = GetPostString("addwechat");
  154. if (addwechat.Length > 0)
  155. {
  156. int addWt = Convert.ToInt32(addwechat);
  157. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  158. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  159. }
  160. string customer = GetPostString("customer");
  161. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  162. string design = GetPostString("design");
  163. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  164. string orderState = GetPostString("orderState");
  165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  166. string address = GetPostString("address");
  167. 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));
  168. string sellermemo = GetPostString("seller_memo");
  169. if (sellermemo.Length > 0)
  170. {
  171. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  172. }
  173. string backReason = GetPostString("backReason");
  174. if (backReason.Length > 0)
  175. {
  176. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  177. }
  178. string apdate1 = GetPostString("apdate1");
  179. string apdate2 = GetPostString("apdate2");
  180. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  181. if (dwap.Length > 0) lw.Add(dwap);
  182. string price1 = GetPostString("price1");
  183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  184. string price2 = GetPostString("price2");
  185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  186. string isoldcustomer = GetPostString("isoldcus");
  187. string finishdate1 = GetPostString("finishdate1");
  188. string finishdate2 = GetPostString("finishdate2");
  189. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  190. bool isFinish = false;
  191. if (finishdate.Length > 0)
  192. {
  193. lw.Add(finishdate);
  194. isFinish = true;
  195. paramsCount++;
  196. }
  197. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  198. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  199. if (ex_psize > 0)
  200. {
  201. int UserID = CurrentUser.UserID;
  202. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  203. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  204. {
  205. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  206. }
  207. dStruct.Order = "pay_time desc";
  208. }
  209. string isNew = GetPostString("isNew");
  210. if (isNew == "true")
  211. {
  212. lw.Add(string.Format("IsNew = {0}", 1));
  213. }
  214. string overtime = GetPostString("overtime");
  215. if (overtime == "1")
  216. {
  217. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  218. }
  219. String usePost = CurrentUser.UserPost.Post.Code;
  220. if (usePost.Equals("Operation") == true)
  221. {
  222. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. else
  225. {
  226. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  227. }
  228. //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";
  229. if (dStruct.PageSize == 100000)
  230. {
  231. dStruct.Order = "";
  232. }
  233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  234. DataTable dt = null;
  235. string tablename = "view_orderlist";
  236. if (isFinish)
  237. {
  238. tablename = "view_orderlist_end";
  239. }
  240. dt = WebCache.GetData(tablename, dStruct);
  241. if (dt != null && dt.Rows.Count > 0)
  242. {
  243. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  244. foreach (DataRow dr in dt.Rows)
  245. {
  246. try
  247. {
  248. if (dr["refund_fees"] != null)
  249. {
  250. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  251. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  252. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  253. if (payment == refund_fees)
  254. {
  255. dr["refund_fees"] = Math.Round(refund_fees, 2);
  256. }
  257. else if (refund_fees == total_fee)
  258. {
  259. dr["refund_fees"] = payment;
  260. }
  261. else
  262. {
  263. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  264. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  265. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  266. }
  267. }
  268. // 对象操作
  269. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  270. ceErpTradeCell.ctid = dr["ctid"].ToString();
  271. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  272. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  273. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  274. if (dStruct.PageSize != 100000)
  275. {
  276. if (dr["DispatchSort"].ToString() == "2")
  277. {
  278. dr["gongchuang"] = 200;
  279. }
  280. else
  281. {
  282. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  283. dr["gongchuang"] = response.code;
  284. }
  285. }
  286. }
  287. catch (NullReferenceException ex)
  288. {
  289. // 处理空引用异常
  290. dr["refund_fees"] = "0.00";
  291. }
  292. }
  293. }
  294. writeGridDataTableJson(dStruct.TotalCount, dt);
  295. }
  296. public void get_erp_orderlist_sumprice()
  297. {
  298. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  299. return;
  300. List<string> lw = new List<string>();
  301. string tid = GetPostString("ctid");
  302. string date1 = GetPostString("date1");
  303. string date2 = GetPostString("date2");
  304. if (tid.Length > 0 || date1.Length > 0)
  305. {
  306. lw.Add(string.Format("ctid like '%{0}%'", tid));
  307. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  308. if (dw.Length > 0) lw.Add(dw);
  309. }
  310. else
  311. {
  312. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  313. }
  314. string shopname = GetPostString("shopname");
  315. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  316. string buyernick = GetPostString("buyer_nick");
  317. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  318. string customer = GetPostString("customer");
  319. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  320. string design = GetPostString("design");
  321. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  322. string orderState = GetPostString("orderState");
  323. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  324. string address = GetPostString("address");
  325. 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));
  326. string sellermemo = GetPostString("seller_memo");
  327. if (sellermemo.Length > 0)
  328. {
  329. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  330. }
  331. string apdate1 = GetPostString("apdate1");
  332. string apdate2 = GetPostString("apdate2");
  333. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  334. if (dwap.Length > 0) lw.Add(dwap);
  335. string price1 = GetPostString("price1");
  336. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  337. string price2 = GetPostString("price2");
  338. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  339. string isoldcustomer = GetPostString("isoldcus");
  340. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  341. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  342. if (PKey != "admin")
  343. {
  344. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  345. lw.Add(string.Format("shopId in ({0})", usershop));
  346. }
  347. //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";
  348. string mainWhere = string.Join(" and ", lw.ToArray());
  349. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  350. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  351. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  352. decimal total = 0;
  353. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  354. {
  355. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  356. }
  357. var res = new
  358. {
  359. data = total
  360. };
  361. string ro_jsond = JsonConvert.SerializeObject(res);
  362. returnSuccess(ro_jsond);
  363. return;
  364. }
  365. public void get_erp_CustomerServiceGather()
  366. {
  367. string userWhere = "", orderWhere = "";
  368. List<string> lw = new List<string>();
  369. string customer = GetPostString("customer");
  370. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  371. string shopname = GetPostString("shopname");
  372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  373. string date1 = GetPostString("date1");
  374. string date2 = GetPostString("date2");
  375. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  376. if (dw.Length > 0) lw.Add(dw);
  377. orderWhere = string.Join(" and ", lw.ToArray());
  378. 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 " +
  379. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  380. "left join " +
  381. "( " +
  382. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  383. ") as b on a.ID = b.CustomerUserId " +
  384. "left join " +
  385. "( " +
  386. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  387. ") as d on a.ID = d.CustomerUserId " +
  388. "left join " +
  389. "( " +
  390. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  391. ") as e on a.ID = e.CustomerUserId " +
  392. "left join " +
  393. "( " +
  394. " select CustomerUserId, RefundCount, RefundSum from " +
  395. " ( " +
  396. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  397. " from CE_ErpTradeRefund a " +
  398. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  399. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  400. " group by CustomerUserId " +
  401. " ) as a " +
  402. ") as f on a.ID = f.CustomerUserId " +
  403. "where a.PostCode = 'CustomerService'",
  404. userWhere, orderWhere);
  405. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  406. writeGridDataTableJson(dt.Rows.Count, dt);
  407. //writeGridDataTableJson(dt.Rows.Count, dt);
  408. }
  409. //设计汇总
  410. public void get_erp_DesignerGather()
  411. {
  412. string userWhere = "", orderWhere = "";
  413. List<string> lw = new List<string>();
  414. string Designer = GetPostString("designer");
  415. int org = GetPostInt("org");
  416. if (Designer.Length > 0)
  417. {
  418. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  419. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  420. }
  421. else if (org > 0)
  422. {
  423. userWhere = string.Format(" where OrgID ={0}", org);
  424. }
  425. string shopname = GetPostString("shopname");
  426. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  427. string state = GetPostString("state");
  428. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  429. string OrderArea = GetPostString("order_area");
  430. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  431. string date1 = GetPostString("date1");
  432. string date2 = GetPostString("date2");
  433. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  434. if (dw.Length > 0) lw.Add(dw);
  435. string UpDate1 = GetPostString("UpDate1");
  436. string UpDate2 = GetPostString("UpDate2");
  437. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  438. if (dw.Length > 0) lw.Add(dw);
  439. orderWhere = string.Join(" and ", lw.ToArray());
  440. 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 (" +
  441. "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 " +
  442. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  443. "left join " +
  444. "( " +
  445. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  446. ") as b on a.ID = b.DesignUserId " +
  447. "left join " +
  448. "( " +
  449. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  450. ") as d on a.ID = d.DesignUserId " +
  451. "left join " +
  452. "( " +
  453. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  454. ") as e on a.ID = e.DesignUserId " +
  455. "left join " +
  456. "( " +
  457. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  458. ") as g on a.ID = g.DesignUserId " +
  459. "left join " +
  460. "( " +
  461. " select CustomerUserId, RefundCount, RefundSum from " +
  462. " ( " +
  463. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  464. " from CE_ErpTradeRefund a " +
  465. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  466. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  467. " group by CustomerUserId " +
  468. " ) as a " +
  469. ") as f on a.ID = f.CustomerUserId " +
  470. "where a.PostCode = 'Designer') as z",
  471. userWhere, orderWhere);
  472. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  473. writeGridDataTableJson(dt.Rows.Count, dt);
  474. }
  475. //删除tradecell的订单
  476. public void del_erp_cellorder()
  477. {
  478. if (UrlPostParmsCheck("ctid"))
  479. {
  480. string eid = GetPostString("ctid");
  481. CeErpTradeCell.DelByCtid(eid);
  482. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  483. returnSuccessMsg("删除成功");
  484. }
  485. }
  486. public void clear_erp_refundstate()
  487. {
  488. if (UrlPostParmsCheck("ids"))
  489. {
  490. string eids = GetPostString("ids");
  491. string[] ctidList = eids.Split(',');
  492. foreach (string ctid in ctidList)
  493. {
  494. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  495. if (entity != null)
  496. {
  497. entity.IsRefund = 0;
  498. entity.Update();
  499. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  500. }
  501. else
  502. continue;
  503. }
  504. returnSuccessMsg("操作成功");
  505. return;
  506. }
  507. returnErrorMsg("缺少必要参数");
  508. }
  509. public void set_erp_urgency()
  510. {
  511. if (UrlPostParmsCheck("ctid"))
  512. {
  513. string eid = GetPostString("ctid");
  514. CeErpTradeCell entity = null;
  515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  516. if (entity != null)
  517. {
  518. string utime = GetPostString("urgencytime");
  519. if (utime.Length > 0)
  520. {
  521. entity.UrgencyTime = Convert.ToDateTime(utime);
  522. }
  523. else
  524. {
  525. returnErrorMsg("请选择加急时间");
  526. return;
  527. }
  528. if (entity.OrderState <= 4)
  529. {
  530. //entity.seller_memo = entity.seller_memo + "-加急";
  531. string smemo = entity.seller_memo;
  532. int kindex = smemo.IndexOf(")");
  533. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  534. if (lastoneStr != "-")
  535. {
  536. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  537. }
  538. string prememo = smemo.Substring(0, kindex + 2);
  539. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  540. int lastkindex = lastmemo.IndexOf("(");
  541. DateTime urgtime = Convert.ToDateTime(utime);
  542. string newlastmemo = "";
  543. if (lastkindex == 0)
  544. {
  545. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  546. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  547. }
  548. else
  549. {
  550. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  551. }
  552. entity.seller_memo = prememo + newlastmemo;
  553. }
  554. entity.IsUrgency = true;
  555. entity.UpdateTime = DateTime.Now;
  556. entity.Update();
  557. ApiVo apiVo = new ApiVo();
  558. apiVo.orderNumber = entity.ctid;
  559. apiVo.actionName = "changeDesign";
  560. apiVo.orderRemarks = entity.seller_memo;
  561. apiVo.remarkSign = 3;
  562. designHelper.API_WorkCore(apiVo); //changeDesign
  563. CeErpSukuraData.createInfo(entity.ctid, 7);
  564. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  565. returnSuccessMsg("设置成功!");
  566. return;
  567. }
  568. returnErrorMsg("找不到记录");
  569. }
  570. }
  571. public void set_erp_reset()
  572. {
  573. if (UrlPostParmsCheck("ctid"))
  574. {
  575. string eid = GetPostString("ctid");
  576. CeErpTradeCell entity = null;
  577. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  578. if (entity != null)
  579. {
  580. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  581. {
  582. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  583. {
  584. returnErrorMsg("财务要求已下单已发货无法重置");
  585. return;
  586. }
  587. }
  588. entity.IsUrgency = false;
  589. entity.seller_memo = "";
  590. entity.OtherMemo = "";
  591. entity.OrderState = 0;
  592. entity.IsReturn = 0;
  593. //entity.IsRefund = 0;
  594. entity.MemoOpt = 0;
  595. entity.AfterSaleState = 0;
  596. entity.AfterSaleResponsible = "";
  597. entity.AfterSaleUserId = 0;
  598. entity.IsNeedBill = 0;
  599. entity.CustomerUserId = 0;
  600. entity.DesignUserId = 0;
  601. entity.SupplierId = 0;
  602. entity.PlaceUserId = 0;
  603. entity.ptid = "";
  604. entity.IsSample = 0;
  605. entity.IsXianHuo = 0;
  606. entity.isDianziOrder = 0;
  607. entity.DispatchSort = 0;
  608. entity.FinishPlaceTime = null;
  609. entity.Update();
  610. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  611. if (trade != null)
  612. {
  613. trade.seller_memo = "";
  614. trade.Update();
  615. }
  616. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  617. returnSuccessMsg("重置成功!");
  618. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  619. if (desginBill != null)
  620. {
  621. desginBill.isDel = 1;
  622. desginBill.Update();
  623. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  624. }
  625. ApiVo apiVo = new ApiVo();
  626. apiVo.orderNumber = entity.ctid;
  627. apiVo.actionName = "resetDesign";
  628. designHelper.API_WorkCore(apiVo);//resetDesign
  629. return;
  630. }
  631. returnErrorMsg("找不到记录");
  632. }
  633. }
  634. public void save_erp_sellermemo()
  635. {
  636. if (UrlPostParmsCheck("ctid"))
  637. {
  638. string ctid = GetPostString("ctid");
  639. CeErpTradeCell entity = null;
  640. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  641. if (entity != null)
  642. {
  643. string memo = GetPostString("seller_memo");
  644. memo = memo.Replace(" ", "");
  645. if (memo.Contains("补差"))
  646. {
  647. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  648. return;
  649. }
  650. if (entity.seller_memo != memo)
  651. {
  652. if (entity.IsSample == 2)
  653. {
  654. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  655. return;
  656. }
  657. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  658. {
  659. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  660. {
  661. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  662. return;
  663. }
  664. }
  665. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  666. }
  667. commonHelper.getCytPrice(entity);
  668. int memoopt = GetPostInt("MemoOpt");
  669. Boolean ismemoopt = false;
  670. if (memoopt > 0)
  671. {
  672. string stropt = "";
  673. if (memoopt == 1)
  674. {
  675. stropt = "“改稿”";
  676. ismemoopt = true;
  677. }
  678. else if (memoopt == 2)
  679. {
  680. stropt = "“定稿”";
  681. }
  682. else if (memoopt == 3)
  683. {
  684. stropt = "“查货”";
  685. CeErpSukuraData.createInfo(entity.ctid, 6);
  686. }
  687. entity.MemoOpt = Convert.ToInt32(memoopt);
  688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  689. }
  690. if (entity.OrderState < 5)
  691. {
  692. memo = memo.Replace("(", "(");
  693. memo = memo.Replace(")", ")");
  694. }
  695. entity.seller_memo = memo;
  696. entity.UpdateTime = DateTime.Now;
  697. entity.Update();
  698. ApiVo apiVo = new ApiVo();
  699. apiVo.orderNumber = entity.ctid;
  700. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  701. apiVo.orderRemarks = memo;
  702. apiVo.remarkSign = memoopt;
  703. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  704. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  705. returnSuccessMsg("保存成功!");
  706. return;
  707. }
  708. returnErrorMsg("找不到记录");
  709. }
  710. }
  711. public void ins_erp_checkorder()
  712. {
  713. if (UrlPostParmsCheck("ctid"))
  714. {
  715. string ctid = GetPostString("ctid");
  716. CeErpTradeCell entity = null;
  717. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  718. if (entity != null)
  719. {
  720. if (entity.OrderState < 6)
  721. {
  722. returnErrorMsg("下单完成后才可查货");
  723. return;
  724. }
  725. /*if (entity.OrderState > 6)
  726. {
  727. returnErrorMsg("订单已发货");
  728. return;
  729. }*/
  730. if (entity.FinishPlaceTime != null)
  731. {
  732. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  733. {
  734. returnErrorMsg("下单时间不足,无法查货");
  735. return;
  736. }
  737. }
  738. entity.MemoOpt = 3;
  739. entity.CheckOrderTime = DateTime.Now;
  740. entity.UpdateTime = DateTime.Now;
  741. entity.Update();
  742. CeErpSukuraData.createInfo(entity.ctid, 6);
  743. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  744. returnSuccessMsg("操作成功!");
  745. return;
  746. }
  747. returnErrorMsg("找不到记录");
  748. }
  749. }
  750. public void save_erp_othermemo()
  751. {
  752. if (UrlPostParmsCheck("ctid"))
  753. {
  754. string ctid = GetPostString("ctid");
  755. CeErpTradeCell entity = null;
  756. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  757. if (entity != null)
  758. {
  759. entity.OtherMemo = GetPostString("otherMemo");
  760. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  761. {
  762. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  763. StringBuilder sql = new StringBuilder();
  764. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  765. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  766. if (dt != null && dt.Rows.Count > 0)
  767. {
  768. foreach (DataRow dr in dt.Rows)
  769. {
  770. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  771. {
  772. //品类一直
  773. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  774. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  775. if (ceErpSampleCustomer == null)
  776. {
  777. ceErpSampleCustomer = new CeErpSampleCustomer();
  778. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  779. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  780. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  781. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  782. ceErpSampleCustomer.shopId = entity.ShopId;
  783. }
  784. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  785. ceErpSampleCustomer.lastTid = entity.tid;
  786. if (ceErpSampleCustomer.ID > 0)
  787. {
  788. ceErpSampleCustomer.Update();
  789. }
  790. else
  791. {
  792. ceErpSampleCustomer.Create();
  793. }
  794. }
  795. }
  796. }
  797. }
  798. //if (entity.IsOldCustomer == 1)
  799. //{
  800. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  801. //{
  802. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  803. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  804. //}
  805. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  806. //{
  807. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  808. // {
  809. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  810. // {
  811. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  813. // }
  814. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  815. // {
  816. // entity.OrderState = 2;
  817. // entity.DesignUserId = 0;
  818. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  819. // }
  820. // else
  821. // {
  822. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  823. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  824. // }
  825. // }
  826. //}
  827. //}
  828. entity.Update();
  829. returnSuccessMsg("保存成功!");
  830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  831. return;
  832. }
  833. returnErrorMsg("找不到记录");
  834. }
  835. }
  836. public void save_erp_customermemo()
  837. {
  838. if (UrlPostParmsCheck("ctid"))
  839. {
  840. string ctid = GetPostString("ctid");
  841. CeErpTradeCell entity = null;
  842. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  843. if (entity != null)
  844. {
  845. entity.CustomerMemo = GetPostString("CustomerMemo");
  846. entity.Update();
  847. ApiVo apiVo = new ApiVo();
  848. apiVo.orderNumber = entity.ctid;
  849. apiVo.actionName = "followRemarks";
  850. apiVo.orderRemarks = entity.CustomerMemo;
  851. designHelper.API_WorkCore(apiVo);//followRemarks
  852. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  853. returnSuccessMsg("保存成功!");
  854. return;
  855. }
  856. returnErrorMsg("找不到记录");
  857. }
  858. }
  859. public void upd_erp_addmemotag()
  860. {
  861. if (UrlPostParmsCheck("ctid"))
  862. {
  863. ;
  864. string eid = GetPostString("ctid");
  865. string sfTagstr = GetPostString("memotag");
  866. CeErpTradeCell entity = null;
  867. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  868. if (entity != null)
  869. {
  870. if (entity.OrderState == 0)
  871. {
  872. returnErrorMsg("请先领单");
  873. return;
  874. }
  875. //撤销顺丰
  876. if (sfTagstr == "撤销顺丰")
  877. {
  878. entity.IsSF = 0;
  879. string reMsg = "";
  880. string oldmemo = entity.seller_memo;
  881. if (entity.OrderState < 5)
  882. {
  883. oldmemo = oldmemo.Replace("顺丰到付", "");
  884. oldmemo = oldmemo.Replace("顺丰寄付", "");
  885. entity.seller_memo = oldmemo;
  886. }
  887. else
  888. {
  889. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  890. {
  891. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  892. }
  893. }
  894. entity.Update();
  895. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  896. api.orderNumber = entity.ctid;
  897. api.actionName = "followRemarks";
  898. api.orderRemarks = entity.seller_memo;
  899. api.isSf = entity.IsSF.ToString();
  900. designHelper.API_WorkCore(api);//followRemarks
  901. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  902. returnSuccessMsg("撤销成功!" + reMsg);
  903. return;
  904. }
  905. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  906. {
  907. //string oldmemo = entity.seller_memo;
  908. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  909. string sfStr = GetPostString("memotag");
  910. string smemo = entity.seller_memo;
  911. int kindex = smemo.IndexOf(")");
  912. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  913. if (lastoneStr != "-")
  914. {
  915. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  916. }
  917. string prememo = smemo.Substring(0, kindex + 2);
  918. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  919. int lastkindex = lastmemo.IndexOf("(");
  920. string newlastmemo = "";
  921. if (lastkindex == 0)
  922. {
  923. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  924. newlastmemo = "(" + sfStr + "." + useLastmemo;
  925. }
  926. else
  927. {
  928. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  929. }
  930. entity.seller_memo = prememo + newlastmemo;
  931. }
  932. string sfTagMSg = "";
  933. if (sfTagstr == "顺丰寄付")
  934. {
  935. entity.IsSF = 1;
  936. sfTagMSg = "顺丰寄付";
  937. }
  938. else if (sfTagstr == "顺丰到付")
  939. {
  940. entity.IsSF = 2;
  941. sfTagMSg = "顺丰到付";
  942. }
  943. entity.Update();
  944. ApiVo apiVo = new ApiVo();
  945. apiVo.orderNumber = entity.ctid;
  946. apiVo.actionName = "orderRemarks";
  947. apiVo.orderRemarks = entity.seller_memo;
  948. apiVo.isSf = entity.IsSF.ToString();
  949. designHelper.API_WorkCore(apiVo);//orderRemarks
  950. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  951. returnSuccessMsg("标记成功!");
  952. return;
  953. }
  954. returnErrorMsg("找不到记录");
  955. }
  956. }
  957. public void upd_erp_ordertag()
  958. {
  959. if (UrlPostParmsCheck("ctid"))
  960. {
  961. string eid = GetPostString("ctid");
  962. CeErpTradeCell entity = null;
  963. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  964. if (entity != null)
  965. {
  966. int tag = GetPostInt("wechattag");
  967. //if(tag==4 && entity.IsSample == 2)
  968. //{
  969. // returnErrorMsg("补差价单不能标记微信单");
  970. // return;
  971. //}
  972. entity.wechatTag = tag;
  973. entity.Update();
  974. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  975. if (tag == 1)
  976. {
  977. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  978. if (cash == null)
  979. {
  980. CeErpTrade main = CeErpTrade.Get(entity.tid);
  981. cash = new CeErpReturnCash();
  982. cash.tid = entity.tid;
  983. cash.seller_nick = main.seller_nick;
  984. cash.payment = trade.payment;
  985. cash.buyer_nick = main.buyer_nick;
  986. cash.cashstate = 0;
  987. cash.rtype = "微信返现";
  988. cash.returnprice = 0;
  989. cash.created = DateTime.Now;
  990. cash.con = "订单标记微信单";
  991. cash.img = "";
  992. cash.applyuserid = CurrentUser.UserID;
  993. cash.Create();
  994. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  995. }
  996. else
  997. {
  998. cash.cashstate = 0;
  999. cash.Update();
  1000. }
  1001. CeErpSukuraData.createInfo(entity.ctid, 9);
  1002. }
  1003. else if (tag == 2)
  1004. {
  1005. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1006. if (cash == null)
  1007. {
  1008. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1009. cash = new CeErpReturnCash();
  1010. cash.tid = entity.tid;
  1011. cash.seller_nick = main.seller_nick;
  1012. cash.payment = trade.payment;
  1013. cash.buyer_nick = main.buyer_nick;
  1014. cash.cashstate = 0;
  1015. cash.rtype = "推购返现";
  1016. cash.returnprice = 5;
  1017. cash.created = DateTime.Now;
  1018. cash.con = "订单标记推购单";
  1019. cash.img = "";
  1020. cash.applyuserid = CurrentUser.UserID;
  1021. cash.Create();
  1022. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1023. }
  1024. else
  1025. {
  1026. cash.cashstate = 0;
  1027. cash.Update();
  1028. }
  1029. CeErpSukuraData.createInfo(entity.ctid, 9);
  1030. }
  1031. else if (tag == 3)
  1032. {
  1033. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1034. if (pers == null)
  1035. {
  1036. pers = new CeErpPersuade();
  1037. pers.ctid = entity.ctid;
  1038. pers.pstate = 0;
  1039. pers.created = DateTime.Now;
  1040. pers.applyuserid = CurrentUser.UserID;
  1041. pers.Create();
  1042. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1043. }
  1044. else
  1045. {
  1046. pers.pstate = 0;
  1047. pers.Update();
  1048. }
  1049. }
  1050. else if (tag == 4 || tag == 5)
  1051. {
  1052. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1053. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1054. if (pers == null)
  1055. {
  1056. pers = new CeErpStayGoods();
  1057. pers.t_id = entity.tid;
  1058. pers.status = "待审核";
  1059. pers.audit_type = 0;
  1060. if (tag == 4)
  1061. {
  1062. pers.stay_type = "微信推购";
  1063. }
  1064. else
  1065. {
  1066. pers.stay_type = "旺旺推购";
  1067. }
  1068. if (entity.IsXianHuo == 0)
  1069. {
  1070. pers.product_id = entity.ProductId;
  1071. }
  1072. pers.wangwang = main.buyer_nick;
  1073. pers.shop_name = main.seller_nick;
  1074. pers.creata_time = DateTime.Now;
  1075. pers.create_u_id = CurrentUser.UserID;
  1076. pers.create_u_name = CurrentUser.UserName;
  1077. pers.Create();
  1078. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1079. }
  1080. else
  1081. {
  1082. pers.audit_type = 0;
  1083. pers.Update();
  1084. }
  1085. CeErpSukuraData.createInfo(entity.ctid, 10);
  1086. }
  1087. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1088. returnSuccessMsg("标记成功!");
  1089. return;
  1090. }
  1091. returnErrorMsg("找不到记录");
  1092. }
  1093. }
  1094. public void upd_erp_ordertag_cancel()
  1095. {
  1096. if (UrlPostParmsCheck("ctid"))
  1097. {
  1098. string eid = GetPostString("ctid");
  1099. CeErpTradeCell entity = null;
  1100. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1101. if (entity != null)
  1102. {
  1103. entity.wechatTag = 0;
  1104. entity.Update();
  1105. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1106. if (pers != null)
  1107. {
  1108. pers.status = "取消推购";
  1109. pers.audit_type = 3;
  1110. pers.Update();
  1111. }
  1112. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1113. returnSuccessMsg("标记成功!");
  1114. return;
  1115. }
  1116. returnErrorMsg("找不到记录");
  1117. }
  1118. }
  1119. public void upd_erp_addweichattag()
  1120. {
  1121. if (UrlPostParmsCheck("ctid"))
  1122. {
  1123. ;
  1124. string eid = GetPostString("ctid");
  1125. CeErpTradeCell entity = null;
  1126. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1127. if (entity != null)
  1128. {
  1129. if (entity.IsAddWechat > 0)
  1130. {
  1131. returnErrorMsg("此单已经标记过了");
  1132. return;
  1133. }
  1134. 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);
  1135. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1136. if (dt.Rows.Count > 0)
  1137. {
  1138. entity.IsAddWechat = 2;
  1139. }
  1140. else
  1141. {
  1142. entity.IsAddWechat = 1;
  1143. }
  1144. entity.Update();
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1146. returnSuccessMsg("标记成功!");
  1147. return;
  1148. }
  1149. returnErrorMsg("找不到记录");
  1150. }
  1151. }
  1152. public void upd_erp_getmyorder()
  1153. {
  1154. if (UrlPostParmsCheck("ctid"))
  1155. {
  1156. ;
  1157. string eid = GetPostString("ctid");
  1158. CeErpTradeCell entity = null;
  1159. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1160. if (entity != null)
  1161. {
  1162. if (entity.ctid.IndexOf("C") != -1)
  1163. {
  1164. StringBuilder sql = new StringBuilder();
  1165. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1166. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1167. if (dt.Rows.Count > 0)
  1168. {
  1169. decimal total = 0;
  1170. foreach (DataRow dr in dt.Rows)
  1171. {
  1172. total += Convert.ToDecimal(dr["payment"]);
  1173. }
  1174. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1175. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1176. {
  1177. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1178. return;
  1179. }
  1180. }
  1181. }
  1182. entity.CustomerUserId = CurrentUser.UserID;
  1183. if (entity.OrderState < 2)
  1184. {
  1185. entity.OrderState = 2;
  1186. if (entity.ShopId != 0)
  1187. {
  1188. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1189. }
  1190. }
  1191. entity.UpdateTime = DateTime.Now;
  1192. entity.Update();
  1193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1194. returnSuccessMsg("领单成功!");
  1195. return;
  1196. }
  1197. returnErrorMsg("找不到记录");
  1198. }
  1199. }
  1200. public void getmyorder_from_init()
  1201. {
  1202. if (UrlPostParmsCheck("ctid"))
  1203. {
  1204. string eid = GetPostString("ctid");
  1205. CeErpTradeCell entity = null;
  1206. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1207. if (entity != null)
  1208. {
  1209. string sellerMemo = GetPostString("sellerMemo");
  1210. if (sellerMemo.Length > 0)
  1211. {
  1212. entity.seller_memo = sellerMemo;
  1213. }
  1214. string oterhMemo = GetPostString("otherMemo");
  1215. if (oterhMemo.Length > 0)
  1216. {
  1217. entity.OtherMemo = oterhMemo;
  1218. }
  1219. int urg = GetPostInt("urgency");
  1220. entity.IsUrgency = (urg == 1 ? true : false);
  1221. int wechat = GetPostInt("wechat");
  1222. int command = GetPostInt("command");
  1223. if (wechat == 1)
  1224. {
  1225. entity.wechatTag = 1;
  1226. }
  1227. if (command == 1)
  1228. {
  1229. entity.wechatTag = 2;
  1230. }
  1231. string pPro = GetPostString("pprofession");
  1232. if (pPro.Length > 0)
  1233. {
  1234. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1235. string spro = GetPostString("profession");
  1236. if (spro.Length > 0)
  1237. {
  1238. entity.ProfessionId = Convert.ToInt32(spro);
  1239. }
  1240. }
  1241. string proId = GetPostString("productId");
  1242. if (proId.Length > 0)
  1243. {
  1244. entity.ProductId = Convert.ToInt32(proId);
  1245. }
  1246. entity.Material = GetPostString("material");
  1247. entity.Craft = GetPostString("craft");
  1248. entity.CustomerUserId = CurrentUser.UserID;
  1249. if (entity.OrderState < 2)
  1250. {
  1251. entity.OrderState = 2;
  1252. if (entity.ShopId != 0)
  1253. {
  1254. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1255. }
  1256. }
  1257. entity.Update();
  1258. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1259. returnSuccessMsg("领单成功!");
  1260. return;
  1261. }
  1262. returnErrorMsg("找不到记录");
  1263. }
  1264. }
  1265. public void upd_erp_setrelationorder()
  1266. {
  1267. if (UrlPostParmsCheck("ctid"))
  1268. {
  1269. ;
  1270. string eid = GetPostString("ctid");
  1271. string ftid = GetPostString("ftid");
  1272. CeErpTradeCell entity = null;
  1273. CeErpTradeCell fentity = null;
  1274. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1275. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1276. if (fentity == null)
  1277. {
  1278. returnErrorMsg("找不到关联的主订单");
  1279. return;
  1280. }
  1281. if (entity != null)
  1282. {
  1283. if (entity.OrderState >= 5)
  1284. {
  1285. returnErrorMsg("本单已经设计完成无法关联");
  1286. return;
  1287. }
  1288. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1289. {
  1290. returnErrorMsg("线下单续审核后才能关联!");
  1291. return;
  1292. }
  1293. entity.ptid = ftid;
  1294. entity.OrderState = fentity.OrderState;
  1295. //entity.status = fentity.status;
  1296. entity.CustomerUserId = fentity.CustomerUserId;
  1297. entity.DesignUserId = fentity.DesignUserId;
  1298. entity.seller_memo = "补差价单:" + ftid;
  1299. entity.IsSample = 2;
  1300. entity.Update();
  1301. ApiVo apiVo = new ApiVo();
  1302. apiVo.orderNumber = ftid;
  1303. apiVo.payment = entity.payment;
  1304. apiVo.actionName = "repairDesign";
  1305. designHelper.API_WorkCore(apiVo);//repairDesign
  1306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1307. returnSuccessMsg("关联成功!");
  1308. return;
  1309. }
  1310. else
  1311. returnErrorMsg("找不到记录");
  1312. }
  1313. }
  1314. public void download_erp_neworder()
  1315. {
  1316. string seller = GetPostString("seller_nick");
  1317. string tid = GetPostString("tid");
  1318. if (seller.Length <= 0 || tid.Length <= 0)
  1319. {
  1320. returnErrorMsg("数据错误");
  1321. }
  1322. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1323. //{
  1324. // returnErrorMsg("找不到店铺Sessionkey");
  1325. //}
  1326. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1327. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1328. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1329. if (res.IndexOf("refOid") == -1)
  1330. {
  1331. returnErrorMsg("下载订单数据失败");
  1332. return;
  1333. }
  1334. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1335. returnSuccessMsg("下载完成");
  1336. //tmcHelper.createNewOrder(res);
  1337. //CeErpTrade entr = null;
  1338. //entr = CeErpTrade.Get(tid);
  1339. //if (entr != null)
  1340. //{
  1341. // returnSuccess("下载成功");
  1342. // //下载成功之后,Cell表生成对应的订单;
  1343. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1344. //}
  1345. //else
  1346. //{
  1347. // returnErrorMsg("下载失败或者创建订单失败");
  1348. //}
  1349. }
  1350. public void set_erp_atersale()
  1351. {
  1352. if (UrlPostParmsCheck("ctid"))
  1353. {
  1354. string eid = GetPostString("ctid");
  1355. string reason = GetPostString("AfterSaleReason");
  1356. CeErpTradeCell entity = null;
  1357. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1358. if (entity != null)
  1359. {
  1360. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1361. {
  1362. returnErrorMsg("此订单已经在售后");
  1363. return;
  1364. }
  1365. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1366. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1367. entity.AfterSaleTime = DateTime.Now;
  1368. entity.Update();
  1369. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1370. returnSuccessMsg("转售后成功!");
  1371. return;
  1372. }
  1373. returnErrorMsg("找不到记录");
  1374. }
  1375. }
  1376. public void set_erp_withdraw()
  1377. {
  1378. if (UrlPostParmsCheck("ctid"))
  1379. {
  1380. try
  1381. {
  1382. string eid = GetPostString("ctid");//商品id
  1383. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1384. CeWithdraw ceWithdrawSelect = null;
  1385. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1386. if (ceWithdrawSelect != null)
  1387. {
  1388. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1389. {
  1390. ceWithdrawSelect.status = -1;
  1391. ceWithdrawSelect.Update();
  1392. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1393. returnSuccessMsg("重新发起审核成功");
  1394. return;
  1395. }
  1396. else
  1397. {
  1398. returnSuccessMsg("请勿重复申请!");
  1399. return;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1405. if (string.IsNullOrEmpty(CustomerUserId))
  1406. {
  1407. CustomerUserId = "-1";
  1408. }
  1409. int Userid = CurrentUser.UserID;//用户id
  1410. CeWithdraw ceWithdraw = new CeWithdraw();
  1411. ceWithdraw.tid = eid;
  1412. ceWithdraw.userid = Userid;
  1413. ceWithdraw.providerid = CustomerUserId;
  1414. ceWithdraw.status = 3;
  1415. ceWithdraw.creationtime = DateTime.Now;
  1416. ceWithdraw.Create();
  1417. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1418. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1419. return;
  1420. }
  1421. }
  1422. catch
  1423. {
  1424. returnErrorMsg("申请撤回订单失败");
  1425. return;
  1426. }
  1427. }
  1428. }
  1429. public void ins_erp_billinfo()
  1430. {
  1431. if (UrlPostParmsCheck("ctid"))
  1432. {
  1433. string eid = GetPostString("ctid");
  1434. CeErpTradeCell entity = null;
  1435. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1436. if (entity != null)
  1437. {
  1438. CeErpBill bill = CeErpBill.GetByTid(eid);
  1439. bool isHave = false;
  1440. if (bill != null)
  1441. {
  1442. isHave = true;
  1443. if (bill.state != 4)
  1444. {
  1445. returnErrorMsg("此单已经申请过发票了");
  1446. return;
  1447. }
  1448. }
  1449. if (entity.IsNeedBill == 0)
  1450. {
  1451. entity.IsNeedBill = 1;
  1452. }
  1453. entity.Update();
  1454. string errjson = "";
  1455. try
  1456. {
  1457. CeErpBill bill_entity = new CeErpBill();
  1458. bill_entity.tid = entity.tid;
  1459. bill_entity.title = GetPostString("title");
  1460. string taxstr = GetPostString("tax");
  1461. taxstr = taxstr.Replace(" ", "");
  1462. bill_entity.tax = taxstr;
  1463. bill_entity.bank = GetPostString("bank");
  1464. string bankacstr = GetPostString("bankac");
  1465. bankacstr = bankacstr.Replace(" ", "");
  1466. bill_entity.bankac = bankacstr;
  1467. bill_entity.address = GetPostString("address");
  1468. bill_entity.phone = GetPostString("phone");
  1469. bill_entity.price = GetPostString("price");
  1470. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1471. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1472. {
  1473. billCount += 1;
  1474. }
  1475. string prebill = "ltb";
  1476. for (int idx = 1; idx <= billCount; idx++)
  1477. {
  1478. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1479. string billoid = prebill + idx + dtstr;
  1480. bill_entity.billOrderId += billoid;
  1481. if (idx < billCount)
  1482. {
  1483. bill_entity.billOrderId += ",";
  1484. }
  1485. }
  1486. bill_entity.productId = GetPostInt("ProductName");
  1487. bill_entity.num = GetPostInt("num");
  1488. bill_entity.unit = GetPostString("unit");
  1489. bill_entity.type = GetPostString("type");
  1490. bill_entity.sendType = GetPostString("SendType");
  1491. bill_entity.email = GetPostString("email");
  1492. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1493. bill_entity.shopName = GetPostString("ShopName");
  1494. bill_entity.applymemo = GetPostString("applyMemo");
  1495. bill_entity.createTime = DateTime.Now;
  1496. bill_entity.state = 0;
  1497. bill_entity.userId = CurrentUser.UserID;
  1498. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1499. bill_entity.Create();
  1500. }
  1501. catch (Exception ex)
  1502. {
  1503. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1504. returnErrorMsg("创建发票出错!");
  1505. return;
  1506. }
  1507. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1508. returnSuccessMsg("发票申请成功!");
  1509. return;
  1510. }
  1511. returnErrorMsg("找不到记录");
  1512. }
  1513. }
  1514. public void ins_erp_neworder()
  1515. {
  1516. if (UrlPostParmsCheck("receiver_name"))
  1517. {
  1518. CeErpTrade entity = new CeErpTrade();
  1519. string plat_form = GetPostString("platform");
  1520. string preStr = "N_";
  1521. if (plat_form == "拼多多")
  1522. {
  1523. preStr = "P_";
  1524. }
  1525. else if (plat_form == "阿里巴巴")
  1526. {
  1527. preStr = "A_";
  1528. }
  1529. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1530. entity.seller_nick = GetPostString("seller_nick");
  1531. entity.buyer_nick = GetPostString("buyer_nick");
  1532. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1533. entity.total_fee = entity.payment;
  1534. entity.pay_time = DateTime.Now;
  1535. entity.status = "NOT_SHIPPED";
  1536. entity.receiver_name = GetPostString("receiver_name");
  1537. entity.receiver_mobile = GetPostString("receiver_mobile");
  1538. entity.receiver_state = GetPostString("receiver_state");
  1539. entity.receiver_city = GetPostString("receiver_city");
  1540. entity.receiver_district = GetPostString("receiver_district");
  1541. entity.receiver_address = GetPostString("receiver_address");
  1542. if (entity.receiver_state == "" || entity.receiver_city == "")
  1543. {
  1544. returnErrorMsg("收件地址不能为空");
  1545. return;
  1546. }
  1547. int shopId = 0;
  1548. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1549. if (nShop != null)
  1550. {
  1551. shopId = nShop.ID;
  1552. }
  1553. if (shopId != 34 && entity.payment == 0)
  1554. {
  1555. returnErrorMsg("公司自用的单金额才能为0");
  1556. return;
  1557. }
  1558. entity.Create();
  1559. CeErpTradeCell entitycell = new CeErpTradeCell();
  1560. entitycell.ctid = entity.tid;
  1561. entitycell.tid = entity.tid;
  1562. entitycell.ShopId = shopId;
  1563. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1564. entitycell.OrderState = 0;
  1565. entitycell.pay_time = entity.pay_time;
  1566. entitycell.IsOffLineOrder = 1;
  1567. entitycell.Create();
  1568. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1569. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1570. return;
  1571. }
  1572. }
  1573. public void ins_erp_neworder2()
  1574. {
  1575. if (UrlPostParmsCheck("receiver_name"))
  1576. {
  1577. //string plat_form = GetPostString("platform");
  1578. string preStr = "X_";
  1579. string memo = GetPostString("memo");
  1580. string productId = GetPostString("productId");
  1581. string primg = GetPostString("proofimg");
  1582. string sellerNick = GetPostString("seller_nick");
  1583. string addFrom = GetPostString("addfrom");
  1584. if (addFrom == "1")
  1585. {
  1586. preStr = "N_";
  1587. }
  1588. int shopId = 0;
  1589. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1590. if (nShop != null)
  1591. {
  1592. shopId = nShop.ID;
  1593. }
  1594. else
  1595. {
  1596. returnErrorMsg("找不到对应店铺");
  1597. return;
  1598. }
  1599. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1600. {
  1601. returnErrorMsg("必须上传付款凭证");
  1602. return;
  1603. }
  1604. CeErpTrade entity = new CeErpTrade();
  1605. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1606. entity.seller_nick = sellerNick;
  1607. entity.buyer_nick = GetPostString("buyer_nick");
  1608. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1609. entity.total_fee = entity.payment;
  1610. entity.pay_time = DateTime.Now;
  1611. entity.status = "NOT_SHIPPED";
  1612. entity.receiver_name = GetPostString("receiver_name");
  1613. entity.receiver_mobile = GetPostString("receiver_mobile");
  1614. entity.receiver_state = GetPostString("receiver_state");
  1615. entity.receiver_city = GetPostString("receiver_city");
  1616. entity.receiver_district = GetPostString("receiver_district");
  1617. entity.receiver_address = GetPostString("receiver_address");
  1618. entity.seller_memo = memo;
  1619. entity.orderFrom = 20;
  1620. entity.orderType = 15;
  1621. if (entity.receiver_state == "" || entity.receiver_city == "")
  1622. {
  1623. returnErrorMsg("收件地址不能为空");
  1624. return;
  1625. }
  1626. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1627. {
  1628. returnErrorMsg("公司自用的单金额才能为0");
  1629. return;
  1630. }
  1631. entity.Create();
  1632. string toWhere = GetPostString("towhere");
  1633. CeErpTradeCell entitycell = new CeErpTradeCell();
  1634. entitycell.ctid = entity.tid;
  1635. //唯一标识
  1636. entitycell.OrderSn = entity.tid;
  1637. string orderSn = dataHelper.getSaleOrderSn();
  1638. if (orderSn != "")
  1639. {
  1640. entitycell.OrderSn = orderSn;
  1641. }
  1642. entitycell.tid = entity.tid;
  1643. //if (preStr == "X_")
  1644. //{
  1645. entitycell.IsOffLineOrder = 1;
  1646. //}
  1647. entitycell.CustomerUserId = CurrentUser.UserID;
  1648. entitycell.PayProofImg = primg;
  1649. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1650. entitycell.ProductId = Convert.ToInt32(productId);
  1651. entitycell.ShopId = shopId;
  1652. entitycell.UpdateTime = DateTime.Now;
  1653. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1654. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1655. {
  1656. entitycell.IsXianHuo = 1;
  1657. }
  1658. entitycell.pay_time = entity.pay_time;
  1659. if (toWhere == "1")
  1660. {
  1661. entitycell.OrderState = 2;
  1662. }
  1663. else
  1664. {
  1665. entitycell.OrderState = 6;
  1666. entitycell.FinishPlaceTime = entitycell.pay_time;
  1667. }
  1668. if (shopId == 94)
  1669. {
  1670. entitycell.OrderState = 4;
  1671. entitycell.WaitDesignTime = entitycell.pay_time;
  1672. entitycell.StartDesignTime = entitycell.pay_time;
  1673. entitycell.DesignUserId = 218;
  1674. }
  1675. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1676. {
  1677. entitycell.OrderState = -1;//修改12-5
  1678. CeWithdraw ceWithdraw = new CeWithdraw();
  1679. ceWithdraw.tid = entity.tid;
  1680. ceWithdraw.providerid = "-1";
  1681. ceWithdraw.status = -1;
  1682. ceWithdraw.creationtime = DateTime.Now;
  1683. ceWithdraw.userid = 1337;
  1684. ceWithdraw.Create();
  1685. }
  1686. entitycell.Create();
  1687. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1688. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1689. {
  1690. addPlaceRegist(entitycell, CurrentUser.UserID);
  1691. }
  1692. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1693. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1694. return;
  1695. }
  1696. }
  1697. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1698. {
  1699. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1700. entity.PlactTime = tradecell.pay_time;
  1701. entity.AddUserId = userid;
  1702. entity.FileName = tradecell.seller_memo;
  1703. entity.Supplier = 24;
  1704. entity.CreateTime = DateTime.Now;
  1705. entity.Did = tradecell.ctid;
  1706. entity.tid = tradecell.tid;
  1707. entity.splitTag = tradecell.SplitTag;
  1708. entity.CurState = "未完成";
  1709. entity.Create();
  1710. }
  1711. public void get_erp_offlinelist()
  1712. {
  1713. DataStruct dStruct = GetPostStruct();
  1714. List<string> lw = new List<string>();
  1715. string tid = GetPostString("ctid");
  1716. string date1 = GetPostString("date1");
  1717. string date2 = GetPostString("date2");
  1718. if (tid.Length > 0 || date1.Length > 0)
  1719. {
  1720. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1721. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1722. if (dw.Length > 0) lw.Add(dw);
  1723. }
  1724. else
  1725. {
  1726. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1727. }
  1728. string shopname = GetPostString("shopname");
  1729. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1730. string buyernick = GetPostString("buyer_nick");
  1731. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1732. string customer = GetPostString("customer");
  1733. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1734. string design = GetPostString("design");
  1735. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1736. string orderState = GetPostString("orderState");
  1737. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1738. string address = GetPostString("address");
  1739. 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));
  1740. string sellermemo = GetPostString("seller_memo");
  1741. if (sellermemo.Length > 0)
  1742. {
  1743. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1744. }
  1745. string price1 = GetPostString("price1");
  1746. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1747. string price2 = GetPostString("price2");
  1748. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1749. //if (PKey != "admin")
  1750. //{
  1751. // string usershop = CurrentUser.User.pemShop;
  1752. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1753. //}
  1754. //if (ex_psize > 0)
  1755. //{
  1756. dStruct.Order = "pay_time desc";
  1757. //}
  1758. //else
  1759. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1760. lw.Add(string.Format("IsOffLineOrder=1"));
  1761. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1762. DataTable dt = null;
  1763. dt = WebCache.GetData("view_erptradecell", dStruct);
  1764. writeGridDataTableJson(dStruct.TotalCount, dt);
  1765. }
  1766. public void get_erp_returncashrecord()
  1767. {
  1768. DataStruct dStruct = GetPostStruct();
  1769. List<string> lw = new List<string>();
  1770. string tid = GetPostString("ctid");
  1771. if (tid.Length > 0)
  1772. {
  1773. lw.Add(string.Format("tid like '%{0}%'", tid));
  1774. dStruct.Order = "id desc";
  1775. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1776. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1777. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1778. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1779. return;
  1780. }
  1781. returnErrorMsg("id数据错误!");
  1782. }
  1783. public void ins_erp_returncashrecord()
  1784. {
  1785. if (UrlPostParmsCheck("tid"))
  1786. {
  1787. string tid = GetPostString("tid");
  1788. string retype = GetPostString("type");
  1789. StringBuilder sql = new StringBuilder();
  1790. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1791. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1792. if (dt.Rows.Count > 0)
  1793. {
  1794. returnErrorMsg("相同返现类型记录已存在");
  1795. return;
  1796. }
  1797. CeErpReturnCash entity = new CeErpReturnCash();
  1798. entity.tid = tid;
  1799. entity.seller_nick = GetPostString("seller_nick");
  1800. string pment = GetPostString("payment");
  1801. if (pment.Length > 0)
  1802. {
  1803. entity.payment = Convert.ToDouble(pment);
  1804. }
  1805. entity.buyer_nick = GetPostString("buyer_nick");
  1806. entity.cashstate = 0;
  1807. entity.rtype = retype;
  1808. string rPrice = GetPostString("returnprice");
  1809. if (rPrice.Length > 0)
  1810. {
  1811. entity.returnprice = Convert.ToDouble(rPrice);
  1812. }
  1813. entity.created = DateTime.Now;
  1814. entity.con = GetPostString("con");
  1815. entity.img = GetPostString("img");
  1816. entity.applyuserid = CurrentUser.UserID;
  1817. entity.Create();
  1818. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1819. returnSuccessMsg("操作成功!");
  1820. return;
  1821. }
  1822. }
  1823. public void set_erp_predelivery()
  1824. {
  1825. if (UrlPostParmsCheck("ctid"))
  1826. {
  1827. string eid = GetPostString("ctid");
  1828. CeErpTradeCell entity = null;
  1829. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1830. if (entity != null)
  1831. {
  1832. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1833. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1834. //{
  1835. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1836. // return;
  1837. //}
  1838. entity.IsPreDelivery = 1;
  1839. entity.Update();
  1840. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1841. returnSuccessMsg("预发货成功!");
  1842. return;
  1843. //string shop = GetPostString("seller_nick");
  1844. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1845. //string comName = GetPostString("comName");
  1846. //string comCode = GetPostString("comCode");
  1847. //string outSid = GetPostString("outSid");//运单号
  1848. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1849. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1850. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1851. //string apires = "";
  1852. //if (deliveryType == "虚拟发货")
  1853. //{
  1854. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1855. //}
  1856. //else
  1857. //{
  1858. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1859. //}
  1860. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1861. ////{
  1862. //if (apires.IndexOf("发货成功") != -1)
  1863. //{
  1864. // if (deliveryType != "虚拟发货")
  1865. // {
  1866. // //还要插入快递信息到 快递信息表
  1867. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1868. // exinfo.tid = eid;
  1869. // exinfo.out_sid = outSid;
  1870. // exinfo.company_code = comCode;
  1871. // exinfo.company_name = comName;
  1872. // exinfo.delivery_memo = deliveryMemo;
  1873. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1874. // exinfo.deliveryType = deliveryType;
  1875. // exinfo.Create();
  1876. // }
  1877. // returnSuccessMsg("发货成功!");
  1878. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1879. //}
  1880. //else
  1881. //{
  1882. // returnErrorMsg("淘宝发货失败!!");
  1883. //}
  1884. //return;
  1885. }
  1886. returnErrorMsg("找不到订单记录");
  1887. }
  1888. }
  1889. public void get_erp_unusuallist()
  1890. {
  1891. DataStruct dStruct = GetPostStruct();
  1892. List<string> lw = new List<string>();
  1893. string tid = GetPostString("ctid");
  1894. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1895. string shopname = GetPostString("shopname");
  1896. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1897. string buyernick = GetPostString("buyer_nick");
  1898. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1899. string ResponsibleMan = GetPostString("responsible");
  1900. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1901. string date1 = GetPostString("date1");
  1902. string date2 = GetPostString("date2");
  1903. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1904. if (dw.Length > 0) lw.Add(dw);
  1905. string price1 = GetPostString("price1");
  1906. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1907. string price2 = GetPostString("price2");
  1908. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1909. string orderState = GetPostString("orderState");
  1910. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1911. string sellermemo = GetPostString("seller_memo");
  1912. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1913. lw.Add(string.Format("UnusualTag > 0"));
  1914. lw.Add(string.Format("IsRefund<={0}", 1));
  1915. dStruct.Order = "pay_time desc";
  1916. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1917. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1918. writeGridDataTableJson(dStruct.TotalCount, dt);
  1919. }
  1920. public void set_erp_unusualtonomal()
  1921. {
  1922. if (UrlPostParmsCheck("ctid"))
  1923. {
  1924. string eid = GetPostString("ctid");
  1925. CeErpTradeCell entity = null;
  1926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1927. if (entity != null)
  1928. {
  1929. entity.UnusualTag = -1;
  1930. entity.Update();
  1931. returnSuccessMsg("忽略成功!");
  1932. return;
  1933. }
  1934. returnErrorMsg("找不到记录");
  1935. }
  1936. }
  1937. public void ins_erp_unusualreason()
  1938. {
  1939. if (UrlPostParmsCheck("ctid"))
  1940. {
  1941. string eid = GetPostString("ctid");
  1942. CeErpTradeCell entity = null;
  1943. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1944. if (entity != null)
  1945. {
  1946. entity.MemoOpt = 4;
  1947. entity.UnusualCon = GetPostString("con");
  1948. entity.Update();
  1949. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1950. if (trade != null)
  1951. {
  1952. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1953. }
  1954. //查货是否超时
  1955. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1956. if (ceErpTradeCellExtend == null)
  1957. {
  1958. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1959. ceErpTradeCellExtend.ctid = entity.ctid;
  1960. }
  1961. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1962. {
  1963. ceErpTradeCellExtend.CheckOut += 1;
  1964. }
  1965. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1966. if (ceErpTradeCellExtend.ID > 0)
  1967. {
  1968. ceErpTradeCellExtend.Update();
  1969. }
  1970. else
  1971. {
  1972. ceErpTradeCellExtend.Create();
  1973. }
  1974. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1975. returnSuccessMsg("操作成功!");
  1976. return;
  1977. }
  1978. returnErrorMsg("找不到记录");
  1979. }
  1980. }
  1981. public void upd_erp_sampleorder()
  1982. {
  1983. if (UrlPostParmsCheck("ctid"))
  1984. {
  1985. string eid = GetPostString("ctid");
  1986. string[] eArr = eid.Split(',');
  1987. if (eArr.Length > 1)
  1988. {
  1989. List<string> eLst = new List<string>();
  1990. for (int i = 0; i < eArr.Length; i++)
  1991. {
  1992. eLst.Add("'" + eArr[i] + "'");
  1993. }
  1994. eid = string.Join(",", eLst.ToArray());
  1995. }
  1996. else
  1997. {
  1998. eid = "'" + eid + "'";
  1999. }
  2000. StringBuilder sql = new StringBuilder();
  2001. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2002. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2003. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2004. if (dt.Rows.Count > 0)
  2005. {
  2006. string errmsg = "";
  2007. foreach (DataRow dr in dt.Rows)
  2008. {
  2009. StringBuilder sqlsb = new StringBuilder();
  2010. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2011. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2012. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2013. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2014. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2015. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2016. {
  2017. continue;
  2018. }
  2019. else
  2020. {
  2021. string emsg = commonHelper.KeepChinese(apires);
  2022. errmsg += emsg;
  2023. }
  2024. }
  2025. if (errmsg.Length > 0)
  2026. {
  2027. returnErrorMsg(errmsg);
  2028. return;
  2029. }
  2030. returnSuccessMsg("操作成功");
  2031. return;
  2032. }
  2033. returnErrorMsg("找不到记录");
  2034. }
  2035. }
  2036. public void upd_erp_transcustomer()
  2037. {
  2038. if (UrlPostParmsCheck("ctid"))
  2039. {
  2040. string eid = GetPostString("ctid");
  2041. int userid = GetPostInt("CustomerUserId");
  2042. CeErpTradeCell entity = null;
  2043. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2044. if (entity != null)
  2045. {
  2046. //string[] mlist = entity.seller_memo.Split('-');
  2047. //string sql = "select * from view_erpuser where id=" + userid;
  2048. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2049. //if (dt != null && dt.Rows.Count > 0)
  2050. //{
  2051. // string nmemo = "";
  2052. // for(int i = 0; i < mlist.Length - 1; i++)
  2053. // {
  2054. // nmemo += mlist[i];
  2055. // nmemo += "-";
  2056. // }
  2057. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2058. // entity.seller_memo = nmemo;
  2059. //}
  2060. entity.CustomerUserId = userid;
  2061. entity.Update();
  2062. returnSuccessMsg("操作成功!");
  2063. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2064. return;
  2065. }
  2066. returnErrorMsg("找不到记录");
  2067. }
  2068. }
  2069. public void upd_erp_transdesigner()
  2070. {
  2071. if (UrlPostParmsCheck("ctid"))
  2072. {
  2073. string eids = GetPostString("ctid");
  2074. string[] ctidList = eids.Split(',');
  2075. int userid = GetPostInt("DesignUserId");
  2076. foreach (string ctid in ctidList)
  2077. {
  2078. CeErpTradeCell entity = null;
  2079. CeErpDesignerBill entitys = null;
  2080. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2081. entitys = CeErpDesignerBill.GetByTid(ctid);
  2082. if (entity != null)
  2083. {
  2084. if (entity.OrderState > 4)
  2085. {
  2086. continue;
  2087. }
  2088. //存在退款不能流转
  2089. if (entity.IsRefund > 0)
  2090. {
  2091. continue;
  2092. }
  2093. entity.DesignUserId = userid;
  2094. entity.WaitDesignTime = DateTime.Now;
  2095. entity.Update();
  2096. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2097. }
  2098. }
  2099. returnSuccessMsg("操作成功!");
  2100. }
  2101. }
  2102. public void upd_erp_distributedesigner()
  2103. {
  2104. if (UrlPostParmsCheck("ctid"))
  2105. {
  2106. string eid = GetPostString("ctid");
  2107. int userid = GetPostInt("DesignUserId");
  2108. string[] idlist = eid.Split(',');
  2109. if (idlist.Length <= 0)
  2110. {
  2111. returnErrorMsg("订单不能为空");
  2112. return;
  2113. }
  2114. foreach (string ctid in idlist)
  2115. {
  2116. CeErpTradeCell entity = null;
  2117. CeErpDesignerBill entitys = null;
  2118. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2119. else continue;
  2120. if (entity != null)
  2121. {
  2122. if (userid == 2125 || userid == 3542)
  2123. { }
  2124. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2125. {
  2126. returnErrorMsg("金额错误的订单无法指派");
  2127. return;
  2128. }
  2129. if (entity.OrderState >= 5)
  2130. {
  2131. returnErrorMsg("已经设计完成无法指派");
  2132. return;
  2133. }
  2134. if (entity.OrderState == -1)
  2135. {
  2136. returnErrorMsg("审核中的订单无法指派");
  2137. return;
  2138. }
  2139. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2140. {
  2141. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2142. return;
  2143. }
  2144. //157赖橙帆 159林晨
  2145. 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)
  2146. {
  2147. returnErrorMsg("指派设计共创无法再次指派!");
  2148. return;
  2149. }
  2150. entity.OrderState = 3;
  2151. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2152. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2153. {
  2154. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2155. entity.SupplierId = suid;
  2156. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2157. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2158. }
  2159. if (userid == 2125 && entity.seller_memo != "")
  2160. {
  2161. apiDesign.API_GetPrintData_CreateOrder(entity);
  2162. }
  2163. if (userid == 3542 && entity.seller_memo != "")
  2164. {
  2165. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2166. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2167. if (response.msg != "设计共创:成功")
  2168. {
  2169. returnErrorMsg(response.msg);
  2170. return;
  2171. }
  2172. entity.DispatchSort = 2;
  2173. }
  2174. else
  2175. {
  2176. if (entity.DispatchSort == 2)
  2177. {
  2178. ApiVo apiVo = new ApiVo();
  2179. apiVo.actionName = "closeDesign";
  2180. apiVo.orderNumber = entity.ctid;
  2181. designHelper.API_WorkCore(apiVo);//closeDesign
  2182. }
  2183. entity.DispatchSort = 0;
  2184. }
  2185. entity.DesignUserId = userid;
  2186. entity.WaitDesignTime = DateTime.Now;
  2187. entity.UpdateTime = DateTime.Now;
  2188. entity.Update();
  2189. string name = commonHelper.getUserNameById(userid);
  2190. commonHelper.UpdateRelationOrder(entity.ctid);
  2191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2192. }
  2193. }
  2194. returnSuccessMsg("操作成功!");
  2195. return;
  2196. }
  2197. }
  2198. public string getTidByCtid(string ctid)
  2199. {
  2200. string tid = "";
  2201. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2202. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2203. if (dataTable != null && dataTable.Rows.Count > 0)
  2204. {
  2205. tid = dataTable.Rows[0]["tid"].ToString();
  2206. }
  2207. return tid;
  2208. }
  2209. public List<string> getTidByCtidLike(string ctid)
  2210. {
  2211. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2212. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2213. List<string> list = new List<string>();
  2214. if (dataTable != null && dataTable.Rows.Count > 0)
  2215. {
  2216. foreach (DataRow item in dataTable.Rows)
  2217. {
  2218. list.Add("'" + item["tid"].ToString() + "'");
  2219. }
  2220. }
  2221. return list;
  2222. }
  2223. public void get_erp_myorderlist()
  2224. {
  2225. DataStruct dStruct = GetPostStruct();
  2226. List<string> lw = new List<string>();
  2227. string tid = GetPostString("ctid");
  2228. if (tid.Length > 0)
  2229. {
  2230. string select_tid = getTidByCtid(tid);
  2231. lw.Add(string.Format("tid='{0}'", select_tid));
  2232. }
  2233. else
  2234. {
  2235. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2236. }
  2237. //12-1 修改
  2238. string urgent = GetPostString("urgent");
  2239. string back = GetPostString("back");
  2240. string offlineSearch = GetPostString("offlineSearch");
  2241. if (!string.IsNullOrWhiteSpace(urgent))
  2242. {
  2243. if (urgent.Equals("true"))
  2244. {
  2245. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2246. }
  2247. }
  2248. if (!string.IsNullOrWhiteSpace(back))
  2249. {
  2250. if (back.Equals("true"))
  2251. {
  2252. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2253. }
  2254. }
  2255. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2256. {
  2257. if (offlineSearch.Equals("true"))
  2258. {
  2259. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2260. }
  2261. }
  2262. //end
  2263. string shopname = GetPostString("shopname");
  2264. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2265. string buyernick = GetPostString("buyer_nick");
  2266. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2267. string design = GetPostString("design");
  2268. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2269. string orderState = GetPostString("orderState");
  2270. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2271. string sellermemo = GetPostString("seller_memo");
  2272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2273. string date1 = GetPostString("date1");
  2274. string date2 = GetPostString("date2");
  2275. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2276. if (dw.Length > 0) lw.Add(dw);
  2277. string price1 = GetPostString("price1");
  2278. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2279. string price2 = GetPostString("price2");
  2280. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2281. string urgency = GetPostString("urgency");
  2282. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2283. string after = GetPostString("after");
  2284. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2285. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2286. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2287. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2289. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2290. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2291. if (dt != null && dt.Rows.Count > 0)
  2292. {
  2293. foreach (DataRow dr in dt.Rows)
  2294. {
  2295. try
  2296. {
  2297. // 对象操作
  2298. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2299. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2300. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2301. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2302. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2303. if (dStruct.PageSize != 100000)
  2304. {
  2305. if (dr["DispatchSort"].ToString() == "2")
  2306. {
  2307. dr["gongchuang"] = 200;
  2308. }
  2309. else
  2310. {
  2311. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2312. dr["gongchuang"] = response.code;
  2313. }
  2314. }
  2315. }
  2316. catch (NullReferenceException ex)
  2317. {
  2318. }
  2319. }
  2320. }
  2321. writeGridDataTableJson(dStruct.TotalCount, dt);
  2322. }
  2323. public void get_erp_myreturnorderlist()
  2324. {
  2325. DataStruct dStruct = GetPostStruct();
  2326. List<string> lw = new List<string>();
  2327. string tid = GetPostString("ctid");
  2328. if (tid.Length > 0)
  2329. {
  2330. string select_tid = getTidByCtid(tid);
  2331. lw.Add(string.Format("tid='{0}'", select_tid));
  2332. }
  2333. else
  2334. {
  2335. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2336. }
  2337. string shopname = GetPostString("shopname");
  2338. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2339. string buyernick = GetPostString("buyer_nick");
  2340. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2341. string design = GetPostString("design");
  2342. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2343. string orderState = GetPostString("orderState");
  2344. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2345. string sellermemo = GetPostString("seller_memo");
  2346. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2347. string date1 = GetPostString("date1");
  2348. string date2 = GetPostString("date2");
  2349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2350. if (dw.Length > 0) lw.Add(dw);
  2351. string price1 = GetPostString("price1");
  2352. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2353. string price2 = GetPostString("price2");
  2354. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2355. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2356. {
  2357. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2358. }
  2359. else
  2360. {
  2361. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2362. }
  2363. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2364. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2365. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2366. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2367. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2368. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2369. if (dt != null && dt.Rows.Count > 0)
  2370. {
  2371. foreach (DataRow dr in dt.Rows)
  2372. {
  2373. try
  2374. {
  2375. // 对象操作
  2376. if (dStruct.PageSize != 100000)
  2377. {
  2378. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2379. dr["gongchuang"] = response.code;
  2380. }
  2381. }
  2382. catch (NullReferenceException ex)
  2383. {
  2384. // 处理空引用异常
  2385. }
  2386. }
  2387. }
  2388. writeGridDataTableJson(dStruct.TotalCount, dt);
  2389. }
  2390. public void get_erp_myorderlist_pregather()
  2391. {
  2392. string date1 = GetPostString("date1");
  2393. string date2 = GetPostString("date2");
  2394. int userId = CurrentUser.UserID; //客服id
  2395. string orderWhere = "";
  2396. List<string> lw = new List<string>();
  2397. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2398. if (dw.Length > 0) lw.Add(dw);
  2399. lw.Add(string.Format("CustomerUserId={0}", userId));
  2400. lw.Add(string.Format("OrderState<9"));
  2401. orderWhere = string.Join(" and ", lw.ToArray());
  2402. string orderWhere2 = "";
  2403. List<string> lw2 = new List<string>();
  2404. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2405. if (dw2.Length > 0) lw2.Add(dw2);
  2406. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2407. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2408. string sql = string.Format("select *" +
  2409. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2410. "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 " +
  2411. "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 " +
  2412. "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");
  2413. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2414. //writeGridDataTableJson(dt.Rows.Count, dt);
  2415. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2416. }
  2417. public void upd_erp_publishorder()
  2418. {
  2419. if (UrlPostParmsCheck("ctid"))
  2420. {
  2421. string eid = GetPostString("ctid");
  2422. CeErpTradeCell entity = null;
  2423. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2424. if (entity != null)
  2425. {
  2426. entity.OrderState = 0; //发布后,变为待抢单
  2427. entity.Update();
  2428. commonHelper.UpdateRelationOrder(entity.ctid);
  2429. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2430. returnSuccessMsg("发布成功!");
  2431. return;
  2432. }
  2433. returnErrorMsg("找不到记录");
  2434. }
  2435. }
  2436. public void get_erp_my_tiporder()
  2437. {
  2438. StringBuilder sql = new StringBuilder();
  2439. int userId = 0;
  2440. if (CurrentUser != null) userId = CurrentUser.UserID;
  2441. string posCode = CurrentUser.UserPost.Post.Code;
  2442. string isTipedAfterSaleVerify = GetPostString("af");
  2443. DataTable dt = new DataTable();
  2444. if (posCode != "Supplier")
  2445. {
  2446. if (posCode == "CustomerService" || posCode == "Director")
  2447. {
  2448. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2449. }
  2450. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2451. {
  2452. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2453. }
  2454. else
  2455. {
  2456. string teamIds = CurrentUser.User.TeamIds;
  2457. if (teamIds == "")
  2458. {
  2459. teamIds = "0";
  2460. }
  2461. 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);
  2462. }
  2463. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2464. }
  2465. if (dt.Rows.Count <= 0)
  2466. {
  2467. string key = "aftersale_order_" + userId;
  2468. if (RedisHelper.HasKey(key))
  2469. {
  2470. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2471. dt.Columns.Add("ctid", typeof(string));
  2472. dt.Columns.Add("IsReadTag", typeof(int));
  2473. foreach (var i in list)
  2474. {
  2475. DataRow data = dt.NewRow();
  2476. data["ctid"] = i;
  2477. data["IsReadTag"] = 4;
  2478. dt.Rows.Add(data);
  2479. }
  2480. RedisHelper.StringDelete(key);
  2481. }
  2482. }
  2483. if (dt.Rows.Count <= 0)
  2484. {
  2485. sql = new StringBuilder();
  2486. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2487. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2488. }
  2489. if (posCode == "Supplier")
  2490. {
  2491. string ids = CurrentUser.User.pemVend;
  2492. if (ids != null && ids.Length > 0)
  2493. {
  2494. string[] ids_list = ids.Split(',');
  2495. foreach (var item in ids_list)
  2496. {
  2497. string key = "return_order_" + item;
  2498. if (RedisHelper.HasKey(key))
  2499. {
  2500. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2501. dt.Columns.Add("ctid", typeof(string));
  2502. dt.Columns.Add("IsReadTag", typeof(int));
  2503. foreach (var i in list)
  2504. {
  2505. DataRow data = dt.NewRow();
  2506. data["ctid"] = i;
  2507. data["IsReadTag"] = 1;
  2508. dt.Rows.Add(data);
  2509. }
  2510. RedisHelper.StringDelete(key);
  2511. }
  2512. }
  2513. }
  2514. if (dt.Rows.Count <= 0)
  2515. {
  2516. sql = new StringBuilder();
  2517. 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);
  2518. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2519. }
  2520. }
  2521. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2522. }
  2523. public void reset_erp_tiporder()
  2524. {
  2525. string ids = GetPostString("ids");
  2526. string[] ctidList = ids.Split(',');
  2527. foreach (string ctid in ctidList)
  2528. {
  2529. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2530. if (enty != null)
  2531. {
  2532. enty.IsReadTag = 0;
  2533. enty.Update();
  2534. }
  2535. }
  2536. returnSuccessMsg("成功!");
  2537. return;
  2538. }
  2539. public void get_erp_designlist()
  2540. {
  2541. DataStruct dStruct = GetPostStruct();
  2542. List<string> lw = new List<string>();
  2543. string tid = GetPostString("ctid");
  2544. if (tid.Length > 0)
  2545. {
  2546. string select_tid = getTidByCtid(tid);
  2547. lw.Add(string.Format("tid='{0}'", select_tid));
  2548. }
  2549. string shopname = GetPostString("shopname");
  2550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2551. string buyernick = GetPostString("buyer_nick");
  2552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2553. string customer = GetPostString("customer");
  2554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2555. string design = GetPostString("design");
  2556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2557. string orderState = GetPostString("orderState");
  2558. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2559. lw.Add(string.Format("OrderState<6"));
  2560. string address = GetPostString("address");
  2561. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2562. string sellermemo = GetPostString("seller_memo");
  2563. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2564. string date1 = GetPostString("date1");
  2565. string date2 = GetPostString("date2");
  2566. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2567. if (dw.Length > 0) lw.Add(dw);
  2568. string apdate1 = GetPostString("apdate1");
  2569. string apdate2 = GetPostString("apdate2");
  2570. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2571. if (dwap.Length > 0) lw.Add(dwap);
  2572. string price1 = GetPostString("price1");
  2573. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2574. string price2 = GetPostString("price2");
  2575. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2576. string designTime = GetPostString("designtime");
  2577. if (designTime.Length > 0)
  2578. {
  2579. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2580. }
  2581. string usershop = CurrentUser.User.pemShop;
  2582. if (usershop.Length > 0)
  2583. {
  2584. lw.Add(string.Format("shopId in ({0})", usershop));
  2585. }
  2586. int myOrgid = CurrentUser.UserPost.OrgID;
  2587. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2588. if (myOrgCode.IndexOf("Designer") != -1)
  2589. {
  2590. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2591. {
  2592. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2593. }
  2594. else
  2595. {
  2596. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2597. }
  2598. }
  2599. else
  2600. {
  2601. string orgId = GetPostString("designerhd");
  2602. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2603. }
  2604. if (tid.Length > 0 || buyernick.Length > 0)
  2605. {
  2606. lw.Add(string.Format("OrderState >= 3"));
  2607. }
  2608. else
  2609. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2610. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2611. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2612. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2613. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2614. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2615. if (dt != null && dt.Rows.Count > 0)
  2616. {
  2617. foreach (DataRow dr in dt.Rows)
  2618. {
  2619. try
  2620. {
  2621. // 对象操作
  2622. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2623. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2624. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2625. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2626. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2627. if (dStruct.PageSize != 100000)
  2628. {
  2629. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2630. dr["gongchuang"] = response.code;
  2631. }
  2632. }
  2633. catch (NullReferenceException ex)
  2634. {
  2635. }
  2636. }
  2637. }
  2638. writeGridDataTableJson(dStruct.TotalCount, dt);
  2639. }
  2640. public void get_erp_mydesignlist()
  2641. {
  2642. DataStruct dStruct = GetPostStruct();
  2643. List<string> lw = new List<string>();
  2644. string tid = GetPostString("ctid");
  2645. if (tid.Length > 0)
  2646. {
  2647. string select_tid = getTidByCtid(tid);
  2648. lw.Add(string.Format("tid='{0}'", select_tid));
  2649. }
  2650. string shopname = GetPostString("shopname");
  2651. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2652. string buyernick = GetPostString("buyer_nick");
  2653. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2654. string customer = GetPostString("customer");
  2655. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2656. string orderState = GetPostString("orderState");
  2657. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2658. //lw.Add(string.Format("OrderState<6"));
  2659. string date1 = GetPostString("date1");
  2660. string date2 = GetPostString("date2");
  2661. string dw = GetDateWhere("pay_time", date1, date2);
  2662. if (dw.Length > 0) lw.Add(dw);
  2663. string apdate1 = GetPostString("apdate1");
  2664. string apdate2 = GetPostString("apdate2");
  2665. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2666. if (dwap.Length > 0) lw.Add(dwap);
  2667. string price1 = GetPostString("price1");
  2668. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2669. string price2 = GetPostString("price2");
  2670. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2671. string olddownload = GetPostString("olddown");
  2672. if (olddownload == "1")
  2673. {
  2674. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2675. }
  2676. else if (olddownload == "2")
  2677. {
  2678. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2679. }
  2680. string sellermemo = GetPostString("seller_memo");
  2681. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2682. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2683. if (CurrentUser.User.TeamIds.Length > 0)
  2684. {
  2685. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2686. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2687. else
  2688. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2689. }
  2690. else
  2691. {
  2692. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2693. }
  2694. if (tid.Length <= 0)
  2695. {
  2696. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2697. }
  2698. lw.Add(string.Format("IsReturn!=3"));
  2699. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2700. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2701. string teamids = CurrentUser.User.TeamIds.ToString();
  2702. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2703. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2704. if (dt != null && dt.Rows.Count > 0)
  2705. {
  2706. foreach (DataRow dr in dt.Rows)
  2707. {
  2708. try
  2709. {
  2710. // 对象操作
  2711. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2712. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2713. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2714. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2715. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2716. if (dStruct.PageSize != 100000)
  2717. {
  2718. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2719. dr["gongchuang"] = response.code;
  2720. }
  2721. }
  2722. catch (NullReferenceException ex)
  2723. {
  2724. }
  2725. }
  2726. }
  2727. writeGridDataTableJson(dStruct.TotalCount, dt);
  2728. }
  2729. public void set_erp_startdesign()
  2730. {
  2731. if (UrlPostParmsCheck("ctid"))
  2732. {
  2733. string eid = GetPostString("ctid");
  2734. CeErpTradeCell entity = null;
  2735. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2736. if (entity != null)
  2737. {
  2738. if (entity.OrderState != 3)
  2739. {
  2740. returnErrorMsg("请刷新,订单已经设计了");
  2741. return;
  2742. }
  2743. entity.StartDesignTime = DateTime.Now;
  2744. entity.OrderState = 4;
  2745. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2746. {
  2747. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2748. entity.SupplierId = suid;
  2749. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2750. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2751. }
  2752. entity.UpdateTime = DateTime.Now;
  2753. //entity.MakeSupplier = suname;
  2754. entity.Update();
  2755. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2756. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2757. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2758. commonHelper.getCytPrice(entity);
  2759. returnSuccessMsg("操作成功!");
  2760. return;
  2761. }
  2762. returnErrorMsg("找不到记录");
  2763. }
  2764. }
  2765. public void ins_erp_designselfmemo()
  2766. {
  2767. if (UrlPostParmsCheck("ctid"))
  2768. {
  2769. string eid = GetPostString("ctid");
  2770. string con = GetPostString("con");
  2771. CeErpTradeCell entity = null;
  2772. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2773. if (entity != null)
  2774. {
  2775. entity.DesignSelfMemo = con;
  2776. entity.Update();
  2777. returnSuccessMsg("操作成功!");
  2778. return;
  2779. }
  2780. returnErrorMsg("找不到记录");
  2781. }
  2782. }
  2783. public void ins_erp_designprice()
  2784. {
  2785. if (UrlPostParmsCheck("ctid"))
  2786. {
  2787. string eid = GetPostString("ctid");
  2788. int uid = CurrentUser.UserID;
  2789. string userName = CurrentUser.UserName;
  2790. CeErpTradeCell entity = null;
  2791. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2792. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2793. if (entitys == null)
  2794. {
  2795. entitys = new CeErpDesignerBill();
  2796. }
  2797. if (entity != null)
  2798. {
  2799. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2800. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2801. entity.StartDesignTime = DateTime.Now;
  2802. entity.OrderState = 4;
  2803. string suname = "";
  2804. if (entity.SupplierId == 0)
  2805. {
  2806. int sid = commonHelper.autoDistributeToSupplier(entity);
  2807. entity.SupplierId = sid;
  2808. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2809. }
  2810. entity.Update();
  2811. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2812. if (ceErpUserPost != null)
  2813. {
  2814. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2815. if (ceErpPost != null)
  2816. {
  2817. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2818. {
  2819. entitys.tid = entity.ctid;
  2820. entitys.oid = entity.tid;
  2821. entitys.uid = uid;
  2822. entitys.userName = userName;
  2823. entitys.designerType = 1;
  2824. entitys.designerTypeText = "内部设计师";
  2825. entitys.price = Convert.ToDouble(GetPostString("price"));
  2826. entitys.designNum = GetPostInt("designNum");
  2827. entitys.modifyNum = GetPostInt("modifyNum");
  2828. entitys.designSize = GetPostString("designSize");
  2829. entitys.modifySize = GetPostString("modifySize");
  2830. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2831. {
  2832. entitys.create_time = DateTime.Now;
  2833. entitys.create_u_id = uid;
  2834. entitys.create_u_name = userName;
  2835. entitys.Save();
  2836. }
  2837. else
  2838. {
  2839. entitys.update_time = DateTime.Now;
  2840. entitys.update_u_id = uid;
  2841. entitys.update_u_name = userName;
  2842. entitys.Update();
  2843. }
  2844. }
  2845. }
  2846. }
  2847. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2848. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2849. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2850. if (suname != "")
  2851. {
  2852. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2853. }
  2854. commonHelper.getCytPrice(entity);
  2855. returnSuccessMsg("操作成功!");
  2856. return;
  2857. }
  2858. returnErrorMsg("找不到记录");
  2859. }
  2860. }
  2861. public void upload_erp_filecomplete()
  2862. {
  2863. if (UrlPostParmsCheck("ctid"))
  2864. {
  2865. string eid = GetPostString("ctid");
  2866. CeErpTradeCell entity = null;
  2867. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2868. if (entity != null)
  2869. {
  2870. entity.OrderState = 5; //设计完成
  2871. entity.Update();
  2872. returnSuccessMsg(eid + "上传成功,设计完成!");
  2873. return;
  2874. }
  2875. returnErrorMsg("找不到订单记录");
  2876. }
  2877. }
  2878. public void get_erp_designovertimelist()
  2879. {
  2880. DataStruct dStruct = GetPostStruct();
  2881. List<string> lw = new List<string>();
  2882. string tid = GetPostString("ctid");
  2883. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2884. string shopname = GetPostString("shopname");
  2885. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2886. string buyernick = GetPostString("buyer_nick");
  2887. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2888. string ResponsibleMan = GetPostString("responsible");
  2889. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2890. string date1 = GetPostString("date1");
  2891. string date2 = GetPostString("date2");
  2892. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2893. if (dw.Length > 0) lw.Add(dw);
  2894. string price1 = GetPostString("price1");
  2895. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2896. string price2 = GetPostString("price2");
  2897. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2898. string orderState = GetPostString("orderState");
  2899. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2900. string sellermemo = GetPostString("seller_memo");
  2901. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2902. lw.Add(string.Format("UnusualTag=3"));
  2903. lw.Add(string.Format("IsRefund<={0}", 1));
  2904. dStruct.Order = "WaitDesignTime desc";
  2905. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2906. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2907. writeGridDataTableJson(dStruct.TotalCount, dt);
  2908. }
  2909. //设计管理 获取抢单大厅列表
  2910. public void get_erp_grabinglist()
  2911. {
  2912. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2913. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2914. bool oldOrder = false;
  2915. if (org != null)
  2916. {
  2917. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2918. }
  2919. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2920. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2921. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2922. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2923. //先处理订单数据
  2924. if (dt.Rows.Count > 0)
  2925. {
  2926. Dictionary<string, int> design = null;
  2927. int count = 0;
  2928. foreach (DataRow row in dt.Rows)
  2929. {
  2930. if (map.ContainsKey(row["ShopId"].ToString()))
  2931. {
  2932. map.TryGetValue(row["ShopId"].ToString(), out design);
  2933. }
  2934. else
  2935. {
  2936. design = new Dictionary<string, int>();
  2937. }
  2938. if (design.ContainsKey(row["ProductId"].ToString()))
  2939. {
  2940. design.TryGetValue(row["ProductId"].ToString(), out count);
  2941. }
  2942. count++;
  2943. design[row["ProductId"].ToString()] = count;
  2944. map[row["ShopId"].ToString()] = design;
  2945. }
  2946. }
  2947. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2948. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2949. //把店铺排序和技能排序分类
  2950. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2951. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2952. if (design_dt.Rows.Count > 0)
  2953. {
  2954. Dictionary<string, string> design = null;
  2955. List<string> shopIds = null;
  2956. foreach (DataRow row in design_dt.Rows)
  2957. {
  2958. if ("0".Equals(row["designId"].ToString()))
  2959. {
  2960. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2961. {
  2962. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2963. }
  2964. else
  2965. {
  2966. shopIds = new List<string>();
  2967. }
  2968. shopIds.Add(row["shopId"].ToString());
  2969. shop_orders[row["orders"].ToString()] = shopIds;
  2970. }
  2971. else
  2972. {
  2973. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2974. {
  2975. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2976. }
  2977. else
  2978. {
  2979. design = new Dictionary<string, string>();
  2980. }
  2981. design[row["orders"].ToString()] = row["designId"].ToString();
  2982. design_orders[row["shopId"].ToString()] = design;
  2983. }
  2984. }
  2985. //处理成key value后根据key排序
  2986. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2987. foreach (List<string> val in shop_orders.Values)
  2988. {
  2989. if (val != null)
  2990. {
  2991. foreach (string key in val)
  2992. {
  2993. if (design_orders.ContainsKey(key.ToString()))
  2994. {
  2995. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2996. }
  2997. }
  2998. }
  2999. }
  3000. }
  3001. //校验哪个优先级有订单
  3002. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3003. foreach (string key in shop_orders.Keys)
  3004. {
  3005. List<string> ids = null;
  3006. shop_orders.TryGetValue(key, out ids);
  3007. //id为shopid
  3008. foreach (string id in ids)
  3009. {
  3010. Dictionary<string, int> list = null;
  3011. Dictionary<string, string> desing = null;
  3012. map.TryGetValue(id, out list);
  3013. design_orders.TryGetValue(id, out desing);
  3014. if (list != null && desing != null)
  3015. {
  3016. foreach (var item in desing)
  3017. {
  3018. int count = 0;
  3019. if (list.ContainsKey(item.Value))
  3020. {
  3021. list.TryGetValue(item.Value, out count);
  3022. if (count > 0)
  3023. {
  3024. designIds[id] = item.Value;
  3025. break;
  3026. }
  3027. }
  3028. }
  3029. }
  3030. }
  3031. if (designIds.Count > 0)
  3032. {
  3033. break;
  3034. }
  3035. }
  3036. DataTable table = new DataTable();
  3037. table.Columns.Add("tid", typeof(string));
  3038. table.Columns.Add("ctid", typeof(string));
  3039. table.Columns.Add("seller_nick", typeof(string));
  3040. table.Columns.Add("productName", typeof(string));
  3041. table.Columns.Add("pay_time", typeof(string));
  3042. table.Columns.Add("seller_memo", typeof(string));
  3043. if (designIds.Count > 0)
  3044. {
  3045. string shopId = "";
  3046. string productId = "";
  3047. foreach (var designInfo in designIds)
  3048. {
  3049. shopId = designInfo.Key;
  3050. productId = designInfo.Value;
  3051. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3052. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3053. if (dt.Rows.Count > 0)
  3054. {
  3055. foreach (DataRow row in dt.Rows)
  3056. {
  3057. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3058. {
  3059. DataRow data = table.NewRow();
  3060. data["ctid"] = row["ctid"].ToString();
  3061. data["tid"] = row["tid"].ToString();
  3062. data["seller_nick"] = ceErpShop.ShopName;
  3063. data["pay_time"] = row["pay_time"].ToString();
  3064. data["seller_memo"] = row["seller_memo"].ToString();
  3065. data["productName"] = ceErpProduct.PType;
  3066. table.Rows.Add(data);
  3067. }
  3068. }
  3069. }
  3070. }
  3071. }
  3072. writeGridDataTableJson(table.Rows.Count, table);
  3073. }
  3074. private object rushLockObject = new object();
  3075. public void set_erp_grabingorder()
  3076. {
  3077. if (UrlPostParmsCheck("ctid"))
  3078. {
  3079. int total = CurrentUser.User.Person.Total;
  3080. int userId = CurrentUser.User.ID;
  3081. int noFinish = CurrentUser.User.Person.NoFinish;
  3082. int finalization = CurrentUser.User.Person.Finalization;
  3083. string eids = GetPostString("ctid");
  3084. string key = "RushKey_" + userId;
  3085. int count = 0;
  3086. if (erpRedis.RedisHelper.KeyExists(key))
  3087. {
  3088. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3089. if (redisCount != null)
  3090. {
  3091. count = Convert.ToInt32(redisCount);
  3092. }
  3093. }
  3094. if (count >= total)
  3095. {
  3096. returnErrorMsg("半小时内已经抢" + total + "单");
  3097. return;
  3098. }
  3099. string[] ctidlist = eids.Split(',');
  3100. if (count + ctidlist.Length > total)
  3101. {
  3102. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3103. return;
  3104. }
  3105. int itag = 0;
  3106. lock (rushLockObject)
  3107. {
  3108. if (ctidlist.Length > 0)
  3109. {
  3110. string[] dtList = new string[ctidlist.Length];
  3111. for (int i = 0; i < ctidlist.Length; i++)
  3112. {
  3113. dtList[i] = "'" + ctidlist[i] + "'";
  3114. }
  3115. 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"));
  3116. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3117. if (dt_user.Rows.Count > 0)
  3118. {
  3119. int doing = 0;//未定稿
  3120. int finish = 0;//已完成
  3121. foreach (DataRow dr in dt_user.Rows)
  3122. {
  3123. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3124. {
  3125. doing++;
  3126. }
  3127. else
  3128. {
  3129. finish++;
  3130. }
  3131. }
  3132. if (doing >= noFinish)
  3133. {
  3134. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3135. return;
  3136. }
  3137. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3138. {
  3139. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3140. return;
  3141. }
  3142. }
  3143. //校验选择单子状态
  3144. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3145. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3146. if (dt.Rows.Count > 0)
  3147. {
  3148. List<string> list = new List<string>();
  3149. foreach (DataRow dr in dt.Rows)
  3150. {
  3151. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3152. {
  3153. list.Add(dr["ctid"].ToString());
  3154. }
  3155. }
  3156. if (list.Count > 0)
  3157. {
  3158. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3159. return;
  3160. }
  3161. }
  3162. foreach (string ctid in ctidlist)
  3163. {
  3164. CeErpTradeCell entity = null;
  3165. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3166. if (entity != null)
  3167. {
  3168. entity.OrderState = 3;
  3169. entity.DesignUserId = CurrentUser.UserID;
  3170. entity.WaitDesignTime = DateTime.Now;
  3171. entity.StartDesignTime = DateTime.Now;
  3172. entity.Update();
  3173. commonHelper.UpdateRelationOrder(entity.ctid);
  3174. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3175. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3176. itag++;
  3177. }
  3178. }
  3179. }
  3180. }
  3181. count += ctidlist.Length;
  3182. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3183. if (itag == 0)
  3184. returnErrorMsg("没有找到相关订单");
  3185. else
  3186. returnSuccessMsg("抢单成功!");
  3187. return;
  3188. }
  3189. }
  3190. public void get_erp_waitorderlist()
  3191. {
  3192. DataStruct dStruct = GetPostStruct();
  3193. List<string> lw = new List<string>();
  3194. string tid = GetPostString("ctid");
  3195. if (tid.Length > 0)
  3196. {
  3197. string select_tid = getTidByCtid(tid);
  3198. lw.Add(string.Format("tid='{0}'", select_tid));
  3199. }
  3200. string shopname = GetPostString("shopname");
  3201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3202. string buyernick = GetPostString("buyer_nick");
  3203. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3204. string customer = GetPostString("customer");
  3205. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3206. string design = GetPostString("design");
  3207. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3208. string orderState = GetPostString("orderState");
  3209. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3210. string supplier = GetPostString("supplier");
  3211. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3212. string sellermemo = GetPostString("seller_memo");
  3213. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3214. string otherMemo = GetPostString("otherMemo");
  3215. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3216. string address = GetPostString("address");
  3217. 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));
  3218. string date1 = GetPostString("date1");
  3219. string date2 = GetPostString("date2");
  3220. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3221. if (dw.Length > 0) lw.Add(dw);
  3222. string price1 = GetPostString("price1");
  3223. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3224. string price2 = GetPostString("price2");
  3225. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3226. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3227. lw.Add(string.Format("IsSample != 2 "));
  3228. lw.Add(string.Format("OrderState = 5 "));
  3229. lw.Add(string.Format("IsRefund<={0}", 1));
  3230. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3231. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3232. string pagesize = GetPostString("pagesize");
  3233. if (pagesize != null)
  3234. {
  3235. dStruct.PageSize = 200;
  3236. }
  3237. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3238. if (dt != null)
  3239. {
  3240. foreach (DataRow dr in dt.Rows)
  3241. {
  3242. 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();
  3243. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3244. {
  3245. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3246. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3247. entity.SupplierId = suid;
  3248. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3249. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3250. entity.Update();
  3251. }
  3252. }
  3253. }
  3254. writeGridDataTableJson(dStruct.TotalCount, dt);
  3255. }
  3256. public void get_erp_supplierwaitorderlist()
  3257. {
  3258. DataStruct dStruct = GetPostStruct();
  3259. List<string> lw = new List<string>();
  3260. string tid = GetPostString("ctid");
  3261. if (tid.Length > 0)
  3262. {
  3263. string select_tid = getTidByCtid(tid);
  3264. lw.Add(string.Format("tid='{0}'", select_tid));
  3265. }
  3266. string shopname = GetPostString("shopname");
  3267. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3268. string sellermemo = GetPostString("seller_memo");
  3269. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3270. string date1 = GetPostString("date1");
  3271. string date2 = GetPostString("date2");
  3272. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3273. if (dw.Length > 0) lw.Add(dw);
  3274. lw.Add(string.Format("OrderState = 5 "));
  3275. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3276. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3277. {
  3278. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3279. }
  3280. string supplier = GetPostString("supplier");
  3281. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3282. {
  3283. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3284. }
  3285. lw.Add(string.Format("IsRefund<={0}", 1));
  3286. dStruct.Order = "FinishDesignTime desc";
  3287. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3288. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3289. if (dt != null)
  3290. {
  3291. foreach (DataRow dr in dt.Rows)
  3292. {
  3293. 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();
  3294. }
  3295. }
  3296. writeGridDataTableJson(dStruct.TotalCount, dt);
  3297. }
  3298. public void upd_erp_verifytosupplier()
  3299. {
  3300. if (UrlPostParmsCheck("ctid"))
  3301. {
  3302. string eids = GetPostString("ctid");
  3303. CeErpTradeCell entity = null;
  3304. string[] eidsList = eids.Split(',');
  3305. if (eidsList.Length <= 0)
  3306. {
  3307. returnErrorMsg("订单号不能空");
  3308. return;
  3309. }
  3310. List<string> tLst = new List<string>();
  3311. foreach (string ctidstr in eidsList)
  3312. {
  3313. tLst.Add("'" + ctidstr + "'");
  3314. CeErpDataSendOrderInfo.createObject(ctidstr);
  3315. }
  3316. string needtids = string.Join(",", tLst.ToArray());
  3317. StringBuilder sql = new StringBuilder();
  3318. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3319. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3320. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3321. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3322. returnSuccessMsg("操作成功!");
  3323. return;
  3324. /**foreach (string ctidstr in eidsList)
  3325. {
  3326. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3327. if (entity != null)
  3328. {
  3329. if (entity.SupplierId == 0)
  3330. {
  3331. continue;
  3332. }
  3333. entity.IsVerifyToSupplier = true;
  3334. if (entity.IsReturn == 1) //1是供应商打回
  3335. {
  3336. entity.IsReturn = 0;
  3337. }
  3338. entity.FinishPlaceTime = DateTime.Now;
  3339. entity.PlaceUserId = CurrentUser.UserID;
  3340. entity.Update();
  3341. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3342. }
  3343. }
  3344. returnSuccessMsg("操作成功!");
  3345. return;**/
  3346. }
  3347. }
  3348. public void upd_erp_supplierback()
  3349. {
  3350. if (UrlPostParmsCheck("ctid"))
  3351. {
  3352. string eid = GetPostString("ctid");
  3353. string reason = GetPostString("returnreason");
  3354. CeErpTradeCell entity = null;
  3355. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3356. if (entity != null)
  3357. {
  3358. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3359. {
  3360. string key = "return_order_" + entity.SupplierId;
  3361. List<string> list = new List<string>();
  3362. if (RedisHelper.HasKey(key))
  3363. {
  3364. object data = RedisHelper.StringGet(key);
  3365. list = Convert.ToString(data).Split(',').ToList();
  3366. }
  3367. list.Add(eid);
  3368. RedisHelper.StringSet(key, string.Join(",", list));
  3369. }
  3370. entity.IsVerifyToSupplier = false;
  3371. entity.IsReturn = 1;
  3372. entity.ReturnTime = DateTime.Now;
  3373. entity.ReturnReason = reason;
  3374. if (entity.OrderState == 6)
  3375. {
  3376. entity.OrderState = 5;
  3377. }
  3378. entity.Update();
  3379. CeErpSukuraData.createInfo(entity.ctid, 5);
  3380. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3381. returnSuccessMsg("操作成功!");
  3382. return;
  3383. }
  3384. returnErrorMsg("找不到订单记录");
  3385. }
  3386. }
  3387. public void upd_erp_toaftersaleorder()
  3388. {
  3389. if (UrlPostParmsCheck("ctid"))
  3390. {
  3391. string eid = GetPostString("ctid");
  3392. string reason = GetPostString("returnreason");
  3393. CeErpTradeCell entity = null;
  3394. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3395. if (entity != null)
  3396. {
  3397. if (entity.isAfterSaleOrder != 1)
  3398. {
  3399. returnErrorMsg("带S的售后单才能打回给售后");
  3400. return;
  3401. }
  3402. if (entity.OrderState >= 5)
  3403. {
  3404. returnErrorMsg("已经设计完成了不能打回给售后");
  3405. return;
  3406. }
  3407. entity.OrderState = 0;
  3408. entity.IsReturn = 3;
  3409. entity.ReturnTime = DateTime.Now;
  3410. entity.UpdateTime = DateTime.Now;
  3411. entity.ReturnReason = reason;
  3412. entity.Update();
  3413. CeErpSukuraData.createInfo(entity.ctid, 5);
  3414. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3415. returnSuccessMsg("操作成功!");
  3416. return;
  3417. }
  3418. returnErrorMsg("找不到订单记录");
  3419. }
  3420. }
  3421. public void upd_erp_aftersaletodesign()
  3422. {
  3423. if (UrlPostParmsCheck("ctid"))
  3424. {
  3425. string eid = GetPostString("ctid");
  3426. CeErpTradeCell entity = null;
  3427. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3428. if (entity != null)
  3429. {
  3430. entity.OrderState = 3;
  3431. entity.IsReturn = 0;
  3432. entity.UpdateTime = DateTime.Now;
  3433. entity.Update();
  3434. CeErpSukuraData.createInfo(entity.ctid, 5);
  3435. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3436. returnSuccessMsg("操作成功!");
  3437. return;
  3438. }
  3439. returnErrorMsg("找不到订单记录");
  3440. }
  3441. }
  3442. public void assign_erp_supplier()
  3443. {
  3444. if (UrlPostParmsCheck("ctid"))
  3445. {
  3446. string eids = GetPostString("ctid");
  3447. int sid = GetPostInt("SupplierName");
  3448. string fromTag = GetPostString("tag");
  3449. string[] eidList = eids.Split(',');
  3450. if (eidList.Length <= 0)
  3451. {
  3452. returnErrorMsg("指派不能为空");
  3453. return;
  3454. }
  3455. string errMsg = "";
  3456. string suname = commonHelper.getSupplierNameById(sid);
  3457. foreach (string ctid in eidList)
  3458. {
  3459. CeErpTradeCell entity = null;
  3460. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3461. if (entity != null)
  3462. {
  3463. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3464. {
  3465. errMsg += (ctid + "指派失败!!!");
  3466. continue;
  3467. }
  3468. entity.SupplierId = sid;
  3469. entity.Update();
  3470. commonHelper.UpdateRelationOrder(entity.ctid);
  3471. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3472. if (entity.OrderState >= 6)
  3473. {
  3474. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3475. //{
  3476. // string msl = entity.MakeSupplier;
  3477. // string[] mslist = msl.Split(',');
  3478. // 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);
  3479. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3480. //}
  3481. //else
  3482. //{
  3483. StringBuilder sql = new StringBuilder();
  3484. 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);
  3485. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3486. //}
  3487. }
  3488. }
  3489. else
  3490. {
  3491. continue;
  3492. }
  3493. }
  3494. if (errMsg.Length > 0)
  3495. {
  3496. returnErrorMsg(errMsg);
  3497. return;
  3498. }
  3499. returnSuccessMsg("操作成功!");
  3500. return;
  3501. }
  3502. }
  3503. public void assign_erp_makesupplier()
  3504. {
  3505. if (UrlPostParmsCheck("ctid"))
  3506. {
  3507. string eids = GetPostString("ctid");
  3508. string sname = GetPostString("SupplierName");
  3509. string[] eidList = eids.Split(',');
  3510. if (eidList.Length <= 0)
  3511. {
  3512. returnErrorMsg("指派不能为空");
  3513. return;
  3514. }
  3515. List<string> tLst = new List<string>();
  3516. foreach (string ctid in eidList)
  3517. {
  3518. CeErpTradeCell entity = null;
  3519. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3520. if (entity != null)
  3521. {
  3522. entity.MakeSupplier = sname;
  3523. entity.Update();
  3524. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3525. tLst.Add("'" + ctid + "'");
  3526. }
  3527. else
  3528. {
  3529. continue;
  3530. }
  3531. }
  3532. string ctids = string.Join(",", tLst.ToArray());
  3533. StringBuilder sql2 = new StringBuilder();
  3534. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3535. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3536. returnSuccessMsg("操作成功!");
  3537. return;
  3538. }
  3539. }
  3540. public void ins_erp_returnreason()
  3541. {
  3542. if (UrlPostParmsCheck("ctid"))
  3543. {
  3544. string eid = GetPostString("ctid");
  3545. CeErpTradeCell entity = null;
  3546. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3547. string userpost = CurrentUser.UserPost.Post.Code;
  3548. if (entity != null)
  3549. {
  3550. bool isPlace = false;
  3551. if (entity.OrderState > 6)
  3552. {
  3553. returnErrorMsg("已发货无法打回!");
  3554. return;
  3555. }
  3556. if (entity.OrderState == 6)
  3557. {
  3558. isPlace = true;
  3559. }
  3560. bool isNeedUpdateCell2 = false;
  3561. if (entity.OrderState >= 6)
  3562. {
  3563. isNeedUpdateCell2 = true;
  3564. }
  3565. int returnTag = 2;
  3566. if (userpost == "Supplier")
  3567. {
  3568. returnTag = 1;
  3569. }
  3570. int toType = GetPostInt("totype");
  3571. string fromType = "3";
  3572. if (entity.OrderState < 5)
  3573. {
  3574. fromType = "3";
  3575. }
  3576. else
  3577. {
  3578. fromType = "4";
  3579. }
  3580. if (entity.IsXianHuo == 0)
  3581. {
  3582. if (returnTag == 2)
  3583. {
  3584. if (toType == 1)
  3585. {
  3586. entity.OrderState = 0;
  3587. entity.ReturnUserType = 1;
  3588. string clearman = GetPostString("clearman");
  3589. if (!string.IsNullOrEmpty(clearman))
  3590. {
  3591. entity.DesignUserId = 0;
  3592. }
  3593. }
  3594. else
  3595. {
  3596. entity.OrderState = 3;
  3597. entity.ReturnUserType = 2;
  3598. }
  3599. entity.IsReadTag = 1;
  3600. }
  3601. else if (returnTag == 1)
  3602. {
  3603. entity.OrderState = 5;
  3604. }
  3605. entity.IsVerifyToSupplier = false;
  3606. }
  3607. if (entity.IsXianHuo == 1)
  3608. {
  3609. entity.OrderState = 5;
  3610. }
  3611. entity.UnusualTag = 0;
  3612. entity.UnusualTime = null;
  3613. entity.UnusualCon = "";
  3614. entity.IsReturn = returnTag;
  3615. entity.ReturnTime = DateTime.Now;
  3616. entity.UpdateTime = DateTime.Now;
  3617. entity.ReturnReason = GetPostString("returnreason");
  3618. entity.Update();
  3619. if (entity.OrderState == 3)
  3620. {
  3621. ApiVo apiVo = new ApiVo();
  3622. apiVo.orderNumber = entity.ctid;
  3623. apiVo.actionName = "rebutDesign";
  3624. apiVo.orderRemarks = entity.ReturnReason;
  3625. designHelper.API_WorkCore(apiVo);//rebutDesign
  3626. }
  3627. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3628. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3629. {
  3630. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3631. }
  3632. CeErpSukuraData.createInfo(entity.ctid, 5);
  3633. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3634. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3635. if (isPlace)
  3636. {
  3637. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3638. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3639. if (dth != null && dth.Rows.Count > 0)
  3640. {
  3641. dataSendOrderBean dataSendOrderBean = null;
  3642. foreach (DataRow item in dth.Rows)
  3643. {
  3644. try
  3645. {
  3646. dataSendOrderBean = new dataSendOrderBean();
  3647. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3648. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3649. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3650. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3651. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3652. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3653. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3654. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3655. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3656. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3657. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3658. dataSendOrderBean.Radio1723534706288 = "打回";
  3659. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3660. if (result != null)
  3661. {
  3662. if ("0".Equals(result.errcode))
  3663. {
  3664. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3665. }
  3666. else
  3667. {
  3668. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3669. }
  3670. }
  3671. }
  3672. catch (Exception ex)
  3673. {
  3674. }
  3675. }
  3676. }
  3677. }
  3678. if (isNeedUpdateCell2)
  3679. {
  3680. if (entity.MakeSupplier.IndexOf(",") != -1)
  3681. {
  3682. StringBuilder sql2 = new StringBuilder();
  3683. 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);
  3684. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3685. }
  3686. else
  3687. {
  3688. StringBuilder sql2 = new StringBuilder();
  3689. 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);
  3690. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3691. }
  3692. }
  3693. returnSuccessMsg("操作成功!");
  3694. return;
  3695. }
  3696. returnErrorMsg("找不到订单记录");
  3697. }
  3698. }
  3699. public void cyt_erp_returnreason()
  3700. {
  3701. if (UrlPostParmsCheck("ctid"))
  3702. {
  3703. string eid = GetPostString("ctid");
  3704. CeErpTradeCell entity = null;
  3705. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3706. string userpost = CurrentUser.UserPost.Post.Code;
  3707. if (entity != null)
  3708. {
  3709. if (entity.OrderState > 6)
  3710. {
  3711. returnErrorMsg("已发货无法打回!");
  3712. return;
  3713. }
  3714. JObject jsonObject = new JObject
  3715. {
  3716. { "Userid", "77886" },
  3717. { "Pwd", "lt666888" },
  3718. { "LTOrderId",eid }
  3719. };
  3720. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3721. JObject jsonObjects = JObject.Parse(response);
  3722. string msg = (string)jsonObjects["msg"];
  3723. if (msg != "取消成功")
  3724. {
  3725. returnErrorMsg(msg);
  3726. return;
  3727. }
  3728. bool isNeedUpdateCell2 = false;
  3729. if (entity.OrderState >= 6)
  3730. {
  3731. isNeedUpdateCell2 = true;
  3732. }
  3733. int returnTag = 2;
  3734. if (userpost == "Supplier")
  3735. {
  3736. returnTag = 1;
  3737. }
  3738. if (entity.IsXianHuo == 0)
  3739. {
  3740. if (returnTag == 2)
  3741. {
  3742. int toType = GetPostInt("totype");
  3743. if (toType == 1)
  3744. {
  3745. entity.OrderState = 0;
  3746. entity.ReturnUserType = 1;
  3747. }
  3748. else
  3749. {
  3750. entity.OrderState = 4;
  3751. entity.ReturnUserType = 2;
  3752. }
  3753. entity.IsReadTag = 1;
  3754. }
  3755. else if (returnTag == 1)
  3756. {
  3757. entity.OrderState = 5;
  3758. }
  3759. entity.IsVerifyToSupplier = false;
  3760. }
  3761. entity.UnusualTag = 0;
  3762. entity.UnusualTime = null;
  3763. entity.UnusualCon = "";
  3764. entity.IsReturn = returnTag;
  3765. entity.ReturnTime = DateTime.Now;
  3766. entity.ReturnReason = GetPostString("returnreason");
  3767. entity.Update();
  3768. if (entity.OrderState == 4)
  3769. {
  3770. ApiVo apiVo = new ApiVo();
  3771. apiVo.orderNumber = entity.ctid;
  3772. apiVo.actionName = "rebutDesign";
  3773. apiVo.orderRemarks = entity.ReturnReason;
  3774. designHelper.API_WorkCore(apiVo);//rebutDesign
  3775. }
  3776. CeErpSukuraData.createInfo(entity.ctid, 5);
  3777. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3778. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3779. if (isNeedUpdateCell2)
  3780. {
  3781. if (entity.MakeSupplier.IndexOf(",") != -1)
  3782. {
  3783. StringBuilder sql2 = new StringBuilder();
  3784. 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);
  3785. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3786. }
  3787. else
  3788. {
  3789. StringBuilder sql2 = new StringBuilder();
  3790. 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);
  3791. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3792. }
  3793. }
  3794. returnSuccessMsg("操作成功!");
  3795. return;
  3796. }
  3797. returnErrorMsg("找不到订单记录");
  3798. }
  3799. }
  3800. public void upd_erp_xianhuoreturntag()
  3801. {
  3802. if (UrlPostParmsCheck("ctid"))
  3803. {
  3804. string eids = GetPostString("ctid");
  3805. string[] ctids = eids.Split(',');
  3806. foreach (string ctid in ctids)
  3807. {
  3808. CeErpTradeCell entity = null;
  3809. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3810. if (entity != null)
  3811. {
  3812. entity.IsReturn = 0;
  3813. entity.Update();
  3814. CeErpSukuraData.createInfo(entity.ctid, 5);
  3815. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3816. }
  3817. }
  3818. returnSuccessMsg("操作成功!");
  3819. return;
  3820. }
  3821. }
  3822. public void get_erp_waitdeliverylist()
  3823. {
  3824. DataStruct dStruct = GetPostStruct();
  3825. List<string> lw = new List<string>();
  3826. string tid = GetPostString("ctid");
  3827. if (tid.Length > 0)
  3828. {
  3829. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3830. if (tid.Length > 5)
  3831. {
  3832. List<string> tids = getTidByCtidLike(tid);
  3833. if (tids.Count > 0 && tids.Count < 10)
  3834. {
  3835. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3836. }
  3837. }
  3838. lw.Add(tid_sql);
  3839. }
  3840. string shopname = GetPostString("shopname");
  3841. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3842. string buyernick = GetPostString("buyer_nick");
  3843. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3844. //if (tid.Length == 0 && buyernick.Length == 0)
  3845. //{
  3846. // lw.Add(string.Format("IsRefund<={0}", 1));
  3847. //}
  3848. string customer = GetPostString("customer");
  3849. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3850. string design = GetPostString("design");
  3851. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3852. string orderState = GetPostString("orderState");
  3853. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3854. string address = GetPostString("address");
  3855. 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));
  3856. string sellermemo = GetPostString("seller_memo");
  3857. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3858. string supplier = GetPostString("supplier");
  3859. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3860. string OrderArea = GetPostString("order_area");
  3861. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3862. string placedate1 = GetPostString("placedate1");
  3863. string placedate2 = GetPostString("placedate2");
  3864. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3865. if (fdw.Length > 0) lw.Add(fdw);
  3866. string price1 = GetPostString("price1");
  3867. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3868. string price2 = GetPostString("price2");
  3869. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3870. string unusualCon = GetPostString("unusualcon");
  3871. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3872. string otherMemo = GetPostString("otherMemo");
  3873. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3874. string posTag = CurrentUser.UserPost.Post.Code;
  3875. if (posTag == "Supplier")
  3876. {
  3877. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3878. }
  3879. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3880. lw.Add(string.Format("type != 'PDD' "));
  3881. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3882. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3883. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3884. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3885. writeGridDataTableJson(dStruct.TotalCount, dt);
  3886. }
  3887. public void get_erp_changedeliverylist()
  3888. {
  3889. DataStruct dStruct = GetPostStruct();
  3890. List<string> lw = new List<string>();
  3891. string tid = GetPostString("ctid");
  3892. if (tid.Length > 0)
  3893. {
  3894. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3895. if (tid.Length > 5)
  3896. {
  3897. List<string> tids = getTidByCtidLike(tid);
  3898. if (tids.Count > 0 && tids.Count < 10)
  3899. {
  3900. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3901. }
  3902. }
  3903. lw.Add(tid_sql);
  3904. }
  3905. string shopname = GetPostString("shopname");
  3906. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3907. string buyernick = GetPostString("buyer_nick");
  3908. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3909. //if (tid.Length == 0 && buyernick.Length == 0)
  3910. //{
  3911. // lw.Add(string.Format("IsRefund<={0}", 1));
  3912. //}
  3913. string customer = GetPostString("customer");
  3914. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3915. string design = GetPostString("design");
  3916. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3917. string orderState = GetPostString("orderState");
  3918. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3919. string address = GetPostString("address");
  3920. 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));
  3921. string sellermemo = GetPostString("seller_memo");
  3922. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3923. string supplier = GetPostString("supplier");
  3924. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3925. string OrderArea = GetPostString("order_area");
  3926. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3927. string placedate1 = GetPostString("placedate1");
  3928. string placedate2 = GetPostString("placedate2");
  3929. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3930. if (fdw.Length > 0) lw.Add(fdw);
  3931. string price1 = GetPostString("price1");
  3932. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3933. string price2 = GetPostString("price2");
  3934. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3935. string unusualCon = GetPostString("unusualcon");
  3936. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3937. string otherMemo = GetPostString("otherMemo");
  3938. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3939. string posTag = CurrentUser.UserPost.Post.Code;
  3940. if (posTag == "Supplier")
  3941. {
  3942. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3943. }
  3944. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3945. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3946. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3947. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3948. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3949. /*if (tid.Length > 0)
  3950. {
  3951. List<string> tids = new List<string>();
  3952. if (dt != null && dt.Rows.Count > 0)
  3953. {
  3954. foreach (DataRow item in dt.Rows)
  3955. {
  3956. tids.Add("'" + item["tid"] + "'");
  3957. }
  3958. }
  3959. if (tids.Count > 0)
  3960. {
  3961. lw.RemoveAt(0);
  3962. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3963. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3964. dt = WebCache.GetData("view_erptradecell", dStruct);
  3965. }
  3966. }*/
  3967. writeGridDataTableJson(dStruct.TotalCount, dt);
  3968. }
  3969. public void get_erp_pddderiving()
  3970. {
  3971. DataStruct dStruct = GetPostStruct();
  3972. List<string> lw = new List<string>();
  3973. string tid = GetPostString("ctid");
  3974. if (tid.Length > 0)
  3975. {
  3976. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3977. if (tid.Length > 5)
  3978. {
  3979. List<string> tids = getTidByCtidLike(tid);
  3980. if (tids.Count > 0 && tids.Count < 10)
  3981. {
  3982. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3983. }
  3984. }
  3985. lw.Add(tid_sql);
  3986. }
  3987. string shopname = GetPostString("shopname");
  3988. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3989. string buyernick = GetPostString("buyer_nick");
  3990. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3991. //if (tid.Length == 0 && buyernick.Length == 0)
  3992. //{
  3993. // lw.Add(string.Format("IsRefund<={0}", 1));
  3994. //}
  3995. string customer = GetPostString("customer");
  3996. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3997. string design = GetPostString("design");
  3998. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3999. string orderState = GetPostString("orderState");
  4000. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4001. string address = GetPostString("address");
  4002. 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));
  4003. string sellermemo = GetPostString("seller_memo");
  4004. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4005. string supplier = GetPostString("supplier");
  4006. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4007. string OrderArea = GetPostString("order_area");
  4008. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4009. string placedate1 = GetPostString("placedate1");
  4010. string placedate2 = GetPostString("placedate2");
  4011. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4012. if (fdw.Length > 0) lw.Add(fdw);
  4013. string price1 = GetPostString("price1");
  4014. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4015. string price2 = GetPostString("price2");
  4016. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4017. string unusualCon = GetPostString("unusualcon");
  4018. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4019. string posTag = CurrentUser.UserPost.Post.Code;
  4020. if (posTag == "Supplier")
  4021. {
  4022. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4023. }
  4024. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4025. lw.Add(string.Format("type = 'PDD' "));
  4026. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4027. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4028. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4029. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4030. /*if (tid.Length > 0)
  4031. {
  4032. List<string> tids = new List<string>();
  4033. if (dt != null && dt.Rows.Count > 0)
  4034. {
  4035. foreach (DataRow item in dt.Rows)
  4036. {
  4037. tids.Add("'" + item["tid"] + "'");
  4038. }
  4039. }
  4040. if (tids.Count > 0)
  4041. {
  4042. lw.RemoveAt(0);
  4043. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4044. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4045. dt = WebCache.GetData("view_erptradecell", dStruct);
  4046. }
  4047. }*/
  4048. writeGridDataTableJson(dStruct.TotalCount, dt);
  4049. }
  4050. public void get_erp_jdderiving()
  4051. {
  4052. DataStruct dStruct = GetPostStruct();
  4053. List<string> lw = new List<string>();
  4054. string tid = GetPostString("ctid");
  4055. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4056. string shopname = GetPostString("shopname");
  4057. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4058. string buyernick = GetPostString("buyer_nick");
  4059. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4060. //if (tid.Length == 0 && buyernick.Length == 0)
  4061. //{
  4062. // lw.Add(string.Format("IsRefund<={0}", 1));
  4063. //}
  4064. string customer = GetPostString("customer");
  4065. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4066. string design = GetPostString("design");
  4067. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4068. string orderState = GetPostString("orderState");
  4069. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4070. string address = GetPostString("address");
  4071. 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));
  4072. string sellermemo = GetPostString("seller_memo");
  4073. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4074. string supplier = GetPostString("supplier");
  4075. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4076. string OrderArea = GetPostString("order_area");
  4077. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4078. string placedate1 = GetPostString("placedate1");
  4079. string placedate2 = GetPostString("placedate2");
  4080. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4081. if (fdw.Length > 0) lw.Add(fdw);
  4082. string price1 = GetPostString("price1");
  4083. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4084. string price2 = GetPostString("price2");
  4085. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4086. string unusualCon = GetPostString("unusualcon");
  4087. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4088. string posTag = CurrentUser.UserPost.Post.Code;
  4089. if (posTag == "Supplier")
  4090. {
  4091. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4092. }
  4093. lw.Add(string.Format("OrderState = 6 "));
  4094. lw.Add(string.Format("type = 'JD' "));
  4095. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4096. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4097. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4098. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4099. writeGridDataTableJson(dStruct.TotalCount, dt);
  4100. }
  4101. public void get_erp_demoorderlist()
  4102. {
  4103. DataStruct dStruct = GetPostStruct();
  4104. List<string> lw = new List<string>();
  4105. string tid = GetPostString("ctid");
  4106. if (tid.Length > 0)
  4107. {
  4108. string select_tid = getTidByCtid(tid);
  4109. lw.Add(string.Format("tid='{0}'", select_tid));
  4110. }
  4111. string shopname = GetPostString("shopname");
  4112. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4113. string buyernick = GetPostString("buyer_nick");
  4114. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4115. string customer = GetPostString("customer");
  4116. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4117. string design = GetPostString("design");
  4118. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4119. string orderState = GetPostString("orderState");
  4120. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4121. string address = GetPostString("address");
  4122. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4123. string sellermemo = GetPostString("seller_memo");
  4124. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4125. string supplier = GetPostString("supplier");
  4126. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4127. string OrderArea = GetPostString("order_area");
  4128. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4129. string date1 = GetPostString("date1");
  4130. string date2 = GetPostString("date2");
  4131. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4132. if (dw.Length > 0) lw.Add(dw);
  4133. string price1 = GetPostString("price1");
  4134. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4135. string price2 = GetPostString("price2");
  4136. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4137. string posTag = CurrentUser.UserPost.Post.Code;
  4138. if (posTag == "Supplier")
  4139. {
  4140. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4141. }
  4142. //lw.Add(string.Format("OrderState = 6 "));
  4143. lw.Add(string.Format("IsSample={0}", 3));
  4144. lw.Add(string.Format("IsRefund<={0}", 1));
  4145. dStruct.Order = "pay_time desc";
  4146. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4147. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4148. writeGridDataTableJson(dStruct.TotalCount, dt);
  4149. }
  4150. public void save_erp_checkmemo()
  4151. {
  4152. if (UrlPostParmsCheck("ctid"))
  4153. {
  4154. string ctid = GetPostString("ctid");
  4155. CeErpTradeCell entity = null;
  4156. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4157. if (entity != null)
  4158. {
  4159. entity.CheckMemo = GetPostString("CheckMemo");
  4160. entity.Update();
  4161. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4162. if (trade != null)
  4163. {
  4164. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4165. }
  4166. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4167. returnSuccessMsg("保存成功!");
  4168. return;
  4169. }
  4170. returnErrorMsg("找不到记录");
  4171. }
  4172. }
  4173. public void get_erp_returnlist()
  4174. {
  4175. DataStruct dStruct = GetPostStruct();
  4176. List<string> lw = new List<string>();
  4177. string tid = GetPostString("ctid");
  4178. if (tid.Length > 0)
  4179. {
  4180. string select_tid = getTidByCtid(tid);
  4181. lw.Add(string.Format("tid='{0}'", select_tid));
  4182. }
  4183. string shopname = GetPostString("shopname");
  4184. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4185. string buyernick = GetPostString("buyer_nick");
  4186. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4187. string customer = GetPostString("customer");
  4188. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4189. string design = GetPostString("design");
  4190. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4191. string orderState = GetPostString("orderState");
  4192. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4193. string address = GetPostString("address");
  4194. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4195. string sellermemo = GetPostString("seller_memo");
  4196. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4197. string supplier = GetPostString("supplier");
  4198. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4199. string date1 = GetPostString("date1");
  4200. string date2 = GetPostString("date2");
  4201. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4202. if (dw.Length > 0) lw.Add(dw);
  4203. string bdate1 = GetPostString("backdate1");
  4204. string bdate2 = GetPostString("backdate2");
  4205. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4206. if (dw_back.Length > 0) lw.Add(dw_back);
  4207. string price1 = GetPostString("price1");
  4208. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4209. string price2 = GetPostString("price2");
  4210. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4211. lw.Add(string.Format("IsReturn>0"));
  4212. lw.Add(string.Format("IsXianHuo=0"));
  4213. lw.Add(string.Format("IsReturn!=3"));
  4214. string backtype = GetPostString("backtype");
  4215. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4216. dStruct.Order = "FinishDesignTime desc";
  4217. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4218. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4219. writeGridDataTableJson(dStruct.TotalCount, dt);
  4220. }
  4221. public void get_erp_today_sumreturn()
  4222. {
  4223. DataStruct dStruct = GetPostStruct();
  4224. List<string> lw = new List<string>();
  4225. string bdate1 = GetPostString("returnTimeS");
  4226. string bdate2 = GetPostString("returnTimeE");
  4227. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4228. if (dw_back.Length > 0) lw.Add(dw_back);
  4229. lw.Add(string.Format("IsReturn=0"));
  4230. lw.Add(string.Format("IsXianHuo=0"));
  4231. string mainWhere = string.Join(" and ", lw.ToArray());
  4232. string sql = "";
  4233. if (dw_back.Length > 0)
  4234. {
  4235. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4236. }
  4237. else
  4238. {
  4239. 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 + "'";
  4240. }
  4241. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4242. decimal total = 0, today_finish = 0;
  4243. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4244. {
  4245. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4246. }
  4247. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4248. {
  4249. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4250. }
  4251. var res = new
  4252. {
  4253. data = total,
  4254. data1 = today_finish,
  4255. };
  4256. string ro_jsond = JsonConvert.SerializeObject(res);
  4257. returnSuccess(ro_jsond);
  4258. return;
  4259. }
  4260. public void get_erp_allreturnlist()
  4261. {
  4262. DataStruct dStruct = GetPostStruct();
  4263. List<string> lw = new List<string>();
  4264. string tid = GetPostString("ctid");
  4265. if (tid.Length > 0)
  4266. {
  4267. string select_tid = getTidByCtid(tid);
  4268. lw.Add(string.Format("tid='{0}'", select_tid));
  4269. }
  4270. string shopname = GetPostString("shopname");
  4271. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4272. string buyernick = GetPostString("buyer_nick");
  4273. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4274. string customer = GetPostString("customer");
  4275. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4276. string design = GetPostString("design");
  4277. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4278. string orderState = GetPostString("orderState");
  4279. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4280. string address = GetPostString("address");
  4281. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4282. string sellermemo = GetPostString("seller_memo");
  4283. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4284. string supplier = GetPostString("supplier");
  4285. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4286. string date1 = GetPostString("date1");
  4287. string date2 = GetPostString("date2");
  4288. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4289. if (dw.Length > 0) lw.Add(dw);
  4290. string bdate1 = GetPostString("backdate1");
  4291. string bdate2 = GetPostString("backdate2");
  4292. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4293. if (dw_back.Length > 0) lw.Add(dw_back);
  4294. string price1 = GetPostString("price1");
  4295. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4296. string price2 = GetPostString("price2");
  4297. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4298. string backreason = GetPostString("backreason");
  4299. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4300. lw.Add(string.Format("IsXianHuo=0"));
  4301. lw.Add(string.Format("ReturnTime != ''"));
  4302. string backtype = GetPostString("backtype");
  4303. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4304. dStruct.Order = "FinishDesignTime desc";
  4305. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4306. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4307. writeGridDataTableJson(dStruct.TotalCount, dt);
  4308. }
  4309. public void get_erp_aftersalereturnlist()
  4310. {
  4311. DataStruct dStruct = GetPostStruct();
  4312. List<string> lw = new List<string>();
  4313. string tid = GetPostString("ctid");
  4314. if (tid.Length > 0)
  4315. {
  4316. string select_tid = getTidByCtid(tid);
  4317. lw.Add(string.Format("tid='{0}'", select_tid));
  4318. }
  4319. string shopname = GetPostString("shopname");
  4320. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4321. string buyernick = GetPostString("buyer_nick");
  4322. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4323. string customer = GetPostString("customer");
  4324. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4325. string design = GetPostString("design");
  4326. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4327. string orderState = GetPostString("orderState");
  4328. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4329. string address = GetPostString("address");
  4330. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4331. string sellermemo = GetPostString("seller_memo");
  4332. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4333. string supplier = GetPostString("supplier");
  4334. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4335. string date1 = GetPostString("date1");
  4336. string date2 = GetPostString("date2");
  4337. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4338. if (dw.Length > 0) lw.Add(dw);
  4339. string bdate1 = GetPostString("backdate1");
  4340. string bdate2 = GetPostString("backdate2");
  4341. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4342. if (dw_back.Length > 0) lw.Add(dw_back);
  4343. string price1 = GetPostString("price1");
  4344. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4345. string price2 = GetPostString("price2");
  4346. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4347. lw.Add(string.Format("IsReturn=3"));
  4348. string backtype = GetPostString("backtype");
  4349. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4350. string backreason = GetPostString("backreason");
  4351. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4352. dStruct.Order = "ReturnTime desc";
  4353. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4354. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4355. writeGridDataTableJson(dStruct.TotalCount, dt);
  4356. }
  4357. public void get_erp_xianhuoreturnlist()
  4358. {
  4359. DataStruct dStruct = GetPostStruct();
  4360. List<string> lw = new List<string>();
  4361. string tid = GetPostString("ctid");
  4362. if (tid.Length > 0)
  4363. {
  4364. string select_tid = getTidByCtid(tid);
  4365. lw.Add(string.Format("tid='{0}'", select_tid));
  4366. }
  4367. string shopname = GetPostString("shopname");
  4368. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4369. string buyernick = GetPostString("buyer_nick");
  4370. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4371. string customer = GetPostString("customer");
  4372. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4373. string design = GetPostString("design");
  4374. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4375. string orderState = GetPostString("orderState");
  4376. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4377. string address = GetPostString("address");
  4378. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4379. string sellermemo = GetPostString("seller_memo");
  4380. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4381. string supplier = GetPostString("supplier");
  4382. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4383. string OrderArea = GetPostString("order_area");
  4384. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4385. string date1 = GetPostString("date1");
  4386. string date2 = GetPostString("date2");
  4387. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4388. if (dw.Length > 0) lw.Add(dw);
  4389. string price1 = GetPostString("price1");
  4390. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4391. string price2 = GetPostString("price2");
  4392. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4393. string posTag = CurrentUser.UserPost.Post.Code;
  4394. if (posTag == "Supplier")
  4395. {
  4396. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4397. }
  4398. lw.Add(string.Format("OrderState=6 "));
  4399. lw.Add(string.Format("IsXianHuo=1 "));
  4400. lw.Add(string.Format("IsReturn>0 "));
  4401. lw.Add(string.Format("IsReturn!=3"));
  4402. lw.Add(string.Format("IsRefund<={0}", 1));
  4403. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4404. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4405. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4406. writeGridDataTableJson(dStruct.TotalCount, dt);
  4407. }
  4408. public void set_erp_orderdelivery()
  4409. {
  4410. if (UrlPostParmsCheck("ctid"))
  4411. {
  4412. string eid = GetPostString("ctid");
  4413. CeErpTradeCell entity = null;
  4414. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4415. if (entity != null)
  4416. {
  4417. if (entity.OrderState >= 7)
  4418. {
  4419. returnErrorMsg("此单已发货,无需重复发货");
  4420. return;
  4421. }
  4422. if (entity.OrderState != 6)
  4423. {
  4424. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4425. return;
  4426. }
  4427. string shop = GetPostString("seller_nick");
  4428. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4429. string comName = GetPostString("comName");
  4430. string comCode = GetPostString("comCode");
  4431. string outSid = GetPostString("outSid");
  4432. string deliveryType = GetPostString("deliveryType");
  4433. string deliveryMemo = GetPostString("deliveryMemo");
  4434. outSid = outSid.Trim();
  4435. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4436. if (mainEn == null)
  4437. {
  4438. returnErrorMsg("找不到原始订单记录");
  4439. return;
  4440. }
  4441. bool isInitOrderDeliv = false;
  4442. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4443. {
  4444. isInitOrderDeliv = true;
  4445. }
  4446. string apires = "";
  4447. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4448. 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)
  4449. {
  4450. apires = "发货成功true";
  4451. }
  4452. else
  4453. {
  4454. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4455. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4456. }
  4457. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4458. {
  4459. entity.OrderState = 7;//发货后订单已发货
  4460. entity.OutSid = outSid;
  4461. entity.MemoOpt = 0;
  4462. entity.UpdateTime = DateTime.Now;
  4463. entity.FinishDeliveryTime = DateTime.Now;
  4464. entity.Update();
  4465. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4466. commonHelper.UpdateRelationOrder(entity.ctid);
  4467. //还要插入快递信息到 快递信息表
  4468. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4469. exinfo.tid = eid;
  4470. exinfo.out_sid = outSid;
  4471. exinfo.company_code = comCode;
  4472. exinfo.company_name = comName;
  4473. exinfo.delivery_memo = deliveryMemo;
  4474. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4475. exinfo.deliveryType = deliveryType;
  4476. exinfo.Create();
  4477. returnSuccessMsg("发货操作成功!");
  4478. commonHelper.UpdateRelationOrder(entity.ctid);
  4479. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4480. CeErpSukuraData.createInfo(entity.ctid, 4);
  4481. if (entity.SupplierId == 64)
  4482. {
  4483. commonHelper.sendCytExpress(exinfo);
  4484. }
  4485. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4486. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4487. }
  4488. else
  4489. {
  4490. string errmsg = commonHelper.KeepChinese(apires);
  4491. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4492. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4493. }
  4494. return;
  4495. }
  4496. returnErrorMsg("找不到订单记录");
  4497. }
  4498. }
  4499. public void set_erp_multidelivery()
  4500. {
  4501. string eids = GetPostString("tids");
  4502. string[] eidList = eids.Split(',');
  4503. if (eidList.Length <= 0)
  4504. {
  4505. returnErrorMsg("发货不能为空");
  4506. return;
  4507. }
  4508. foreach (string ctid in eidList)
  4509. {
  4510. if (ctid.Length <= 0) continue;
  4511. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4512. if (expInfo != null)
  4513. {
  4514. StringBuilder sql = new StringBuilder();
  4515. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4516. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4517. if (dt.Rows.Count > 0)
  4518. {
  4519. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4520. {
  4521. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4522. expInfo.state = "异常";
  4523. expInfo.isMultiDelivery = 1;
  4524. expInfo.Update();
  4525. continue;
  4526. }
  4527. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4528. {
  4529. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4530. expInfo.state = "异常";
  4531. expInfo.Update();
  4532. continue;
  4533. }
  4534. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4535. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4536. bool isInitOrderDeliv = false;
  4537. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4538. {
  4539. isInitOrderDeliv = true;
  4540. expInfo.isMultiDelivery = 1;
  4541. }
  4542. if (ctid.IndexOf("N") != -1)
  4543. {
  4544. StringBuilder sqlbucha = new StringBuilder();
  4545. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4546. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4547. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4548. commonHelper.UpdateRelationOrder(ctid);
  4549. expInfo.delivery_memo = "发货成功";
  4550. expInfo.state = "发货成功";
  4551. expInfo.isMultiDelivery = 1;
  4552. expInfo.Update();
  4553. }
  4554. else
  4555. {
  4556. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4557. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4558. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4559. {
  4560. expInfo.delivery_memo = "发货成功";
  4561. expInfo.state = "发货成功";
  4562. expInfo.isMultiDelivery = 1;
  4563. expInfo.Update();
  4564. commonHelper.UpdateRelationOrder(ctid);
  4565. CeErpSukuraData.createInfo(ctid, 4);
  4566. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4567. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4568. }
  4569. else
  4570. {
  4571. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4572. expInfo.state = "异常";
  4573. expInfo.Update();
  4574. }
  4575. }
  4576. }
  4577. }
  4578. }
  4579. returnSuccessMsg("操作完成");
  4580. }
  4581. public void reset_erp_memoopt()
  4582. {
  4583. if (UrlPostParmsCheck("ctid"))
  4584. {
  4585. string eid = GetPostString("ctid");
  4586. CeErpTradeCell entity = null;
  4587. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4588. if (entity != null)
  4589. {
  4590. string stropt = "";
  4591. if (entity.MemoOpt == 1)
  4592. {
  4593. stropt = "“改稿”";
  4594. }
  4595. else if (entity.MemoOpt == 2)
  4596. {
  4597. stropt = "“定稿”";
  4598. }
  4599. else if (entity.MemoOpt == 3)
  4600. {
  4601. stropt = "“完成查货”";
  4602. CeErpSukuraData.createInfo(entity.ctid, 6);
  4603. }
  4604. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4605. entity.UpdateTime = DateTime.Now;
  4606. entity.MemoOpt = 0;
  4607. entity.Update();
  4608. returnSuccessMsg("操作成功!");
  4609. return;
  4610. }
  4611. returnErrorMsg("找不到记录");
  4612. }
  4613. }
  4614. public void get_erp_deliveryunusual()
  4615. {
  4616. DataStruct dStruct = GetPostStruct();
  4617. List<string> lw = new List<string>();
  4618. string tid = GetPostString("ctid");
  4619. if (tid.Length > 0)
  4620. {
  4621. string select_tid = getTidByCtid(tid);
  4622. lw.Add(string.Format("tid='{0}'", select_tid));
  4623. }
  4624. string shopname = GetPostString("shopname");
  4625. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4626. string buyernick = GetPostString("buyer_nick");
  4627. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4628. string customer = GetPostString("customer");
  4629. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4630. string design = GetPostString("design");
  4631. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4632. string sellermemo = GetPostString("seller_memo");
  4633. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4634. string supplier = GetPostString("supplier");
  4635. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4636. string date1 = GetPostString("date1");
  4637. string date2 = GetPostString("date2");
  4638. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4639. if (dw.Length > 0) lw.Add(dw);
  4640. string placedate1 = GetPostString("placedate1");
  4641. string placedate2 = GetPostString("placedate2");
  4642. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4643. if (dw_place.Length > 0) lw.Add(dw_place);
  4644. string price1 = GetPostString("price1");
  4645. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4646. string price2 = GetPostString("price2");
  4647. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4648. string unusualCon = GetPostString("unusualcon");
  4649. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4650. string posTag = CurrentUser.UserPost.Post.Code;
  4651. if (posTag == "Supplier")
  4652. {
  4653. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4654. }
  4655. lw.Add(string.Format("OrderState = 6"));
  4656. lw.Add(string.Format("UnusualTag = 5"));
  4657. lw.Add(string.Format("IsRefund<={0}", 1));
  4658. dStruct.Order = "FinishPlaceTime desc";
  4659. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4660. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4661. writeGridDataTableJson(dStruct.TotalCount, dt);
  4662. }
  4663. public void get_erp_deliveryedlist()
  4664. {
  4665. DataStruct dStruct = GetPostStruct();
  4666. List<string> lw = new List<string>();
  4667. string tid = GetPostString("ctid");
  4668. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4669. string shopname = GetPostString("shopname");
  4670. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4671. string buyernick = GetPostString("buyer_nick");
  4672. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4673. string customer = GetPostString("customer");
  4674. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4675. string design = GetPostString("design");
  4676. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4677. string sellermemo = GetPostString("seller_memo");
  4678. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4679. string logistics = GetPostString("logistics");
  4680. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4681. string date1 = GetPostString("date1");
  4682. string date2 = GetPostString("date2");
  4683. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4684. //if (dw.Length > 0) lw.Add(dw);
  4685. string placedate1 = GetPostString("placedate1");
  4686. string placedate2 = GetPostString("placedate2");
  4687. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4688. if (fdw.Length > 0) lw.Add(fdw);
  4689. string devdate1 = GetPostString("deliverydate1");
  4690. string devdate2 = GetPostString("deliverydate2");
  4691. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4692. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4693. string price1 = GetPostString("price1");
  4694. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4695. string price2 = GetPostString("price2");
  4696. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4697. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4698. {
  4699. if (tid.Length > 0)
  4700. {
  4701. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4702. if (tid.Length > 5)
  4703. {
  4704. List<string> tids = getTidByCtidLike(tid);
  4705. if (tids.Count > 0 && tids.Count < 10)
  4706. {
  4707. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4708. }
  4709. }
  4710. lw.Add(tid_sql);
  4711. }
  4712. if (buyernick.Length > 0)
  4713. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4714. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4715. if (dw.Length > 0) lw.Add(dw);
  4716. }
  4717. else
  4718. {
  4719. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4720. }
  4721. string posTag = CurrentUser.UserPost.Post.Code;
  4722. if (posTag == "Supplier")
  4723. {
  4724. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4725. }
  4726. else
  4727. {
  4728. string supplier = GetPostString("supplier");
  4729. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4730. }
  4731. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4732. lw.Add(string.Format("type != 'PDD' "));
  4733. lw.Add(string.Format("IsRefund!={0}", 2));
  4734. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4735. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4736. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4737. /*if (tid.Length > 0)
  4738. {
  4739. List<string> tids = new List<string>();
  4740. if (dt != null && dt.Rows.Count > 0)
  4741. {
  4742. foreach (DataRow item in dt.Rows)
  4743. {
  4744. tids.Add("'" + item["tid"] + "'");
  4745. }
  4746. }
  4747. if (tids.Count > 0)
  4748. {
  4749. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4750. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4751. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4752. dt = WebCache.GetData("view_erptradecell", dStruct);
  4753. }
  4754. }*/
  4755. if (dt != null)
  4756. {
  4757. foreach (DataRow dr in dt.Rows)
  4758. {
  4759. 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();
  4760. }
  4761. }
  4762. writeGridDataTableJson(dStruct.TotalCount, dt);
  4763. }
  4764. public void get_erp_pdddeliveryed()
  4765. {
  4766. DataStruct dStruct = GetPostStruct();
  4767. List<string> lw = new List<string>();
  4768. string tid = GetPostString("ctid");
  4769. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4770. string shopname = GetPostString("shopname");
  4771. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4772. string buyernick = GetPostString("buyer_nick");
  4773. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4774. string customer = GetPostString("customer");
  4775. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4776. string design = GetPostString("design");
  4777. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4778. string sellermemo = GetPostString("seller_memo");
  4779. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4780. string logistics = GetPostString("logistics");
  4781. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4782. string date1 = GetPostString("date1");
  4783. string date2 = GetPostString("date2");
  4784. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4785. //if (dw.Length > 0) lw.Add(dw);
  4786. string placedate1 = GetPostString("placedate1");
  4787. string placedate2 = GetPostString("placedate2");
  4788. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4789. if (fdw.Length > 0) lw.Add(fdw);
  4790. string devdate1 = GetPostString("deliverydate1");
  4791. string devdate2 = GetPostString("deliverydate2");
  4792. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4793. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4794. string price1 = GetPostString("price1");
  4795. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4796. string price2 = GetPostString("price2");
  4797. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4798. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4799. {
  4800. if (tid.Length > 0)
  4801. {
  4802. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4803. if (tid.Length > 5)
  4804. {
  4805. List<string> tids = getTidByCtidLike(tid);
  4806. if (tids.Count > 0 && tids.Count < 10)
  4807. {
  4808. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4809. }
  4810. }
  4811. lw.Add(tid_sql);
  4812. }
  4813. if (buyernick.Length > 0)
  4814. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4815. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4816. if (dw.Length > 0) lw.Add(dw);
  4817. }
  4818. else
  4819. {
  4820. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4821. }
  4822. string posTag = CurrentUser.UserPost.Post.Code;
  4823. if (posTag == "Supplier")
  4824. {
  4825. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4826. }
  4827. else
  4828. {
  4829. string supplier = GetPostString("supplier");
  4830. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4831. }
  4832. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4833. lw.Add(string.Format("type = 'PDD' "));
  4834. lw.Add(string.Format("IsRefund!={0}", 2));
  4835. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4836. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4837. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4838. /* if (tid.Length > 0)
  4839. {
  4840. List<string> tids = new List<string>();
  4841. if (dt != null && dt.Rows.Count > 0)
  4842. {
  4843. foreach (DataRow item in dt.Rows)
  4844. {
  4845. tids.Add("'" + item["tid"] + "'");
  4846. }
  4847. }
  4848. if (tids.Count > 0)
  4849. {
  4850. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4851. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4852. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4853. dt = WebCache.GetData("view_erptradecell", dStruct);
  4854. }
  4855. }*/
  4856. foreach (DataRow dr in dt.Rows)
  4857. {
  4858. 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();
  4859. }
  4860. writeGridDataTableJson(dStruct.TotalCount, dt);
  4861. }
  4862. public void get_erp_jddeliveryed()
  4863. {
  4864. DataStruct dStruct = GetPostStruct();
  4865. List<string> lw = new List<string>();
  4866. string tid = GetPostString("ctid");
  4867. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4868. string shopname = GetPostString("shopname");
  4869. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4870. string buyernick = GetPostString("buyer_nick");
  4871. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4872. string customer = GetPostString("customer");
  4873. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4874. string design = GetPostString("design");
  4875. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4876. string sellermemo = GetPostString("seller_memo");
  4877. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4878. string date1 = GetPostString("date1");
  4879. string date2 = GetPostString("date2");
  4880. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4881. //if (dw.Length > 0) lw.Add(dw);
  4882. string placedate1 = GetPostString("placedate1");
  4883. string placedate2 = GetPostString("placedate2");
  4884. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4885. if (fdw.Length > 0) lw.Add(fdw);
  4886. string devdate1 = GetPostString("deliverydate1");
  4887. string devdate2 = GetPostString("deliverydate2");
  4888. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4889. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4890. string price1 = GetPostString("price1");
  4891. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4892. string price2 = GetPostString("price2");
  4893. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4894. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4895. {
  4896. if (tid.Length > 0)
  4897. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4898. if (buyernick.Length > 0)
  4899. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4900. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4901. if (dw.Length > 0) lw.Add(dw);
  4902. }
  4903. else
  4904. {
  4905. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4906. }
  4907. string posTag = CurrentUser.UserPost.Post.Code;
  4908. if (posTag == "Supplier")
  4909. {
  4910. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4911. }
  4912. else
  4913. {
  4914. string supplier = GetPostString("supplier");
  4915. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4916. }
  4917. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4918. lw.Add(string.Format("type = 'JD' "));
  4919. lw.Add(string.Format("IsRefund!={0}", 2));
  4920. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4921. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4922. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4923. foreach (DataRow dr in dt.Rows)
  4924. {
  4925. 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();
  4926. }
  4927. writeGridDataTableJson(dStruct.TotalCount, dt);
  4928. }
  4929. public void get_erp_allplacelist()
  4930. {
  4931. DataStruct dStruct = GetPostStruct();
  4932. List<string> lw = new List<string>();
  4933. string tid = GetPostString("ctid");
  4934. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4935. string shopname = GetPostString("shopname");
  4936. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4937. string buyernick = GetPostString("buyer_nick");
  4938. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4939. string customer = GetPostString("customer");
  4940. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4941. string design = GetPostString("design");
  4942. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4943. string sellermemo = GetPostString("seller_memo");
  4944. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4945. string supplier = GetPostString("supplier");
  4946. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4947. string date1 = GetPostString("date1");
  4948. string date2 = GetPostString("date2");
  4949. string pldate1 = GetPostString("placedate1");
  4950. string pldate2 = GetPostString("placedate2");
  4951. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4952. //if (dw.Length > 0) lw.Add(dw);
  4953. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4954. {
  4955. if (tid.Length > 0)
  4956. {
  4957. string select_tid = getTidByCtid(tid);
  4958. lw.Add(string.Format("tid='{0}'", select_tid));
  4959. }
  4960. if (buyernick.Length > 0)
  4961. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4962. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4963. if (dw.Length > 0) lw.Add(dw);
  4964. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4965. if (dw_place.Length > 0) lw.Add(dw_place);
  4966. }
  4967. else
  4968. {
  4969. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4970. {
  4971. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4972. }
  4973. }
  4974. string price1 = GetPostString("price1");
  4975. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4976. string price2 = GetPostString("price2");
  4977. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4978. string posTag = CurrentUser.UserPost.Post.Code;
  4979. if (posTag == "Supplier")
  4980. {
  4981. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4982. }
  4983. lw.Add(string.Format("OrderState >= 6"));
  4984. lw.Add(string.Format("IsSample != 2 "));
  4985. //lw.Add(string.Format("isDianziOrder = 0 "));
  4986. lw.Add(string.Format("SupplierId > 0 "));
  4987. //lw.Add(string.Format("IsRefund<={0}", 1));
  4988. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4989. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4990. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4991. foreach (DataRow dr in dt.Rows)
  4992. {
  4993. 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();
  4994. }
  4995. writeGridDataTableJson(dStruct.TotalCount, dt);
  4996. }
  4997. public void get_erp_financeallplacelist()
  4998. {
  4999. DataStruct dStruct = GetPostStruct();
  5000. List<string> lw = new List<string>();
  5001. string tid = GetPostString("ctid");
  5002. string shopname = GetPostString("shopname");
  5003. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5004. string buyernick = GetPostString("buyer_nick");
  5005. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5006. string customer = GetPostString("customer");
  5007. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5008. string design = GetPostString("design");
  5009. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5010. string sellermemo = GetPostString("seller_memo");
  5011. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5012. string supplier = GetPostString("supplier");
  5013. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5014. string date1 = GetPostString("date1");
  5015. string date2 = GetPostString("date2");
  5016. string pldate1 = GetPostString("placedate1");
  5017. string pldate2 = GetPostString("placedate2");
  5018. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5019. {
  5020. if (tid.Length > 0)
  5021. {
  5022. string select_tid = getTidByCtid(tid);
  5023. lw.Add(string.Format("tid='{0}'", select_tid));
  5024. }
  5025. if (buyernick.Length > 0)
  5026. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5027. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5028. if (dw.Length > 0) lw.Add(dw);
  5029. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5030. if (dw_place.Length > 0) lw.Add(dw_place);
  5031. }
  5032. else
  5033. {
  5034. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5035. {
  5036. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5037. }
  5038. }
  5039. string price1 = GetPostString("price1");
  5040. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5041. string price2 = GetPostString("price2");
  5042. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5043. string posTag = CurrentUser.UserPost.Post.Code;
  5044. if (posTag == "Supplier")
  5045. {
  5046. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5047. }
  5048. //lw.Add(string.Format("OrderState >= 6"));
  5049. lw.Add(string.Format("IsSample != 2 "));
  5050. lw.Add(string.Format("isDianziOrder = 0 "));
  5051. //lw.Add(string.Format("IsRefund<={0}", 1));
  5052. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5053. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5054. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5055. foreach (DataRow dr in dt.Rows)
  5056. {
  5057. 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();
  5058. }
  5059. writeGridDataTableJson(dStruct.TotalCount, dt);
  5060. }
  5061. public void get_erp_expresslist()
  5062. {
  5063. int listtype = GetInt("ltype");
  5064. DataStruct dStruct = GetPostStruct();
  5065. List<string> lw = new List<string>();
  5066. string tid = GetPostString("tid");
  5067. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5068. string outsid = GetPostString("out_sid");
  5069. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5070. string importer = GetPostString("ImportUserName");
  5071. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5072. string file = GetPostString("import_file");
  5073. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5074. string printman = GetPostString("printman");
  5075. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5076. string date1 = GetPostString("date1");
  5077. string date2 = GetPostString("date2");
  5078. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5079. if (dw.Length > 0) lw.Add(dw);
  5080. string fdate1 = GetPostString("finishdate1");
  5081. string fdate2 = GetPostString("finishdate2");
  5082. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5083. if (fdw.Length > 0) lw.Add(fdw);
  5084. string supplierId = GetPostString("supplierId");
  5085. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5086. if (listtype == 1)
  5087. {
  5088. lw.Add(string.Format("importUserId !=0"));
  5089. }
  5090. string posTag = CurrentUser.UserPost.Post.Code;
  5091. if (posTag == "Supplier")
  5092. {
  5093. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5094. }
  5095. if (dStruct.PageSize != 100000)
  5096. {
  5097. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5098. }
  5099. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5100. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5101. writeGridDataTableJson(dStruct.TotalCount, dt);
  5102. }
  5103. public void set_erp_buchaorderdelivery()
  5104. {
  5105. if (UrlPostParmsCheck("ctid"))
  5106. {
  5107. string eid = GetPostString("ctid");
  5108. CeErpTradeCell entity = null;
  5109. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5110. if (entity != null)
  5111. {
  5112. if (entity.IsSample != 2)
  5113. {
  5114. returnErrorMsg("补差价单才能标记为已发货");
  5115. return;
  5116. }
  5117. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5118. entity.OrderState = 7;
  5119. entity.Update();
  5120. returnSuccessMsg("操作成功!");
  5121. return;
  5122. }
  5123. returnErrorMsg("找不到记录");
  5124. }
  5125. }
  5126. public void get_stdtemplates()
  5127. {
  5128. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5129. //string res = taobaoHelper.test();
  5130. string res = apiHelper.API_PrintTemplate();
  5131. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5132. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5133. {
  5134. int sidx = res.IndexOf("error_code");
  5135. int eidx = res.IndexOf("success");
  5136. string msg = res.Substring(sidx, eidx - sidx);
  5137. returnErrorMsg(msg);
  5138. return;
  5139. }
  5140. if (res.Length <= 0)
  5141. {
  5142. returnErrorMsg("模板数据为空!");
  5143. return;
  5144. }
  5145. ReturnSuccess(res);
  5146. }
  5147. public void cancel_print_order()
  5148. {
  5149. if (UrlPostParmsCheck("ctid"))
  5150. {
  5151. string ctid = GetPostString("ctid");
  5152. CeErpTradeCell entity = null;
  5153. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5154. if (entity != null)
  5155. {
  5156. string res = "";
  5157. string code = entity.LastBillWaybillCode;
  5158. if (code == "")
  5159. {
  5160. code = entity.OutSid;
  5161. }
  5162. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5163. XLog.SaveLog(0, "取消面单" + res);
  5164. }
  5165. }
  5166. }
  5167. public void set_erp_printwaybill()
  5168. {
  5169. if (UrlPostParmsCheck("ctid"))
  5170. {
  5171. string ctid = GetPostString("ctid");
  5172. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5173. string cpName = GetPostString("cpname");
  5174. string isTogether = GetPostString("together");
  5175. //var res_obj = new
  5176. //{
  5177. // restype = 1,
  5178. // 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\"}"
  5179. //};
  5180. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5181. //ReturnSuccess(ro_json);
  5182. //return;
  5183. bool isUseLastWayBillCode = false;
  5184. CeErpTradeCell entity = null;
  5185. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5186. if (entity != null)
  5187. {
  5188. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5189. {
  5190. isUseLastWayBillCode = true;
  5191. }
  5192. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5193. {
  5194. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5195. return;
  5196. }
  5197. }
  5198. string res = "";
  5199. Api_waybill_code_response_Obj fullObj = null;
  5200. string pData_str = "";
  5201. string curUseWayBillCode = "";
  5202. if (isUseLastWayBillCode == false)
  5203. {
  5204. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5205. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5206. if (res.IndexOf("failure") != -1)
  5207. {
  5208. //int idx = res.IndexOf("sub_message");
  5209. //int idx2 = res.IndexOf("flag");
  5210. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5211. string errMsgNeed = commonHelper.KeepChinese(res);
  5212. var res_objd = new
  5213. {
  5214. restype = 0,
  5215. data = "获取面单失败" + errMsgNeed
  5216. };
  5217. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5218. returnSuccess(ro_jsond);
  5219. if (res.IndexOf("停发") != -1)
  5220. {
  5221. entity.UnusualCon = "物流停发";
  5222. entity.Update();
  5223. }
  5224. //returnErrorMsg("获取面单失败,"+emsg);
  5225. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5226. return;
  5227. }
  5228. else if (res.IndexOf("errorMsg") != -1)
  5229. {
  5230. //int idx = res.IndexOf("errorMsg");
  5231. //int idx2 = res.IndexOf("}]}");
  5232. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5233. string errMsgNeed = commonHelper.KeepChinese(res);
  5234. var res_objf = new
  5235. {
  5236. restype = 0,
  5237. data = "获取面单失败2" + errMsgNeed
  5238. };
  5239. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5240. if (res.IndexOf("停发") != -1)
  5241. {
  5242. entity.UnusualCon = "物流停发";
  5243. entity.Update();
  5244. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5245. if (trade != null)
  5246. {
  5247. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5248. }
  5249. }
  5250. returnSuccess(ro_jsonf);
  5251. //returnErrorMsg("获取面单失败," + emsg);
  5252. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5253. return;
  5254. }
  5255. try
  5256. {
  5257. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5258. //res = res.Replace(" ", "");
  5259. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5260. }
  5261. catch (Exception ex)
  5262. {
  5263. XLog.SaveLog(0, "生成fullObj" + res);
  5264. var res_objf = new
  5265. {
  5266. restype = 0,
  5267. data = "生成fullObj发生错误" + ex.Message
  5268. };
  5269. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5270. returnSuccess(ro_jsonf);
  5271. return;
  5272. }
  5273. if (fullObj.response.data.content.Count > 0)
  5274. {
  5275. ContentItem codeObj = fullObj.response.data.content[0];
  5276. if (cpCode.IndexOf("SFFQ-") != -1)
  5277. {
  5278. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5279. }
  5280. else
  5281. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5282. curUseWayBillCode = codeObj.waybillCode;
  5283. }
  5284. else
  5285. {
  5286. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5287. var res_objf = new
  5288. {
  5289. restype = 0,
  5290. data = "生成fullObj找不到快递单号waybillCode"
  5291. };
  5292. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5293. returnSuccess(ro_jsonf);
  5294. return;
  5295. }
  5296. }
  5297. else
  5298. {
  5299. //使用上次打印的快递单号
  5300. if (cpCode == "SFFQ-LY")
  5301. {
  5302. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5303. }
  5304. else
  5305. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5306. curUseWayBillCode = entity.LastBillWaybillCode;
  5307. }
  5308. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5309. {
  5310. var res_obje = new
  5311. {
  5312. restype = 0,
  5313. data = "获取加密打印数据失败"
  5314. };
  5315. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5316. returnSuccess(ro_jsone);
  5317. entity.LastBillCpCode = cpCode;
  5318. entity.LastBillWaybillCode = curUseWayBillCode;
  5319. entity.Update();
  5320. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5321. //returnErrorMsg("获取加密打印数据失败");
  5322. return;
  5323. }
  5324. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5325. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5326. string btnType = "";
  5327. if (entity != null)
  5328. {
  5329. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5330. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5331. //cpcode是 YTO-CAINIAO
  5332. //string comCode = cpCode.Split('-')[0].ToString();
  5333. string apires = "";
  5334. if (ctid.IndexOf("N") != -1)
  5335. {
  5336. apires = "发货成功";
  5337. }
  5338. else
  5339. {
  5340. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5341. }
  5342. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5343. //打单后发货
  5344. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5345. {
  5346. try
  5347. {
  5348. btnType = "待发货";
  5349. entity.OutSid = curUseWayBillCode;
  5350. entity.OrderState = 7;
  5351. entity.IsUrgency = false;
  5352. entity.LastBillCpCode = "";
  5353. entity.LastBillWaybillCode = "";
  5354. entity.FinishDeliveryTime = DateTime.Now;
  5355. entity.IsReturn = 0;
  5356. entity.MemoOpt = 0;
  5357. entity.UpdateTime = DateTime.Now;
  5358. entity.Update();
  5359. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5360. //还要插入快递信息到 快递信息表
  5361. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5362. exinfo.tid = entity.ctid;
  5363. exinfo.out_sid = entity.OutSid;
  5364. exinfo.company_code = cpCode;
  5365. exinfo.company_name = cpName;
  5366. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5367. exinfo.deliveryType = "发货成功";
  5368. exinfo.print_time = DateTime.Now;
  5369. exinfo.printUser = CurrentUser.UserName;
  5370. exinfo.Create();
  5371. commonHelper.UpdateRelationOrder(entity.ctid);
  5372. CeErpSukuraData.createInfo(ctid, 4);
  5373. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5374. if (entity.SupplierId == 64)
  5375. {
  5376. commonHelper.sendCytExpress(exinfo);
  5377. }
  5378. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5379. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5380. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5381. if (isTogether == "1" && ceErpDeliverMark == null)
  5382. {
  5383. StringBuilder sqlsb = new StringBuilder();
  5384. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5385. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5386. }
  5387. if (ceErpDeliverMark != null)
  5388. {
  5389. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5390. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5391. {
  5392. List<string> list = new List<string>();
  5393. foreach (DataRow row in dt1.Rows)
  5394. {
  5395. list.Add("'" + row["ctid"] + "'");
  5396. }
  5397. DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
  5398. }
  5399. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5400. }
  5401. }
  5402. catch (Exception ex)
  5403. {
  5404. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5405. }
  5406. }
  5407. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5408. {
  5409. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5410. if (entity.OrderState == 6)
  5411. {
  5412. entity.OrderState = 7;
  5413. }
  5414. entity.UpdateTime = DateTime.Now;
  5415. entity.FinishDeliveryTime = DateTime.Now;
  5416. btnType = "已发货";
  5417. entity.Update();
  5418. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5419. exinfo.tid = entity.ctid;
  5420. exinfo.out_sid = entity.OutSid;
  5421. exinfo.company_code = cpCode;
  5422. exinfo.company_name = cpName;
  5423. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5424. exinfo.deliveryType = "发货成功";
  5425. exinfo.print_time = DateTime.Now;
  5426. exinfo.printUser = CurrentUser.UserName;
  5427. exinfo.Create();
  5428. commonHelper.UpdateRelationOrder(entity.ctid);
  5429. CeErpSukuraData.createInfo(entity.ctid, 4);
  5430. if (entity.SupplierId == 64)
  5431. {
  5432. commonHelper.sendCytExpress(exinfo);
  5433. }
  5434. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5435. if (isTogether == "1" && ceErpDeliverMark == null)
  5436. {
  5437. StringBuilder sqlsb = new StringBuilder();
  5438. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5439. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5440. }
  5441. if (ceErpDeliverMark != null)
  5442. {
  5443. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5444. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5445. {
  5446. List<string> list = new List<string>();
  5447. foreach (DataRow row in dt1.Rows)
  5448. {
  5449. list.Add("'" + row["ctid"] + "'");
  5450. }
  5451. DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
  5452. }
  5453. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5454. }
  5455. //不处理
  5456. }
  5457. else
  5458. {
  5459. entity.UpdateTime = DateTime.Now;
  5460. entity.LastBillCpCode = cpCode;
  5461. entity.LastBillWaybillCode = curUseWayBillCode;
  5462. entity.Update();
  5463. string errmsg = commonHelper.KeepChinese(apires);
  5464. var res_objz = new
  5465. {
  5466. restype = 0,
  5467. data = "打单后发货失败"
  5468. };
  5469. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5470. returnSuccess(ro_jsonz);
  5471. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5472. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5473. return;
  5474. }
  5475. }
  5476. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5477. var res_obj = new
  5478. {
  5479. restype = 1,
  5480. data = pData_str
  5481. };
  5482. string ro_json = JsonConvert.SerializeObject(res_obj);
  5483. ReturnSuccess(ro_json);
  5484. return;
  5485. }
  5486. }
  5487. private string GetUTF8String(byte[] vs)
  5488. {
  5489. throw new NotImplementedException();
  5490. }
  5491. public void set_erp_printwaybill_cn()
  5492. {
  5493. if (UrlPostParmsCheck("ctid"))
  5494. {
  5495. string ctid = GetPostString("ctid");
  5496. string cpCode = GetPostString("cpcode");
  5497. string cpName = GetPostString("cpname");
  5498. string tempUrl = GetPostString("tempurl");
  5499. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5500. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5501. //string res = taobaoHelper.test();
  5502. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5503. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5504. {
  5505. int sidx = res.IndexOf("errorMsg");
  5506. int eidx = res.IndexOf("}");
  5507. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5508. var res_objzxx = new
  5509. {
  5510. restype = 0,
  5511. data = msg
  5512. };
  5513. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5514. returnSuccess(ro_jsonzxx);
  5515. //returnErrorMsg(msg);
  5516. return;
  5517. }
  5518. int idx = res.IndexOf("waybillCode");
  5519. int idx2 = res.IndexOf("printData");
  5520. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5521. string eid = GetPostString("ctid");
  5522. CeErpTradeCell entity = null;
  5523. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5524. if (entity != null)
  5525. {
  5526. string osid = entity.OutSid;
  5527. entity.OutSid = osid + "," + outsid;
  5528. entity.FinishDeliveryTime = DateTime.Now;
  5529. entity.OrderState = 7;
  5530. entity.UpdateTime = DateTime.Now;
  5531. entity.IsReturn = 0;
  5532. entity.Update();
  5533. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5534. exinfo.tid = entity.ctid;
  5535. exinfo.out_sid = outsid;
  5536. exinfo.company_code = cpCode;
  5537. exinfo.company_name = cpName;
  5538. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5539. exinfo.deliveryType = "发货成功";
  5540. exinfo.print_time = DateTime.Now;
  5541. exinfo.printUser = CurrentUser.UserName;
  5542. exinfo.Create();
  5543. if (entity.SupplierId == 64)
  5544. {
  5545. commonHelper.sendCytExpress(exinfo);
  5546. }
  5547. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5548. }
  5549. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5550. var res_objz = new
  5551. {
  5552. restype = 1,
  5553. data = res
  5554. };
  5555. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5556. returnSuccess(ro_jsonz);
  5557. //ReturnSuccess(res);
  5558. }
  5559. }
  5560. ////打单,打印面单 获取面单号
  5561. //public void set_erp_printwaybill()
  5562. //{
  5563. // if (UrlPostParmsCheck("ctid"))
  5564. // {
  5565. // string ctid = GetPostString("ctid");
  5566. // string cpCode = GetPostString("cpcode");
  5567. // string tempUrl = GetPostString("tempurl");
  5568. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5569. // //string res = taobaoHelper.test();
  5570. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5571. // if (res.IndexOf("error_response") != -1)
  5572. // {
  5573. // int sidx = res.IndexOf("sub_msg");
  5574. // int eidx = res.IndexOf("request_id");
  5575. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5576. // returnErrorMsg(msg);
  5577. // return;
  5578. // }
  5579. // int idx = res.IndexOf("waybill_code");
  5580. // int idx2 = res.IndexOf("}]}");
  5581. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5582. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5583. // ReturnSuccess(res);
  5584. // }
  5585. //}
  5586. public void cancel_erp_aftersale()
  5587. {
  5588. if (UrlPostParmsCheck("ctid"))
  5589. {
  5590. string eid = GetPostString("ctid");
  5591. CeErpTradeCell entity = null;
  5592. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5593. if (entity != null)
  5594. {
  5595. //有过处理的售后,取消也不能删除 售 字,保留
  5596. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5597. {
  5598. entity.AfterSaleState = 4;
  5599. }
  5600. else
  5601. entity.AfterSaleState = 0;
  5602. entity.UpdateTime = DateTime.Now;
  5603. entity.Update();
  5604. returnSuccessMsg("操作成功!");
  5605. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5606. return;
  5607. }
  5608. returnErrorMsg("找不到订单记录");
  5609. }
  5610. }
  5611. public void get_erp_aftersalelist()
  5612. {
  5613. DataStruct dStruct = GetPostStruct();
  5614. List<string> lw = new List<string>();
  5615. int st = GetInt("st");
  5616. string tid = GetPostString("ctid");
  5617. if (st == 3)
  5618. {
  5619. if (tid.Length > 0)
  5620. {
  5621. string select_tid = getTidByCtid(tid);
  5622. lw.Add(string.Format("tid='{0}'", select_tid));
  5623. }
  5624. }
  5625. else
  5626. {
  5627. if (tid.Length > 0)
  5628. {
  5629. string select_tid = getTidByCtid(tid);
  5630. lw.Add(string.Format("tid='{0}'", select_tid));
  5631. }
  5632. }
  5633. string shopname = GetPostString("shopname");
  5634. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5635. string buyernick = GetPostString("buyer_nick");
  5636. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5637. string sellermemo = GetPostString("seller_memo");
  5638. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5639. string orderState = GetPostString("orderState");
  5640. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5641. string afterState = GetPostString("afterstate");
  5642. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5643. string date1 = GetPostString("date1");
  5644. string date2 = GetPostString("date2");
  5645. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5646. if (dw.Length > 0) lw.Add(dw);
  5647. string price1 = GetPostString("price1");
  5648. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5649. string price2 = GetPostString("price2");
  5650. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5651. //lw.Add(string.Format("IsRefund!={0}", 1));
  5652. string reason = GetPostString("reason");
  5653. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5654. string method = GetPostString("method");
  5655. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5656. string handler = GetPostString("handler");
  5657. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5658. string handledate1 = GetPostString("handledate1");
  5659. string handledate2 = GetPostString("handledate2");
  5660. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5661. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5662. string finish1 = GetPostString("finishdate1");
  5663. string finish2 = GetPostString("finishdate2");
  5664. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5665. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5666. string afterdate1 = GetPostString("afterdate1");
  5667. string afterdate2 = GetPostString("afterdate2");
  5668. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5669. if (afterDate.Length > 0) lw.Add(afterDate);
  5670. string supplier = GetPostString("supplier");
  5671. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5672. string responsible = GetPostString("responsibleman");
  5673. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5674. string customer = GetPostString("customer");
  5675. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5676. string design = GetPostString("design");
  5677. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5678. string afterMemoType = GetPostString("aftermemotype");
  5679. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5680. string posCode = CurrentUser.UserPost.Post.Code;
  5681. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5682. //{
  5683. // string vstate = GetPostString("vstate");
  5684. // if (vstate.Length > 0)
  5685. // {
  5686. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5687. // }
  5688. // if (posCode == "Supplier")
  5689. // {
  5690. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5691. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5692. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5693. // }
  5694. // else
  5695. // {
  5696. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5697. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5698. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5699. // {
  5700. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5701. // }
  5702. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5703. // {
  5704. // int orgid = CurrentUser.UserPost.OrgID;
  5705. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5706. // }
  5707. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5708. // {
  5709. // string shopid = CurrentUser.User.pemShop;
  5710. // lw.Add(string.Format("shopId in ({0})", shopid));
  5711. // }
  5712. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5713. // //{
  5714. // // int org_id = CurrentUser.UserPost.OrgID;
  5715. // // lw.Add(string.Format("OrgID={0}", org_id));
  5716. // //}
  5717. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5718. // }
  5719. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5720. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5721. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5722. //}
  5723. if (st == 5)
  5724. {
  5725. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5726. {
  5727. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5728. {
  5729. string shopid = CurrentUser.User.pemShop;
  5730. lw.Add(string.Format("shopId in ({0})", shopid));
  5731. }
  5732. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5733. {
  5734. int mrOrgid = CurrentUser.UserPost.OrgID;
  5735. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5736. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5737. }
  5738. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5739. //{
  5740. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5741. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5742. //}
  5743. else
  5744. {
  5745. string userIdStr = "";
  5746. if (posCode == "CustomerService")
  5747. {
  5748. userIdStr = CurrentUser.UserID + "_k";
  5749. }
  5750. else if (posCode == "Designer" || posCode == "wxDesigner")
  5751. {
  5752. userIdStr = CurrentUser.UserID + "_s";
  5753. }
  5754. else if (posCode == "Place")
  5755. {
  5756. userIdStr = CurrentUser.UserID + "_x";
  5757. }
  5758. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5759. }
  5760. }
  5761. string placedate1 = GetPostString("placedate1");
  5762. string placedate2 = GetPostString("placedate2");
  5763. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5764. if (dwplace.Length > 0) lw.Add(dwplace);
  5765. string supState = GetPostString("supState");
  5766. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5767. string searchType = GetPostString("searchType");
  5768. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5769. {
  5770. lw.Add(string.Format("BackNum>1"));
  5771. }
  5772. lw.Add(string.Format("AfterSaleState>0"));
  5773. if (ex_psize > 0)
  5774. {
  5775. if (CurrentUser.UserPost.Post.Code == "Finance")
  5776. dStruct.Order = "pay_time desc";
  5777. else
  5778. dStruct.Order = "HandleTime desc";
  5779. }
  5780. else
  5781. dStruct.Order = "HandleTime desc";
  5782. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5783. DataTable dt = WebCache.GetData("view_test", dStruct);
  5784. writeGridDataTableJson(dStruct.TotalCount, dt);
  5785. }
  5786. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5787. //{
  5788. // lw.Add(string.Format("AfterSaleState=4"));
  5789. // string code = CurrentUser.UserPost.Post.Code;
  5790. // if (code == "CustomerService")
  5791. // {
  5792. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5793. // }
  5794. // else if (code == "Designer" || code == "DesignerMr")
  5795. // {
  5796. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5797. // }
  5798. // else if (code == "Place" || code == "PlaceMr")
  5799. // {
  5800. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5801. // }
  5802. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5803. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5804. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5805. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5806. //}
  5807. //else //处理中的售后,待处理和处理中合并
  5808. //{
  5809. // if (afterState.Length <= 0)
  5810. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5811. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5812. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5813. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5814. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5815. //}
  5816. }
  5817. public void get_erp_disagreeftersalelist()
  5818. {
  5819. DataStruct dStruct = GetPostStruct();
  5820. List<string> lw = new List<string>();
  5821. int st = 2;
  5822. string tid = GetPostString("ctid");
  5823. if (tid.Length > 0)
  5824. {
  5825. string select_tid = getTidByCtid(tid);
  5826. lw.Add(string.Format("tid='{0}'", select_tid));
  5827. }
  5828. string shopname = GetPostString("shopname");
  5829. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5830. string buyernick = GetPostString("buyer_nick");
  5831. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5832. string sellermemo = GetPostString("seller_memo");
  5833. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5834. string orderState = GetPostString("orderState");
  5835. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5836. string afterState = GetPostString("afterstate");
  5837. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5838. string date1 = GetPostString("date1");
  5839. string date2 = GetPostString("date2");
  5840. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5841. if (dw.Length > 0) lw.Add(dw);
  5842. string price1 = GetPostString("price1");
  5843. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5844. string price2 = GetPostString("price2");
  5845. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5846. //lw.Add(string.Format("IsRefund!={0}", 1));
  5847. string reason = GetPostString("reason");
  5848. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5849. string method = GetPostString("method");
  5850. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5851. string handler = GetPostString("handler");
  5852. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5853. string handledate1 = GetPostString("handledate1");
  5854. string handledate2 = GetPostString("handledate2");
  5855. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5856. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5857. string afterdate1 = GetPostString("afterdate1");
  5858. string afterdate2 = GetPostString("afterdate2");
  5859. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5860. if (afterDate.Length > 0) lw.Add(afterDate);
  5861. string backdate1 = GetPostString("backdate1");
  5862. string backdate2 = GetPostString("backdate2");
  5863. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5864. if (backDate.Length > 0) lw.Add(backDate);
  5865. string supplier = GetPostString("supplier");
  5866. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5867. string responsible = GetPostString("responsibleman");
  5868. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5869. string customer = GetPostString("customer");
  5870. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5871. string design = GetPostString("design");
  5872. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5873. string afterSaleMemo = GetPostString("afterSaleMemo");
  5874. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5875. string afterMemoType = GetPostString("aftermemotype");
  5876. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5877. string aftersakereason = GetPostString("aftersakereason");
  5878. if (aftersakereason.Length > 0)
  5879. {
  5880. if (aftersakereason == "1")
  5881. {
  5882. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5883. }
  5884. if (aftersakereason == "2")
  5885. {
  5886. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5887. }
  5888. }
  5889. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5890. string poscode = CurrentUser.UserPost.Post.Code;
  5891. if (poscode != "SysAdmin")
  5892. {
  5893. string shopid = CurrentUser.User.pemShop;
  5894. lw.Add(string.Format("shopId in ({0})", shopid));
  5895. }
  5896. string searchType = GetPostString("searchType");
  5897. if (searchType == "wait")
  5898. {
  5899. lw.Add(string.Format("HandleTime is null"));
  5900. }
  5901. if (searchType == "handling")
  5902. {
  5903. lw.Add(string.Format("HandleTime is not null "));
  5904. }
  5905. if (searchType == "back" || searchType == "puBack")
  5906. {
  5907. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5908. }
  5909. if (searchType == "reBack")
  5910. {
  5911. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5912. }
  5913. if (searchType == "moreBack")
  5914. {
  5915. lw.Add(string.Format("backNum > 1"));
  5916. }
  5917. lw.Add(string.Format("(AfterSaleState=5)"));
  5918. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5919. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5920. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5921. writeGridDataTableJson(dStruct.TotalCount, dt);
  5922. }
  5923. public void get_erp_handlingaftersalelist()
  5924. {
  5925. DataStruct dStruct = GetPostStruct();
  5926. List<string> lw = new List<string>();
  5927. int st = 2;
  5928. string tid = GetPostString("ctid");
  5929. if (tid.Length > 0)
  5930. {
  5931. string select_tid = getTidByCtid(tid);
  5932. lw.Add(string.Format("tid='{0}'", select_tid));
  5933. }
  5934. string shopname = GetPostString("shopname");
  5935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5936. string buyernick = GetPostString("buyer_nick");
  5937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5938. string sellermemo = GetPostString("seller_memo");
  5939. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5940. string orderState = GetPostString("orderState");
  5941. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5942. string afterState = GetPostString("afterstate");
  5943. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5944. string date1 = GetPostString("date1");
  5945. string date2 = GetPostString("date2");
  5946. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5947. if (dw.Length > 0) lw.Add(dw);
  5948. string price1 = GetPostString("price1");
  5949. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5950. string price2 = GetPostString("price2");
  5951. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5952. //lw.Add(string.Format("IsRefund!={0}", 1));
  5953. string reason = GetPostString("reason");
  5954. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5955. string method = GetPostString("method");
  5956. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5957. string handler = GetPostString("handler");
  5958. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5959. string handledate1 = GetPostString("handledate1");
  5960. string handledate2 = GetPostString("handledate2");
  5961. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5962. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5963. string afterdate1 = GetPostString("afterdate1");
  5964. string afterdate2 = GetPostString("afterdate2");
  5965. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5966. if (afterDate.Length > 0) lw.Add(afterDate);
  5967. string supplier = GetPostString("supplier");
  5968. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5969. string responsible = GetPostString("responsibleman");
  5970. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5971. string customer = GetPostString("customer");
  5972. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5973. string design = GetPostString("design");
  5974. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5975. string afterSaleMemo = GetPostString("afterSaleMemo");
  5976. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5977. string afterMemoType = GetPostString("aftermemotype");
  5978. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5979. string afterresult = GetPostString("afterresult");
  5980. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5981. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5982. string poscode = CurrentUser.UserPost.Post.Code;
  5983. if (poscode != "SysAdmin")
  5984. {
  5985. string shopid = CurrentUser.User.pemShop;
  5986. lw.Add(string.Format("shopId in ({0})", shopid));
  5987. }
  5988. string searchType = GetPostString("searchType");
  5989. if (searchType == "wait")
  5990. {
  5991. lw.Add(string.Format("HandleTime is null"));
  5992. }
  5993. if (searchType == "documentary")
  5994. {
  5995. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5996. }
  5997. if (searchType == "handling")
  5998. {
  5999. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6000. }
  6001. if (searchType == "back" || searchType == "puBack")
  6002. {
  6003. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6004. }
  6005. if (searchType == "reBack")
  6006. {
  6007. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6008. }
  6009. if (afterState.Length <= 0)
  6010. {
  6011. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6012. }
  6013. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6015. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6016. writeGridDataTableJson(dStruct.TotalCount, dt);
  6017. }
  6018. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6019. //public void get_erp_back_handlingaftersalelist()
  6020. //{
  6021. // DataStruct dStruct = GetPostStruct();
  6022. // List<string> lw = new List<string>();
  6023. // string tid = GetPostString("ctid");
  6024. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6025. // string shopname = GetPostString("shopname");
  6026. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6027. // string buyernick = GetPostString("buyer_nick");
  6028. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6029. // string sellermemo = GetPostString("seller_memo");
  6030. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6031. // string orderState = GetPostString("orderState");
  6032. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6033. // string afterState = GetPostString("afterstate");
  6034. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6035. // string date1 = GetPostString("date1");
  6036. // string date2 = GetPostString("date2");
  6037. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6038. // if (dw.Length > 0) lw.Add(dw);
  6039. // string price1 = GetPostString("price1");
  6040. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6041. // string price2 = GetPostString("price2");
  6042. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6043. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6044. // string reason = GetPostString("reason");
  6045. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6046. // string method = GetPostString("method");
  6047. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6048. // string handler = GetPostString("handler");
  6049. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6050. // string handledate1 = GetPostString("handledate1");
  6051. // string handledate2 = GetPostString("handledate2");
  6052. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6053. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6054. // string afterdate1 = GetPostString("afterdate1");
  6055. // string afterdate2 = GetPostString("afterdate2");
  6056. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6057. // if (afterDate.Length > 0) lw.Add(afterDate);
  6058. // string supplier = GetPostString("supplier");
  6059. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6060. // string responsible = GetPostString("responsibleman");
  6061. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6062. // string customer = GetPostString("customer");
  6063. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6064. // string design = GetPostString("design");
  6065. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6066. // string afterMemoType = GetPostString("aftermemotype");
  6067. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6068. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6069. // if (afterState.Length <= 0)
  6070. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6071. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6072. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6073. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6074. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6075. //}
  6076. public void get_erp_aftersaleverifylist()
  6077. {
  6078. DataStruct dStruct = GetPostStruct();
  6079. List<string> lw = new List<string>();
  6080. string tid = GetPostString("ctid");
  6081. if (tid.Length > 0)
  6082. {
  6083. string select_tid = getTidByCtid(tid);
  6084. lw.Add(string.Format("tid='{0}'", select_tid));
  6085. }
  6086. string shopname = GetPostString("shopname");
  6087. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6088. string buyernick = GetPostString("buyer_nick");
  6089. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6090. string sellermemo = GetPostString("seller_memo");
  6091. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6092. string orderState = GetPostString("orderState");
  6093. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6094. //lw.Add(string.Format("IsRefund!={0}", 1));
  6095. string reason = GetPostString("reason");
  6096. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6097. string method = GetPostString("method");
  6098. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6099. string handler = GetPostString("handler");
  6100. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6101. string handledate1 = GetPostString("handledate1");
  6102. string handledate2 = GetPostString("handledate2");
  6103. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6104. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6105. string finish1 = GetPostString("finishdate1");
  6106. string finish2 = GetPostString("finishdate2");
  6107. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6108. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6109. string supplier = GetPostString("supplier");
  6110. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6111. string responsible = GetPostString("responsibleman");
  6112. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6113. string posCode = CurrentUser.UserPost.Post.Code;
  6114. string vstate = GetPostString("vstate");
  6115. if (vstate.Length > 0)
  6116. {
  6117. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6118. }
  6119. if (posCode == "Supplier")
  6120. {
  6121. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6122. lw.Add(string.Format("VerifyState = 0"));
  6123. lw.Add("type = 1");
  6124. lw.Add(string.Format("AfterSaleState={0}", 3));
  6125. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6126. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6127. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6128. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6129. writeGridDataTableJson(dStruct.TotalCount, dt);
  6130. }
  6131. else if (posCode == "logistics")
  6132. {
  6133. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6134. lw.Add(string.Format("VerifyState = 0"));
  6135. lw.Add("type = 2");
  6136. lw.Add(string.Format("AfterSaleState={0}", 3));
  6137. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6138. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6139. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6140. writeGridDataTableJson(dStruct.TotalCount, dt);
  6141. }
  6142. else
  6143. {
  6144. lw.Add(string.Format("(AfterSaleState = 3)"));
  6145. string reasonState = GetPostString("reasonState");
  6146. lw.Add("type = 0");
  6147. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6148. || posCode == "Summarize" || posCode == "Finance")
  6149. {
  6150. if (reasonState == "2")
  6151. {
  6152. lw.Add("VerifyState = 3");
  6153. }
  6154. else if (reasonState == "1")
  6155. {
  6156. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6157. }
  6158. else
  6159. {
  6160. lw.Add("VerifyState in (0,3)");
  6161. }
  6162. //不加条件,可以看全部
  6163. }
  6164. 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")
  6165. {
  6166. int orgid = CurrentUser.UserPost.OrgID;
  6167. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6168. if (string.IsNullOrEmpty(manageOrgId))
  6169. {
  6170. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6171. }
  6172. else
  6173. {
  6174. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6175. }
  6176. if (reasonState == "1")
  6177. {
  6178. lw.Add("VerifyState = 3");
  6179. }
  6180. else if (reasonState == "2")
  6181. {
  6182. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6183. }
  6184. else
  6185. {
  6186. }
  6187. }
  6188. else
  6189. {
  6190. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6191. }
  6192. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6193. //{
  6194. // int org_id = CurrentUser.UserPost.OrgID;
  6195. // lw.Add(string.Format("OrgID={0}", org_id));
  6196. //}
  6197. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6198. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6199. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6200. writeGridDataTableJson(dStruct.TotalCount, dt);
  6201. }
  6202. }
  6203. public void get_erp_finishaftersalelist()
  6204. {
  6205. DataStruct dStruct = GetPostStruct();
  6206. List<string> lw = new List<string>();
  6207. int st = 4;
  6208. string tid = GetPostString("ctid");
  6209. if (tid.Length > 0)
  6210. {
  6211. string select_tid = getTidByCtid(tid);
  6212. lw.Add(string.Format("tid='{0}'", select_tid));
  6213. }
  6214. string shopname = GetPostString("shopname");
  6215. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6216. //lw.Add(string.Format("IsRefund!={0}", 1));
  6217. string reason = GetPostString("reason");
  6218. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6219. string method = GetPostString("method");
  6220. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6221. string buyernick = GetPostString("buyer_nick");
  6222. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6223. string handler = GetPostString("handler");
  6224. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6225. string handledate1 = GetPostString("handledate1");
  6226. string handledate2 = GetPostString("handledate2");
  6227. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6228. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6229. string finish1 = GetPostString("finishdate1");
  6230. string finish2 = GetPostString("finishdate2");
  6231. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6232. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6233. string supplier = GetPostString("supplier");
  6234. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6235. string responsible = GetPostString("responsibleman");
  6236. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6237. string vstate = GetPostString("vstate");
  6238. if (vstate.Length > 0)
  6239. {
  6240. if ("3".Equals(vstate))
  6241. {
  6242. lw.Add(string.Format("IsTem=1"));
  6243. }
  6244. else
  6245. {
  6246. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6247. }
  6248. }
  6249. lw.Add(string.Format("AfterSaleState=4"));
  6250. string code = CurrentUser.UserPost.Post.Code;
  6251. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6252. {
  6253. //不加条件,可以看全部
  6254. }
  6255. else if (code == "Supplier")
  6256. {
  6257. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6258. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6259. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6260. }
  6261. else if (code == "logistics")
  6262. {
  6263. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6264. lw.Add("type = 2");
  6265. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6266. }
  6267. 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")
  6268. {
  6269. int orgid = CurrentUser.UserPost.OrgID;
  6270. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6271. if (string.IsNullOrEmpty(manageOrgIds))
  6272. {
  6273. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6274. }
  6275. else
  6276. {
  6277. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6278. }
  6279. }
  6280. else
  6281. {
  6282. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6283. }
  6284. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6285. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6286. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6287. writeGridDataTableJson(dStruct.TotalCount, dt);
  6288. }
  6289. public void handle_erp_aftersale()
  6290. {
  6291. if (UrlPostParmsCheck("ctid"))
  6292. {
  6293. string eid = GetPostString("ctid");
  6294. string responStr = GetPostString("AfterSaleResponsible");
  6295. if (responStr.Length <= 0)
  6296. {
  6297. returnErrorMsg("售后责任人不能为空");
  6298. return;
  6299. }
  6300. bool isDesign = false;
  6301. double designFree = 0.00;
  6302. int responsibleId = 0;
  6303. CeErpTradeCell entity = null;
  6304. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6305. if (entity != null)
  6306. {
  6307. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6308. string afterMethod = GetPostString("AfterSaleMethod");
  6309. if (isNeedNewOrder == 1)
  6310. {
  6311. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6312. bool ishav = true;
  6313. if (newentity == null)
  6314. {
  6315. newentity = entity.Clone() as CeErpTradeCell;
  6316. ishav = false;
  6317. newentity.ctid = "S_" + entity.ctid;
  6318. newentity.OrderState = 0;
  6319. //唯一标识
  6320. newentity.OrderSn = newentity.ctid;
  6321. string orderSn = dataHelper.getSaleOrderSn();
  6322. if (orderSn != "")
  6323. {
  6324. newentity.OrderSn = orderSn;
  6325. }
  6326. }
  6327. newentity.UpdateTime = DateTime.Now;
  6328. newentity.AfterSaleState = 0;
  6329. newentity.AfterSaleMethod = afterMethod;
  6330. if (!ishav)
  6331. {
  6332. string memo_str = newentity.seller_memo;
  6333. memo_str = memo_str.Replace("(", "(");
  6334. memo_str = memo_str.Replace(")", ")");
  6335. int sIndex = memo_str.IndexOf("(");
  6336. int eIndex = memo_str.IndexOf(")");
  6337. if (sIndex == -1 || eIndex == -1)
  6338. {
  6339. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6340. return;
  6341. }
  6342. string first = memo_str.Substring(0, sIndex + 1);
  6343. string memoCtid = newentity.OrderSn;
  6344. //if (memoCtid.IndexOf("C") != -1)
  6345. //{
  6346. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6347. //if (CIdx.IndexOf("+") != -1)
  6348. //{
  6349. //CIdx = "C" + CIdx.Split('+')[1];
  6350. //}
  6351. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6352. //}
  6353. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6354. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6355. string newMemo = first + memoCtid + last;
  6356. newentity.seller_memo = newMemo;
  6357. newentity.FinishPlaceTime = null;
  6358. newentity.UnusualTag = 0;
  6359. newentity.UnusualCon = "";
  6360. newentity.UnusualTime = null;
  6361. newentity.AfterSaleMemo = "";
  6362. newentity.AfterSaleMethod = afterMethod;
  6363. newentity.AfterSalePreTime = null;
  6364. newentity.AfterSaleReason = "";
  6365. newentity.AfterSaleResponsible = "";
  6366. newentity.AfterSaleState = 0;
  6367. newentity.AfterSaleTime = null;
  6368. newentity.AfterSaleUserId = 0;
  6369. newentity.AfterSaleSupplierState = 0;
  6370. newentity.LastBillWaybillCode = "";
  6371. newentity.LastBillCpCode = "";
  6372. newentity.FinishAfterSaleTime = null;
  6373. newentity.HandleTime = null;
  6374. newentity.IsSF = 0;
  6375. newentity.IsOldCustomer = 0;
  6376. newentity.UrgencyTime = null;
  6377. newentity.ResponsibleUserId = "";
  6378. newentity.IsVerifyToSupplier = false;
  6379. newentity.payment = 0;
  6380. newentity.CheckMemo = "";
  6381. newentity.OutSid = "";
  6382. newentity.CheckOrderTime = null;
  6383. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6384. }
  6385. newentity.isAfterSaleOrder = 1;
  6386. newentity.IsRefund = 0;
  6387. string receiveMobile = GetPostString("receiver_mobile");
  6388. if (receiveMobile.Length > 0)
  6389. {
  6390. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6391. if (trade != null)
  6392. {
  6393. trade.receiver_name = GetPostString("receiver_name");
  6394. trade.receiver_mobile = receiveMobile;
  6395. trade.receiver_state = GetPostString("receiver_state");
  6396. trade.receiver_city = GetPostString("receiver_city");
  6397. trade.receiver_district = GetPostString("receiver_district");
  6398. trade.receiver_address = GetPostString("receiver_address");
  6399. newentity.IsOffLineOrder = 1;
  6400. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6401. }
  6402. }
  6403. string st = GetPostString("ToState");
  6404. if (st.Length > 0)
  6405. {
  6406. if (newentity.OrderState <= 3)
  6407. {
  6408. newentity.WaitDesignTime = DateTime.Now;
  6409. newentity.StartDesignTime = null;
  6410. newentity.FinishDesignTime = null;
  6411. newentity.OrderState = 3;
  6412. if (st == "下单员")
  6413. {
  6414. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6415. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6416. {
  6417. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6418. }
  6419. }
  6420. else
  6421. {
  6422. newentity.WaitDesignTime = DateTime.Now;
  6423. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6424. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6425. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6426. {
  6427. DataRow user = dt1.Rows[0];
  6428. //找主管
  6429. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6430. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6431. if (dt != null && dt.Rows.Count > 0)
  6432. {
  6433. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6434. newentity.DesignUserId = designMr;
  6435. string key = "aftersale_order_" + designMr;
  6436. if (RedisHelper.HasKey(key))
  6437. {
  6438. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6439. list.Add(newentity.ctid);
  6440. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6441. }
  6442. }
  6443. //账号正常
  6444. if (user["State"].ToString() == "0")
  6445. {
  6446. newentity.DesignUserId = entity.DesignUserId;
  6447. string key = "aftersale_order_" + entity.DesignUserId;
  6448. if (RedisHelper.HasKey(key))
  6449. {
  6450. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6451. list.Add(newentity.ctid);
  6452. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6453. }
  6454. }
  6455. }
  6456. }
  6457. }
  6458. if (entity.IsXianHuo == 1)
  6459. {
  6460. newentity.OrderState = 6;
  6461. entity.FinishPlaceTime = DateTime.Now;
  6462. }
  6463. }
  6464. if (ishav)
  6465. {
  6466. newentity.Update();
  6467. }
  6468. else
  6469. {
  6470. newentity.Create();
  6471. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6472. newCellExtend.ctid = newentity.ctid;
  6473. newCellExtend.orderFrom = 20;
  6474. newCellExtend.orderType = 30;
  6475. if (st == "下单员")
  6476. {
  6477. }
  6478. else
  6479. {
  6480. newCellExtend.ReprintTime = DateTime.Now;
  6481. }
  6482. newCellExtend.Create();
  6483. }
  6484. if (st != "下单员")
  6485. {
  6486. designHelper.API_GetPrintData_CreateOrder(newentity);
  6487. }
  6488. }
  6489. //处理售后扩展
  6490. string resIdStr = GetPostString("ResponsibleUserId");
  6491. string refundFees = GetPostString("refundFrees");
  6492. int IsComplain = GetPostInt("isComplain");
  6493. int IsBad = GetPostInt("isBad");
  6494. string IsOriginal = GetPostString("isOriginal");
  6495. double diffResultPrice = GetPostDouble("diffResultPrice");
  6496. string textResult = GetPostString("textResult");
  6497. string supplierResponsible = GetPostString("supplierResponsible");
  6498. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6499. if (ceErpTradeAfterSaleExtend == null)
  6500. {
  6501. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6502. ceErpTradeAfterSaleExtend.tid = eid;
  6503. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6504. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6505. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6506. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6507. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6508. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6509. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6510. ceErpTradeAfterSaleExtend.Create();
  6511. }
  6512. else
  6513. {
  6514. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6515. {
  6516. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6517. }
  6518. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6519. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6520. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6521. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6522. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6523. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6524. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6525. ceErpTradeAfterSaleExtend.Update();
  6526. }
  6527. int gysid = GetPostInt("ResponsibleSupId");
  6528. if (entity.AfterSaleUserId == 0)
  6529. {
  6530. entity.AfterSaleUserId = CurrentUser.UserID;
  6531. }
  6532. entity.ResponsibleUserId = resIdStr;
  6533. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6534. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6535. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6536. {
  6537. CeErpTradeResponsible.DelByTid(eid, -1);
  6538. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6539. int backNum = 0;
  6540. if (number != null)
  6541. {
  6542. backNum = number.BackNum;
  6543. }
  6544. char[] separator = { ',' };
  6545. string[] sArray = resIdStr.Split(separator);
  6546. string[] refundFreeList = { };
  6547. if (refundFees.Length > 0)
  6548. {
  6549. refundFreeList = refundFees.Split(separator);
  6550. }
  6551. int index = -1;
  6552. foreach (string i in sArray)
  6553. {
  6554. index++;
  6555. if (i.Length <= 0) continue;
  6556. char[] separator2 = { '_' };
  6557. string idstr = i.Split(separator2)[0];
  6558. string idtype = i.Split(separator2)[1];
  6559. double refudFree = 0;
  6560. if (refundFreeList.Length > 0)
  6561. {
  6562. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6563. }
  6564. if (idtype == "s")
  6565. {
  6566. isDesign = true;
  6567. designFree = refudFree;
  6568. }
  6569. int userId = Convert.ToInt32(idstr);
  6570. int type = 0;
  6571. if (idtype == "g")
  6572. {
  6573. type = 1;
  6574. }
  6575. if (idtype == "w")
  6576. {
  6577. type = 2;
  6578. }
  6579. if (idtype == "t")
  6580. {
  6581. type = 3;
  6582. }
  6583. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6584. if (ceErpTradeResponsible == null)
  6585. {
  6586. ceErpTradeResponsible = new CeErpTradeResponsible();
  6587. ceErpTradeResponsible.tid = eid;
  6588. ceErpTradeResponsible.UserId = userId;
  6589. ceErpTradeResponsible.createdTime = DateTime.Now;
  6590. ceErpTradeResponsible.type = type;
  6591. if (type == 1)
  6592. {
  6593. ceErpTradeResponsible.IsSup = 1;
  6594. }
  6595. if (type == 2)
  6596. {
  6597. ceErpTradeResponsible.IsFlow = 1;
  6598. }
  6599. }
  6600. ceErpTradeResponsible.RefundFee = refudFree;
  6601. ceErpTradeResponsible.VerifyState = 0;
  6602. if (userId == 2125 || idtype == "w")
  6603. {
  6604. ceErpTradeResponsible.VerifyState = 1;
  6605. }
  6606. if (idtype == "w" && userId == 101)
  6607. {
  6608. ceErpTradeResponsible.VerifyState = 0;
  6609. }
  6610. if (ceErpTradeResponsible.ID > 0)
  6611. {
  6612. ceErpTradeResponsible.Update();
  6613. }
  6614. else
  6615. {
  6616. ceErpTradeResponsible.Create();
  6617. }
  6618. if (isDesign)
  6619. {
  6620. responsibleId = ceErpTradeResponsible.ID;
  6621. }
  6622. }
  6623. CeErpTradeResponsible.NumByTid(backNum, eid);
  6624. }
  6625. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6626. if (ceErpTradeCellExtend != null)
  6627. {
  6628. ceErpTradeCellExtend.returnVisit = 0;
  6629. ceErpTradeCellExtend.Update();
  6630. }
  6631. if (entity.HandleTime != null)
  6632. {
  6633. if (entity.AfterSaleState == 1)
  6634. {
  6635. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6636. }
  6637. else
  6638. {
  6639. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6640. }
  6641. }
  6642. else
  6643. {
  6644. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6645. entity.HandleTime = DateTime.Now;
  6646. }
  6647. bool isCompale = false;
  6648. if (entity.AfterSaleState == 5)
  6649. {
  6650. isCompale = true;
  6651. entity.AfterSaleState = 3;
  6652. }
  6653. entity.AfterSaleSupplierState = 0;
  6654. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6655. {
  6656. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6657. }
  6658. string sImgs = GetPostString("img");
  6659. entity.AfterSaleSupplierImg = sImgs;
  6660. entity.supRefundType = GetPostString("supRefundType");
  6661. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6662. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6663. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6664. entity.AfterSaleMemoType = GetPostString("MemoType");
  6665. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6666. {
  6667. //entity.AfterSaleSupplierState = 2;
  6668. }
  6669. string df = GetPostString("DeductFee");
  6670. if (df == "")
  6671. {
  6672. df = "0";
  6673. }
  6674. string rf = GetPostString("RefundFee");
  6675. if (rf == "")
  6676. {
  6677. rf = "0";
  6678. }
  6679. string pm = GetPostString("AfterSalePayment");
  6680. if (pm == "")
  6681. {
  6682. pm = "0";
  6683. }
  6684. entity.AfterSalePayment = Convert.ToDouble(pm);
  6685. entity.DeductFee = Convert.ToDouble(df);
  6686. entity.RefundFee = Convert.ToDouble(rf);
  6687. entity.UpdateTime = DateTime.Now;
  6688. entity.Update();
  6689. string toState = GetPostString("ToState");
  6690. string original = GetPostString("isOriginal");
  6691. ApiVo apiVo = new ApiVo();
  6692. apiVo.orderNumber = entity.ctid;
  6693. apiVo.actionName = "afterDesign";
  6694. apiVo.orderRemarks = entity.AfterSaleMethod;
  6695. apiVo.reasonRemarks = entity.AfterSaleReason;
  6696. apiVo.isDesign = isDesign;
  6697. apiVo.designFree = designFree;
  6698. apiVo.responsibleId = responsibleId;
  6699. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6700. if (toState == "设计师")
  6701. {
  6702. apiVo.isOriginal = Convert.ToBoolean(original);
  6703. }
  6704. designHelper.API_WorkCore(apiVo);//afterDesign
  6705. CeErpMethod methodSql = new CeErpMethod();
  6706. methodSql.con = entity.AfterSaleMethod;
  6707. methodSql.addTime = DateTime.Now;
  6708. methodSql.Create();
  6709. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6710. CeErpMethod.ExecuteNonQuery(delsql);
  6711. if (isCompale)
  6712. {
  6713. aftersale_data_change(entity.ctid);
  6714. }
  6715. returnSuccessMsg("操作成功!");
  6716. return;
  6717. }
  6718. returnErrorMsg("找不到订单记录");
  6719. }
  6720. }
  6721. public void ins_erp_toresponsible()
  6722. {
  6723. if (UrlPostParmsCheck("ctid"))
  6724. {
  6725. string eid = GetPostString("ctid");
  6726. CeErpTradeCell entity = null;
  6727. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6728. if (entity != null)
  6729. {
  6730. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6731. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6732. {
  6733. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6734. return;
  6735. }
  6736. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6737. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6738. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6739. if (entity.AfterSalePreTime == null)
  6740. {
  6741. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6742. {
  6743. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6744. }
  6745. }
  6746. entity.AfterSalePreTime = DateTime.Now;
  6747. //预完成给售后主管审核客户问题直接完成
  6748. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6749. {
  6750. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6751. {
  6752. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6753. }
  6754. }
  6755. ceErpTradeAfterSaleExtend.Update();
  6756. entity.AfterSaleState = 2;
  6757. entity.UpdateTime = DateTime.Now;
  6758. entity.Update();
  6759. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6760. aftersale_data_change(entity.ctid);
  6761. returnSuccessMsg("操作成功!");
  6762. return;
  6763. }
  6764. returnErrorMsg("找不到订单记录");
  6765. }
  6766. }
  6767. public void cancel_erp_aftersaleanddelnew()
  6768. {
  6769. if (UrlPostParmsCheck("ctid"))
  6770. {
  6771. string eid = GetPostString("ctid");
  6772. CeErpTradeCell entity = null;
  6773. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6774. if (entity != null)
  6775. {
  6776. entity.AfterSaleState = 0;
  6777. entity.AfterSaleReason = "";
  6778. entity.AfterSaleMethod = "";
  6779. entity.AfterSaleMemo = "";
  6780. entity.AfterSaleResponsible = "";
  6781. entity.ResponsibleUserId = "";
  6782. entity.DeductFee = 0;
  6783. entity.RefundFee = 0;
  6784. entity.IsArbitrate = 0;
  6785. CeErpTradeResponsible.DelByTid(eid, -1);
  6786. entity.Update();
  6787. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6788. if (after != null)
  6789. {
  6790. if (after.OrderState < 5)
  6791. CeErpTradeCell.DelByCtid("S_" + eid);
  6792. }
  6793. returnSuccessMsg("操作成功!");
  6794. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6795. return;
  6796. }
  6797. returnErrorMsg("找不到订单记录");
  6798. }
  6799. }
  6800. public void get_erp_aftersale_pregather()
  6801. {
  6802. List<string> lw = new List<string>();
  6803. int st = GetInt("st");
  6804. string tid = GetPostString("ctid");
  6805. if (tid.Length > 0)
  6806. {
  6807. string select_tid = getTidByCtid(tid);
  6808. lw.Add(string.Format("tid='{0}'", select_tid));
  6809. }
  6810. string shopname = GetPostString("shopname");
  6811. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6812. string buyernick = GetPostString("buyer_nick");
  6813. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6814. string sellermemo = GetPostString("seller_memo");
  6815. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6816. string orderState = GetPostString("orderState");
  6817. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6818. string reason = GetPostString("reason");
  6819. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6820. string method = GetPostString("method");
  6821. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6822. string handler = GetPostString("handler");
  6823. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6824. string handledate1 = GetPostString("handledate1");
  6825. string handledate2 = GetPostString("handledate2");
  6826. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6827. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6828. string supplier = GetPostString("supplier");
  6829. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6830. string responsible = GetPostString("responsibleman");
  6831. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6832. string customer = GetPostString("customer");
  6833. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6834. string design = GetPostString("design");
  6835. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6836. string afterMemoType = GetPostString("aftermemotype");
  6837. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6838. string afterSaleMemo = GetPostString("afterSaleMemo");
  6839. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6840. string afterresult = GetPostString("afterresult");
  6841. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6842. string poscode = CurrentUser.UserPost.Post.Code;
  6843. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6844. {
  6845. string shopid = CurrentUser.User.pemShop;
  6846. lw.Add(string.Format("shopId in ({0})", shopid));
  6847. }
  6848. var mainwhere = string.Join(" and ", lw.ToArray());
  6849. string ro_json = "";
  6850. string type = GetPostString("gather_type");
  6851. int number = 0;
  6852. if (poscode == "AfterSale")
  6853. {
  6854. //处理中
  6855. if (type == "Handling")
  6856. {
  6857. 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) : ""));
  6858. DataTable dt = null;
  6859. try
  6860. {
  6861. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6862. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6863. }
  6864. catch (Exception e)
  6865. {
  6866. dt = new DataTable();
  6867. }
  6868. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6869. return;
  6870. }
  6871. if (type == "Wait")
  6872. {
  6873. //待处理
  6874. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6875. DataTable dt1 = null;
  6876. try
  6877. {
  6878. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6879. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6880. }
  6881. catch (Exception e)
  6882. {
  6883. dt1 = new DataTable();
  6884. }
  6885. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6886. return;
  6887. }
  6888. if (type == "back")
  6889. {
  6890. //打回
  6891. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6892. DataTable dt2 = null;
  6893. try
  6894. {
  6895. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6896. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6897. }
  6898. catch (Exception e)
  6899. {
  6900. dt2 = new DataTable();
  6901. }
  6902. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6903. return;
  6904. }
  6905. if (type == "preCompletion")
  6906. {
  6907. //预完成
  6908. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6909. DataTable dt3 = null;
  6910. try
  6911. {
  6912. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6913. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6914. }
  6915. catch (Exception e)
  6916. {
  6917. dt3 = new DataTable();
  6918. }
  6919. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6920. return;
  6921. }
  6922. if (type == "documentary")
  6923. {
  6924. //跟单中
  6925. 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) : ""));
  6926. DataTable dt4 = null;
  6927. try
  6928. {
  6929. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6930. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6931. }
  6932. catch (Exception e)
  6933. {
  6934. dt4 = new DataTable();
  6935. }
  6936. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6937. return;
  6938. }
  6939. if (type == "reBack")
  6940. {
  6941. //被打回
  6942. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6943. DataTable dt1 = null;
  6944. try
  6945. {
  6946. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6947. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6948. }
  6949. catch (Exception e)
  6950. {
  6951. dt1 = new DataTable();
  6952. }
  6953. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6954. return;
  6955. }
  6956. }
  6957. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6958. {
  6959. if (type == "puBack")
  6960. {
  6961. //退回
  6962. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6963. DataTable dt = null;
  6964. try
  6965. {
  6966. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6967. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6968. }
  6969. catch (Exception e)
  6970. {
  6971. dt = new DataTable();
  6972. }
  6973. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6974. return;
  6975. }
  6976. if (type == "reBack")
  6977. {
  6978. //打回
  6979. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6980. DataTable dt1 = null;
  6981. try
  6982. {
  6983. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6984. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6985. }
  6986. catch (Exception e)
  6987. {
  6988. dt1 = new DataTable();
  6989. }
  6990. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6991. return;
  6992. }
  6993. if (type == "examEd")
  6994. {
  6995. //已审核
  6996. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6997. DataTable dt2 = null;
  6998. try
  6999. {
  7000. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7001. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7002. }
  7003. catch (Exception e)
  7004. {
  7005. dt2 = new DataTable();
  7006. }
  7007. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7008. return;
  7009. }
  7010. if (type == "waitExam")
  7011. {
  7012. //待审核
  7013. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7014. DataTable dt3 = null;
  7015. try
  7016. {
  7017. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7018. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7019. }
  7020. catch (Exception e)
  7021. {
  7022. dt3 = new DataTable();
  7023. }
  7024. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7025. return;
  7026. }
  7027. if (type == "Handling")
  7028. {
  7029. //处理中
  7030. 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) : ""));
  7031. DataTable dt4 = null;
  7032. try
  7033. {
  7034. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7035. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7036. }
  7037. catch (Exception e)
  7038. {
  7039. dt4 = new DataTable();
  7040. }
  7041. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7042. return;
  7043. }
  7044. if (type == "Wait")
  7045. {
  7046. //待处理
  7047. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7048. DataTable dt5 = null;
  7049. try
  7050. {
  7051. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7052. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7053. }
  7054. catch (Exception e)
  7055. {
  7056. dt5 = new DataTable();
  7057. }
  7058. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7059. return;
  7060. }
  7061. if (type == "documentary")
  7062. {
  7063. //跟单中
  7064. 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) : ""));
  7065. DataTable dt6 = null;
  7066. try
  7067. {
  7068. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7069. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7070. }
  7071. catch (Exception e)
  7072. {
  7073. dt6 = new DataTable();
  7074. }
  7075. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7076. return;
  7077. }
  7078. }
  7079. returnSuccess(ro_json);
  7080. }
  7081. public void end_erp_aftersale()
  7082. {
  7083. if (UrlPostParmsCheck("ctid"))
  7084. {
  7085. string eid = GetPostString("ctid");
  7086. CeErpTradeCell entity = null;
  7087. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7088. if (entity != null)
  7089. {
  7090. string stype = GetPostString("stype");
  7091. string typeStr = stype;
  7092. entity.AfterSaleState = 4;
  7093. entity.FinishAfterSaleTime = DateTime.Now;
  7094. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7095. entity.Update();
  7096. ApiVo apiVo = new ApiVo();
  7097. apiVo.orderNumber = entity.ctid;
  7098. apiVo.actionName = "afterOver";
  7099. designHelper.API_WorkCore(apiVo); //afterOver
  7100. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7101. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7102. CeErpSukuraData.createInfo(entity.ctid, 8);
  7103. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7104. returnSuccessMsg("操作成功!");
  7105. return;
  7106. }
  7107. returnErrorMsg("找不到订单记录");
  7108. }
  7109. }
  7110. public void ins_erp_finishaftersale()
  7111. {
  7112. if (UrlPostParmsCheck("id"))
  7113. {
  7114. string eid = GetPostString("id");
  7115. CeErpTradeResponsible entity = null;
  7116. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7117. if (entity != null)
  7118. {
  7119. entity.VerifyState = 1;
  7120. entity.VerifyTime = DateTime.Now;
  7121. entity.Update();
  7122. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7123. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7124. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7125. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7126. if (dt.Rows.Count <= 0)
  7127. {
  7128. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7129. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7130. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7131. CeErpSukuraData.createInfo(entity.tid, 8);
  7132. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7133. {
  7134. CeErpDesignerBill.Del(entity.tid);
  7135. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7136. }
  7137. }
  7138. returnSuccessMsg("操作成功!");
  7139. return;
  7140. }
  7141. returnErrorMsg("找不到订单记录");
  7142. }
  7143. }
  7144. public void upd_erp_arbitrateaftersale()
  7145. {
  7146. if (UrlPostParmsCheck("id"))
  7147. {
  7148. string eid = GetPostString("id");
  7149. CeErpTradeResponsible entity = null;
  7150. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7151. if (entity != null)
  7152. {
  7153. entity.IsArbitrate = 1;
  7154. entity.ArbitradeMemo = GetPostString("reason");
  7155. entity.VerifyState = 2;
  7156. entity.Update();
  7157. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7158. if (tradecell != null)
  7159. {
  7160. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7161. tradecell.IsArbitrate = 1;
  7162. tradecell.Update();
  7163. }
  7164. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7165. returnSuccessMsg("操作成功!");
  7166. return;
  7167. }
  7168. returnErrorMsg("找不到订单记录");
  7169. }
  7170. }
  7171. public void upd_erp_backaftersale()
  7172. {
  7173. if (UrlPostParmsCheck("tid"))
  7174. {
  7175. string eid = GetPostString("tid");
  7176. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7177. int backNum = 0;
  7178. if (number != null)
  7179. {
  7180. backNum = number.BackNum;
  7181. }
  7182. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7183. CeErpTradeCell entity = null;
  7184. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7185. if (entity != null)
  7186. {
  7187. entity.AfterSaleBackReason = GetPostString("backreason");
  7188. entity.AfterSaleState = 1;
  7189. entity.AfterSaleSupplierState = 0;
  7190. entity.UpdateTime = DateTime.Now;
  7191. entity.Update();
  7192. returnSuccessMsg("操作成功!");
  7193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7194. return;
  7195. }
  7196. returnErrorMsg("找不到订单记录");
  7197. }
  7198. }
  7199. public void get_erp_supplieraftersalelist()
  7200. {
  7201. DataStruct dStruct = GetPostStruct();
  7202. List<string> lw = new List<string>();
  7203. string tid = GetPostString("ctid");
  7204. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7205. string shopname = GetPostString("shopname");
  7206. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7207. string buyernick = GetPostString("buyer_nick");
  7208. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7209. string sellermemo = GetPostString("seller_memo");
  7210. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7211. string orderState = GetPostString("orderState");
  7212. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7213. string afterState = GetPostString("afterstate");
  7214. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7215. string date1 = GetPostString("date1");
  7216. string date2 = GetPostString("date2");
  7217. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7218. if (dw.Length > 0) lw.Add(dw);
  7219. string price1 = GetPostString("price1");
  7220. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7221. string price2 = GetPostString("price2");
  7222. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7223. string reason = GetPostString("reason");
  7224. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7225. string method = GetPostString("method");
  7226. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7227. string handledate1 = GetPostString("handledate1");
  7228. string handledate2 = GetPostString("handledate2");
  7229. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7230. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7231. string handler = GetPostString("handler");
  7232. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7233. string afterdate1 = GetPostString("afterdate1");
  7234. string afterdate2 = GetPostString("afterdate2");
  7235. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7236. if (afterDate.Length > 0) lw.Add(afterDate);
  7237. string customer = GetPostString("customer");
  7238. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7239. string design = GetPostString("design");
  7240. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7241. string afterMemoType = GetPostString("aftermemotype");
  7242. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7243. string vstate = GetPostString("vstate");
  7244. if (vstate.Length > 0)
  7245. {
  7246. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7247. }
  7248. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7249. string supplier = GetPostString("supplier");
  7250. int supid = commonHelper.getSupplierIDByName(supplier);
  7251. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7252. string posCode = CurrentUser.UserPost.Post.Code;
  7253. if (posCode == "Supplier")
  7254. {
  7255. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7256. }
  7257. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7258. {
  7259. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7260. }
  7261. else
  7262. {
  7263. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7264. }
  7265. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7266. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7267. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7268. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7269. writeGridDataTableJson(dStruct.TotalCount, dt);
  7270. }
  7271. public void upd_erp_supverifyaftersale()
  7272. {
  7273. if (UrlPostParmsCheck("id"))
  7274. {
  7275. string id = GetPostString("id");
  7276. int st = GetPostInt("afterstate");
  7277. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7278. CeErpTradeCell entity = null;
  7279. if (ceErpTradeResponsible != null)
  7280. {
  7281. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7282. }
  7283. string afmemo = GetPostString("supmemo");
  7284. string image = GetPostString("image");
  7285. if (entity != null)
  7286. {
  7287. entity.AfterSaleSupplierState = st;
  7288. entity.AfterSaleSupplierMemo = afmemo;
  7289. if (st == 1)
  7290. {
  7291. ceErpTradeResponsible.VerifyState = 1;
  7292. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7293. ceErpTradeResponsible.Update();
  7294. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7295. if (isAll)
  7296. {
  7297. entity.AfterSaleState = 4;
  7298. entity.FinishAfterSaleTime = DateTime.Now;
  7299. }
  7300. }
  7301. else
  7302. {
  7303. CeErpTradeResponsible.dateByTid(entity.ctid);
  7304. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7305. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7306. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7307. if (num <= 1)
  7308. {
  7309. entity.AfterSaleState = 1;
  7310. }
  7311. else
  7312. {
  7313. entity.AfterSaleState = 5;
  7314. }
  7315. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7316. if (ceErpTradeAfterSaleExtend != null)
  7317. {
  7318. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7319. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7320. ceErpTradeAfterSaleExtend.Update();
  7321. }
  7322. else
  7323. {
  7324. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7325. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7326. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7327. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7328. ceErpTradeAfterSaleExtend.Create();
  7329. }
  7330. }
  7331. if (entity.AfterSaleState == 4)
  7332. {
  7333. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7334. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7335. {
  7336. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7337. }
  7338. ApiVo apiVo = new ApiVo();
  7339. apiVo.orderNumber = entity.ctid;
  7340. apiVo.actionName = "afterOver";
  7341. designHelper.API_WorkCore(apiVo); //afterOver
  7342. }
  7343. entity.UpdateTime = DateTime.Now;
  7344. entity.Update();
  7345. returnSuccessMsg("操作成功!");
  7346. CeErpSukuraData.createInfo(entity.ctid, 8);
  7347. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7348. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7349. return;
  7350. }
  7351. returnErrorMsg("找不到订单记录");
  7352. }
  7353. }
  7354. public void upd_erp_masteraftersale()
  7355. {
  7356. if (UrlPostParmsCheck("id"))
  7357. {
  7358. string id = GetPostString("id");
  7359. int st = GetPostInt("afterstate");
  7360. string afmemo = GetPostString("supmemo");
  7361. string image = GetPostString("image");
  7362. string textResult = GetPostString("textResult");
  7363. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7364. if (ceErpTradeResponsible != null)
  7365. {
  7366. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7367. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7368. ceErpTradeResponsible.Update();
  7369. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7370. if (entity != null)
  7371. {
  7372. entity.AfterSaleSupplierState = st;
  7373. entity.AfterSaleSupplierMemo = afmemo;
  7374. if (st == 1)
  7375. {
  7376. }
  7377. else
  7378. {
  7379. CeErpTradeResponsible.dateByTid(entity.ctid);
  7380. //退回到售后
  7381. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7382. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7383. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7384. if (num <= 1)
  7385. {
  7386. entity.AfterSaleState = 1;
  7387. }
  7388. else
  7389. {
  7390. entity.AfterSaleState = 5;
  7391. }
  7392. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7393. if (ceErpTradeAfterSaleExtend != null)
  7394. {
  7395. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7396. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7397. ceErpTradeAfterSaleExtend.Update();
  7398. }
  7399. else
  7400. {
  7401. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7402. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7403. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7404. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7405. ceErpTradeAfterSaleExtend.Create();
  7406. }
  7407. }
  7408. entity.UpdateTime = DateTime.Now;
  7409. entity.Update();
  7410. returnSuccessMsg("操作成功!");
  7411. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7412. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7413. return;
  7414. }
  7415. }
  7416. returnErrorMsg("找不到订单记录");
  7417. }
  7418. }
  7419. public void upd_erp_personaftersale()
  7420. {
  7421. if (UrlPostParmsCheck("id"))
  7422. {
  7423. string id = GetPostString("id");
  7424. int st = GetPostInt("afterstate");
  7425. string afmemo = GetPostString("supmemo");
  7426. string image = GetPostString("image");
  7427. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7428. if (ceErpTradeResponsible != null)
  7429. {
  7430. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7431. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7432. ceErpTradeResponsible.Update();
  7433. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7434. if (entity != null)
  7435. {
  7436. entity.AfterSaleSupplierMemo = afmemo;
  7437. entity.AfterSaleSupplierState = st;
  7438. if (st == 1)
  7439. {
  7440. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7441. if (isAll)
  7442. {
  7443. entity.AfterSaleState = 4;
  7444. entity.FinishAfterSaleTime = DateTime.Now;
  7445. }
  7446. }
  7447. else
  7448. {
  7449. CeErpTradeResponsible.dateByTid(entity.ctid);
  7450. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7451. if (ceErpTradeAfterSaleExtend != null)
  7452. {
  7453. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7454. ceErpTradeAfterSaleExtend.Update();
  7455. }
  7456. else
  7457. {
  7458. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7459. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7460. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7461. ceErpTradeAfterSaleExtend.Create();
  7462. }
  7463. //退回到主管
  7464. //entity.AfterSaleState = 2;
  7465. }
  7466. if (entity.AfterSaleState == 4)
  7467. {
  7468. ApiVo apiVo = new ApiVo();
  7469. apiVo.orderNumber = entity.ctid;
  7470. apiVo.actionName = "afterOver";
  7471. designHelper.API_WorkCore(apiVo); //afterOver
  7472. }
  7473. entity.UpdateTime = DateTime.Now;
  7474. entity.Update();
  7475. returnSuccessMsg("操作成功!");
  7476. CeErpSukuraData.createInfo(entity.ctid, 8);
  7477. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7478. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7479. return;
  7480. }
  7481. }
  7482. returnErrorMsg("找不到订单记录");
  7483. }
  7484. }
  7485. public void set_erp_supplierrefundtag()
  7486. {
  7487. if (UrlPostParmsCheck("ctid"))
  7488. {
  7489. string eid = GetPostString("ctid");
  7490. CeErpTradeCell entity = null;
  7491. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7492. if (entity != null)
  7493. {
  7494. entity.IsSupplierRefund = GetPostInt("tag");
  7495. entity.Update();
  7496. returnSuccessMsg("操作成功!");
  7497. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7498. return;
  7499. }
  7500. returnErrorMsg("找不到订单记录");
  7501. }
  7502. }
  7503. public void get_erp_refundlist()
  7504. {
  7505. DataStruct dStruct = GetPostStruct();
  7506. List<string> lw = new List<string>();
  7507. string tid = GetPostString("tid");
  7508. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7509. //string rid = GetPostString("refund_id");
  7510. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7511. string shopname = GetPostString("shopname");
  7512. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7513. string buyernick = GetPostString("buyer_nick");
  7514. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7515. string customer = GetPostString("customer");
  7516. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7517. string design = GetPostString("design");
  7518. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7519. string sellermemo = GetPostString("seller_memo");
  7520. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7521. //string date1 = GetPostString("date1");
  7522. //string date2 = GetPostString("date2");
  7523. //string dateType = GetPostString("dateType");
  7524. //if (dateType.Length > 0)
  7525. //{
  7526. // if (dateType == "1001") dateType = "0";
  7527. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7528. // if (searchDT.Count == 2)
  7529. // {
  7530. // date1 = searchDT[0].ToString();
  7531. // date2 = searchDT[1].ToString();
  7532. // }
  7533. //}
  7534. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7535. //if (dw.Length > 0) lw.Add(dw);
  7536. string redate1 = GetPostString("refunddate1");
  7537. string redate2 = GetPostString("refunddate2");
  7538. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7539. if (dwdate.Length > 0) lw.Add(dwdate);
  7540. string price1 = GetPostString("price1");
  7541. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7542. string price2 = GetPostString("price2");
  7543. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7544. string ispartrefund = GetPostString("ispartrefund");
  7545. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7546. string refundState = GetPostString("refundvstate");
  7547. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7548. int st = GetInt("st");
  7549. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7550. {
  7551. string responsible = GetPostString("responsibleman");
  7552. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7553. lw.Add(string.Format("RefundState>={0}", st));
  7554. string code = CurrentUser.UserPost.Post.Code;
  7555. if (code == "CustomerService")
  7556. {
  7557. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7558. }
  7559. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7560. {
  7561. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7562. }
  7563. else if (code == "Place" || code == "PlaceMr")
  7564. {
  7565. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7566. }
  7567. dStruct.Order = "RefundState asc,created desc";
  7568. }
  7569. else if (st == 10)
  7570. {
  7571. string responsible = GetPostString("responsibleman");
  7572. if (responsible == "空白")
  7573. {
  7574. lw.Add(string.Format("ResponsibleUserName = ''"));
  7575. }
  7576. else if (responsible.Length > 0)
  7577. {
  7578. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7579. }
  7580. lw.Add(string.Format("RefundState>=0"));
  7581. dStruct.Order = "created desc";
  7582. }
  7583. else
  7584. {
  7585. string responsible = GetPostString("responsibleman");
  7586. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7587. lw.Add(string.Format("RefundState={0}", st));
  7588. dStruct.Order = "created desc";
  7589. }
  7590. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7591. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7592. dt.Columns.Add("refund_fees");
  7593. foreach (DataRow dr in dt.Rows)
  7594. {
  7595. String status = dr["status"].ToString();
  7596. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7597. {
  7598. dr["refund_fees"] = dr["refund_fee"];
  7599. }
  7600. else
  7601. {
  7602. dr["refund_fees"] = "0.0";
  7603. }
  7604. }
  7605. writeGridDataTableJson(dStruct.TotalCount, dt);
  7606. }
  7607. public void get_erp_refunddesignlist()
  7608. {
  7609. DataStruct dStruct = GetPostStruct();
  7610. List<string> lw = new List<string>();
  7611. string tid = GetPostString("tid");
  7612. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7613. string shopname = GetPostString("shopname");
  7614. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7615. string buyernick = GetPostString("buyer_nick");
  7616. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7617. string customer = GetPostString("customer");
  7618. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7619. string design = GetPostString("design");
  7620. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7621. string sellermemo = GetPostString("seller_memo");
  7622. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7623. string redate1 = GetPostString("refunddate1");
  7624. string redate2 = GetPostString("refunddate2");
  7625. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7626. if (dwdate.Length > 0) lw.Add(dwdate);
  7627. string price1 = GetPostString("price1");
  7628. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7629. string price2 = GetPostString("price2");
  7630. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7631. string ispartrefund = GetPostString("ispartrefund");
  7632. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7633. string designerorg = GetPostString("designerorg");
  7634. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7635. string refundState = GetPostString("refundState");
  7636. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7637. int myOrgid = CurrentUser.UserPost.OrgID;
  7638. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7639. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7640. {
  7641. if (CurrentUser.User.TeamIds.Length > 0)
  7642. {
  7643. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7644. }
  7645. else
  7646. {
  7647. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7648. }
  7649. }
  7650. else if ("SysAdmin".Equals(myOrgCode))
  7651. {
  7652. }
  7653. else
  7654. {
  7655. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7656. {
  7657. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7658. }
  7659. else
  7660. {
  7661. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7662. }
  7663. }
  7664. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7665. dStruct.Order = "created desc";
  7666. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7667. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7668. dt.Columns.Add("refund_fees");
  7669. foreach (DataRow dr in dt.Rows)
  7670. {
  7671. String status = dr["status"].ToString();
  7672. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7673. {
  7674. dr["refund_fees"] = dr["refund_fee"];
  7675. }
  7676. else
  7677. {
  7678. dr["refund_fees"] = "0.0";
  7679. }
  7680. }
  7681. writeGridDataTableJson(dStruct.TotalCount, dt);
  7682. }
  7683. public void handle_erp_refundtag()
  7684. {
  7685. if (UrlPostParmsCheck("refund_id"))
  7686. {
  7687. string eid = GetPostString("refund_id");
  7688. string respMan = GetPostString("ResponsibleName");
  7689. if (respMan.Length <= 0)
  7690. {
  7691. returnErrorMsg("责任人不能为空");
  7692. return;
  7693. }
  7694. CeErpTradeRefund entity = null;
  7695. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7696. if (entity != null)
  7697. {
  7698. entity.ResponsibleUserName = respMan;
  7699. string userid = GetPostString("ResponsibleUserId");
  7700. if (userid.Length > 0)
  7701. {
  7702. entity.ResponsibleUserId = userid;
  7703. }
  7704. entity.Memo = GetPostString("Memo");
  7705. if (respMan.IndexOf("客服") != -1 ||
  7706. respMan.IndexOf("设计师") != -1 ||
  7707. respMan.IndexOf("下单员") != -1)
  7708. {
  7709. entity.RefundState = 2;
  7710. }
  7711. else
  7712. {
  7713. entity.RefundState = 3;
  7714. }
  7715. entity.modified = DateTime.Now;
  7716. entity.Update();
  7717. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7718. returnSuccessMsg("操作成功!");
  7719. return;
  7720. }
  7721. returnErrorMsg("找不到订单记录");
  7722. }
  7723. }
  7724. public void handle_erp_designrefundtag()
  7725. {
  7726. if (UrlPostParmsCheck("refund_id"))
  7727. {
  7728. string eid = GetPostString("refund_id");
  7729. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7730. if (ceErpTradeCellExtend == null)
  7731. {
  7732. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7733. ceErpTradeCellExtend.ctid = eid;
  7734. }
  7735. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7736. if (ceErpTradeCellExtend.ID > 0)
  7737. {
  7738. ceErpTradeCellExtend.Update();
  7739. }
  7740. else
  7741. {
  7742. ceErpTradeCellExtend.Create();
  7743. }
  7744. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7745. returnSuccessMsg("操作成功!");
  7746. return;
  7747. }
  7748. returnErrorMsg("找不到订单记录");
  7749. }
  7750. public void upd_erp_refundverify()
  7751. {
  7752. if (UrlPostParmsCheck("refund_id"))
  7753. {
  7754. string eid = GetPostString("refund_id");
  7755. CeErpTradeRefund entity = null;
  7756. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7757. if (entity != null)
  7758. {
  7759. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7760. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7761. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7762. {
  7763. entity.RefundState = 2;
  7764. }
  7765. else
  7766. {
  7767. entity.RefundState = 3;
  7768. }
  7769. entity.Update();
  7770. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7771. returnSuccessMsg("操作成功!");
  7772. return;
  7773. }
  7774. returnErrorMsg("找不到订单记录");
  7775. }
  7776. }
  7777. public void upd_erp_refundapprove()
  7778. {
  7779. if (UrlPostParmsCheck("refund_id"))
  7780. {
  7781. string eid = GetPostString("refund_id");
  7782. CeErpTradeRefund entity = null;
  7783. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7784. if (entity != null)
  7785. {
  7786. int apr = GetPostInt("approve");
  7787. if (apr == 0)
  7788. {
  7789. entity.RefundState = 1;
  7790. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7791. }
  7792. else if (apr == 1)
  7793. {
  7794. entity.RefundState = 3;
  7795. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7796. }
  7797. entity.modified = DateTime.Now;
  7798. entity.Update();
  7799. returnSuccessMsg("操作成功!");
  7800. return;
  7801. }
  7802. returnErrorMsg("找不到订单记录");
  7803. }
  7804. }
  7805. public void get_erp_billlist()
  7806. {
  7807. DataStruct dStruct = GetPostStruct();
  7808. List<string> lw = new List<string>();
  7809. string title = GetPostString("title");
  7810. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7811. string tid = GetPostString("tid");
  7812. string tids = GetPostString("tids");
  7813. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7814. if (tids.Length > 0)
  7815. {
  7816. tids = "'" + tids + "'";
  7817. tids = tids.Replace(",", "','");
  7818. lw.Add(string.Format("tid in ({0})", tids));
  7819. }
  7820. string shopname = GetPostString("shopname");
  7821. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7822. string buyernick = GetPostString("buyer_nick");
  7823. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7824. string customer = GetPostString("customer");
  7825. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7826. string date1 = GetPostString("date1");
  7827. string date2 = GetPostString("date2");
  7828. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7829. if (dw.Length > 0) lw.Add(dw);
  7830. string price1 = GetPostString("price1");
  7831. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7832. string price2 = GetPostString("price2");
  7833. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7834. string returndate1 = GetPostString("returndate1");
  7835. string returndate2 = GetPostString("returndate2");
  7836. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7837. if (dw1.Length > 0) lw.Add(dw1);
  7838. string billtype = GetPostString("billtype");
  7839. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7840. string billstate = GetPostString("billstate");
  7841. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7842. string usershop = CurrentUser.User.pemShop;
  7843. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7844. dStruct.Order = "createTime desc";
  7845. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7846. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7847. //foreach (DataRow dr in dt.Rows)
  7848. //{
  7849. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7850. //}
  7851. writeGridDataTableJson(dStruct.TotalCount, dt);
  7852. }
  7853. public void modify_erp_billinfo()
  7854. {
  7855. if (UrlPostParmsCheck("ID"))
  7856. {
  7857. string eid = GetPostString("ID");
  7858. CeErpBill bill_entity = null;
  7859. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7860. if (bill_entity != null)
  7861. {
  7862. bill_entity.tid = GetPostString("tid");
  7863. bill_entity.title = GetPostString("title");
  7864. bill_entity.tax = GetPostString("tax");
  7865. bill_entity.bank = GetPostString("bank");
  7866. bill_entity.bankac = GetPostString("bankac");
  7867. bill_entity.address = GetPostString("address");
  7868. bill_entity.phone = GetPostString("phone");
  7869. bill_entity.price = GetPostString("price");
  7870. bill_entity.productId = GetPostInt("ProductName");
  7871. bill_entity.num = GetPostInt("num");
  7872. bill_entity.unit = GetPostString("unit");
  7873. bill_entity.type = GetPostString("type");
  7874. bill_entity.sendType = GetPostString("SendType");
  7875. bill_entity.email = GetPostString("email");
  7876. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7877. bill_entity.shopName = GetPostString("ShopName");
  7878. bill_entity.applymemo = GetPostString("applymemo");
  7879. bill_entity.modifyTime = DateTime.Now;
  7880. bill_entity.createTime = DateTime.Now;
  7881. bill_entity.state = 0;
  7882. bill_entity.Update();
  7883. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7884. returnSuccessMsg("发票修改成功!");
  7885. return;
  7886. }
  7887. returnErrorMsg("找不到对应记录");
  7888. }
  7889. }
  7890. public void set_erp_invoicing()
  7891. {
  7892. if (UrlPostParmsCheck("id"))
  7893. {
  7894. try
  7895. {
  7896. string eid = GetPostString("id");
  7897. CeErpBill bill_entity = null;
  7898. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7899. if (bill_entity != null)
  7900. {
  7901. int ComId = GetPostInt("ComId");
  7902. //string memo = GetPostString("Memo");
  7903. int allInfo = GetPostInt("allinfo");
  7904. string clert = CurrentUser.User.Name;
  7905. //string detailValue = GetPostString("detailvalue");
  7906. string billId = bill_entity.billOrderId;
  7907. string[] billIdList = billId.Split(',');
  7908. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7909. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7910. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7911. {
  7912. billCount += 1;
  7913. }
  7914. if (billId.Length <= 0 || billIdList.Length != billCount)
  7915. {
  7916. bill_entity.billOrderId = "";
  7917. string prebill = "ltb";
  7918. for (int idx = 1; idx <= billCount; idx++)
  7919. {
  7920. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7921. string billoid = prebill + idx + dtstr;
  7922. bill_entity.billOrderId += billoid;
  7923. if (idx < billCount)
  7924. {
  7925. bill_entity.billOrderId += ",";
  7926. }
  7927. }
  7928. }
  7929. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7930. if (bill_entity.state == 5)
  7931. {
  7932. string errMsg = bill_entity.failerror;
  7933. string[] errlist = errMsg.Split('|');
  7934. string[] errTags = new string[errlist.Length];
  7935. for (int itag = 0; itag < errlist.Length; itag++)
  7936. {
  7937. if (errlist[itag].Length <= 0) continue;
  7938. errTags[itag] = errlist[itag].Split('&')[0];
  7939. }
  7940. for (int iii = 0; iii < errTags.Length; iii++)
  7941. {
  7942. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7943. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7944. if (billOrderList.Length >= erroBillOrderTag)
  7945. {
  7946. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7947. if (needModifyBillId.Length <= 19)
  7948. {
  7949. needModifyBillId = needModifyBillId + "1";
  7950. }
  7951. else
  7952. {
  7953. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7954. last = last + 1;
  7955. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7956. }
  7957. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7958. }
  7959. }
  7960. }
  7961. bool isHaveBillSucces = false;
  7962. string totalRes = "";
  7963. bill_entity.failerror = "";
  7964. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7965. {
  7966. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7967. totalRes += res;
  7968. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7969. {
  7970. isHaveBillSucces = true;
  7971. bill_entity.comId = ComId;
  7972. bill_entity.state = 1;
  7973. bill_entity.executeTime = DateTime.Now;
  7974. bill_entity.executeUser = clert;
  7975. }
  7976. else
  7977. {
  7978. bill_entity.state = 5;
  7979. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7980. }
  7981. }
  7982. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7983. bill_entity.Update();
  7984. if (isHaveBillSucces)
  7985. {
  7986. StringBuilder sql = new StringBuilder();
  7987. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7988. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7989. }
  7990. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7991. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7992. {
  7993. returnErrorMsg("开票失败");
  7994. }
  7995. else
  7996. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7997. return;
  7998. }
  7999. returnErrorMsg("找不到对应记录");
  8000. }
  8001. catch (Exception ex)
  8002. {
  8003. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8004. returnErrorMsg("操作失败");
  8005. }
  8006. }
  8007. }
  8008. public void get_erp_invoicing_back()
  8009. {
  8010. if (UrlPostParmsCheck("id"))
  8011. {
  8012. try
  8013. {
  8014. string id = GetPostString("id");
  8015. CeErpBill entiy = CeErpBill.Get(id);
  8016. if (entiy != null)
  8017. {
  8018. if (entiy.state == 0)
  8019. {
  8020. returnErrorMsg("发票还未开具");
  8021. return;
  8022. }
  8023. string[] billOrderList = entiy.billOrderId.Split(',');
  8024. int iTag = 0;
  8025. entiy.fplsh = "";
  8026. entiy.fpdm = "";
  8027. entiy.fphm = "";
  8028. foreach (string billOrderId in billOrderList)
  8029. {
  8030. iTag++;
  8031. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8032. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8033. {
  8034. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8035. try
  8036. {
  8037. Invoicing_get_response_Obj iObj = null;
  8038. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8039. if (iObj != null)
  8040. {
  8041. entiy.state = 2;
  8042. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8043. entiy.fpdm += iObj.list[0].c_fpdm;
  8044. entiy.fphm += iObj.list[0].c_fphm;
  8045. if (iTag < billOrderList.Length)
  8046. {
  8047. entiy.fplsh += ",";
  8048. entiy.fpdm += ",";
  8049. entiy.fphm += ",";
  8050. }
  8051. entiy.Update();
  8052. }
  8053. StringBuilder sql = new StringBuilder();
  8054. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8055. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8056. returnSuccessMsg("开票成功");
  8057. }
  8058. catch (Exception ex)
  8059. {
  8060. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8061. }
  8062. return;
  8063. }
  8064. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8065. {
  8066. var res_obj = new
  8067. {
  8068. data = "开票中"
  8069. };
  8070. string ro_json = JsonConvert.SerializeObject(res_obj);
  8071. returnSuccess(ro_json);
  8072. return;
  8073. }
  8074. else
  8075. {
  8076. int eidx = res.IndexOf("c_resultmsg");
  8077. int lidx = res.IndexOf("c_status");
  8078. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8079. entiy.state = 5;
  8080. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8081. entiy.Update();
  8082. returnErrorMsg("开票失败");
  8083. return;
  8084. }
  8085. }
  8086. }
  8087. }
  8088. catch (Exception ex)
  8089. {
  8090. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8091. }
  8092. return;
  8093. }
  8094. }
  8095. public void get_erp_invoicing()
  8096. {
  8097. if (UrlPostParmsCheck("id"))
  8098. {
  8099. try
  8100. {
  8101. string id = GetPostString("id");
  8102. CeErpBill entiy = CeErpBill.Get(id);
  8103. if (entiy != null)
  8104. {
  8105. if (entiy.state == 0)
  8106. {
  8107. returnErrorMsg("发票还未开具");
  8108. return;
  8109. }
  8110. if (entiy.sendType == "纸质发票")
  8111. {
  8112. if (entiy.img.Length <= 0)
  8113. {
  8114. returnErrorMsg("查无纸质发票");
  8115. return;
  8116. }
  8117. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8118. returnSuccess(returnres);
  8119. return;
  8120. }
  8121. string[] billOrderList = entiy.billOrderId.Split(',');
  8122. int iTag = 0;
  8123. string fpUrl = "";
  8124. entiy.fplsh = "";
  8125. entiy.fpdm = "";
  8126. entiy.fphm = "";
  8127. foreach (string billOrderId in billOrderList)
  8128. {
  8129. iTag++;
  8130. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8131. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8132. {
  8133. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8134. Invoicing_get_response_Obj iObj = null;
  8135. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8136. if (iObj != null)
  8137. {
  8138. //entiy.state = 2;
  8139. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8140. entiy.fpdm += iObj.list[0].c_fpdm;
  8141. entiy.fphm += iObj.list[0].c_fphm;
  8142. if (iTag < billOrderList.Length)
  8143. {
  8144. entiy.fplsh += ",";
  8145. entiy.fpdm += ",";
  8146. entiy.fphm += ",";
  8147. }
  8148. entiy.Update();
  8149. fpUrl += iObj.list[0].c_url + ",";
  8150. }
  8151. //returnSuccess(res);
  8152. StringBuilder sql = new StringBuilder();
  8153. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8154. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8155. }
  8156. else
  8157. {
  8158. int eidx = res.IndexOf("c_resultmsg");
  8159. //int lidx = res.IndexOf("c_status");
  8160. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8161. //开票失败
  8162. entiy.state = 5;
  8163. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8164. entiy.Update();
  8165. returnErrorMsg("开票失败");
  8166. return;
  8167. }
  8168. }
  8169. var returnObj = new
  8170. {
  8171. data = fpUrl
  8172. };
  8173. string ro_json = JsonConvert.SerializeObject(returnObj);
  8174. returnSuccess(ro_json);
  8175. }
  8176. }
  8177. catch (Exception ex)
  8178. {
  8179. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8180. }
  8181. return;
  8182. }
  8183. }
  8184. public void save_erp_billimg()
  8185. {
  8186. if (UrlPostParmsCheck("id"))
  8187. {
  8188. string eid = GetPostString("id");
  8189. CeErpBill bill_entity = null;
  8190. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8191. if (bill_entity != null)
  8192. {
  8193. bill_entity.img = GetPostString("img");
  8194. bill_entity.executeTime = DateTime.Now;
  8195. bill_entity.state = 2;
  8196. bill_entity.Update();
  8197. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8198. returnSuccessMsg("保存成功");
  8199. }
  8200. return;
  8201. }
  8202. }
  8203. public void upd_erp_billreturnback()
  8204. {
  8205. if (UrlPostParmsCheck("id"))
  8206. {
  8207. int eid = GetPostInt("id");
  8208. CeErpBill bill_entity = null;
  8209. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8210. if (bill_entity != null)
  8211. {
  8212. bill_entity.state = 3;
  8213. bill_entity.returnReason = GetPostString("reason");
  8214. bill_entity.Update();
  8215. returnSuccessMsg("驳回成功!");
  8216. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8217. }
  8218. return;
  8219. }
  8220. }
  8221. public void cancel_erp_bill()
  8222. {
  8223. if (UrlPostParmsCheck("id"))
  8224. {
  8225. int eid = GetPostInt("id");
  8226. int detailValue = GetPostInt("detailvalue");
  8227. CeErpBill bill_entity = null;
  8228. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8229. string cres = "";
  8230. string gres = "";
  8231. if (bill_entity != null)
  8232. {
  8233. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8234. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8235. {
  8236. int iTag = 0;
  8237. bill_entity.fplsh = "";
  8238. bill_entity.fpdm = "";
  8239. bill_entity.fphm = "";
  8240. foreach (string billOrderId in billOrderList)
  8241. {
  8242. iTag++;
  8243. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8244. if (gres.IndexOf("success") != -1)
  8245. {
  8246. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8247. Invoicing_get_response_Obj iObj = null;
  8248. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8249. if (iObj != null)
  8250. {
  8251. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8252. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8253. bill_entity.fphm += iObj.list[0].c_fphm;
  8254. if (iTag < billOrderList.Length)
  8255. {
  8256. bill_entity.fplsh += ",";
  8257. bill_entity.fpdm += ",";
  8258. bill_entity.fphm += ",";
  8259. }
  8260. bill_entity.Update();
  8261. }
  8262. }
  8263. else
  8264. {
  8265. returnErrorMsg(gres);
  8266. return;
  8267. }
  8268. }
  8269. }
  8270. if (bill_entity.sendType == "纸质发票")
  8271. {
  8272. //作废
  8273. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8274. //if (DateTime.Now.Month == extime.Month)
  8275. //{
  8276. //cres = taobaoHelper.cancel_invoicing(eid);
  8277. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8278. //{
  8279. bill_entity.state = 4;//已作废
  8280. bill_entity.Update();
  8281. returnSuccessMsg("发票已作废");
  8282. return;
  8283. //}
  8284. //else
  8285. //{
  8286. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8287. // bill_entity.Update();
  8288. // returnErrorMsg(cres);
  8289. // return;
  8290. //}
  8291. //}
  8292. //else
  8293. //{
  8294. // returnErrorMsg("纸质发票只能作废本月的发票");
  8295. // return;
  8296. //}
  8297. }
  8298. //红冲
  8299. int redTag = 0;
  8300. string[] fpdmList = bill_entity.fpdm.Split(',');
  8301. string[] fphmList = bill_entity.fphm.Split(',');
  8302. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8303. {
  8304. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8305. return;
  8306. }
  8307. foreach (string billOrderId in billOrderList)
  8308. {
  8309. redTag++;
  8310. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8311. cres += onecres;
  8312. cres += ",";
  8313. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8314. {
  8315. bill_entity.state = 4;//已作废
  8316. //bill_entity.Update();
  8317. //returnSuccessMsg("发票已红冲");
  8318. }
  8319. else if (onecres.IndexOf("重复冲红") != -1)
  8320. {
  8321. bill_entity.state = 4;//已作废
  8322. //bill_entity.Update();
  8323. //returnSuccessMsg("发票已红冲");
  8324. }
  8325. else
  8326. {
  8327. string errmsg = commonHelper.KeepChinese(onecres);
  8328. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8329. }
  8330. }
  8331. bill_entity.Update();
  8332. if (cres.IndexOf("失败") != -1)
  8333. returnErrorMsg("红冲失败");
  8334. else
  8335. returnSuccessMsg("发票已红冲");
  8336. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8337. return;
  8338. }
  8339. return;
  8340. }
  8341. }
  8342. public void del_erp_billorder()
  8343. {
  8344. if (UrlPostParmsCheck("id"))
  8345. {
  8346. string eid = GetPostString("id");
  8347. CeErpBill.Del(eid);
  8348. CeErpBill bill = CeErpBill.Get(eid);
  8349. if (bill != null)
  8350. {
  8351. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8352. }
  8353. returnSuccessMsg("删除成功");
  8354. }
  8355. }
  8356. public void finish_erp_bill()
  8357. {
  8358. if (UrlPostParmsCheck("ids"))
  8359. {
  8360. string eids = GetPostString("ids");
  8361. string[] list = eids.Split(',');
  8362. foreach (string eid in list)
  8363. {
  8364. CeErpBill bill = CeErpBill.Get(eid);
  8365. if (bill != null)
  8366. {
  8367. bill.state = 2;
  8368. bill.Update();
  8369. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8370. }
  8371. }
  8372. returnSuccessMsg("操作成功");
  8373. }
  8374. }
  8375. public void get_erp_returncash()
  8376. {
  8377. DataStruct dStruct = GetPostStruct();
  8378. List<string> lw = new List<string>();
  8379. string tid = GetPostString("tid");
  8380. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8381. string shopname = GetPostString("shopname");
  8382. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8383. string buyernick = GetPostString("buyer_nick");
  8384. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8385. string customer = GetPostString("customer");
  8386. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8387. string returndate1 = GetPostString("returndate1");
  8388. string returndate2 = GetPostString("returndate2");
  8389. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8390. if (dw.Length > 0) lw.Add(dw);
  8391. string finishDate1 = GetPostString("finishdate1");
  8392. string finishDate2 = GetPostString("finishdate2");
  8393. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8394. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8395. string returntype = GetPostString("returntype");
  8396. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8397. string returnvstate = GetPostString("returnvstate");
  8398. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8399. dStruct.Order = "created desc";
  8400. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8401. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8402. writeGridDataTableJson(dStruct.TotalCount, dt);
  8403. }
  8404. public void get_erp_staygoods()
  8405. {
  8406. DataStruct dStruct = GetPostStruct();
  8407. List<string> lw = new List<string>();
  8408. string tid = GetPostString("tid");
  8409. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8410. string shopname = GetPostString("shopname");
  8411. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8412. string wangwang = GetPostString("wangwang");
  8413. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8414. string customer = GetPostString("customer");
  8415. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8416. string returndate1 = GetPostString("returndate1");
  8417. string returndate2 = GetPostString("returndate2");
  8418. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8419. if (dw.Length > 0) lw.Add(dw);
  8420. string finishDate1 = GetPostString("finishdate1");
  8421. string finishDate2 = GetPostString("finishdate2");
  8422. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8423. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8424. string returnvstate = GetPostString("returnvstate");
  8425. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8426. string persuadetype = GetPostString("persuadetype");
  8427. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8428. string customerOrg = GetPostString("customerOrg");
  8429. if (customerOrg.Length > 0)
  8430. {
  8431. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8432. }
  8433. dStruct.Order = "creata_time desc";
  8434. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8435. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8436. writeGridDataTableJson(dStruct.TotalCount, dt);
  8437. }
  8438. public void upd_erp_staygoods()
  8439. {
  8440. if (UrlPostParmsCheck("id"))
  8441. {
  8442. int eid = GetPostInt("id");
  8443. CeErpStayGoods entity = null;
  8444. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8445. if (entity != null)
  8446. {
  8447. entity.audit_type = 1;
  8448. entity.audit_time = DateTime.Now;
  8449. entity.audit_u_id = CurrentUser.UserID;
  8450. entity.audit_u_name = CurrentUser.UserName;
  8451. entity.Update();
  8452. returnSuccessMsg("审核成功!");
  8453. return;
  8454. }
  8455. returnErrorMsg("找不到订单记录");
  8456. }
  8457. }
  8458. public void upd_erp_stayGoodsback()
  8459. {
  8460. if (UrlPostParmsCheck("id"))
  8461. {
  8462. int eid = GetPostInt("id");
  8463. CeErpStayGoods entity = null;
  8464. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8465. if (entity != null)
  8466. {
  8467. entity.audit_text = GetPostString("reason");
  8468. entity.audit_type = 2;
  8469. entity.audit_time = DateTime.Now;
  8470. entity.audit_u_id = CurrentUser.UserID;
  8471. entity.audit_u_name = CurrentUser.UserName;
  8472. entity.Update();
  8473. returnSuccessMsg("退回成功!");
  8474. return;
  8475. }
  8476. returnErrorMsg("找不到订单记录");
  8477. }
  8478. }
  8479. public void upd_erp_returncashverify()
  8480. {
  8481. if (UrlPostParmsCheck("ID"))
  8482. {
  8483. int eid = GetPostInt("ID");
  8484. CeErpReturnCash entity = null;
  8485. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8486. if (entity != null)
  8487. {
  8488. entity.cashstate = 1;
  8489. entity.verifytime = DateTime.Now;
  8490. entity.verifyuserid = CurrentUser.UserID;
  8491. entity.Update();
  8492. returnSuccessMsg("审核成功!");
  8493. return;
  8494. }
  8495. returnErrorMsg("找不到订单记录");
  8496. }
  8497. }
  8498. public void upd_all_erp_returncashverify()
  8499. {
  8500. if (UrlPostParmsCheck("ID"))
  8501. {
  8502. String[] list = GetPostString("ID").Split(',');
  8503. CeErpReturnCash entity = null;
  8504. for (int i = 0; i < list.Length; i++)
  8505. {
  8506. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8507. if (entity != null)
  8508. {
  8509. if (entity.cashstate == 1)
  8510. {
  8511. returnErrorMsg("已审核过的订单不需要在审核!");
  8512. return;
  8513. }
  8514. entity.cashstate = 1;
  8515. entity.verifytime = DateTime.Now;
  8516. entity.verifyuserid = CurrentUser.UserID;
  8517. entity.Update();
  8518. }
  8519. }
  8520. returnSuccessMsg("审核成功!");
  8521. return;
  8522. }
  8523. }
  8524. public void upd_erp_returncashback()
  8525. {
  8526. if (UrlPostParmsCheck("ID"))
  8527. {
  8528. int eid = GetPostInt("ID");
  8529. CeErpReturnCash entity = null;
  8530. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8531. if (entity != null)
  8532. {
  8533. entity.backreason = GetPostString("reason");
  8534. entity.cashstate = 2;
  8535. entity.verifytime = DateTime.Now;
  8536. entity.verifyuserid = CurrentUser.UserID;
  8537. entity.Update();
  8538. returnSuccessMsg("退回成功!");
  8539. return;
  8540. }
  8541. returnErrorMsg("找不到订单记录");
  8542. }
  8543. }
  8544. public void upd_erp_returnprice()
  8545. {
  8546. if (UrlPostParmsCheck("ID"))
  8547. {
  8548. int eid = GetPostInt("ID");
  8549. CeErpReturnCash entity = null;
  8550. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8551. if (entity != null)
  8552. {
  8553. if (entity.cashstate == 1)
  8554. {
  8555. returnErrorMsg("审核通过了不能改");
  8556. return;
  8557. }
  8558. entity.returnprice = GetPostDouble("returnprice");
  8559. entity.Update();
  8560. returnSuccessMsg("修改成功!");
  8561. return;
  8562. }
  8563. returnErrorMsg("找不到订单记录");
  8564. }
  8565. }
  8566. public void del_erp_returncash()
  8567. {
  8568. if (UrlPostParmsCheck("ID"))
  8569. {
  8570. int eid = GetPostInt("ID");
  8571. CeErpReturnCash.Del(eid);
  8572. returnSuccessMsg("操作成功");
  8573. return;
  8574. }
  8575. }
  8576. public void test_for_do_sql()
  8577. {
  8578. string sql = GetPostString("sqlstr");
  8579. if (sql.Length > 0)
  8580. {
  8581. try
  8582. {
  8583. DbHelper.DbConn.ExecuteNonQuery(sql);
  8584. var res_obj = new
  8585. {
  8586. data = "成功",
  8587. };
  8588. string ro_json = JsonConvert.SerializeObject(res_obj);
  8589. returnSuccess(ro_json);
  8590. }
  8591. catch (Exception ex)
  8592. {
  8593. var res_obj = new
  8594. {
  8595. data = ex.Message,
  8596. };
  8597. string ro_json = JsonConvert.SerializeObject(res_obj);
  8598. returnSuccess(ro_json);
  8599. }
  8600. }
  8601. }
  8602. public void get_user_info()
  8603. {
  8604. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8605. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8606. }
  8607. public void get_total_data()
  8608. {
  8609. int userId = CurrentUser.UserID;
  8610. string sql = "";
  8611. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8612. {
  8613. 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);
  8614. }
  8615. else
  8616. {
  8617. 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 " +
  8618. "(select ID from CE_ErpUser where ID = {0}) d " +
  8619. "left join " +
  8620. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8621. ") a on d.ID = a.id left join " +
  8622. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8623. ") b on a.id = b.id1 left join" +
  8624. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8625. ") c on a.id = c.id2;", userId);
  8626. }
  8627. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8628. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8629. }
  8630. public void get_date_area_total_data2()
  8631. {
  8632. int userId = CurrentUser.UserID;
  8633. string date_type = GetPostString("timetype");
  8634. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8635. string sql = "";
  8636. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8637. {
  8638. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8639. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8640. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8641. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8642. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8643. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8644. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8645. ") a on e.ID = a.id left join " +
  8646. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8647. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8648. ") b on a.id = b.id1 " +
  8649. "left join " +
  8650. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8651. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8652. ") c on a.id = c.id2 " +
  8653. "left join " +
  8654. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8655. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8656. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8657. }
  8658. else
  8659. {
  8660. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8661. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8662. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8663. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8664. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8665. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8666. ") a on e.ID = a.id left join " +
  8667. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8668. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8669. ") c on a.id = c.id2 " +
  8670. "left join " +
  8671. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8672. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8673. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8674. }
  8675. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8676. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8677. }
  8678. public void get_date_area_total_data()
  8679. {
  8680. int userId = CurrentUser.UserID;
  8681. string date_type = GetPostString("timetype");
  8682. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8683. string date1 = searchDT[0].ToString();
  8684. string date2 = searchDT[1].ToString();
  8685. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8686. {
  8687. SqlParameter[] sqlParameter ={
  8688. new SqlParameter("@userId", SqlDbType.Int,4),
  8689. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8690. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8691. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8692. };
  8693. sqlParameter[0].Value = userId;
  8694. sqlParameter[1].Value = date1;
  8695. sqlParameter[2].Value = date2;
  8696. sqlParameter[3].Direction = ParameterDirection.Output;
  8697. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8698. string res = sqlParameter[3].Value.ToString();
  8699. var res_obj = new
  8700. {
  8701. data = res
  8702. };
  8703. string ro_json = JsonConvert.SerializeObject(res_obj);
  8704. returnSuccess(ro_json);
  8705. }
  8706. else
  8707. {
  8708. SqlParameter[] sqlParameter ={
  8709. new SqlParameter("@userId", SqlDbType.Int,4),
  8710. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8711. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8712. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8713. };
  8714. sqlParameter[0].Value = userId;
  8715. sqlParameter[1].Value = date1;
  8716. sqlParameter[2].Value = date2;
  8717. sqlParameter[3].Direction = ParameterDirection.Output;
  8718. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8719. string res = sqlParameter[3].Value.ToString();
  8720. var res_obj = new
  8721. {
  8722. data = res
  8723. };
  8724. string ro_json = JsonConvert.SerializeObject(res_obj);
  8725. returnSuccess(ro_json);
  8726. }
  8727. //writeGridDataViewJson(dt.Rows.Count, dv);
  8728. }
  8729. public void get_order_list()
  8730. {
  8731. string strFields = GetPostString("paraFields");
  8732. string strOrder = GetPostString("paraOrder");
  8733. string strWhere = GetPostString("paraWhere");
  8734. string strPageSize = GetPostString("paraPageSize");
  8735. DataStruct dStruct = GetPostStruct();
  8736. dStruct.PageSize = int.Parse(strPageSize);
  8737. dStruct.Fileds = strFields;
  8738. dStruct.Order = strOrder;
  8739. dStruct.MainWhere = strWhere;
  8740. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8741. writeGridDataTableJson(dStruct.TotalCount, dt);
  8742. }
  8743. ////获取待开始订单列表
  8744. //public void get_wait_design_order_list()
  8745. //{
  8746. // string date_type = GetPostString("date_type");
  8747. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8748. // DataStruct dStruct = GetPostStruct();
  8749. // dStruct.PageSize = 1000;
  8750. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8751. // List<string> lw = new List<string>();
  8752. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8753. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8754. // dStruct.Order = "WaitDesignTime asc";
  8755. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8756. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8757. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8758. //}
  8759. //获取完成单量排名
  8760. public void get_finish_order_count_ranking()
  8761. {
  8762. /* string date_type = GetPostString("date_type");
  8763. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8764. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8765. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8766. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8767. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8768. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8769. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8770. writeGridDataTableJson(0, new DataTable());
  8771. }
  8772. public void get_finish_order_amount_ranking()
  8773. {
  8774. /*string date_type = GetPostString("date_type");
  8775. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8776. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8777. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8778. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8779. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8780. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8781. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8782. writeGridDataTableJson(0, new DataTable());
  8783. }
  8784. public void get_finish_refund_count_ranking()
  8785. {
  8786. string date_type = GetPostString("date_type");
  8787. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8788. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8789. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8790. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8791. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8792. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8793. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8794. writeGridDataTableJson(dt.Rows.Count, dt);
  8795. }
  8796. public void get_finish_refund_amount_ranking()
  8797. {
  8798. string date_type = GetPostString("date_type");
  8799. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8800. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8801. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8802. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8803. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8804. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8805. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8806. writeGridDataTableJson(dt.Rows.Count, dt);
  8807. }
  8808. public void set_erp_finishorder_director()
  8809. {
  8810. if (UrlPostParmsCheck("ctid"))
  8811. {
  8812. string eid = GetPostString("ctid");
  8813. CeErpTradeCell entity = null;
  8814. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8815. if (entity != null)
  8816. {
  8817. entity.OrderState = 8;
  8818. entity.Update();
  8819. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8820. returnSuccessMsg("操作成功!");
  8821. return;
  8822. }
  8823. returnErrorMsg("找不到记录");
  8824. }
  8825. }
  8826. public void get_erp_placeregistlist()
  8827. {
  8828. DataStruct dStruct = GetPostStruct();
  8829. List<string> lw = new List<string>();
  8830. string outsid = GetPostString("outsid");
  8831. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8832. string memo = GetPostString("memo");
  8833. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8834. string filename = GetPostString("filename");
  8835. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8836. string islate = GetPostString("islate");
  8837. if (islate.Length > 0)
  8838. {
  8839. if (islate == "1")
  8840. lw.Add(string.Format("OutLate>0"));
  8841. else
  8842. lw.Add(string.Format("OutLate=0"));
  8843. }
  8844. string placedate1 = GetPostString("placedate1");
  8845. string placedate2 = GetPostString("placedate2");
  8846. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8847. if (dw.Length > 0) lw.Add(dw);
  8848. string deliveryDate1 = GetPostString("deliverydate1");
  8849. string deliveryDate2 = GetPostString("deliverydate2");
  8850. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8851. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8852. dStruct.Order = "ID desc";
  8853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8854. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8855. writeGridDataTableJson(dStruct.TotalCount, dt);
  8856. }
  8857. public void ins_erp_placeregist()
  8858. {
  8859. if (UrlPostParmsCheck("id"))
  8860. {
  8861. string eid = GetPostString("id");
  8862. CeErpPlaceRegister entity = null;
  8863. if (eid == "0")//新增
  8864. {
  8865. entity = new CeErpPlaceRegister();
  8866. string xdTime = GetPostString("placeTime");
  8867. if (xdTime.Length > 0)
  8868. {
  8869. entity.PlactTime = Convert.ToDateTime(xdTime);
  8870. }
  8871. string fhTime = GetPostString("deliveryTime");
  8872. if (fhTime.Length > 0)
  8873. {
  8874. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8875. }
  8876. string preTime = GetPostString("preOutTime");
  8877. if (preTime.Length > 0)
  8878. {
  8879. entity.PreOutTime = Convert.ToDateTime(preTime);
  8880. }
  8881. entity.DeliveryCount = GetPostInt("deliveryCount");
  8882. entity.ReceiveCount = GetPostInt("receiveCount");
  8883. entity.OutSid = GetPostString("outSid");
  8884. entity.FileName = GetPostString("fileName");
  8885. entity.Memo = GetPostString("memo");
  8886. entity.AddUserId = CurrentUser.UserID;
  8887. entity.CreateTime = DateTime.Now;
  8888. entity.Img = GetPostString("img");
  8889. entity.Supplier = GetPostInt("supplier");
  8890. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8891. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8892. {
  8893. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8894. DateTime dt2 = (DateTime)entity.PreOutTime;
  8895. TimeSpan span = dt1.Subtract(dt2);
  8896. if (span.Days > 0)
  8897. {
  8898. entity.OutLate = span.Days;
  8899. }
  8900. }
  8901. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8902. entity.Create();
  8903. returnSuccessMsg("添加成功!");
  8904. return;
  8905. }
  8906. else //修改
  8907. {
  8908. entity = CeErpPlaceRegister.Get(eid);
  8909. if (entity != null)
  8910. {
  8911. string xdTime = GetPostString("placeTime");
  8912. if (xdTime.Length > 0)
  8913. {
  8914. entity.PlactTime = Convert.ToDateTime(xdTime);
  8915. }
  8916. string fhTime = GetPostString("deliveryTime");
  8917. if (fhTime.Length > 0)
  8918. {
  8919. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8920. }
  8921. string preTime = GetPostString("preOutTime");
  8922. if (preTime.Length > 0)
  8923. {
  8924. entity.PreOutTime = Convert.ToDateTime(preTime);
  8925. }
  8926. entity.DeliveryCount = GetPostInt("deliveryCount");
  8927. entity.ReceiveCount = GetPostInt("receiveCount");
  8928. if (entity.DeliveryCount == entity.ReceiveCount)
  8929. {
  8930. entity.CurState = "已完成";
  8931. }
  8932. else
  8933. {
  8934. entity.CurState = "未完成";
  8935. }
  8936. entity.OutSid = GetPostString("outSid");
  8937. entity.FileName = GetPostString("fileName");
  8938. entity.Memo = GetPostString("memo");
  8939. entity.Img = GetPostString("img");
  8940. entity.Supplier = GetPostInt("supplier");
  8941. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8942. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8943. {
  8944. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8945. DateTime dt2 = (DateTime)entity.PreOutTime;
  8946. TimeSpan span = dt1.Subtract(dt2);
  8947. if (span.Days > 0)
  8948. {
  8949. entity.OutLate = span.Days;
  8950. }
  8951. }
  8952. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8953. entity.Update();
  8954. returnSuccessMsg("修改成功");
  8955. return;
  8956. }
  8957. returnErrorMsg("找不到对应的记录");
  8958. return;
  8959. }
  8960. }
  8961. returnErrorMsg("缺少必要参数");
  8962. }
  8963. public void del_erp_placeregist()
  8964. {
  8965. string eid = GetPostString("id");
  8966. CeErpPlaceRegister.Del(eid);
  8967. returnSuccessMsg("删除成功!");
  8968. return;
  8969. }
  8970. public void ins_erp_placeregistbyorder()
  8971. {
  8972. string ctid = GetPostString("ctid");
  8973. if (ctid.Length > 0)
  8974. {
  8975. StringBuilder sql = new StringBuilder();
  8976. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8977. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8978. if (dt.Rows.Count > 0)
  8979. {
  8980. foreach (DataRow dr in dt.Rows)
  8981. {
  8982. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8983. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8984. entity.AddUserId = CurrentUser.UserID;
  8985. entity.tid = dr["tid"].ToString();
  8986. entity.Did = Convert.ToString(dr["ctid"]);
  8987. entity.splitTag = dr["SplitTag"].ToString();
  8988. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8989. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8990. if (pre_ctid.Length > 0)
  8991. {
  8992. sellmemo = sellmemo.Replace(pre_ctid, "");
  8993. }
  8994. sellmemo = sellmemo.Replace("[", "");
  8995. sellmemo = sellmemo.Replace("]", "");
  8996. entity.FileName = sellmemo;
  8997. string count = dr["ProductCount"].ToString();
  8998. int usecount = commonHelper.getIntCountFromString(count);
  8999. entity.DeliveryCount = usecount;
  9000. entity.CurState = "未完成";
  9001. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9002. {
  9003. entity.Supplier = 24;//dl手提袋定制
  9004. }
  9005. else
  9006. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9007. entity.CreateTime = DateTime.Now;
  9008. entity.Create();
  9009. }
  9010. returnSuccessMsg("操作成功");
  9011. return;
  9012. }
  9013. returnErrorMsg("没有找到对应订单");
  9014. return;
  9015. }
  9016. returnErrorMsg("缺少订单编号");
  9017. return;
  9018. }
  9019. public void get_erp_persuadelist()
  9020. {
  9021. DataStruct dStruct = GetPostStruct();
  9022. List<string> lw = new List<string>();
  9023. string ctid = GetPostString("ctid");
  9024. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9025. string shopname = GetPostString("shopname");
  9026. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9027. string buyernick = GetPostString("buyer_nick");
  9028. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9029. string customer = GetPostString("customer");
  9030. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9031. string returndate1 = GetPostString("returndate1");
  9032. string returndate2 = GetPostString("returndate2");
  9033. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9034. if (dw.Length > 0) lw.Add(dw);
  9035. string finishDate1 = GetPostString("finishdate1");
  9036. string finishDate2 = GetPostString("finishdate2");
  9037. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9038. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9039. string persuadetype = GetPostString("persuadetype");
  9040. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9041. string returnvstate = GetPostString("returnvstate");
  9042. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9043. dStruct.Order = "created desc";
  9044. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9045. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9046. writeGridDataTableJson(dStruct.TotalCount, dt);
  9047. }
  9048. public void upd_erp_returnpersuadeback()
  9049. {
  9050. if (UrlPostParmsCheck("ID"))
  9051. {
  9052. int eid = GetPostInt("ID");
  9053. CeErpPersuade entity = null;
  9054. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9055. if (entity != null)
  9056. {
  9057. entity.backreason = GetPostString("reason");
  9058. entity.pstate = 2;
  9059. entity.verifytime = DateTime.Now;
  9060. entity.verifyuserid = CurrentUser.UserID;
  9061. entity.Update();
  9062. returnSuccessMsg("退回成功!");
  9063. return;
  9064. }
  9065. returnErrorMsg("找不到订单记录");
  9066. }
  9067. }
  9068. public void upd_erp_returnpersuadeverify()
  9069. {
  9070. if (UrlPostParmsCheck("ID"))
  9071. {
  9072. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9073. {
  9074. returnErrorMsg("暂无权限审核");
  9075. return;
  9076. }
  9077. int eid = GetPostInt("ID");
  9078. CeErpPersuade entity = null;
  9079. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9080. if (entity != null)
  9081. {
  9082. entity.pstate = 1;
  9083. entity.verifytime = DateTime.Now;
  9084. entity.verifyuserid = CurrentUser.UserID;
  9085. entity.Update();
  9086. returnSuccessMsg("审核成功!");
  9087. return;
  9088. }
  9089. returnErrorMsg("找不到订单记录");
  9090. }
  9091. }
  9092. public void del_erp_persuade()
  9093. {
  9094. if (UrlPostParmsCheck("ID"))
  9095. {
  9096. int eid = GetPostInt("ID");
  9097. CeErpPersuade.Del(eid);
  9098. returnSuccessMsg("操作成功");
  9099. return;
  9100. }
  9101. }
  9102. public void get_erp_oldcustoupload()
  9103. {
  9104. DataStruct dStruct = GetPostStruct();
  9105. List<string> lw = new List<string>();
  9106. string buyernick = GetPostString("buyer_nick");
  9107. if (buyernick.Length > 0)
  9108. {
  9109. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9110. }
  9111. else
  9112. return;
  9113. dStruct.Order = "pay_time desc";
  9114. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9115. DataTable dt = null;
  9116. dt = WebCache.GetData("view_erptradecell", dStruct);
  9117. writeGridDataTableJson(dStruct.TotalCount, dt);
  9118. }
  9119. public void get_erp_checkorderlist()
  9120. {
  9121. DataStruct dStruct = GetPostStruct();
  9122. List<string> lw = new List<string>();
  9123. string tid = GetPostString("ctid");
  9124. if (tid.Length > 0)
  9125. {
  9126. string select_tid = getTidByCtid(tid);
  9127. lw.Add(string.Format("tid='{0}'", select_tid));
  9128. }
  9129. string shopname = GetPostString("shopname");
  9130. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9131. string buyernick = GetPostString("buyer_nick");
  9132. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9133. string customer = GetPostString("customer");
  9134. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9135. string design = GetPostString("design");
  9136. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9137. string orderState = GetPostString("orderState");
  9138. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9139. string address = GetPostString("address");
  9140. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9141. string sellermemo = GetPostString("seller_memo");
  9142. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9143. string supplier = GetPostString("supplier");
  9144. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9145. {
  9146. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9147. }
  9148. else
  9149. {
  9150. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9151. }
  9152. string date1 = GetPostString("date1");
  9153. string date2 = GetPostString("date2");
  9154. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9155. if (dw.Length > 0) lw.Add(dw);
  9156. string placedate1 = GetPostString("placedate1");
  9157. string placedate2 = GetPostString("placedate2");
  9158. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9159. if (fdw.Length > 0) lw.Add(fdw);
  9160. string price1 = GetPostString("price1");
  9161. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9162. string price2 = GetPostString("price2");
  9163. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9164. string checkst = GetPostString("checkstate");
  9165. if (checkst.Length > 0 && "10".Equals(checkst))
  9166. {
  9167. lw.Add(string.Format("CheckOut>0"));
  9168. }
  9169. else
  9170. {
  9171. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9172. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9173. }
  9174. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9175. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9176. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9177. writeGridDataTableJson(dStruct.TotalCount, dt);
  9178. }
  9179. public void ins_erp_startCheck()
  9180. {
  9181. if (UrlPostParmsCheck("ctid"))
  9182. {
  9183. string eid = GetPostString("ctid");
  9184. CeErpTradeCell entity = null;
  9185. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9186. if (entity != null)
  9187. {
  9188. entity.MemoOpt = 4;
  9189. entity.UpdateTime = DateTime.Now;
  9190. entity.Update();
  9191. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9192. CeErpSukuraData.createInfo(entity.ctid, 6);
  9193. returnSuccessMsg("操作成功!");
  9194. return;
  9195. }
  9196. returnErrorMsg("找不到记录");
  9197. }
  9198. }
  9199. public void upd_erp_sendXlw()
  9200. {
  9201. if (UrlPostParmsCheck("ctid"))
  9202. {
  9203. string eid = GetPostString("ctid");
  9204. CeErpTradeCell entity = null;
  9205. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9206. if (entity != null)
  9207. {
  9208. if (entity.IsSendGift == 1)
  9209. {
  9210. returnErrorMsg("请勿重复标记");
  9211. return;
  9212. }
  9213. entity.IsSendGift = 1;
  9214. entity.Update();
  9215. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9216. returnSuccessMsg("操作成功!");
  9217. return;
  9218. }
  9219. returnErrorMsg("找不到记录");
  9220. }
  9221. }
  9222. public void cancel_sendXlw()
  9223. {
  9224. if (UrlPostParmsCheck("ctid"))
  9225. {
  9226. string eid = GetPostString("ctid");
  9227. CeErpTradeCell entity = null;
  9228. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9229. if (entity != null)
  9230. {
  9231. if (entity.IsSendGift == 0)
  9232. {
  9233. returnErrorMsg("未标记小礼物");
  9234. return;
  9235. }
  9236. entity.IsSendGift = 0;
  9237. entity.Update();
  9238. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9239. returnSuccessMsg("操作成功!");
  9240. return;
  9241. }
  9242. returnErrorMsg("找不到记录");
  9243. }
  9244. }
  9245. public void get_erp_designbill()
  9246. {
  9247. DataStruct dStruct = GetPostStruct();
  9248. List<string> lw = new List<string>();
  9249. int isMy = GetInt("my");
  9250. if (isMy == 1)
  9251. {
  9252. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9253. }
  9254. string tid = GetPostString("tid");
  9255. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9256. string userName = GetPostString("design");
  9257. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9258. string price1 = GetPostString("price1");
  9259. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9260. string price2 = GetPostString("price2");
  9261. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9262. string rePrice1 = GetPostString("rePrice1");
  9263. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9264. string rePrice2 = GetPostString("rePrice2");
  9265. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9266. string designerType = GetPostString("designerType");
  9267. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9268. string orderState = GetPostString("orderState");
  9269. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9270. string endTime1 = GetPostString("endTime1");
  9271. string endTime2 = GetPostString("endTime2");
  9272. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9273. if (dw.Length > 0) lw.Add(dw);
  9274. string isDk = GetPostString("isDk");
  9275. if (isDk == "1")
  9276. {
  9277. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9278. }
  9279. else if (isDk == "0")
  9280. {
  9281. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9282. }
  9283. dStruct.Order = "oid, create_time desc";
  9284. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9285. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9286. writeGridDataTableJson(dStruct.TotalCount, dt);
  9287. }
  9288. public void upd_erp_designerbill()
  9289. {
  9290. if (UrlPostParmsCheck("ID"))
  9291. {
  9292. string eid = GetPostString("ID");
  9293. CeErpDesignerBill entity = null;
  9294. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9295. if (entity != null)
  9296. {
  9297. if (GetPostDouble("designerpirce") > 0)
  9298. {
  9299. entity.realPrice = GetPostDouble("designerpirce");
  9300. entity.update_time = DateTime.Now;
  9301. entity.update_u_id = CurrentUser.UserID;
  9302. entity.update_u_name = CurrentUser.UserName;
  9303. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9304. entity.Update();
  9305. returnSuccessMsg("操作成功!");
  9306. return;
  9307. }
  9308. else
  9309. {
  9310. entity.price = GetPostDouble("price");
  9311. entity.update_time = DateTime.Now;
  9312. entity.update_u_id = CurrentUser.UserID;
  9313. entity.update_u_name = CurrentUser.UserName;
  9314. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9315. entity.Update();
  9316. returnSuccessMsg("操作成功!");
  9317. return;
  9318. }
  9319. }
  9320. returnErrorMsg("找不到记录");
  9321. }
  9322. }
  9323. public void audit_erp_designerbill()
  9324. {
  9325. if (UrlPostParmsCheck("ID"))
  9326. {
  9327. string eid = GetPostString("ID");
  9328. CeErpDesignerBill entity = null;
  9329. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9330. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9331. if (entity != null)
  9332. {
  9333. entity.realPrice = GetPostDouble("designerpirce");
  9334. entity.update_time = DateTime.Now;
  9335. entity.update_u_id = CurrentUser.UserID;
  9336. entity.update_u_name = CurrentUser.UserName;
  9337. entity.isAudit = 1;
  9338. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9339. entity.Update();
  9340. if (orderEntity != null)
  9341. {
  9342. orderEntity.IsReadTag = 3;
  9343. orderEntity.Update();
  9344. }
  9345. returnSuccessMsg("操作成功!");
  9346. return;
  9347. }
  9348. returnErrorMsg("找不到记录");
  9349. }
  9350. }
  9351. public void all_audit_erp_designerbill()
  9352. {
  9353. if (UrlPostParmsCheck("idList"))
  9354. {
  9355. string[] list = GetPostString("idList").Split(',');
  9356. CeErpDesignerBill entity = null;
  9357. for (int i = 0; i < list.Length; i++)
  9358. {
  9359. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9360. if (entity == null) return;
  9361. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9362. if (orderEntity == null) return;
  9363. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9364. entity.update_time = DateTime.Now;
  9365. entity.update_u_id = CurrentUser.UserID;
  9366. entity.update_u_name = CurrentUser.UserName;
  9367. entity.isAudit = 1;
  9368. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9369. entity.Update();
  9370. orderEntity.IsReadTag = 3;
  9371. orderEntity.Update();
  9372. }
  9373. returnSuccessMsg("操作成功!");
  9374. return;
  9375. }
  9376. }
  9377. public void get_erp_sameorders()
  9378. {
  9379. if (UrlPostParmsCheck("ctid"))
  9380. {
  9381. string eid = GetPostString("ctid");
  9382. CeErpTradeCell entity = null;
  9383. entity = CeErpTradeCell.GetByCtid(eid);
  9384. if (entity != null)
  9385. {
  9386. StringBuilder sql = new StringBuilder();
  9387. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9388. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9389. var res = new
  9390. {
  9391. data = dt.Rows.Count
  9392. };
  9393. string ro_jsond = JsonConvert.SerializeObject(res);
  9394. returnSuccess(ro_jsond);
  9395. return;
  9396. }
  9397. returnErrorMsg("未找到订单");
  9398. return;
  9399. }
  9400. returnErrorMsg("缺少必要的参数");
  9401. }
  9402. public void get_erp_islasthavesameorder()
  9403. {
  9404. if (UrlPostParmsCheck("ctid"))
  9405. {
  9406. string eid = GetPostString("ctid");
  9407. string[] ctidList = eid.Split(',');
  9408. StringBuilder sql = new StringBuilder();
  9409. string tisCtid = "";
  9410. foreach (string ctid in ctidList)
  9411. {
  9412. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9413. if (entity != null)
  9414. {
  9415. sql = new StringBuilder();
  9416. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9417. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9418. if (dth.Rows.Count > 0)
  9419. {
  9420. tisCtid += entity.ctid;
  9421. tisCtid += ",";
  9422. }
  9423. }
  9424. }
  9425. if (tisCtid.Length > 0)
  9426. {
  9427. var res = new
  9428. {
  9429. data = tisCtid
  9430. };
  9431. string ro_jsond = JsonConvert.SerializeObject(res);
  9432. returnSuccess(ro_jsond);
  9433. }
  9434. else
  9435. {
  9436. var res = new
  9437. {
  9438. data = ""
  9439. };
  9440. string ro_jsond = JsonConvert.SerializeObject(res);
  9441. returnSuccess(ro_jsond);
  9442. }
  9443. return;
  9444. }
  9445. returnErrorMsg("缺少必要的参数");
  9446. }
  9447. public void file_client_down_url()
  9448. {
  9449. if (!UrlPostParmsCheck("userId"))
  9450. {
  9451. returnErrorMsg("缺少必要的参数");
  9452. }
  9453. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9454. }
  9455. public void checkout_form_data()
  9456. {
  9457. if (!UrlPostParmsCheck("tid"))
  9458. {
  9459. returnErrorMsg("缺少必要的参数");
  9460. }
  9461. string tid = GetPostString("tid");
  9462. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9463. if (ceErpOrderFormData != null)
  9464. {
  9465. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9466. returnSuccess(ro_jsond);
  9467. return;
  9468. }
  9469. returnErrorMsg("尚未有文件!");
  9470. }
  9471. public void back_supplier_audit()
  9472. {
  9473. int userId = CurrentUser.UserID;
  9474. StringBuilder sql = new StringBuilder();
  9475. 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);
  9476. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9477. if (dt.Rows.Count > 0)
  9478. {
  9479. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9480. }
  9481. else
  9482. {
  9483. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9484. }
  9485. }
  9486. public void back_supplier_query()
  9487. {
  9488. string eid = GetPostString("ctid");
  9489. if (eid != "")
  9490. {
  9491. StringBuilder sql = new StringBuilder();
  9492. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9493. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9494. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9495. }
  9496. else
  9497. {
  9498. returnErrorMsg("找不到订单记录");
  9499. return;
  9500. }
  9501. }
  9502. public void verified_to_order()
  9503. {
  9504. int userId = CurrentUser.UserID;
  9505. StringBuilder sql = new StringBuilder();
  9506. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9507. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9508. if (dt.Rows.Count > 0)
  9509. {
  9510. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9511. }
  9512. else
  9513. {
  9514. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9515. }
  9516. }
  9517. public void upd_supplier_audit()
  9518. {
  9519. if (UrlPostParmsCheck("ctid"))
  9520. {
  9521. string eid = GetPostString("ctid");
  9522. string reason = GetPostString("returnreason");
  9523. CeErpTradeCell entity = null;
  9524. CeWithdraw withdraw = null;
  9525. withdraw = CeWithdraw.GetByTid(eid);
  9526. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9527. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9528. {
  9529. if (withdraw != null)
  9530. {
  9531. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9532. {
  9533. returnSuccessMsg("您没有权限操作!");
  9534. return;
  9535. }
  9536. else
  9537. {
  9538. if (reason.Equals("1"))
  9539. {
  9540. if (entity.OrderState == -1)
  9541. {
  9542. if (entity.FinishPlaceTime == null)
  9543. {
  9544. entity.OrderState = 2;
  9545. }
  9546. else
  9547. {
  9548. entity.OrderState = 6;
  9549. }
  9550. }
  9551. entity.Update();
  9552. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9553. if (withdraw != null)
  9554. {
  9555. withdraw.status = int.Parse(reason);
  9556. withdraw.Update();
  9557. }
  9558. returnSuccessMsg("操作成功!");
  9559. return;
  9560. }
  9561. else
  9562. {
  9563. withdraw.status = int.Parse(reason);
  9564. withdraw.acknowledgingtime = DateTime.Now;
  9565. withdraw.Update();
  9566. returnSuccessMsg("查看详细请点击线下订单查询");
  9567. return;
  9568. }
  9569. }
  9570. }
  9571. // 第一个字符是 'N'
  9572. }
  9573. if (eid[0] != 'N')
  9574. {
  9575. }
  9576. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9577. {
  9578. entity.IsVerifyToSupplier = false;
  9579. entity.IsReturn = 1;
  9580. entity.ReturnTime = DateTime.Now;
  9581. entity.ReturnReason = reason;
  9582. if (entity.OrderState == 6)
  9583. {
  9584. entity.OrderState = 5;
  9585. }
  9586. entity.Update();
  9587. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9588. if (withdraw != null)
  9589. {
  9590. withdraw.status = int.Parse(reason);
  9591. withdraw.Update();
  9592. }
  9593. returnSuccessMsg("操作成功!");
  9594. return;
  9595. }
  9596. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9597. {
  9598. ;
  9599. if (withdraw != null)
  9600. {
  9601. withdraw.status = int.Parse(reason);
  9602. withdraw.acknowledgingtime = DateTime.Now;
  9603. withdraw.Update();
  9604. returnSuccessMsg("供应商取消撤回!");
  9605. return;
  9606. }
  9607. }
  9608. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9609. {
  9610. if (entity.OrderState == -1)
  9611. {
  9612. if (entity.FinishPlaceTime == null)
  9613. {
  9614. entity.OrderState = 2;
  9615. }
  9616. else
  9617. {
  9618. entity.OrderState = 3;
  9619. }
  9620. commonHelper.getCytPrice(entity);
  9621. }
  9622. entity.Update();
  9623. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9624. if (withdraw != null)
  9625. {
  9626. withdraw.status = int.Parse(reason);
  9627. withdraw.Update();
  9628. }
  9629. returnSuccessMsg("操作成功!");
  9630. return;
  9631. }
  9632. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9633. {
  9634. if (withdraw == null)
  9635. {
  9636. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9637. return;
  9638. }
  9639. }
  9640. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9641. {
  9642. if (withdraw != null)
  9643. {
  9644. withdraw.status = int.Parse(reason);
  9645. withdraw.acknowledgingtime = DateTime.Now;
  9646. withdraw.Update();
  9647. returnSuccessMsg("查看详细请点击线下订单查询");
  9648. return;
  9649. }
  9650. }
  9651. return;
  9652. }
  9653. }
  9654. //校验报价
  9655. public void refund_order_tip()
  9656. {
  9657. int userid = CurrentUser.UserID;
  9658. int sectionId = CurrentUser.UserPost.OrgID;
  9659. StringBuilder sql = new StringBuilder();
  9660. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9661. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9662. List<string> ids = new List<string>();
  9663. if (dth.Rows.Count > 0)
  9664. {
  9665. foreach (DataRow dr in dth.Rows)
  9666. {
  9667. ids.Add(dr["ID"].ToString());
  9668. }
  9669. try
  9670. {
  9671. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9672. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9673. }
  9674. catch (Exception ex)
  9675. {
  9676. }
  9677. }
  9678. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9679. }
  9680. public void refund_order_Design()
  9681. {
  9682. int userid = CurrentUser.UserID;
  9683. int sectionId = CurrentUser.UserPost.OrgID;
  9684. StringBuilder sql = new StringBuilder();
  9685. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9686. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9687. List<string> ids = new List<string>();
  9688. if (dth.Rows.Count > 0)
  9689. {
  9690. foreach (DataRow dr in dth.Rows)
  9691. {
  9692. ids.Add(dr["ID"].ToString());
  9693. }
  9694. try
  9695. {
  9696. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9697. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9698. }
  9699. catch (Exception ex)
  9700. {
  9701. }
  9702. }
  9703. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9704. }
  9705. public void change_order_info()
  9706. {
  9707. int userid = CurrentUser.UserID;
  9708. StringBuilder sql = new StringBuilder();
  9709. 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);
  9710. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9711. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9712. }
  9713. public void change_win_mome()
  9714. {
  9715. if (UrlPostParmsCheck("id,ctid"))
  9716. {
  9717. string id = GetPostString("id");
  9718. string ctid = GetPostString("ctid");
  9719. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9720. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9721. if (ce == null || ceErpMessageTip == null)
  9722. {
  9723. returnSuccessMsg("未找到对应的订单!");
  9724. return;
  9725. }
  9726. if (ce.OrderState >= 5)
  9727. {
  9728. returnSuccessMsg("已上传文件无法修改!");
  9729. return;
  9730. }
  9731. int type = GetPostInt("type");
  9732. string content = GetPostString("content");
  9733. if (type == 0)
  9734. {
  9735. content = content.Replace("(", "(");
  9736. content = content.Replace(")", ")");
  9737. string check = MidStrEx(content, "(", ")").Trim();
  9738. if (string.IsNullOrEmpty(check))
  9739. {
  9740. returnSuccessMsg("文件名格式不正确");
  9741. return;
  9742. }
  9743. }
  9744. ce.seller_memo = content;
  9745. ce.Update();
  9746. ceErpMessageTip.isVisit = true;
  9747. ceErpMessageTip.Update();
  9748. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9749. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9750. ApiVo apiVo = new ApiVo();
  9751. apiVo.orderNumber = ce.ctid;
  9752. apiVo.actionName = "demandDesign";
  9753. apiVo.orderRemarks = content;
  9754. apiVo.demandExamine = type + 1;
  9755. designHelper.API_WorkCore(apiVo);//demandDesign
  9756. returnSuccessMsg("修改成功!");
  9757. }
  9758. }
  9759. public static string MidStrEx(string sourse, string startstr, string endstr)
  9760. {
  9761. string result = string.Empty;
  9762. int startindex, endindex;
  9763. try
  9764. {
  9765. startindex = sourse.IndexOf(startstr);
  9766. if (startindex == -1)
  9767. return result;
  9768. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9769. endindex = tmpstr.IndexOf(endstr);
  9770. if (endindex == -1)
  9771. return result;
  9772. result = tmpstr.Remove(endindex);
  9773. }
  9774. catch (Exception ex)
  9775. {
  9776. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9777. }
  9778. return result;
  9779. }
  9780. public void refund_order_list()
  9781. {
  9782. int userid = CurrentUser.UserID;
  9783. int sectionId = CurrentUser.UserPost.OrgID;
  9784. StringBuilder sql = new StringBuilder();
  9785. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9786. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9787. DataStruct dStruct = GetPostStruct();
  9788. DataTable dt = null;
  9789. List<string> ids = new List<string>();
  9790. List<string> tids = new List<string>();
  9791. if (dth.Rows.Count > 0)
  9792. {
  9793. foreach (DataRow dr in dth.Rows)
  9794. {
  9795. tids.Add("'" + dr["tid"].ToString() + "'");
  9796. ids.Add(dr["id"].ToString());
  9797. }
  9798. try
  9799. {
  9800. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9801. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9802. List<string> lw = new List<string>();
  9803. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9804. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9805. dt = WebCache.GetData("view_orderlist", dStruct);
  9806. }
  9807. catch (Exception ex)
  9808. {
  9809. }
  9810. }
  9811. writeGridDataTableJson(dStruct.TotalCount, dt);
  9812. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9813. }
  9814. //新增
  9815. public void order_batch_downloads()
  9816. {
  9817. string ceid = GetPostString("tid");
  9818. String[] tid = ceid.Split(',');
  9819. order_batch_caiyingtong(tid);
  9820. /* (string success, string errors) = UploadFiles(tid);
  9821. returnSuccessMsg(success + errors);*/
  9822. return;
  9823. }
  9824. //报价接口
  9825. public void Get_To_Quote()
  9826. {
  9827. string ceid = GetPostString("ctid");
  9828. if (ceid != null)
  9829. {
  9830. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9831. if (entity != null)
  9832. {
  9833. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9834. {
  9835. return;
  9836. }
  9837. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9838. double price = 0;
  9839. if (cp == null)
  9840. {
  9841. JObject jsonObject12 = new JObject
  9842. {
  9843. { "UserId", "77886" },
  9844. { "Pwd", "lt666888" },
  9845. { "Filename", entity.seller_memo }
  9846. };
  9847. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9848. JObject jsonObjects1 = JObject.Parse(response1);
  9849. string ms1g = (string)jsonObjects1["msg"];
  9850. if (ms1g == "报价成功")
  9851. {
  9852. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9853. string data = (string)jsonObject1["price"];
  9854. 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 + "');";
  9855. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9856. returnSuccessMsg("获取报价成功:" + data);
  9857. price = Convert.ToDouble(data);
  9858. }
  9859. else
  9860. {
  9861. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9862. return;
  9863. }
  9864. }
  9865. String[] beizhu = entity.seller_memo.Split('-');
  9866. String chanp = "";
  9867. if (beizhu.Length > 0)
  9868. {
  9869. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9870. }
  9871. else
  9872. {
  9873. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9874. }
  9875. JObject jsonObject = new JObject
  9876. {
  9877. { "UserId", "77886" },
  9878. { "Pwd", "lt666888" },
  9879. { "Filename", chanp }
  9880. };
  9881. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9882. JObject jsonObjects = JObject.Parse(response);
  9883. string msg = (string)jsonObjects["msg"];
  9884. if (msg == "报价成功")
  9885. {
  9886. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9887. string data = (string)jsonObject1["price"];
  9888. 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 + "');";
  9889. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9890. returnSuccessMsg("获取报价成功:" + data);
  9891. price = Convert.ToDouble(data);
  9892. }
  9893. else
  9894. {
  9895. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9896. return;
  9897. }
  9898. if (price > 0)
  9899. {
  9900. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9901. if (ceErpTradeCellExtend == null)
  9902. {
  9903. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9904. ceErpTradeCellExtend.ctid = entity.ctid;
  9905. ceErpTradeCellExtend.payment_cyt = price;
  9906. ceErpTradeCellExtend.Create();
  9907. }
  9908. else
  9909. {
  9910. ceErpTradeCellExtend.payment_cyt = price;
  9911. ceErpTradeCellExtend.Update();
  9912. }
  9913. }
  9914. return;
  9915. }
  9916. }
  9917. else
  9918. {
  9919. returnErrorMsg("请至少选择一条数据");
  9920. return;
  9921. }
  9922. }
  9923. //新增
  9924. public void order_To_Supplier()
  9925. {
  9926. string ceid = GetPostString("tid");
  9927. String[] tid = ceid.Split(',');
  9928. if (tid.Length > 0)
  9929. {
  9930. try
  9931. {
  9932. for (int i = 0; i < tid.Length; i++)
  9933. {
  9934. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9935. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9936. entity.SupplierId = suid;
  9937. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9938. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9939. entity.Update();
  9940. }
  9941. }
  9942. catch (Exception ex)
  9943. {
  9944. returnErrorMsg("自动匹配供应商失败");
  9945. return;
  9946. }
  9947. }
  9948. else
  9949. {
  9950. returnErrorMsg("请至少选择一条数据");
  9951. return;
  9952. }
  9953. returnSuccessMsg("自动匹配供应商成功");
  9954. return;
  9955. }
  9956. public (string, string) UploadFiles(string[] urls)
  9957. {
  9958. string success = "";
  9959. string errors = "";
  9960. int userid = CurrentUser.UserID;
  9961. foreach (string url in urls)
  9962. {
  9963. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9964. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9965. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9966. {
  9967. JObject jsonObject = new JObject
  9968. {
  9969. { "Userid", "77886" },
  9970. { "pwd", "cyt86435015" },
  9971. { "content", base64FileContent },
  9972. { "ext", Path.GetExtension(fileName) }
  9973. };
  9974. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9975. JObject jsonObjects = JObject.Parse(response);
  9976. string msg = (string)jsonObjects["msg"];
  9977. if (msg.Equals("上传成功"))
  9978. {
  9979. success += url + " 上传成功";
  9980. }
  9981. else
  9982. {
  9983. errors += url + " 上传失败";
  9984. }
  9985. }
  9986. else
  9987. {
  9988. errors += url + " 格式出现问题";
  9989. }
  9990. }
  9991. if (urls.Length == 0)
  9992. {
  9993. return (success, errors);
  9994. }
  9995. return (success, errors);
  9996. }
  9997. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9998. {
  9999. return true; //总是接受
  10000. }
  10001. public static string HttpPost(string url, string param = null)
  10002. {
  10003. HttpWebRequest request;
  10004. //如果是发送HTTPS请求
  10005. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10006. {
  10007. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10008. request = WebRequest.Create(url) as HttpWebRequest;
  10009. request.ProtocolVersion = HttpVersion.Version10;
  10010. }
  10011. else
  10012. {
  10013. request = WebRequest.Create(url) as HttpWebRequest;
  10014. }
  10015. request.Method = "POST";
  10016. request.ContentType = "application/json";
  10017. request.Accept = "*/*";
  10018. request.Timeout = 120000;
  10019. request.AllowAutoRedirect = false;
  10020. StreamWriter requestStream = null;
  10021. WebResponse response = null;
  10022. string responseStr = null;
  10023. try
  10024. {
  10025. requestStream = new StreamWriter(request.GetRequestStream());
  10026. requestStream.Write(param);
  10027. requestStream.Close();
  10028. response = request.GetResponse();
  10029. if (response != null)
  10030. {
  10031. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10032. responseStr = reader.ReadToEnd();
  10033. reader.Close();
  10034. }
  10035. }
  10036. catch (Exception ex)
  10037. {
  10038. return ex.Message;
  10039. }
  10040. finally
  10041. {
  10042. request = null;
  10043. requestStream = null;
  10044. response = null;
  10045. }
  10046. return responseStr;
  10047. }
  10048. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10049. {
  10050. string base64FileContent;
  10051. string fileName;
  10052. using (WebClient webClient = new WebClient())
  10053. {
  10054. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10055. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10056. {
  10057. using (Stream stream = response.GetResponseStream())
  10058. {
  10059. using (MemoryStream memoryStream = new MemoryStream())
  10060. {
  10061. stream.CopyTo(memoryStream);
  10062. byte[] fileBytes = memoryStream.ToArray();
  10063. base64FileContent = Convert.ToBase64String(fileBytes);
  10064. fileName = response.Headers["Content-Disposition"];
  10065. if (!string.IsNullOrEmpty(fileName))
  10066. {
  10067. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10068. if (index >= 0)
  10069. {
  10070. fileName = fileName.Substring(index + 9).Trim('\"');
  10071. }
  10072. }
  10073. else
  10074. {
  10075. fileName = Path.GetFileName(downloadUrl);
  10076. }
  10077. }
  10078. }
  10079. }
  10080. }
  10081. return (fileName, base64FileContent);
  10082. }
  10083. //新增
  10084. public void order_batch_caiyingtong(string[] downloadUrls)
  10085. {
  10086. try
  10087. {
  10088. //遍历文件
  10089. DataStruct dStruct = GetPostStruct();
  10090. DataTable dt = null;
  10091. int userid = CurrentUser.UserID;
  10092. List<string> ids = new List<string>();//失败组
  10093. List<string> tids = new List<string>();
  10094. using (WebClient webClient = new WebClient())
  10095. {
  10096. foreach (var url in downloadUrls)
  10097. {
  10098. try
  10099. {
  10100. tids.Add("'" + url + "'");
  10101. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10102. if (entity != null)
  10103. {
  10104. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10105. if (cp == null)
  10106. {
  10107. JObject jsonObject = new JObject
  10108. {
  10109. { "Userid", "77886" },
  10110. { "pwd", "lt666888" },
  10111. { "Filename",entity.seller_memo }
  10112. };
  10113. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10114. JObject jsonObjects = JObject.Parse(response);
  10115. string msg = (string)jsonObjects["msg"];
  10116. if (msg == "报价成功")
  10117. {
  10118. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10119. DownloadAndConvertToBase64(url1);
  10120. }
  10121. else
  10122. {
  10123. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10124. }
  10125. }
  10126. else
  10127. {
  10128. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10129. JObject jsonObject = new JObject
  10130. {
  10131. { "Userid", "77886" },
  10132. { "pwd", "lt666888" },
  10133. { "Filename",chanp }
  10134. };
  10135. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10136. JObject jsonObjects = JObject.Parse(response);
  10137. string msg = (string)jsonObjects["msg"];
  10138. if (msg == "报价成功")
  10139. {
  10140. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10141. DownloadAndConvertToBase64(url1);
  10142. }
  10143. else
  10144. {
  10145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10146. }
  10147. }
  10148. }
  10149. // 上传文件到FTP
  10150. }
  10151. catch (Exception ex)
  10152. {
  10153. Console.WriteLine($"An error occurred: {ex.Message}");
  10154. }
  10155. }
  10156. List<string> lw = new List<string>();
  10157. lw.Add(string.Format("( OrderState < 6 )"));
  10158. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10159. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10160. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10161. if (dt.Rows.Count > 0)
  10162. {
  10163. foreach (DataRow dr in dt.Rows)
  10164. {
  10165. ids.Add(dr["ctid"].ToString());
  10166. }
  10167. }
  10168. String ErrorMsgs = "";
  10169. foreach (String id in ids)
  10170. {
  10171. ErrorMsgs += id + ",";
  10172. }
  10173. if (ErrorMsgs.Length > 1)
  10174. {
  10175. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10176. }
  10177. if (ErrorMsgs.Length < 1)
  10178. {
  10179. ErrorMsgs = "上传成功";
  10180. returnSuccessMsg(ErrorMsgs);
  10181. }
  10182. else
  10183. {
  10184. returnErrorMsg("以下订单" + ErrorMsgs);
  10185. }
  10186. }
  10187. // 删除文件夹及其内容
  10188. /* Directory.Delete(localDirectory, true);*/
  10189. }
  10190. catch { }
  10191. }
  10192. public void get_center_data()
  10193. {
  10194. int userId = CurrentUser.UserID;
  10195. string postCode = CurrentUser.UserPost.Post.Code;
  10196. List<string> lw = new List<string>();
  10197. List<string> ww = new List<string>();
  10198. DateTime currentTime = DateTime.Now;
  10199. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10200. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10201. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10202. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10203. string sql = " SELECT ";
  10204. string startTime = "2023-10-01 11:22:31";
  10205. //设计
  10206. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10207. {
  10208. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10209. 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));
  10210. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10211. 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));
  10212. }
  10213. //客服
  10214. else if (postCode == "CustomerService" || postCode == "Director")
  10215. {
  10216. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10217. 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));
  10218. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10219. 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));
  10220. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10221. 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));
  10222. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10223. 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));
  10224. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10225. 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));
  10226. }
  10227. //售后
  10228. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10229. {
  10230. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10231. 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));
  10232. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10233. 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));
  10234. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10235. 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));
  10236. }
  10237. //下单部
  10238. else if (postCode == "Place" || postCode == "PlaceMr")
  10239. {
  10240. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10241. 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));
  10242. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10243. 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));
  10244. }
  10245. //车间
  10246. else if (postCode == "Supplier")
  10247. {
  10248. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10249. 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));
  10250. }
  10251. DataTable dt = new DataTable();
  10252. if (lw.Count > 0)
  10253. {
  10254. sql += string.Join(" , ", lw);
  10255. sql += " FROM ";
  10256. sql += string.Join(" , ", ww);
  10257. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10258. }
  10259. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10260. }
  10261. public void get_center_data_list()
  10262. {
  10263. int userId = CurrentUser.UserID;
  10264. string postCode = CurrentUser.UserPost.Post.Code;
  10265. string shopIds = CurrentUser.User.pemShop;
  10266. DataStruct dStruct = GetPostStruct();
  10267. List<string> lw = new List<string>();
  10268. DateTime currentTime = DateTime.Now;
  10269. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10270. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10271. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10272. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10273. string startTime = "2023-10-01 11:22:31";
  10274. int order_type = GetPostInt("order_type");
  10275. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10276. {
  10277. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10278. if (order_type == 0)
  10279. {
  10280. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10281. }
  10282. else if (order_type == 3)
  10283. {
  10284. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10285. }
  10286. else
  10287. {
  10288. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10289. }
  10290. }
  10291. //客服
  10292. if (postCode == "CustomerService" || postCode == "Director")
  10293. {
  10294. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10295. if (order_type == 0)
  10296. {
  10297. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10298. }
  10299. else if (order_type == 1)
  10300. {
  10301. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10302. }
  10303. else if (order_type == 2)
  10304. {
  10305. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10306. }
  10307. else if (order_type == 3)
  10308. {
  10309. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10310. }
  10311. else if (order_type == 4)
  10312. {
  10313. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10314. }
  10315. else
  10316. {
  10317. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10318. }
  10319. }
  10320. //售后
  10321. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10322. {
  10323. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10324. if (shopIds != "")
  10325. {
  10326. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10327. }
  10328. if (order_type == 2)
  10329. {
  10330. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10331. }
  10332. else if (order_type == 4)
  10333. {
  10334. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10335. }
  10336. else if (order_type == 5)
  10337. {
  10338. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10339. }
  10340. else
  10341. {
  10342. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10343. }
  10344. }
  10345. //下单部
  10346. if (postCode == "Place" || postCode == "PlaceMr")
  10347. {
  10348. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10349. if (shopIds != "")
  10350. {
  10351. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10352. }
  10353. else if (order_type == 1)
  10354. {
  10355. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10356. }
  10357. else if (order_type == 2)
  10358. {
  10359. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10360. }
  10361. else
  10362. {
  10363. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10364. }
  10365. }
  10366. //车间
  10367. if (postCode == "Supplier")
  10368. {
  10369. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10370. if (order_type == 5)
  10371. {
  10372. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10373. }
  10374. else
  10375. {
  10376. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10377. }
  10378. }
  10379. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10380. dStruct.Fileds = "tid,ctid";
  10381. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10382. writeGridDataTableJson(dStruct.TotalCount, dt);
  10383. }
  10384. public void aftersale_audit_master()
  10385. {
  10386. if (UrlPostParmsCheck("ctid"))
  10387. {
  10388. string ctid = GetPostString("ctid");
  10389. if (ctid.Length > 0)
  10390. {
  10391. bool result = aftersale_data_change(ctid);
  10392. if (result)
  10393. {
  10394. returnSuccessMsg("修改成功!");
  10395. return;
  10396. }
  10397. }
  10398. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10399. }
  10400. }
  10401. public void aftersale_batch_audit_master()
  10402. {
  10403. if (UrlPostParmsCheck("ctids"))
  10404. {
  10405. string ctids = GetPostString("ctids");
  10406. if (ctids.Length > 0)
  10407. {
  10408. List<string> list = new List<string>();
  10409. string[] ctid_list = ctids.Split(',');
  10410. foreach (var item in ctid_list)
  10411. {
  10412. bool result = aftersale_data_change(item);
  10413. if (!result)
  10414. {
  10415. list.Add(item);
  10416. }
  10417. }
  10418. if (list.Count > 0)
  10419. {
  10420. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10421. return;
  10422. }
  10423. returnSuccessMsg("修改成功!");
  10424. return;
  10425. }
  10426. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10427. }
  10428. }
  10429. public bool aftersale_data_change(string ctid)
  10430. {
  10431. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10432. if (ceErpTradeCell != null)
  10433. {
  10434. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10435. ceErpTradeCell.AfterSaleSupplierState = 0;
  10436. StringBuilder sql = new StringBuilder();
  10437. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10438. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10439. CeErpTradeResponsible.DelByTid(ctid, 0);
  10440. 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 == "不理赔")
  10441. {
  10442. CeErpTradeResponsible.DelByTid(ctid, 1);
  10443. ceErpTradeCell.AfterSaleSupplierState = 1;
  10444. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10445. ceErpTradeCell.AfterSaleState = 4;
  10446. }
  10447. else
  10448. {
  10449. ceErpTradeCell.AfterSaleState = 3;
  10450. }
  10451. bool needCyt = false;
  10452. if (dt != null)
  10453. {
  10454. if (dt.Rows.Count == 1)
  10455. {
  10456. bool isEnd = false;
  10457. foreach (DataRow dr in dt.Rows)
  10458. {
  10459. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10460. {
  10461. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10462. isEnd = true;
  10463. }
  10464. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10465. {
  10466. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10467. isEnd = true;
  10468. }
  10469. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10470. {
  10471. needCyt = true;
  10472. }
  10473. }
  10474. if (isEnd)
  10475. {
  10476. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10477. ceErpTradeCell.AfterSaleState = 4;
  10478. ceErpTradeCell.AfterSaleSupplierState = 1;
  10479. }
  10480. }
  10481. else
  10482. {
  10483. bool isAll = true;
  10484. foreach (DataRow dr in dt.Rows)
  10485. {
  10486. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10487. {
  10488. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10489. continue;
  10490. }
  10491. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10492. {
  10493. string path = "";
  10494. int OrgID = 0;
  10495. if (!Convert.IsDBNull(dr["OrgPath"]))
  10496. {
  10497. path = dr["OrgPath"].ToString();
  10498. }
  10499. if (!Convert.IsDBNull(dr["OrgID"]))
  10500. {
  10501. OrgID = Convert.ToInt32(dr["OrgID"]);
  10502. }
  10503. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10504. {
  10505. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10506. continue;
  10507. }
  10508. }
  10509. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10510. {
  10511. needCyt = true;
  10512. }
  10513. isAll = false;
  10514. }
  10515. if (isAll)
  10516. {
  10517. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10518. ceErpTradeCell.AfterSaleState = 4;
  10519. ceErpTradeCell.AfterSaleSupplierState = 1;
  10520. }
  10521. }
  10522. }
  10523. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10524. {
  10525. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10526. }
  10527. if (ceErpTradeCell.AfterSaleState == 4)
  10528. {
  10529. ApiVo apiVo = new ApiVo();
  10530. apiVo.orderNumber = ceErpTradeCell.ctid;
  10531. apiVo.actionName = "afterOver";
  10532. designHelper.API_WorkCore(apiVo); //afterOver
  10533. }
  10534. ceErpTradeCell.Update();
  10535. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10536. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10537. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10538. return true;
  10539. }
  10540. return false;
  10541. }
  10542. public void get_erp_wechatorder()
  10543. {
  10544. DataStruct dStruct = GetPostStruct();
  10545. List<string> lw = new List<string>();
  10546. string tid = GetPostString("tid");
  10547. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10548. string shopname = GetPostString("shopname");
  10549. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10550. string buyernick = GetPostString("buyer_nick");
  10551. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10552. string customer = GetPostString("customer");
  10553. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10554. string returndate1 = GetPostString("returndate1");
  10555. string returndate2 = GetPostString("returndate2");
  10556. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10557. if (dw.Length > 0) lw.Add(dw);
  10558. string finishDate1 = GetPostString("finishdate1");
  10559. string finishDate2 = GetPostString("finishdate2");
  10560. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10561. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10562. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10563. dStruct.Order = "created desc";
  10564. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10565. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10566. writeGridDataTableJson(dStruct.TotalCount, dt);
  10567. }
  10568. public void get_erp_wechatlist_sumprice()
  10569. {
  10570. DataStruct dStruct = GetPostStruct();
  10571. List<string> lw = new List<string>();
  10572. string tid = GetPostString("tid");
  10573. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10574. string shopname = GetPostString("shopname");
  10575. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10576. string buyernick = GetPostString("buyer_nick");
  10577. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10578. string customer = GetPostString("customer");
  10579. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10580. string returndate1 = GetPostString("returndate1");
  10581. string returndate2 = GetPostString("returndate2");
  10582. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10583. if (dw.Length > 0) lw.Add(dw);
  10584. string finishDate1 = GetPostString("finishdate1");
  10585. string finishDate2 = GetPostString("finishdate2");
  10586. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10587. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10588. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10589. string mainWhere = string.Join(" and ", lw.ToArray());
  10590. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10591. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10592. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10593. decimal total = 0;
  10594. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10595. {
  10596. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10597. }
  10598. var res = new
  10599. {
  10600. data = total
  10601. };
  10602. string ro_jsond = JsonConvert.SerializeObject(res);
  10603. returnSuccess(ro_jsond);
  10604. return;
  10605. }
  10606. public void get_erp_qr_waitdeliverylist()
  10607. {
  10608. DataStruct dStruct = GetPostStruct();
  10609. List<string> lw = new List<string>();
  10610. string tid = GetPostString("ctid");
  10611. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10612. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10613. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10614. var res_objz = new
  10615. {
  10616. restype = 1,
  10617. data = dt
  10618. };
  10619. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10620. returnSuccess(ro_jsonz);
  10621. }
  10622. public void get_erp_yield_list()
  10623. {
  10624. DataStruct dStruct = GetPostStruct();
  10625. List<string> lw = new List<string>();
  10626. string tid = GetPostString("ctid");
  10627. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10628. string shopname = GetPostString("shopname");
  10629. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10630. string buyernick = GetPostString("buyer_nick");
  10631. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10632. //if (tid.Length == 0 && buyernick.Length == 0)
  10633. //{
  10634. // lw.Add(string.Format("IsRefund<={0}", 1));
  10635. //}
  10636. string customer = GetPostString("customer");
  10637. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10638. string design = GetPostString("design");
  10639. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10640. string orderState = GetPostString("orderState");
  10641. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10642. string address = GetPostString("address");
  10643. 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));
  10644. string sellermemo = GetPostString("seller_memo");
  10645. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10646. string supplier = GetPostString("supplier");
  10647. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10648. string OrderArea = GetPostString("order_area");
  10649. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10650. string placedate1 = GetPostString("placedate1");
  10651. string placedate2 = GetPostString("placedate2");
  10652. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10653. if (fdw.Length > 0) lw.Add(fdw);
  10654. string price1 = GetPostString("price1");
  10655. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10656. string price2 = GetPostString("price2");
  10657. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10658. string unusualCon = GetPostString("unusualcon");
  10659. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10660. string posTag = CurrentUser.UserPost.Post.Code;
  10661. if (posTag == "Supplier")
  10662. {
  10663. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10664. }
  10665. lw.Add(string.Format("OrderState = 6 "));
  10666. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10667. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10668. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10669. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10670. writeGridDataTableJson(dStruct.TotalCount, dt);
  10671. }
  10672. public void change_erp_sup_state()
  10673. {
  10674. if (UrlPostParmsCheck("ctid"))
  10675. {
  10676. string ctid = GetPostString("ctid");
  10677. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10678. if (ceErpTradeCell != null)
  10679. {
  10680. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10681. if (ceErpTradeCellExtend == null)
  10682. {
  10683. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10684. ceErpTradeCellExtend.ctid = ctid;
  10685. ceErpTradeCellExtend.SupState = 1;
  10686. ceErpTradeCellExtend.Create();
  10687. }
  10688. else
  10689. {
  10690. ceErpTradeCellExtend.SupState = 1;
  10691. ceErpTradeCellExtend.Update();
  10692. }
  10693. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10694. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10695. return;
  10696. }
  10697. returnErrorMsg("找不到订单");
  10698. }
  10699. }
  10700. public void supplier_all_downs()
  10701. {
  10702. if (UrlPostParmsCheck("tids"))
  10703. {
  10704. string tids = GetPostString("tids");
  10705. if (tids != null && tids.Length > 0)
  10706. {
  10707. StringBuilder sql = new StringBuilder();
  10708. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10709. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10710. sql = new StringBuilder();
  10711. 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, "下载设计文件");
  10712. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10713. string[] list = tids.Split(',');
  10714. foreach (string ctid in list)
  10715. {
  10716. CeErpSukuraData.createInfo(ctid, 3);
  10717. }
  10718. designHelper.api_approveDesign(tids); //approveDesign
  10719. returnSuccessMsg("下载成功!");
  10720. return;
  10721. }
  10722. returnErrorMsg("下载订单更新失败");
  10723. }
  10724. }
  10725. public void uploaderFileSuccess()
  10726. {
  10727. if (UrlPostParmsCheck("fileName"))
  10728. {
  10729. string fileName = GetPostString("fileName");
  10730. ApiVo apiVo = new ApiVo();
  10731. apiVo.orderNumber = fileName;
  10732. apiVo.actionName = "finishDesign";
  10733. designHelper.API_WorkCore(apiVo);//finishDesign
  10734. returnSuccessMsg("");
  10735. }
  10736. }
  10737. public void get_sample2_order()
  10738. {
  10739. if (UrlPostParmsCheck("ctid"))
  10740. {
  10741. string ctid = GetPostString("ctid");
  10742. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10743. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10744. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10745. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10746. double total = 0.0;
  10747. double order_price = 0.0;
  10748. if (dt_bu.Rows.Count > 0)
  10749. {
  10750. foreach (DataRow dr in dt_bu.Rows)
  10751. {
  10752. total += Convert.ToDouble(dr["payment"]);
  10753. }
  10754. }
  10755. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10756. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10757. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10758. string tid = ctid.Replace("S_", "");
  10759. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10760. double paymant = 0.0;
  10761. if (entity != null)
  10762. {
  10763. paymant = entity.payment;
  10764. }
  10765. string return_reason = "";
  10766. if (dt_after != null && dt_after.Rows.Count > 0)
  10767. {
  10768. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10769. }
  10770. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10771. }
  10772. }
  10773. public void get_erp_design_status()
  10774. {
  10775. string designName = GetPostString("designName");
  10776. DataStruct dStruct = GetPostStruct();
  10777. if (designName.Length > 0)
  10778. {
  10779. 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";
  10780. sql_user += " and Name like '%" + designName + "%'";
  10781. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10782. List<string> ids_list = new List<string>();
  10783. if (user_table.Rows.Count > 0)
  10784. {
  10785. foreach (DataRow item in user_table.Rows)
  10786. {
  10787. ids_list.Add(item["id"].ToString());
  10788. string ids_s = item["TeamIds"].ToString();
  10789. if (ids_s.Length > 0)
  10790. {
  10791. ids_list.AddRange(ids_s.Split(','));
  10792. }
  10793. }
  10794. }
  10795. HashSet<string> set = new HashSet<string>(ids_list);
  10796. ids_list = set.ToList();
  10797. if (ids_list.Count > 0)
  10798. {
  10799. 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));
  10800. dStruct.MainWhere = sql;
  10801. DataTable dt = null;
  10802. dt = WebCache.GetData("view_ErpUser", dStruct);
  10803. writeGridDataTableJson(dStruct.TotalCount, dt);
  10804. }
  10805. }
  10806. }
  10807. public void change_erp_order_price()
  10808. {
  10809. string ctid = GetPostString("ctid");
  10810. double price = GetPostDouble("price");
  10811. if (ctid.Length > 0)
  10812. {
  10813. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10814. if (ceErpTradeCellExtend == null)
  10815. {
  10816. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10817. ceErpTradeCellExtend.ctid = ctid;
  10818. ceErpTradeCellExtend.payment_cyt = price;
  10819. ceErpTradeCellExtend.Create();
  10820. }
  10821. else
  10822. {
  10823. ceErpTradeCellExtend.payment_cyt = price;
  10824. ceErpTradeCellExtend.Update();
  10825. }
  10826. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10827. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10828. {
  10829. ceErpDataSendOrderInfo.isSync = false;
  10830. ceErpDataSendOrderInfo.Update();
  10831. }
  10832. if (ceErpDataSendOrderInfo == null)
  10833. {
  10834. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10835. ceErpDataSendOrderInfo.isSync = false;
  10836. ceErpDataSendOrderInfo.ctid = ctid;
  10837. ceErpDataSendOrderInfo.Create();
  10838. }
  10839. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10840. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10841. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10842. if (dth != null && dth.Rows.Count > 0)
  10843. {
  10844. dataSendOrderBean dataSendOrderBean = null;
  10845. foreach (DataRow item in dth.Rows)
  10846. {
  10847. try
  10848. {
  10849. dataSendOrderBean = new dataSendOrderBean();
  10850. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10851. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10852. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10853. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10854. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10855. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10856. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10857. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10858. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10859. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10860. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10861. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10862. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10863. if (result != null)
  10864. {
  10865. if ("0".Equals(result.errcode))
  10866. {
  10867. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10868. }
  10869. else
  10870. {
  10871. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10872. }
  10873. }
  10874. }
  10875. catch (Exception ex)
  10876. {
  10877. }
  10878. }
  10879. }
  10880. returnSuccessMsg("修改成功!");
  10881. return;
  10882. }
  10883. returnErrorMsg("找不到订单");
  10884. }
  10885. public void find_he_together()
  10886. {
  10887. string ctid = GetPostString("ctid");
  10888. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10889. List<string> list = new List<string>();
  10890. if (ceErpTradeCell != null)
  10891. {
  10892. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10893. {
  10894. 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);
  10895. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10896. if (table != null && table.Rows.Count > 0)
  10897. {
  10898. foreach (TableRow row in table.Rows)
  10899. {
  10900. }
  10901. }
  10902. }
  10903. }
  10904. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10905. }
  10906. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10907. {
  10908. //chy----19
  10909. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10910. //GD-CYT-----64
  10911. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10912. //ZHX----3
  10913. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10914. //JK----97
  10915. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10916. //ZT----70
  10917. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10918. //LHCY-----98
  10919. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10920. //XD-----90
  10921. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10922. //CYCY-----14
  10923. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10924. };
  10925. //其他改名
  10926. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10927. {
  10928. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10929. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10930. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10931. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10932. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10933. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10934. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10935. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10936. };
  10937. //不统计
  10938. List<int> no_suppliers = new List<int>()
  10939. {
  10940. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10941. };
  10942. //配件单
  10943. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10944. {
  10945. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10946. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10947. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10948. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10949. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10950. {"旗杆",new List<string>(){ "班旗" } },
  10951. {"牙签",new List<string>(){ "不干胶" } }
  10952. };
  10953. public void get_place_order_data()
  10954. {
  10955. string date1 = GetPostString("date1");
  10956. string date2 = GetPostString("date2");
  10957. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10958. DateTime start = DateTime.Parse(starttime);
  10959. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10960. DateTime end = DateTime.Parse(endtime);
  10961. if (date1 != null && date1.Length > 0)
  10962. {
  10963. DateTime dateTime = DateTime.Parse(date1);
  10964. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10965. start = DateTime.Parse(starttime);
  10966. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10967. end = DateTime.Parse(endtime);
  10968. }
  10969. if (date2 != null && date2.Length > 0)
  10970. {
  10971. DateTime dateTime = DateTime.Parse(date2);
  10972. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10973. end = DateTime.Parse(endtime);
  10974. }
  10975. 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);
  10976. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10977. //不干胶-----1,卡片-----29
  10978. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10979. foreach (DataRow row in data.Rows)
  10980. {
  10981. int productId = Convert.ToInt32(row["ProductId"]);
  10982. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10983. if (no_suppliers.Contains(supplierId))
  10984. {
  10985. continue;
  10986. }
  10987. string seller_memo = row["seller_memo"].ToString();
  10988. bool ispj = false;//是否配件单
  10989. bool isfirst = true;//第一个配
  10990. maps.Keys.ForEach(key =>
  10991. {
  10992. //备注包含配件
  10993. if (seller_memo.Contains(key) && isfirst)
  10994. {
  10995. List<string> list = maps[key];
  10996. ispj = true;
  10997. isfirst = false;
  10998. for (int i = 0; i < list.Count; i++)
  10999. {
  11000. if (seller_memo.Contains(list[i]))
  11001. {
  11002. ispj = false;
  11003. break;
  11004. }
  11005. }
  11006. }
  11007. });
  11008. if (ispj)
  11009. {
  11010. continue;
  11011. }
  11012. seller_memo = seller_memo.Replace("UV", "uv");
  11013. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11014. //吊牌归到卡片
  11015. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11016. seller_memo = seller_memo.Replace("卡套", "卡片");
  11017. seller_memo = seller_memo.Replace("封套", "卡片");
  11018. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11019. seller_memo = seller_memo.Replace("腰封", "卡片");
  11020. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11021. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11022. seller_memo = seller_memo.Replace("横幅", "条幅");
  11023. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11024. string map_key = "";
  11025. string type = "";
  11026. if (supplierMap.ContainsKey(supplierId))
  11027. {
  11028. foreach (var kvp in supplierMap[supplierId])
  11029. {
  11030. if (seller_memo.Contains(kvp.Key))
  11031. {
  11032. map_key = kvp.Value;
  11033. type = kvp.Value;
  11034. break;
  11035. }
  11036. }
  11037. }
  11038. if (map_key == "")
  11039. {
  11040. type = "其他";
  11041. map_key = "其他";
  11042. }
  11043. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11044. {
  11045. map_key = suppliers[supplierId];
  11046. }
  11047. if (supplierId == 70)
  11048. {
  11049. supplierId = 70;
  11050. }
  11051. map_key += "_" + row["SupplierName"].ToString();
  11052. Dictionary<string, int> map = null;
  11053. if (other_map.ContainsKey(map_key))
  11054. {
  11055. other_map.TryGetValue(map_key, out map);
  11056. }
  11057. else
  11058. {
  11059. map = new Dictionary<string, int>();
  11060. map.Add("dayDev", 0);//当天出货
  11061. map.Add("dayTotal", 0);//下单总数
  11062. map.Add("payTotal", 0);//500以上
  11063. map.Add("today", 0);//当天出货数量
  11064. map.Add("unusua", 0);//异常数
  11065. other_map.Add(map_key, map);
  11066. other_map.TryGetValue(map_key, out map);
  11067. }
  11068. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11069. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11070. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11071. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11072. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11073. {
  11074. map["dayTotal"]++;
  11075. if (supplierId == 97)
  11076. {
  11077. supplierId = 97;
  11078. }
  11079. }
  11080. if (Convert.ToDecimal(row["payment"]) >= 500)
  11081. {
  11082. map["payTotal"]++;
  11083. }
  11084. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11085. {
  11086. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11087. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11088. {
  11089. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11090. {
  11091. map["today"]++;
  11092. }
  11093. }
  11094. else
  11095. {
  11096. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11097. {
  11098. map["today"]++;
  11099. }
  11100. else
  11101. {
  11102. if (supplierId == 119)
  11103. {
  11104. Debug.WriteLine(row["seller_memo"].ToString());
  11105. }
  11106. }
  11107. }
  11108. }
  11109. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11110. {
  11111. map["unusua"]++;
  11112. }
  11113. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11114. //GD-CYT-----64
  11115. DateTime two = palceTimeStart.AddHours(14);
  11116. DateTime three = palceTimeStart.AddHours(15);
  11117. DateTime four = palceTimeStart.AddHours(16);
  11118. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11119. {
  11120. //下午四点前 500-1000
  11121. string count = row["ProductCount"].ToString();
  11122. if (count != null && count.Length > 0)
  11123. {
  11124. int productCount = commonHelper.getPlaceProductCount(count);
  11125. if (productCount >= 500 && productCount <= 1000)
  11126. {
  11127. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11128. {
  11129. map["dayDev"]++;
  11130. }
  11131. }
  11132. }
  11133. }
  11134. //UV
  11135. else if ("uv".Equals(type))
  11136. {
  11137. //ZT----70
  11138. //ZHX----3
  11139. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11140. {
  11141. map["dayDev"]++;
  11142. }
  11143. //JK----97
  11144. //HZX----105
  11145. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11146. {
  11147. map["dayDev"]++;
  11148. if (supplierId == 97)
  11149. {
  11150. supplierId = 97;
  11151. }
  11152. }
  11153. }
  11154. //帆布---52|条幅---27
  11155. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11156. {
  11157. //LHCY-----98
  11158. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11159. {
  11160. map["dayDev"]++;
  11161. }
  11162. }
  11163. //条幅
  11164. else if ("条幅".Equals(type))
  11165. {
  11166. //XD-----90
  11167. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11168. {
  11169. map["dayDev"]++;
  11170. }
  11171. }
  11172. //桌布
  11173. else if ("桌布".Equals(type))
  11174. {
  11175. //XD-----90
  11176. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11177. {
  11178. map["dayDev"]++;
  11179. }
  11180. }
  11181. //DL---10
  11182. //AYTW---119
  11183. //FS-CYT-DY ----80
  11184. //JK----97
  11185. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11186. {
  11187. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11188. {
  11189. map["dayDev"]++;
  11190. }
  11191. }
  11192. }
  11193. DataTable dt = new DataTable();
  11194. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11195. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11196. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11197. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11198. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11199. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11200. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11201. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11202. other_map.Keys.ForEach(key =>
  11203. {
  11204. DataRow dr = dt.NewRow();
  11205. Dictionary<string, int> map = other_map[key];
  11206. string[] key_list = key.Split('_');
  11207. dr[0] = key_list[0];
  11208. dr[1] = key_list[1];
  11209. if (key_list.Length > 2)
  11210. {
  11211. dr[1] += "(" + key_list[2] + ")";
  11212. }
  11213. dr[2] = map["dayTotal"];
  11214. dr[3] = map["payTotal"];
  11215. dr[4] = map["today"];
  11216. dr[5] = map["unusua"];
  11217. dr[6] = map["dayDev"];
  11218. double rate = 0.00;
  11219. if (map["dayDev"] > 0)
  11220. {
  11221. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11222. }
  11223. dr[7] = rate.ToString();
  11224. dt.Rows.Add(dr);
  11225. });
  11226. DataView dv = new DataView(dt);
  11227. dv.Sort = "SupplierName";
  11228. //dv.Sort = "AllOrder desc";
  11229. DataTable dtNew = dv.ToTable();
  11230. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11231. }
  11232. public void check_order_desing_info()
  11233. {
  11234. string ctid = GetPostString("ctid");
  11235. if (!string.IsNullOrEmpty(ctid))
  11236. {
  11237. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11238. if (ceErpTradeCell != null)
  11239. {
  11240. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11241. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11242. return;
  11243. }
  11244. returnErrorMsg("找不到订单");
  11245. return;
  11246. }
  11247. returnErrorMsg("找不到订单");
  11248. }
  11249. public void get_timeout_detail()
  11250. {
  11251. string poscode = CurrentUser.UserPost.Post.Code;
  11252. DataStruct dStruct = GetPostStruct();
  11253. List<string> lw = new List<string>();
  11254. string id = GetPostString("id");
  11255. string pay_date1 = GetPostString("pay_date1");
  11256. string pay_date2 = GetPostString("pay_date2");
  11257. int type = GetPostInt("type");
  11258. if (type == 0)
  11259. {
  11260. if (pay_date1.Length > 0)
  11261. {
  11262. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11263. }
  11264. if (pay_date2.Length > 0)
  11265. {
  11266. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11267. }
  11268. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11269. }
  11270. if (type == 1)
  11271. {
  11272. if (pay_date1.Length > 0)
  11273. {
  11274. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11275. }
  11276. if (pay_date2.Length > 0)
  11277. {
  11278. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11279. }
  11280. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11281. }
  11282. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11283. DataTable dt = null;
  11284. dt = WebCache.GetData("view_orderlist", dStruct);
  11285. writeGridDataTableJson(dStruct.TotalCount, dt);
  11286. }
  11287. public void saveUrgentChargePrice()
  11288. {
  11289. string ctid = GetPostString("ctid");
  11290. if (!string.IsNullOrEmpty(ctid))
  11291. {
  11292. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11293. if (ceErpTradeCell != null)
  11294. {
  11295. double price = GetPostDouble("price");
  11296. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11297. if (ceErpTradeCellExtend == null)
  11298. {
  11299. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11300. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11301. }
  11302. ceErpTradeCellExtend.urgentCharge = price;
  11303. if (ceErpTradeCellExtend.ID > 0)
  11304. {
  11305. ceErpTradeCellExtend.Update();
  11306. }
  11307. else
  11308. {
  11309. ceErpTradeCellExtend.Save();
  11310. }
  11311. returnSuccessMsg("修改成功!");
  11312. return;
  11313. }
  11314. returnErrorMsg("找不到订单");
  11315. return;
  11316. }
  11317. returnErrorMsg("找不到订单");
  11318. }
  11319. public void finish_erp_order()
  11320. {
  11321. string ctid = GetPostString("ctid");
  11322. if (!string.IsNullOrEmpty(ctid))
  11323. {
  11324. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11325. {
  11326. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11327. if (ceErpTradeCell != null)
  11328. {
  11329. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11330. ceErpTradeCell.Update();
  11331. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11332. returnSuccessMsg("修改成功!");
  11333. return;
  11334. }
  11335. }
  11336. }
  11337. returnErrorMsg("找不到订单");
  11338. }
  11339. public void get_trade_order_list()
  11340. {
  11341. string tid = GetPostString("tid");
  11342. if (!string.IsNullOrEmpty(tid))
  11343. {
  11344. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11345. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11346. writeGridDataTableJson(data.Rows.Count, data);
  11347. return;
  11348. }
  11349. returnErrorMsg("找不到订单");
  11350. }
  11351. public void save_cell_spu()
  11352. {
  11353. string ctid = GetPostString("ctid");
  11354. string spu_id = GetPostString("spu_id");
  11355. if (!string.IsNullOrEmpty(ctid))
  11356. {
  11357. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11358. if (ceErpTradeCellExtend == null)
  11359. {
  11360. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11361. ceErpTradeCellExtend.ctid = ctid;
  11362. }
  11363. ceErpTradeCellExtend.spu_id = spu_id;
  11364. if (ceErpTradeCellExtend.ID == 0)
  11365. {
  11366. ceErpTradeCellExtend.Create();
  11367. }
  11368. else
  11369. {
  11370. ceErpTradeCellExtend.Update();
  11371. }
  11372. returnSuccessMsg("修改成功!");
  11373. return;
  11374. }
  11375. returnErrorMsg("找不到订单");
  11376. }
  11377. public void change_express_info()
  11378. {
  11379. string ctid = GetPostString("ctid");
  11380. string transNo = GetPostString("transNo");
  11381. string transCom = GetPostString("transCom");
  11382. if (!string.IsNullOrEmpty(ctid))
  11383. {
  11384. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11385. if (ceErpTradeCellExtend == null)
  11386. {
  11387. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11388. ceErpTradeCellExtend.ctid = ctid;
  11389. }
  11390. ceErpTradeCellExtend.modExpressNo = transNo;
  11391. ceErpTradeCellExtend.modExpressCom = transCom;
  11392. ceErpTradeCellExtend.readMod = 2;
  11393. if (ceErpTradeCellExtend.ID == 0)
  11394. {
  11395. ceErpTradeCellExtend.Create();
  11396. }
  11397. else
  11398. {
  11399. ceErpTradeCellExtend.Update();
  11400. }
  11401. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11402. returnSuccessMsg("修改成功!");
  11403. return;
  11404. }
  11405. returnErrorMsg("找不到订单");
  11406. }
  11407. public void get_change_express_list()
  11408. {
  11409. DataStruct dStruct = GetPostStruct();
  11410. List<string> lw = new List<string>();
  11411. int st = 2;
  11412. string tid = GetPostString("ctid");
  11413. if (tid.Length > 0)
  11414. {
  11415. string select_tid = getTidByCtid(tid);
  11416. lw.Add(string.Format("tid='{0}'", select_tid));
  11417. }
  11418. string shopname = GetPostString("shopname");
  11419. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11420. string buyernick = GetPostString("buyer_nick");
  11421. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11422. string sellermemo = GetPostString("seller_memo");
  11423. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11424. string supplier = GetPostString("supplier");
  11425. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11426. string customer = GetPostString("customer");
  11427. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11428. string design = GetPostString("design");
  11429. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11430. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11431. string poscode = CurrentUser.UserPost.Post.Code;
  11432. if (poscode != "SysAdmin")
  11433. {
  11434. string shopid = CurrentUser.User.pemShop;
  11435. lw.Add(string.Format("shopId in ({0})", shopid));
  11436. }
  11437. lw.Add("readMod = 2");
  11438. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11439. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11440. writeGridDataTableJson(dStruct.TotalCount, dt);
  11441. }
  11442. public void deal_express_complete()
  11443. {
  11444. string ctid = GetPostString("ctid");
  11445. if (!string.IsNullOrEmpty(ctid))
  11446. {
  11447. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11448. if (ceErpTradeCellExtend == null)
  11449. {
  11450. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11451. ceErpTradeCellExtend.ctid = ctid;
  11452. }
  11453. ceErpTradeCellExtend.readMod = 1;
  11454. if (ceErpTradeCellExtend.ID == 0)
  11455. {
  11456. ceErpTradeCellExtend.Create();
  11457. }
  11458. else
  11459. {
  11460. ceErpTradeCellExtend.Update();
  11461. }
  11462. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11463. returnSuccessMsg("修改成功!");
  11464. return;
  11465. }
  11466. returnErrorMsg("找不到订单");
  11467. }
  11468. public void aftersale_return_visit()
  11469. {
  11470. string ctid = GetPostString("ctid");
  11471. if (!string.IsNullOrEmpty(ctid))
  11472. {
  11473. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11474. if (ceErpTradeCellExtend == null)
  11475. {
  11476. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11477. ceErpTradeCellExtend.ctid = ctid;
  11478. }
  11479. ceErpTradeCellExtend.returnVisit = 1;
  11480. if (ceErpTradeCellExtend.ID == 0)
  11481. {
  11482. ceErpTradeCellExtend.Create();
  11483. }
  11484. else
  11485. {
  11486. ceErpTradeCellExtend.Update();
  11487. }
  11488. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11489. if (ceErpTradeAfterSaleExtend != null)
  11490. {
  11491. ceErpTradeAfterSaleExtend.TextResult = "";
  11492. ceErpTradeAfterSaleExtend.Update();
  11493. }
  11494. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11495. returnSuccessMsg("修改成功!");
  11496. return;
  11497. }
  11498. returnErrorMsg("找不到订单");
  11499. }
  11500. public void orderPlaceInfo()
  11501. {
  11502. string ctids = GetPostString("ctids");
  11503. string[] list = ctids.Split(',');
  11504. foreach (string ctid in list)
  11505. {
  11506. CeErpSukuraData.createInfo(ctid, 3);
  11507. }
  11508. StringBuilder sql = new StringBuilder();
  11509. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11510. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11511. designHelper.api_approveDesign(ctids); //approveDesign
  11512. returnSuccessMsg("");
  11513. }
  11514. public void get_issue_list()
  11515. {
  11516. DataStruct dStruct = GetPostStruct();
  11517. List<string> lw = new List<string>();
  11518. int st = 2;
  11519. string tid = GetPostString("ctid");
  11520. if (tid.Length > 0)
  11521. {
  11522. string select_tid = getTidByCtid(tid);
  11523. lw.Add(string.Format("tid='{0}'", select_tid));
  11524. }
  11525. string shopname = GetPostString("shopname");
  11526. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11527. string buyernick = GetPostString("buyer_nick");
  11528. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11529. string sellermemo = GetPostString("seller_memo");
  11530. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11531. string supplier = GetPostString("supplier");
  11532. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11533. string customer = GetPostString("customer");
  11534. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11535. string design = GetPostString("design");
  11536. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11537. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11538. string poscode = CurrentUser.UserPost.Post.Code;
  11539. if (poscode != "SysAdmin")
  11540. {
  11541. string shopid = CurrentUser.User.pemShop;
  11542. lw.Add(string.Format("shopId in ({0})", shopid));
  11543. }
  11544. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11545. {
  11546. lw.Add("IssueState = 1");
  11547. }
  11548. lw.Add("IssueState > 0");
  11549. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11550. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11551. writeGridDataTableJson(dStruct.TotalCount, dt);
  11552. }
  11553. public void saveIssueContent()
  11554. {
  11555. string ctid = GetPostString("ctid");
  11556. if (!string.IsNullOrEmpty(ctid))
  11557. {
  11558. string content = GetPostString("content");
  11559. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11560. if (ceErpTradeAfterSaleExtend == null)
  11561. {
  11562. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11563. ceErpTradeAfterSaleExtend.tid = ctid;
  11564. }
  11565. ceErpTradeAfterSaleExtend.IssueContent = content;
  11566. ceErpTradeAfterSaleExtend.IssueState = 1;
  11567. if (ceErpTradeAfterSaleExtend.ID > 0)
  11568. {
  11569. ceErpTradeAfterSaleExtend.Update();
  11570. }
  11571. else
  11572. {
  11573. ceErpTradeAfterSaleExtend.Create();
  11574. }
  11575. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11576. returnSuccessMsg("添加成功!");
  11577. return;
  11578. }
  11579. returnErrorMsg("找不到订单");
  11580. }
  11581. public void dealIssueContent()
  11582. {
  11583. string ctid = GetPostString("ctid");
  11584. if (!string.IsNullOrEmpty(ctid))
  11585. {
  11586. string content = GetPostString("content");
  11587. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11588. if (ceErpTradeAfterSaleExtend != null)
  11589. {
  11590. ceErpTradeAfterSaleExtend.IssueState = 2;
  11591. ceErpTradeAfterSaleExtend.Update();
  11592. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11593. returnSuccessMsg("修改完成!");
  11594. return;
  11595. }
  11596. }
  11597. returnErrorMsg("找不到订单");
  11598. }
  11599. public void set_tid_attachments()
  11600. {
  11601. string tid = GetPostString("tid");
  11602. string atta = GetPostString("atta");
  11603. if (!string.IsNullOrEmpty(tid))
  11604. {
  11605. if (string.IsNullOrEmpty(atta))
  11606. {
  11607. returnErrorMsg("文件地址为空");
  11608. return;
  11609. }
  11610. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11611. if (ceErpTradeCell != null)
  11612. {
  11613. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11614. if (ceErpTrade == null)
  11615. {
  11616. returnErrorMsg("找不到订单");
  11617. return;
  11618. }
  11619. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11620. bool isSend = false;
  11621. if (dt != null && dt.Rows.Count > 0)
  11622. {
  11623. foreach (DataRow row in dt.Rows)
  11624. {
  11625. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11626. {
  11627. isSend = true;
  11628. }
  11629. }
  11630. if (isSend)
  11631. {
  11632. returnErrorMsg("已发货无法修改");
  11633. return;
  11634. }
  11635. ceErpTrade.Attachments = atta;
  11636. ceErpTrade.Update();
  11637. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11638. returnSuccessMsg("上传成功!");
  11639. return;
  11640. }
  11641. }
  11642. }
  11643. returnErrorMsg("找不到订单");
  11644. }
  11645. public void get_tid_attachments()
  11646. {
  11647. string tid = GetPostString("tid");
  11648. if (!string.IsNullOrEmpty(tid))
  11649. {
  11650. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11651. if (ceErpTradeCell != null)
  11652. {
  11653. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11654. if (ceErpTrade == null)
  11655. {
  11656. returnErrorMsg("找不到订单");
  11657. return;
  11658. }
  11659. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11660. return;
  11661. }
  11662. }
  11663. returnErrorMsg("找不到订单");
  11664. }
  11665. public void check_erp_sameorders()
  11666. {
  11667. if (UrlPostParmsCheck("ctid"))
  11668. {
  11669. string eid = GetPostString("ctid");
  11670. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11671. if (entity != null)
  11672. {
  11673. StringBuilder sql = new StringBuilder();
  11674. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11675. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11676. List<string> ids = new List<string>();
  11677. if (dt != null && dt.Rows.Count > 1)
  11678. {
  11679. bool needhe = false;
  11680. foreach (DataRow dr in dt.Rows)
  11681. {
  11682. ids.Add("'" + dr["ctid"] + "'");
  11683. //备注有合包
  11684. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11685. {
  11686. needhe = true;
  11687. }
  11688. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11689. {
  11690. needhe = true;
  11691. }
  11692. //顺丰快递
  11693. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11694. {
  11695. needhe = true;
  11696. }
  11697. }
  11698. if (!needhe)
  11699. {
  11700. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11701. return;
  11702. }
  11703. sql = new StringBuilder();
  11704. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11705. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11706. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11707. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11708. foreach (DataRow dr in dt.Rows)
  11709. {
  11710. dr["dstate"] = 0;
  11711. dr["dnumber"] = 0;
  11712. foreach (DataRow row in dt1.Rows)
  11713. {
  11714. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11715. {
  11716. dr["dstate"] = 2;
  11717. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11718. }
  11719. }
  11720. if (eid.Equals(dr["ctid"].ToString()))
  11721. {
  11722. dr["dstate"] = 1;
  11723. }
  11724. }
  11725. }
  11726. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11727. return;
  11728. }
  11729. returnErrorMsg("未找到订单");
  11730. return;
  11731. }
  11732. returnErrorMsg("缺少必要的参数");
  11733. }
  11734. public void get_mark_number()
  11735. {
  11736. string eid = GetPostString("ctid");
  11737. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11738. if (entity != null)
  11739. {
  11740. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  11741. int current = 1;
  11742. if (ceErpDeliverMark == null)
  11743. {
  11744. StringBuilder sql = new StringBuilder();
  11745. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11746. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11747. List<string> ids = new List<string>();
  11748. if (dt != null && dt.Rows.Count > 1)
  11749. {
  11750. foreach (DataRow dr in dt.Rows)
  11751. {
  11752. ids.Add("'" + dr["ctid"] + "'");
  11753. }
  11754. //查询已有的编号
  11755. sql = new StringBuilder();
  11756. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11757. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11758. if (dt1 == null || dt1.Rows.Count == 0)
  11759. {
  11760. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  11761. List<int> list_number = new List<int>();
  11762. foreach (DataRow row in numbers.Rows)
  11763. {
  11764. list_number.Add(Convert.ToInt32(row["markNumber"]));
  11765. }
  11766. //查询空余编号
  11767. for (int i = 0; i < list_number.Count + 2; i++)
  11768. {
  11769. if (!list_number.Contains(current))
  11770. {
  11771. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  11772. //防止查询过程中有新数据生成
  11773. if (ceErpDeliverMark1 == null)
  11774. {
  11775. break;
  11776. }
  11777. }
  11778. current++;
  11779. }
  11780. }
  11781. else
  11782. {
  11783. foreach (DataRow row in dt1.Rows)
  11784. {
  11785. current = Convert.ToInt32(row["markNumber"]);
  11786. }
  11787. }
  11788. ceErpDeliverMark = new CeErpDeliverMark();
  11789. ceErpDeliverMark.ctid = eid;
  11790. ceErpDeliverMark.createtime = DateTime.Now;
  11791. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11792. if (ceErpTrade != null)
  11793. {
  11794. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  11795. }
  11796. ceErpDeliverMark.markNumber = current;
  11797. ceErpDeliverMark.Create();
  11798. }
  11799. }
  11800. else
  11801. {
  11802. current = ceErpDeliverMark.markNumber;
  11803. }
  11804. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  11805. return;
  11806. }
  11807. }
  11808. }
  11809. }