sync.order.cs 562 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  41. using static SiteCore.taoObj.work_core_vo;
  42. using static System.Net.Mime.MediaTypeNames;
  43. namespace SiteCore.Handler
  44. {
  45. public partial class sync
  46. {
  47. public void get_erp_orderlist()
  48. {
  49. string poscode = CurrentUser.UserPost.Post.Code;
  50. DataStruct dStruct = GetPostStruct();
  51. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  52. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  53. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  54. //banniuApiHelper.sendLogisticsInfo(null);
  55. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  56. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  57. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2449287014185573080");
  58. //int sid = commonHelper.autoDistributeToSupplier(entity);
  59. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  60. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1738821978000,\"deliveryType\":\"OFFLINE\",\"discountFee\":-34.0,\"flag\":\"NONE\",\"lines\":[{\"mark2\":[],\"num\":9,\"outerId\":\"\",\"payment\":350.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2213077796486/O1CN01Tg7cpd1xmdrqFR8F9_!!2-item_pic.png\",\"platServiceFee\":0.0,\"price\":35.0,\"refOlId\":\"2458934582736842566\",\"refSkuId\":\"0\",\"refSpuId\":\"817084548604\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":38.8889,\"singleFee\":38.89,\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"雅柔纸卡片定制logo广告宣传纹理卡纸印刷保养展示饰品卡小卡特种纸名片打印制作包装售后硬卡设计产品养护卡\",\"totalFee\":350.0,\"totalPrice\":315.0,\"totalSellPrice\":350.0},{\"isFreeGift\":true,\"mark2\":[\"GIFT\"],\"num\":1,\"outerId\":\"\",\"payment\":0.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2213077796486/O1CN01Su0uey1xmdtXkF7zu_!!4611686018427381382-0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":1.0,\"refOlId\":\"2458934582737842566\",\"refSkuId\":\"0\",\"refSpuId\":\"856312416459\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.0,\"singleFee\":0.0,\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【联系客服领礼金】【售后保障服务】\",\"totalFee\":0.0,\"totalPrice\":1.0,\"totalSellPrice\":0.0}],\"logisticsOrderNo\":\"\",\"mark2\":[\"GIFT\"],\"modifyTime\":1738821982000,\"openBuyerId\":\"AAEpRHraABkUZRPgSx2LbmHS\",\"openBuyerNick\":\"如**\",\"openSellerNick\":\"领淘文具旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1738821813000,\"payTime\":1738821976000,\"payment\":350.0,\"platServiceFee\":0.0,\"posCode\":\"lingtao\",\"posId\":600090,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"石家庄市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"裕华区\",\"receiverId\":\"a908c5702ff4d1d42009017efc49d0dc$\",\"receiverState\":\"河北省\",\"receiverTown\":\"建通街道\",\"refOid\":\"2458934582735842566\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"90x130mm-200张-卡片-300克铜版纸-双面印刷不覆膜裁切-如何怎样你奈-丹儿-170,90x90mm-200张-卡片-80克硫酸纸-不覆膜单色裁切-如何怎样你奈-丹儿-180\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":350.0,\"totalPrice\":316.0,\"totalSellPrice\":350.0,\"type\":\"SALE\"}}");
  61. //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}}");
  62. List<string> lw = new List<string>();
  63. string tid = GetPostString("ctid");
  64. string date1 = GetPostString("date1");
  65. //12-1 修改
  66. string urgent = GetPostString("urgent");
  67. string back = GetPostString("back");
  68. string offlineSearch = GetPostString("offlineSearch");
  69. int paramsCount = 0;
  70. if (!string.IsNullOrWhiteSpace(urgent))
  71. {
  72. if (urgent.Equals("true"))
  73. {
  74. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  75. }
  76. }
  77. if (!string.IsNullOrWhiteSpace(back))
  78. {
  79. if (back.Equals("true"))
  80. {
  81. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  82. }
  83. }
  84. if (!string.IsNullOrWhiteSpace(offlineSearch))
  85. {
  86. if (offlineSearch.Equals("true"))
  87. {
  88. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  89. }
  90. }
  91. //end
  92. string date2 = GetPostString("date2");
  93. string buyernick = GetPostString("buyer_nick");
  94. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  95. {
  96. if (tid.Length <= 0 && buyernick.Length <= 0)
  97. {
  98. return;
  99. }
  100. }
  101. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  102. {
  103. if (tid.Length > 0)
  104. {
  105. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  106. }
  107. if (buyernick.Length > 0)
  108. {
  109. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  110. }
  111. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  112. if (dw.Length > 0)
  113. {
  114. lw.Add(dw);
  115. }
  116. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  117. {
  118. string usershop = CurrentUser.User.pemShop;
  119. lw.Add(string.Format("ShopId in ({0})", usershop));
  120. }
  121. }
  122. else
  123. {
  124. if (ex_psize == 0)
  125. {
  126. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  127. }
  128. if (PKey != "admin")
  129. {
  130. string usershop = CurrentUser.User.pemShop;
  131. lw.Add(string.Format("ShopId in ({0})", usershop));
  132. paramsCount++;
  133. }
  134. }
  135. string uploaddate1 = GetPostString("uploaddate1");
  136. string uploaddate2 = GetPostString("uploaddate2");
  137. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  138. if (update.Length > 0) lw.Add(update);
  139. string shopname = GetPostString("shopname");
  140. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  141. string addwechat = GetPostString("addwechat");
  142. if (addwechat.Length > 0)
  143. {
  144. int addWt = Convert.ToInt32(addwechat);
  145. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  146. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  147. }
  148. string customer = GetPostString("customer");
  149. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  150. string design = GetPostString("design");
  151. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  152. string orderState = GetPostString("orderState");
  153. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  154. string address = GetPostString("address");
  155. 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));
  156. string sellermemo = GetPostString("seller_memo");
  157. if (sellermemo.Length > 0)
  158. {
  159. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  160. }
  161. string backReason = GetPostString("backReason");
  162. if (backReason.Length > 0)
  163. {
  164. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  165. }
  166. string apdate1 = GetPostString("apdate1");
  167. string apdate2 = GetPostString("apdate2");
  168. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  169. if (dwap.Length > 0) lw.Add(dwap);
  170. string price1 = GetPostString("price1");
  171. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  172. string price2 = GetPostString("price2");
  173. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  174. string isoldcustomer = GetPostString("isoldcus");
  175. string finishdate1 = GetPostString("finishdate1");
  176. string finishdate2 = GetPostString("finishdate2");
  177. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  178. bool isFinish = false;
  179. if (finishdate.Length > 0)
  180. {
  181. lw.Add(finishdate);
  182. isFinish = true;
  183. paramsCount++;
  184. }
  185. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  186. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  187. if (ex_psize > 0)
  188. {
  189. int UserID = CurrentUser.UserID;
  190. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  191. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  192. {
  193. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  194. }
  195. dStruct.Order = "pay_time desc";
  196. }
  197. string isNew = GetPostString("isNew");
  198. if (isNew == "true")
  199. {
  200. lw.Add(string.Format("IsNew = {0}", 1));
  201. }
  202. string overtime = GetPostString("overtime");
  203. if (overtime == "1")
  204. {
  205. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  206. }
  207. String usePost = CurrentUser.UserPost.Post.Code;
  208. if (usePost.Equals("Operation") == true)
  209. {
  210. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  211. }
  212. else
  213. {
  214. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  215. }
  216. //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";
  217. if (dStruct.PageSize == 100000)
  218. {
  219. dStruct.Order = "";
  220. }
  221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  222. DataTable dt = null;
  223. string tablename = "view_orderlist";
  224. if (isFinish)
  225. {
  226. tablename = "view_orderlist_end";
  227. }
  228. dt = WebCache.GetData(tablename, dStruct);
  229. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  230. if (dt != null && dt.Rows.Count > 0)
  231. {
  232. foreach (DataRow dr in dt.Rows)
  233. {
  234. try
  235. {
  236. if (dr["refund_fees"] != null)
  237. {
  238. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  239. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  240. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  241. if (payment == refund_fees)
  242. {
  243. dr["refund_fees"] = Math.Round(refund_fees, 2);
  244. continue; // 跳过当前迭代
  245. }
  246. else if (refund_fees == total_fee)
  247. {
  248. dr["refund_fees"] = payment;
  249. continue; // 跳过当前迭代
  250. }
  251. else
  252. {
  253. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  254. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  255. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  256. }
  257. }
  258. // 对象操作
  259. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  260. ceErpTradeCell.ctid = dr["ctid"].ToString();
  261. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  262. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  263. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  264. if (dStruct.PageSize != 100000)
  265. {
  266. if (dr["DispatchSort"].ToString() == "2")
  267. {
  268. dr["gongchuang"] = 200;
  269. }
  270. else
  271. {
  272. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  273. dr["gongchuang"] = response.code;
  274. }
  275. }
  276. }
  277. catch (NullReferenceException ex)
  278. {
  279. // 处理空引用异常
  280. dr["refund_fees"] = "0.00";
  281. }
  282. }
  283. }
  284. writeGridDataTableJson(dStruct.TotalCount, dt);
  285. }
  286. public void get_erp_orderlist_sumprice()
  287. {
  288. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  289. return;
  290. List<string> lw = new List<string>();
  291. string tid = GetPostString("ctid");
  292. string date1 = GetPostString("date1");
  293. string date2 = GetPostString("date2");
  294. if (tid.Length > 0 || date1.Length > 0)
  295. {
  296. lw.Add(string.Format("ctid like '%{0}%'", tid));
  297. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  298. if (dw.Length > 0) lw.Add(dw);
  299. }
  300. else
  301. {
  302. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  303. }
  304. string shopname = GetPostString("shopname");
  305. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  306. string buyernick = GetPostString("buyer_nick");
  307. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  308. string customer = GetPostString("customer");
  309. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  310. string design = GetPostString("design");
  311. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  312. string orderState = GetPostString("orderState");
  313. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  314. string address = GetPostString("address");
  315. 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));
  316. string sellermemo = GetPostString("seller_memo");
  317. if (sellermemo.Length > 0)
  318. {
  319. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  320. }
  321. string apdate1 = GetPostString("apdate1");
  322. string apdate2 = GetPostString("apdate2");
  323. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  324. if (dwap.Length > 0) lw.Add(dwap);
  325. string price1 = GetPostString("price1");
  326. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  327. string price2 = GetPostString("price2");
  328. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  329. string isoldcustomer = GetPostString("isoldcus");
  330. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  331. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  332. if (PKey != "admin")
  333. {
  334. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  335. lw.Add(string.Format("shopId in ({0})", usershop));
  336. }
  337. //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";
  338. string mainWhere = string.Join(" and ", lw.ToArray());
  339. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  340. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  341. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  342. decimal total = 0;
  343. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  344. {
  345. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  346. }
  347. var res = new
  348. {
  349. data = total
  350. };
  351. string ro_jsond = JsonConvert.SerializeObject(res);
  352. returnSuccess(ro_jsond);
  353. return;
  354. }
  355. public void get_erp_CustomerServiceGather()
  356. {
  357. string userWhere = "", orderWhere = "";
  358. List<string> lw = new List<string>();
  359. string customer = GetPostString("customer");
  360. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  361. string shopname = GetPostString("shopname");
  362. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  363. string date1 = GetPostString("date1");
  364. string date2 = GetPostString("date2");
  365. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  366. if (dw.Length > 0) lw.Add(dw);
  367. orderWhere = string.Join(" and ", lw.ToArray());
  368. 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 " +
  369. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  370. "left join " +
  371. "( " +
  372. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  373. ") as b on a.ID = b.CustomerUserId " +
  374. "left join " +
  375. "( " +
  376. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  377. ") as d on a.ID = d.CustomerUserId " +
  378. "left join " +
  379. "( " +
  380. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  381. ") as e on a.ID = e.CustomerUserId " +
  382. "left join " +
  383. "( " +
  384. " select CustomerUserId, RefundCount, RefundSum from " +
  385. " ( " +
  386. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  387. " from CE_ErpTradeRefund a " +
  388. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  389. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  390. " group by CustomerUserId " +
  391. " ) as a " +
  392. ") as f on a.ID = f.CustomerUserId " +
  393. "where a.PostCode = 'CustomerService'",
  394. userWhere, orderWhere);
  395. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  396. writeGridDataTableJson(dt.Rows.Count, dt);
  397. //writeGridDataTableJson(dt.Rows.Count, dt);
  398. }
  399. //设计汇总
  400. public void get_erp_DesignerGather()
  401. {
  402. string userWhere = "", orderWhere = "";
  403. List<string> lw = new List<string>();
  404. string Designer = GetPostString("designer");
  405. int org = GetPostInt("org");
  406. if (Designer.Length > 0)
  407. {
  408. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  409. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  410. }
  411. else if (org > 0)
  412. {
  413. userWhere = string.Format(" where OrgID ={0}", org);
  414. }
  415. string shopname = GetPostString("shopname");
  416. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  417. string state = GetPostString("state");
  418. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  419. string OrderArea = GetPostString("order_area");
  420. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  421. string date1 = GetPostString("date1");
  422. string date2 = GetPostString("date2");
  423. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  424. if (dw.Length > 0) lw.Add(dw);
  425. string UpDate1 = GetPostString("UpDate1");
  426. string UpDate2 = GetPostString("UpDate2");
  427. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  428. if (dw.Length > 0) lw.Add(dw);
  429. orderWhere = string.Join(" and ", lw.ToArray());
  430. 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 (" +
  431. "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 " +
  432. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  433. "left join " +
  434. "( " +
  435. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  436. ") as b on a.ID = b.DesignUserId " +
  437. "left join " +
  438. "( " +
  439. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  440. ") as d on a.ID = d.DesignUserId " +
  441. "left join " +
  442. "( " +
  443. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  444. ") as e on a.ID = e.DesignUserId " +
  445. "left join " +
  446. "( " +
  447. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  448. ") as g on a.ID = g.DesignUserId " +
  449. "left join " +
  450. "( " +
  451. " select CustomerUserId, RefundCount, RefundSum from " +
  452. " ( " +
  453. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  454. " from CE_ErpTradeRefund a " +
  455. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  456. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  457. " group by CustomerUserId " +
  458. " ) as a " +
  459. ") as f on a.ID = f.CustomerUserId " +
  460. "where a.PostCode = 'Designer') as z",
  461. userWhere, orderWhere);
  462. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  463. writeGridDataTableJson(dt.Rows.Count, dt);
  464. }
  465. //删除tradecell的订单
  466. public void del_erp_cellorder()
  467. {
  468. if (UrlPostParmsCheck("ctid"))
  469. {
  470. string eid = GetPostString("ctid");
  471. CeErpTradeCell.DelByCtid(eid);
  472. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  473. returnSuccessMsg("删除成功");
  474. }
  475. }
  476. public void clear_erp_refundstate()
  477. {
  478. if (UrlPostParmsCheck("ids"))
  479. {
  480. string eids = GetPostString("ids");
  481. string[] ctidList = eids.Split(',');
  482. foreach (string ctid in ctidList)
  483. {
  484. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  485. if (entity != null)
  486. {
  487. entity.IsRefund = 0;
  488. entity.Update();
  489. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  490. }
  491. else
  492. continue;
  493. }
  494. returnSuccessMsg("操作成功");
  495. return;
  496. }
  497. returnErrorMsg("缺少必要参数");
  498. }
  499. public void set_erp_urgency()
  500. {
  501. if (UrlPostParmsCheck("ctid"))
  502. {
  503. string eid = GetPostString("ctid");
  504. CeErpTradeCell entity = null;
  505. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  506. if (entity != null)
  507. {
  508. string utime = GetPostString("urgencytime");
  509. if (utime.Length > 0)
  510. {
  511. entity.UrgencyTime = Convert.ToDateTime(utime);
  512. }
  513. else
  514. {
  515. returnErrorMsg("请选择加急时间");
  516. return;
  517. }
  518. if (entity.OrderState <= 4)
  519. {
  520. //entity.seller_memo = entity.seller_memo + "-加急";
  521. string smemo = entity.seller_memo;
  522. int kindex = smemo.IndexOf(")");
  523. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  524. if (lastoneStr != "-")
  525. {
  526. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  527. }
  528. string prememo = smemo.Substring(0, kindex + 2);
  529. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  530. int lastkindex = lastmemo.IndexOf("(");
  531. DateTime urgtime = Convert.ToDateTime(utime);
  532. string newlastmemo = "";
  533. if (lastkindex == 0)
  534. {
  535. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  536. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  537. }
  538. else
  539. {
  540. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  541. }
  542. entity.seller_memo = prememo + newlastmemo;
  543. }
  544. entity.IsUrgency = true;
  545. entity.Update();
  546. ApiVo apiVo = new ApiVo();
  547. apiVo.orderNumber = entity.ctid;
  548. apiVo.actionName = "changeDesign";
  549. apiVo.orderRemarks = entity.seller_memo;
  550. apiVo.remarkSign = 3;
  551. designHelper.API_WorkCore(apiVo); //changeDesign
  552. CeErpSukuraData.createInfo(entity.ctid, 7);
  553. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  554. returnSuccessMsg("设置成功!");
  555. return;
  556. }
  557. returnErrorMsg("找不到记录");
  558. }
  559. }
  560. public void set_erp_reset()
  561. {
  562. if (UrlPostParmsCheck("ctid"))
  563. {
  564. string eid = GetPostString("ctid");
  565. CeErpTradeCell entity = null;
  566. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  567. if (entity != null)
  568. {
  569. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  570. {
  571. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  572. {
  573. returnErrorMsg("财务要求已下单已发货无法重置");
  574. return;
  575. }
  576. }
  577. entity.IsUrgency = false;
  578. entity.seller_memo = "";
  579. entity.OtherMemo = "";
  580. entity.OrderState = 0;
  581. entity.IsReturn = 0;
  582. //entity.IsRefund = 0;
  583. entity.MemoOpt = 0;
  584. entity.AfterSaleState = 0;
  585. entity.AfterSaleResponsible = "";
  586. entity.AfterSaleUserId = 0;
  587. entity.IsNeedBill = 0;
  588. entity.CustomerUserId = 0;
  589. entity.DesignUserId = 0;
  590. entity.SupplierId = 0;
  591. entity.PlaceUserId = 0;
  592. entity.ptid = "";
  593. entity.IsSample = 0;
  594. entity.IsXianHuo = 0;
  595. entity.isDianziOrder = 0;
  596. entity.FinishPlaceTime = null;
  597. entity.Update();
  598. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  599. if (trade != null)
  600. {
  601. trade.seller_memo = "";
  602. trade.Update();
  603. }
  604. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  605. returnSuccessMsg("重置成功!");
  606. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  607. if (desginBill != null)
  608. {
  609. desginBill.isDel = 1;
  610. desginBill.Update();
  611. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  612. }
  613. ApiVo apiVo = new ApiVo();
  614. apiVo.orderNumber = entity.ctid;
  615. apiVo.actionName = "resetDesign";
  616. designHelper.API_WorkCore(apiVo);//resetDesign
  617. return;
  618. }
  619. returnErrorMsg("找不到记录");
  620. }
  621. }
  622. public void save_erp_sellermemo()
  623. {
  624. if (UrlPostParmsCheck("ctid"))
  625. {
  626. string ctid = GetPostString("ctid");
  627. CeErpTradeCell entity = null;
  628. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  629. if (entity != null)
  630. {
  631. string memo = GetPostString("seller_memo");
  632. memo = memo.Replace(" ", "");
  633. if (memo.Contains("补差"))
  634. {
  635. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  636. return;
  637. }
  638. if (entity.seller_memo != memo)
  639. {
  640. if (entity.IsSample == 2)
  641. {
  642. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  643. return;
  644. }
  645. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  646. {
  647. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  648. {
  649. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  650. return;
  651. }
  652. }
  653. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  654. }
  655. commonHelper.getCytPrice(entity);
  656. int memoopt = GetPostInt("MemoOpt");
  657. Boolean ismemoopt = false;
  658. if (memoopt > 0)
  659. {
  660. string stropt = "";
  661. if (memoopt == 1)
  662. {
  663. stropt = "“改稿”";
  664. ismemoopt = true;
  665. }
  666. else if (memoopt == 2)
  667. {
  668. stropt = "“定稿”";
  669. }
  670. else if (memoopt == 3)
  671. {
  672. stropt = "“查货”";
  673. CeErpSukuraData.createInfo(entity.ctid, 6);
  674. }
  675. entity.MemoOpt = Convert.ToInt32(memoopt);
  676. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  677. }
  678. if (entity.OrderState < 5)
  679. {
  680. memo = memo.Replace("(", "(");
  681. memo = memo.Replace(")", ")");
  682. }
  683. entity.seller_memo = memo;
  684. entity.Update();
  685. ApiVo apiVo = new ApiVo();
  686. apiVo.orderNumber = entity.ctid;
  687. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  688. apiVo.orderRemarks = memo;
  689. apiVo.remarkSign = memoopt;
  690. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  691. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  692. returnSuccessMsg("保存成功!");
  693. return;
  694. }
  695. returnErrorMsg("找不到记录");
  696. }
  697. }
  698. public void ins_erp_checkorder()
  699. {
  700. if (UrlPostParmsCheck("ctid"))
  701. {
  702. string ctid = GetPostString("ctid");
  703. CeErpTradeCell entity = null;
  704. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  705. if (entity != null)
  706. {
  707. if (entity.OrderState < 6)
  708. {
  709. returnErrorMsg("下单完成后才可查货");
  710. return;
  711. }
  712. /*if (entity.OrderState > 6)
  713. {
  714. returnErrorMsg("订单已发货");
  715. return;
  716. }*/
  717. if (entity.FinishPlaceTime != null)
  718. {
  719. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  720. {
  721. returnErrorMsg("下单时间不足,无法查货");
  722. return;
  723. }
  724. }
  725. entity.MemoOpt = 3;
  726. entity.CheckOrderTime = DateTime.Now;
  727. entity.Update();
  728. CeErpSukuraData.createInfo(entity.ctid, 6);
  729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  730. returnSuccessMsg("操作成功!");
  731. return;
  732. }
  733. returnErrorMsg("找不到记录");
  734. }
  735. }
  736. public void save_erp_othermemo()
  737. {
  738. if (UrlPostParmsCheck("ctid"))
  739. {
  740. string ctid = GetPostString("ctid");
  741. CeErpTradeCell entity = null;
  742. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  743. if (entity != null)
  744. {
  745. entity.OtherMemo = GetPostString("otherMemo");
  746. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  747. {
  748. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  749. StringBuilder sql = new StringBuilder();
  750. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  751. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  752. if (dt != null && dt.Rows.Count > 0)
  753. {
  754. foreach (DataRow dr in dt.Rows)
  755. {
  756. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  757. {
  758. //品类一直
  759. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  760. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  761. if (ceErpSampleCustomer == null)
  762. {
  763. ceErpSampleCustomer = new CeErpSampleCustomer();
  764. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  765. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  766. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  767. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  768. ceErpSampleCustomer.shopId = entity.ShopId;
  769. }
  770. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  771. ceErpSampleCustomer.lastTid = entity.tid;
  772. if (ceErpSampleCustomer.ID > 0)
  773. {
  774. ceErpSampleCustomer.Update();
  775. }
  776. else
  777. {
  778. ceErpSampleCustomer.Create();
  779. }
  780. }
  781. }
  782. }
  783. }
  784. //if (entity.IsOldCustomer == 1)
  785. //{
  786. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  787. //{
  788. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  789. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  790. //}
  791. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  792. //{
  793. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  794. // {
  795. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  796. // {
  797. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  798. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  799. // }
  800. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  801. // {
  802. // entity.OrderState = 2;
  803. // entity.DesignUserId = 0;
  804. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  805. // }
  806. // else
  807. // {
  808. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  809. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  810. // }
  811. // }
  812. //}
  813. //}
  814. entity.Update();
  815. returnSuccessMsg("保存成功!");
  816. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  817. return;
  818. }
  819. returnErrorMsg("找不到记录");
  820. }
  821. }
  822. public void save_erp_customermemo()
  823. {
  824. if (UrlPostParmsCheck("ctid"))
  825. {
  826. string ctid = GetPostString("ctid");
  827. CeErpTradeCell entity = null;
  828. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  829. if (entity != null)
  830. {
  831. entity.CustomerMemo = GetPostString("CustomerMemo");
  832. entity.Update();
  833. ApiVo apiVo = new ApiVo();
  834. apiVo.orderNumber = entity.ctid;
  835. apiVo.actionName = "followRemarks";
  836. apiVo.orderRemarks = entity.CustomerMemo;
  837. designHelper.API_WorkCore(apiVo);//followRemarks
  838. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  839. returnSuccessMsg("保存成功!");
  840. return;
  841. }
  842. returnErrorMsg("找不到记录");
  843. }
  844. }
  845. public void upd_erp_addmemotag()
  846. {
  847. if (UrlPostParmsCheck("ctid"))
  848. {
  849. ;
  850. string eid = GetPostString("ctid");
  851. string sfTagstr = GetPostString("memotag");
  852. CeErpTradeCell entity = null;
  853. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  854. if (entity != null)
  855. {
  856. if (entity.OrderState == 0)
  857. {
  858. returnErrorMsg("请先领单");
  859. return;
  860. }
  861. //撤销顺丰
  862. if (sfTagstr == "撤销顺丰")
  863. {
  864. entity.IsSF = 0;
  865. string reMsg = "";
  866. string oldmemo = entity.seller_memo;
  867. if (entity.OrderState < 5)
  868. {
  869. oldmemo = oldmemo.Replace("顺丰到付", "");
  870. oldmemo = oldmemo.Replace("顺丰寄付", "");
  871. entity.seller_memo = oldmemo;
  872. }
  873. else
  874. {
  875. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  876. {
  877. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  878. }
  879. }
  880. entity.Update();
  881. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  882. api.orderNumber = entity.ctid;
  883. api.actionName = "followRemarks";
  884. api.orderRemarks = entity.seller_memo;
  885. api.isSf = entity.IsSF.ToString();
  886. designHelper.API_WorkCore(api);//followRemarks
  887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  888. returnSuccessMsg("撤销成功!" + reMsg);
  889. return;
  890. }
  891. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  892. {
  893. //string oldmemo = entity.seller_memo;
  894. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  895. string sfStr = GetPostString("memotag");
  896. string smemo = entity.seller_memo;
  897. int kindex = smemo.IndexOf(")");
  898. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  899. if (lastoneStr != "-")
  900. {
  901. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  902. }
  903. string prememo = smemo.Substring(0, kindex + 2);
  904. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  905. int lastkindex = lastmemo.IndexOf("(");
  906. string newlastmemo = "";
  907. if (lastkindex == 0)
  908. {
  909. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  910. newlastmemo = "(" + sfStr + "." + useLastmemo;
  911. }
  912. else
  913. {
  914. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  915. }
  916. entity.seller_memo = prememo + newlastmemo;
  917. }
  918. string sfTagMSg = "";
  919. if (sfTagstr == "顺丰寄付")
  920. {
  921. entity.IsSF = 1;
  922. sfTagMSg = "顺丰寄付";
  923. }
  924. else if (sfTagstr == "顺丰到付")
  925. {
  926. entity.IsSF = 2;
  927. sfTagMSg = "顺丰到付";
  928. }
  929. entity.Update();
  930. ApiVo apiVo = new ApiVo();
  931. apiVo.orderNumber = entity.ctid;
  932. apiVo.actionName = "orderRemarks";
  933. apiVo.orderRemarks = entity.seller_memo;
  934. apiVo.isSf = entity.IsSF.ToString();
  935. designHelper.API_WorkCore(apiVo);//orderRemarks
  936. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  937. returnSuccessMsg("标记成功!");
  938. return;
  939. }
  940. returnErrorMsg("找不到记录");
  941. }
  942. }
  943. public void upd_erp_ordertag()
  944. {
  945. if (UrlPostParmsCheck("ctid"))
  946. {
  947. string eid = GetPostString("ctid");
  948. CeErpTradeCell entity = null;
  949. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  950. if (entity != null)
  951. {
  952. int tag = GetPostInt("wechattag");
  953. //if(tag==4 && entity.IsSample == 2)
  954. //{
  955. // returnErrorMsg("补差价单不能标记微信单");
  956. // return;
  957. //}
  958. entity.wechatTag = tag;
  959. entity.Update();
  960. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  961. if (tag == 1)
  962. {
  963. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  964. if (cash == null)
  965. {
  966. CeErpTrade main = CeErpTrade.Get(entity.tid);
  967. cash = new CeErpReturnCash();
  968. cash.tid = entity.tid;
  969. cash.seller_nick = main.seller_nick;
  970. cash.payment = trade.payment;
  971. cash.buyer_nick = main.buyer_nick;
  972. cash.cashstate = 0;
  973. cash.rtype = "微信返现";
  974. cash.returnprice = 0;
  975. cash.created = DateTime.Now;
  976. cash.con = "订单标记微信单";
  977. cash.img = "";
  978. cash.applyuserid = CurrentUser.UserID;
  979. cash.Create();
  980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  981. }
  982. else
  983. {
  984. cash.cashstate = 0;
  985. cash.Update();
  986. }
  987. CeErpSukuraData.createInfo(entity.ctid, 9);
  988. }
  989. else if (tag == 2)
  990. {
  991. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  992. if (cash == null)
  993. {
  994. CeErpTrade main = CeErpTrade.Get(entity.tid);
  995. cash = new CeErpReturnCash();
  996. cash.tid = entity.tid;
  997. cash.seller_nick = main.seller_nick;
  998. cash.payment = trade.payment;
  999. cash.buyer_nick = main.buyer_nick;
  1000. cash.cashstate = 0;
  1001. cash.rtype = "推购返现";
  1002. cash.returnprice = 5;
  1003. cash.created = DateTime.Now;
  1004. cash.con = "订单标记推购单";
  1005. cash.img = "";
  1006. cash.applyuserid = CurrentUser.UserID;
  1007. cash.Create();
  1008. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1009. }
  1010. else
  1011. {
  1012. cash.cashstate = 0;
  1013. cash.Update();
  1014. }
  1015. CeErpSukuraData.createInfo(entity.ctid, 9);
  1016. }
  1017. else if (tag == 3)
  1018. {
  1019. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1020. if (pers == null)
  1021. {
  1022. pers = new CeErpPersuade();
  1023. pers.ctid = entity.ctid;
  1024. pers.pstate = 0;
  1025. pers.created = DateTime.Now;
  1026. pers.applyuserid = CurrentUser.UserID;
  1027. pers.Create();
  1028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1029. }
  1030. else
  1031. {
  1032. pers.pstate = 0;
  1033. pers.Update();
  1034. }
  1035. }
  1036. else if (tag == 4 || tag == 5)
  1037. {
  1038. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1039. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1040. if (pers == null)
  1041. {
  1042. pers = new CeErpStayGoods();
  1043. pers.t_id = entity.tid;
  1044. pers.status = "待审核";
  1045. pers.audit_type = 0;
  1046. if (tag == 4)
  1047. {
  1048. pers.stay_type = "微信推购";
  1049. }
  1050. else
  1051. {
  1052. pers.stay_type = "旺旺推购";
  1053. }
  1054. if (entity.IsXianHuo == 0)
  1055. {
  1056. pers.product_id = entity.ProductId;
  1057. }
  1058. pers.wangwang = main.buyer_nick;
  1059. pers.shop_name = main.seller_nick;
  1060. pers.creata_time = DateTime.Now;
  1061. pers.create_u_id = CurrentUser.UserID;
  1062. pers.create_u_name = CurrentUser.UserName;
  1063. pers.Create();
  1064. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1065. }
  1066. else
  1067. {
  1068. pers.audit_type = 0;
  1069. pers.Update();
  1070. }
  1071. CeErpSukuraData.createInfo(entity.ctid, 10);
  1072. }
  1073. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1074. returnSuccessMsg("标记成功!");
  1075. return;
  1076. }
  1077. returnErrorMsg("找不到记录");
  1078. }
  1079. }
  1080. public void upd_erp_ordertag_cancel()
  1081. {
  1082. if (UrlPostParmsCheck("ctid"))
  1083. {
  1084. string eid = GetPostString("ctid");
  1085. CeErpTradeCell entity = null;
  1086. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1087. if (entity != null)
  1088. {
  1089. entity.wechatTag = 0;
  1090. entity.Update();
  1091. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1092. if (pers != null)
  1093. {
  1094. pers.status = "取消推购";
  1095. pers.audit_type = 3;
  1096. pers.Update();
  1097. }
  1098. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1099. returnSuccessMsg("标记成功!");
  1100. return;
  1101. }
  1102. returnErrorMsg("找不到记录");
  1103. }
  1104. }
  1105. public void upd_erp_addweichattag()
  1106. {
  1107. if (UrlPostParmsCheck("ctid"))
  1108. {
  1109. ;
  1110. string eid = GetPostString("ctid");
  1111. CeErpTradeCell entity = null;
  1112. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1113. if (entity != null)
  1114. {
  1115. if (entity.IsAddWechat > 0)
  1116. {
  1117. returnErrorMsg("此单已经标记过了");
  1118. return;
  1119. }
  1120. 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);
  1121. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1122. if (dt.Rows.Count > 0)
  1123. {
  1124. entity.IsAddWechat = 2;
  1125. }
  1126. else
  1127. {
  1128. entity.IsAddWechat = 1;
  1129. }
  1130. entity.Update();
  1131. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1132. returnSuccessMsg("标记成功!");
  1133. return;
  1134. }
  1135. returnErrorMsg("找不到记录");
  1136. }
  1137. }
  1138. public void upd_erp_getmyorder()
  1139. {
  1140. if (UrlPostParmsCheck("ctid"))
  1141. {
  1142. ;
  1143. string eid = GetPostString("ctid");
  1144. CeErpTradeCell entity = null;
  1145. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1146. if (entity != null)
  1147. {
  1148. if (entity.ctid.IndexOf("C") != -1)
  1149. {
  1150. StringBuilder sql = new StringBuilder();
  1151. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1152. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1153. if (dt.Rows.Count > 0)
  1154. {
  1155. decimal total = 0;
  1156. foreach (DataRow dr in dt.Rows)
  1157. {
  1158. total += Convert.ToDecimal(dr["payment"]);
  1159. }
  1160. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1161. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1162. {
  1163. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1164. return;
  1165. }
  1166. }
  1167. }
  1168. entity.CustomerUserId = CurrentUser.UserID;
  1169. if (entity.OrderState < 2)
  1170. {
  1171. entity.OrderState = 2;
  1172. if (entity.ShopId != 0)
  1173. {
  1174. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1175. }
  1176. }
  1177. entity.Update();
  1178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1179. returnSuccessMsg("领单成功!");
  1180. return;
  1181. }
  1182. returnErrorMsg("找不到记录");
  1183. }
  1184. }
  1185. public void getmyorder_from_init()
  1186. {
  1187. if (UrlPostParmsCheck("ctid"))
  1188. {
  1189. string eid = GetPostString("ctid");
  1190. CeErpTradeCell entity = null;
  1191. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1192. if (entity != null)
  1193. {
  1194. string sellerMemo = GetPostString("sellerMemo");
  1195. if (sellerMemo.Length > 0)
  1196. {
  1197. entity.seller_memo = sellerMemo;
  1198. }
  1199. string oterhMemo = GetPostString("otherMemo");
  1200. if (oterhMemo.Length > 0)
  1201. {
  1202. entity.OtherMemo = oterhMemo;
  1203. }
  1204. int urg = GetPostInt("urgency");
  1205. entity.IsUrgency = (urg == 1 ? true : false);
  1206. int wechat = GetPostInt("wechat");
  1207. int command = GetPostInt("command");
  1208. if (wechat == 1)
  1209. {
  1210. entity.wechatTag = 1;
  1211. }
  1212. if (command == 1)
  1213. {
  1214. entity.wechatTag = 2;
  1215. }
  1216. string pPro = GetPostString("pprofession");
  1217. if (pPro.Length > 0)
  1218. {
  1219. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1220. string spro = GetPostString("profession");
  1221. if (spro.Length > 0)
  1222. {
  1223. entity.ProfessionId = Convert.ToInt32(spro);
  1224. }
  1225. }
  1226. string proId = GetPostString("productId");
  1227. if (proId.Length > 0)
  1228. {
  1229. entity.ProductId = Convert.ToInt32(proId);
  1230. }
  1231. entity.Material = GetPostString("material");
  1232. entity.Craft = GetPostString("craft");
  1233. entity.CustomerUserId = CurrentUser.UserID;
  1234. if (entity.OrderState < 2)
  1235. {
  1236. entity.OrderState = 2;
  1237. if (entity.ShopId != 0)
  1238. {
  1239. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1240. }
  1241. }
  1242. entity.Update();
  1243. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1244. returnSuccessMsg("领单成功!");
  1245. return;
  1246. }
  1247. returnErrorMsg("找不到记录");
  1248. }
  1249. }
  1250. public void upd_erp_setrelationorder()
  1251. {
  1252. if (UrlPostParmsCheck("ctid"))
  1253. {
  1254. ;
  1255. string eid = GetPostString("ctid");
  1256. string ftid = GetPostString("ftid");
  1257. CeErpTradeCell entity = null;
  1258. CeErpTradeCell fentity = null;
  1259. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1260. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1261. if (fentity == null)
  1262. {
  1263. returnErrorMsg("找不到关联的主订单");
  1264. return;
  1265. }
  1266. if (entity != null)
  1267. {
  1268. if (entity.OrderState >= 5)
  1269. {
  1270. returnErrorMsg("本单已经设计完成无法关联");
  1271. return;
  1272. }
  1273. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1274. {
  1275. returnErrorMsg("线下单续审核后才能关联!");
  1276. return;
  1277. }
  1278. entity.ptid = ftid;
  1279. entity.OrderState = fentity.OrderState;
  1280. //entity.status = fentity.status;
  1281. entity.CustomerUserId = fentity.CustomerUserId;
  1282. entity.DesignUserId = fentity.DesignUserId;
  1283. entity.seller_memo = "补差价单:" + ftid;
  1284. entity.IsSample = 2;
  1285. entity.Update();
  1286. ApiVo apiVo = new ApiVo();
  1287. apiVo.orderNumber = ftid;
  1288. apiVo.payment = entity.payment;
  1289. apiVo.actionName = "repairDesign";
  1290. designHelper.API_WorkCore(apiVo);//repairDesign
  1291. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1292. returnSuccessMsg("关联成功!");
  1293. return;
  1294. }
  1295. else
  1296. returnErrorMsg("找不到记录");
  1297. }
  1298. }
  1299. public void download_erp_neworder()
  1300. {
  1301. string seller = GetPostString("seller_nick");
  1302. string tid = GetPostString("tid");
  1303. if (seller.Length <= 0 || tid.Length <= 0)
  1304. {
  1305. returnErrorMsg("数据错误");
  1306. }
  1307. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1308. //{
  1309. // returnErrorMsg("找不到店铺Sessionkey");
  1310. //}
  1311. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1312. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1313. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1314. if (res.IndexOf("refOid") == -1)
  1315. {
  1316. returnErrorMsg("下载订单数据失败");
  1317. return;
  1318. }
  1319. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1320. returnSuccessMsg("下载完成");
  1321. //tmcHelper.createNewOrder(res);
  1322. //CeErpTrade entr = null;
  1323. //entr = CeErpTrade.Get(tid);
  1324. //if (entr != null)
  1325. //{
  1326. // returnSuccess("下载成功");
  1327. // //下载成功之后,Cell表生成对应的订单;
  1328. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1329. //}
  1330. //else
  1331. //{
  1332. // returnErrorMsg("下载失败或者创建订单失败");
  1333. //}
  1334. }
  1335. public void set_erp_atersale()
  1336. {
  1337. if (UrlPostParmsCheck("ctid"))
  1338. {
  1339. string eid = GetPostString("ctid");
  1340. string reason = GetPostString("AfterSaleReason");
  1341. CeErpTradeCell entity = null;
  1342. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1343. if (entity != null)
  1344. {
  1345. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1346. {
  1347. returnErrorMsg("此订单已经在售后");
  1348. return;
  1349. }
  1350. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1351. //entity.AfterSaleReason = reason;
  1352. entity.AfterSaleTime = DateTime.Now;
  1353. entity.Update();
  1354. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1355. returnSuccessMsg("转售后成功!");
  1356. return;
  1357. }
  1358. returnErrorMsg("找不到记录");
  1359. }
  1360. }
  1361. public void set_erp_withdraw()
  1362. {
  1363. if (UrlPostParmsCheck("ctid"))
  1364. {
  1365. try
  1366. {
  1367. string eid = GetPostString("ctid");//商品id
  1368. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1369. CeWithdraw ceWithdrawSelect = null;
  1370. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1371. if (ceWithdrawSelect != null)
  1372. {
  1373. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1374. {
  1375. ceWithdrawSelect.status = -1;
  1376. ceWithdrawSelect.Update();
  1377. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1378. returnSuccessMsg("重新发起审核成功");
  1379. return;
  1380. }
  1381. else
  1382. {
  1383. returnSuccessMsg("请勿重复申请!");
  1384. return;
  1385. }
  1386. }
  1387. else
  1388. {
  1389. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1390. if (string.IsNullOrEmpty(CustomerUserId))
  1391. {
  1392. CustomerUserId = "-1";
  1393. }
  1394. int Userid = CurrentUser.UserID;//用户id
  1395. CeWithdraw ceWithdraw = new CeWithdraw();
  1396. ceWithdraw.tid = eid;
  1397. ceWithdraw.userid = Userid;
  1398. ceWithdraw.providerid = CustomerUserId;
  1399. ceWithdraw.status = 3;
  1400. ceWithdraw.creationtime = DateTime.Now;
  1401. ceWithdraw.Create();
  1402. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1403. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1404. return;
  1405. }
  1406. }
  1407. catch
  1408. {
  1409. returnErrorMsg("申请撤回订单失败");
  1410. return;
  1411. }
  1412. }
  1413. }
  1414. public void ins_erp_billinfo()
  1415. {
  1416. if (UrlPostParmsCheck("ctid"))
  1417. {
  1418. string eid = GetPostString("ctid");
  1419. CeErpTradeCell entity = null;
  1420. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1421. if (entity != null)
  1422. {
  1423. CeErpBill bill = CeErpBill.GetByTid(eid);
  1424. bool isHave = false;
  1425. if (bill != null)
  1426. {
  1427. isHave = true;
  1428. if (bill.state != 4)
  1429. {
  1430. returnErrorMsg("此单已经申请过发票了");
  1431. return;
  1432. }
  1433. }
  1434. if (entity.IsNeedBill == 0)
  1435. {
  1436. entity.IsNeedBill = 1;
  1437. }
  1438. entity.Update();
  1439. string errjson = "";
  1440. try
  1441. {
  1442. CeErpBill bill_entity = new CeErpBill();
  1443. bill_entity.tid = entity.tid;
  1444. bill_entity.title = GetPostString("title");
  1445. string taxstr = GetPostString("tax");
  1446. taxstr = taxstr.Replace(" ", "");
  1447. bill_entity.tax = taxstr;
  1448. bill_entity.bank = GetPostString("bank");
  1449. string bankacstr = GetPostString("bankac");
  1450. bankacstr = bankacstr.Replace(" ", "");
  1451. bill_entity.bankac = bankacstr;
  1452. bill_entity.address = GetPostString("address");
  1453. bill_entity.phone = GetPostString("phone");
  1454. bill_entity.price = GetPostString("price");
  1455. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1456. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1457. {
  1458. billCount += 1;
  1459. }
  1460. string prebill = "ltb";
  1461. for (int idx = 1; idx <= billCount; idx++)
  1462. {
  1463. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1464. string billoid = prebill + idx + dtstr;
  1465. bill_entity.billOrderId += billoid;
  1466. if (idx < billCount)
  1467. {
  1468. bill_entity.billOrderId += ",";
  1469. }
  1470. }
  1471. bill_entity.productId = GetPostInt("ProductName");
  1472. bill_entity.num = GetPostInt("num");
  1473. bill_entity.unit = GetPostString("unit");
  1474. bill_entity.type = GetPostString("type");
  1475. bill_entity.sendType = GetPostString("SendType");
  1476. bill_entity.email = GetPostString("email");
  1477. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1478. bill_entity.shopName = GetPostString("ShopName");
  1479. bill_entity.applymemo = GetPostString("applyMemo");
  1480. bill_entity.createTime = DateTime.Now;
  1481. bill_entity.state = 0;
  1482. bill_entity.userId = CurrentUser.UserID;
  1483. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1484. bill_entity.Create();
  1485. }
  1486. catch (Exception ex)
  1487. {
  1488. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1489. returnErrorMsg("创建发票出错!");
  1490. return;
  1491. }
  1492. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1493. returnSuccessMsg("发票申请成功!");
  1494. return;
  1495. }
  1496. returnErrorMsg("找不到记录");
  1497. }
  1498. }
  1499. public void ins_erp_neworder()
  1500. {
  1501. if (UrlPostParmsCheck("receiver_name"))
  1502. {
  1503. CeErpTrade entity = new CeErpTrade();
  1504. string plat_form = GetPostString("platform");
  1505. string preStr = "N_";
  1506. if (plat_form == "拼多多")
  1507. {
  1508. preStr = "P_";
  1509. }
  1510. else if (plat_form == "阿里巴巴")
  1511. {
  1512. preStr = "A_";
  1513. }
  1514. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1515. entity.seller_nick = GetPostString("seller_nick");
  1516. entity.buyer_nick = GetPostString("buyer_nick");
  1517. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1518. entity.total_fee = entity.payment;
  1519. entity.pay_time = DateTime.Now;
  1520. entity.status = "NOT_SHIPPED";
  1521. entity.receiver_name = GetPostString("receiver_name");
  1522. entity.receiver_mobile = GetPostString("receiver_mobile");
  1523. entity.receiver_state = GetPostString("receiver_state");
  1524. entity.receiver_city = GetPostString("receiver_city");
  1525. entity.receiver_district = GetPostString("receiver_district");
  1526. entity.receiver_address = GetPostString("receiver_address");
  1527. if (entity.receiver_state == "" || entity.receiver_city == "")
  1528. {
  1529. returnErrorMsg("收件地址不能为空");
  1530. return;
  1531. }
  1532. int shopId = 0;
  1533. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1534. if (nShop != null)
  1535. {
  1536. shopId = nShop.ID;
  1537. }
  1538. if (shopId != 34 && entity.payment == 0)
  1539. {
  1540. returnErrorMsg("公司自用的单金额才能为0");
  1541. return;
  1542. }
  1543. entity.Create();
  1544. CeErpTradeCell entitycell = new CeErpTradeCell();
  1545. entitycell.ctid = entity.tid;
  1546. entitycell.tid = entity.tid;
  1547. entitycell.ShopId = shopId;
  1548. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1549. entitycell.OrderState = 0;
  1550. entitycell.pay_time = entity.pay_time;
  1551. entitycell.IsOffLineOrder = 1;
  1552. entitycell.Create();
  1553. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1554. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1555. return;
  1556. }
  1557. }
  1558. public void ins_erp_neworder2()
  1559. {
  1560. if (UrlPostParmsCheck("receiver_name"))
  1561. {
  1562. //string plat_form = GetPostString("platform");
  1563. string preStr = "X_";
  1564. string memo = GetPostString("memo");
  1565. string productId = GetPostString("productId");
  1566. string primg = GetPostString("proofimg");
  1567. string sellerNick = GetPostString("seller_nick");
  1568. string addFrom = GetPostString("addfrom");
  1569. if (addFrom == "1")
  1570. {
  1571. preStr = "N_";
  1572. }
  1573. int shopId = 0;
  1574. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1575. if (nShop != null)
  1576. {
  1577. shopId = nShop.ID;
  1578. }
  1579. else
  1580. {
  1581. returnErrorMsg("找不到对应店铺");
  1582. return;
  1583. }
  1584. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1585. {
  1586. returnErrorMsg("必须上传付款凭证");
  1587. return;
  1588. }
  1589. CeErpTrade entity = new CeErpTrade();
  1590. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1591. entity.seller_nick = sellerNick;
  1592. entity.buyer_nick = GetPostString("buyer_nick");
  1593. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1594. entity.total_fee = entity.payment;
  1595. entity.pay_time = DateTime.Now;
  1596. entity.status = "NOT_SHIPPED";
  1597. entity.receiver_name = GetPostString("receiver_name");
  1598. entity.receiver_mobile = GetPostString("receiver_mobile");
  1599. entity.receiver_state = GetPostString("receiver_state");
  1600. entity.receiver_city = GetPostString("receiver_city");
  1601. entity.receiver_district = GetPostString("receiver_district");
  1602. entity.receiver_address = GetPostString("receiver_address");
  1603. entity.seller_memo = memo;
  1604. entity.orderFrom = 20;
  1605. entity.orderType = 15;
  1606. if (entity.receiver_state == "" || entity.receiver_city == "")
  1607. {
  1608. returnErrorMsg("收件地址不能为空");
  1609. return;
  1610. }
  1611. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1612. {
  1613. returnErrorMsg("公司自用的单金额才能为0");
  1614. return;
  1615. }
  1616. entity.Create();
  1617. string toWhere = GetPostString("towhere");
  1618. CeErpTradeCell entitycell = new CeErpTradeCell();
  1619. entitycell.ctid = entity.tid;
  1620. //唯一标识
  1621. entitycell.OrderSn = entity.tid;
  1622. //string orderSn = dataHelper.getSaleOrderSn();
  1623. //if (orderSn != "")
  1624. // {
  1625. // entitycell.OrderSn = orderSn;
  1626. // }
  1627. entitycell.tid = entity.tid;
  1628. //if (preStr == "X_")
  1629. //{
  1630. entitycell.IsOffLineOrder = 1;
  1631. //}
  1632. entitycell.CustomerUserId = CurrentUser.UserID;
  1633. entitycell.PayProofImg = primg;
  1634. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1635. entitycell.ProductId = Convert.ToInt32(productId);
  1636. entitycell.ShopId = shopId;
  1637. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1638. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1639. {
  1640. entitycell.IsXianHuo = 1;
  1641. }
  1642. entitycell.pay_time = entity.pay_time;
  1643. if (toWhere == "1")
  1644. {
  1645. entitycell.OrderState = 2;
  1646. }
  1647. else
  1648. {
  1649. entitycell.OrderState = 6;
  1650. entitycell.FinishPlaceTime = entitycell.pay_time;
  1651. }
  1652. if (shopId == 94)
  1653. {
  1654. entitycell.OrderState = 4;
  1655. entitycell.WaitDesignTime = entitycell.pay_time;
  1656. entitycell.StartDesignTime = entitycell.pay_time;
  1657. entitycell.DesignUserId = 218;
  1658. }
  1659. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1660. {
  1661. entitycell.OrderState = -1;//修改12-5
  1662. CeWithdraw ceWithdraw = new CeWithdraw();
  1663. ceWithdraw.tid = entity.tid;
  1664. ceWithdraw.providerid = "-1";
  1665. ceWithdraw.status = -1;
  1666. ceWithdraw.creationtime = DateTime.Now;
  1667. ceWithdraw.userid = 1337;
  1668. ceWithdraw.Create();
  1669. }
  1670. entitycell.Create();
  1671. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1672. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1673. {
  1674. addPlaceRegist(entitycell, CurrentUser.UserID);
  1675. }
  1676. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1677. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1678. return;
  1679. }
  1680. }
  1681. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1682. {
  1683. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1684. entity.PlactTime = tradecell.pay_time;
  1685. entity.AddUserId = userid;
  1686. entity.FileName = tradecell.seller_memo;
  1687. entity.Supplier = 24;
  1688. entity.CreateTime = DateTime.Now;
  1689. entity.Did = tradecell.ctid;
  1690. entity.tid = tradecell.tid;
  1691. entity.splitTag = tradecell.SplitTag;
  1692. entity.CurState = "未完成";
  1693. entity.Create();
  1694. }
  1695. public void get_erp_offlinelist()
  1696. {
  1697. DataStruct dStruct = GetPostStruct();
  1698. List<string> lw = new List<string>();
  1699. string tid = GetPostString("ctid");
  1700. string date1 = GetPostString("date1");
  1701. string date2 = GetPostString("date2");
  1702. if (tid.Length > 0 || date1.Length > 0)
  1703. {
  1704. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1705. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1706. if (dw.Length > 0) lw.Add(dw);
  1707. }
  1708. else
  1709. {
  1710. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1711. }
  1712. string shopname = GetPostString("shopname");
  1713. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1714. string buyernick = GetPostString("buyer_nick");
  1715. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1716. string customer = GetPostString("customer");
  1717. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1718. string design = GetPostString("design");
  1719. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1720. string orderState = GetPostString("orderState");
  1721. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1722. string address = GetPostString("address");
  1723. 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));
  1724. string sellermemo = GetPostString("seller_memo");
  1725. if (sellermemo.Length > 0)
  1726. {
  1727. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1728. }
  1729. string price1 = GetPostString("price1");
  1730. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1731. string price2 = GetPostString("price2");
  1732. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1733. //if (PKey != "admin")
  1734. //{
  1735. // string usershop = CurrentUser.User.pemShop;
  1736. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1737. //}
  1738. //if (ex_psize > 0)
  1739. //{
  1740. dStruct.Order = "pay_time desc";
  1741. //}
  1742. //else
  1743. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1744. lw.Add(string.Format("IsOffLineOrder=1"));
  1745. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1746. DataTable dt = null;
  1747. dt = WebCache.GetData("view_erptradecell", dStruct);
  1748. writeGridDataTableJson(dStruct.TotalCount, dt);
  1749. }
  1750. public void get_erp_returncashrecord()
  1751. {
  1752. DataStruct dStruct = GetPostStruct();
  1753. List<string> lw = new List<string>();
  1754. string tid = GetPostString("ctid");
  1755. if (tid.Length > 0)
  1756. {
  1757. lw.Add(string.Format("tid like '%{0}%'", tid));
  1758. dStruct.Order = "id desc";
  1759. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1760. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1761. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1762. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1763. return;
  1764. }
  1765. returnErrorMsg("id数据错误!");
  1766. }
  1767. public void ins_erp_returncashrecord()
  1768. {
  1769. if (UrlPostParmsCheck("tid"))
  1770. {
  1771. string tid = GetPostString("tid");
  1772. string retype = GetPostString("type");
  1773. StringBuilder sql = new StringBuilder();
  1774. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1775. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1776. if (dt.Rows.Count > 0)
  1777. {
  1778. returnErrorMsg("相同返现类型记录已存在");
  1779. return;
  1780. }
  1781. CeErpReturnCash entity = new CeErpReturnCash();
  1782. entity.tid = tid;
  1783. entity.seller_nick = GetPostString("seller_nick");
  1784. string pment = GetPostString("payment");
  1785. if (pment.Length > 0)
  1786. {
  1787. entity.payment = Convert.ToDouble(pment);
  1788. }
  1789. entity.buyer_nick = GetPostString("buyer_nick");
  1790. entity.cashstate = 0;
  1791. entity.rtype = retype;
  1792. string rPrice = GetPostString("returnprice");
  1793. if (rPrice.Length > 0)
  1794. {
  1795. entity.returnprice = Convert.ToDouble(rPrice);
  1796. }
  1797. entity.created = DateTime.Now;
  1798. entity.con = GetPostString("con");
  1799. entity.img = GetPostString("img");
  1800. entity.applyuserid = CurrentUser.UserID;
  1801. entity.Create();
  1802. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1803. returnSuccessMsg("操作成功!");
  1804. return;
  1805. }
  1806. }
  1807. public void set_erp_predelivery()
  1808. {
  1809. if (UrlPostParmsCheck("ctid"))
  1810. {
  1811. string eid = GetPostString("ctid");
  1812. CeErpTradeCell entity = null;
  1813. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1814. if (entity != null)
  1815. {
  1816. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1817. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1818. //{
  1819. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1820. // return;
  1821. //}
  1822. entity.IsPreDelivery = 1;
  1823. entity.Update();
  1824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1825. returnSuccessMsg("预发货成功!");
  1826. return;
  1827. //string shop = GetPostString("seller_nick");
  1828. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1829. //string comName = GetPostString("comName");
  1830. //string comCode = GetPostString("comCode");
  1831. //string outSid = GetPostString("outSid");//运单号
  1832. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1833. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1834. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1835. //string apires = "";
  1836. //if (deliveryType == "虚拟发货")
  1837. //{
  1838. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1839. //}
  1840. //else
  1841. //{
  1842. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1843. //}
  1844. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1845. ////{
  1846. //if (apires.IndexOf("发货成功") != -1)
  1847. //{
  1848. // if (deliveryType != "虚拟发货")
  1849. // {
  1850. // //还要插入快递信息到 快递信息表
  1851. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1852. // exinfo.tid = eid;
  1853. // exinfo.out_sid = outSid;
  1854. // exinfo.company_code = comCode;
  1855. // exinfo.company_name = comName;
  1856. // exinfo.delivery_memo = deliveryMemo;
  1857. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1858. // exinfo.deliveryType = deliveryType;
  1859. // exinfo.Create();
  1860. // }
  1861. // returnSuccessMsg("发货成功!");
  1862. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1863. //}
  1864. //else
  1865. //{
  1866. // returnErrorMsg("淘宝发货失败!!");
  1867. //}
  1868. //return;
  1869. }
  1870. returnErrorMsg("找不到订单记录");
  1871. }
  1872. }
  1873. public void get_erp_unusuallist()
  1874. {
  1875. DataStruct dStruct = GetPostStruct();
  1876. List<string> lw = new List<string>();
  1877. string tid = GetPostString("ctid");
  1878. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1879. string shopname = GetPostString("shopname");
  1880. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1881. string buyernick = GetPostString("buyer_nick");
  1882. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1883. string ResponsibleMan = GetPostString("responsible");
  1884. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1885. string date1 = GetPostString("date1");
  1886. string date2 = GetPostString("date2");
  1887. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1888. if (dw.Length > 0) lw.Add(dw);
  1889. string price1 = GetPostString("price1");
  1890. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1891. string price2 = GetPostString("price2");
  1892. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1893. string orderState = GetPostString("orderState");
  1894. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1895. string sellermemo = GetPostString("seller_memo");
  1896. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1897. lw.Add(string.Format("UnusualTag > 0"));
  1898. lw.Add(string.Format("IsRefund<={0}", 1));
  1899. dStruct.Order = "pay_time desc";
  1900. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1901. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1902. writeGridDataTableJson(dStruct.TotalCount, dt);
  1903. }
  1904. public void set_erp_unusualtonomal()
  1905. {
  1906. if (UrlPostParmsCheck("ctid"))
  1907. {
  1908. string eid = GetPostString("ctid");
  1909. CeErpTradeCell entity = null;
  1910. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1911. if (entity != null)
  1912. {
  1913. entity.UnusualTag = -1;
  1914. entity.Update();
  1915. returnSuccessMsg("忽略成功!");
  1916. return;
  1917. }
  1918. returnErrorMsg("找不到记录");
  1919. }
  1920. }
  1921. public void ins_erp_unusualreason()
  1922. {
  1923. if (UrlPostParmsCheck("ctid"))
  1924. {
  1925. string eid = GetPostString("ctid");
  1926. CeErpTradeCell entity = null;
  1927. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1928. if (entity != null)
  1929. {
  1930. entity.MemoOpt = 4;
  1931. entity.UnusualCon = GetPostString("con");
  1932. entity.Update();
  1933. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1934. if (trade != null)
  1935. {
  1936. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1937. }
  1938. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1939. returnSuccessMsg("操作成功!");
  1940. return;
  1941. }
  1942. returnErrorMsg("找不到记录");
  1943. }
  1944. }
  1945. public void upd_erp_sampleorder()
  1946. {
  1947. if (UrlPostParmsCheck("ctid"))
  1948. {
  1949. string eid = GetPostString("ctid");
  1950. string[] eArr = eid.Split(',');
  1951. if (eArr.Length > 1)
  1952. {
  1953. List<string> eLst = new List<string>();
  1954. for (int i = 0; i < eArr.Length; i++)
  1955. {
  1956. eLst.Add("'" + eArr[i] + "'");
  1957. }
  1958. eid = string.Join(",", eLst.ToArray());
  1959. }
  1960. else
  1961. {
  1962. eid = "'" + eid + "'";
  1963. }
  1964. StringBuilder sql = new StringBuilder();
  1965. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1966. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1967. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1968. if (dt.Rows.Count > 0)
  1969. {
  1970. string errmsg = "";
  1971. foreach (DataRow dr in dt.Rows)
  1972. {
  1973. StringBuilder sqlsb = new StringBuilder();
  1974. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  1975. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  1976. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  1977. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  1978. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  1979. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  1980. {
  1981. continue;
  1982. }
  1983. else
  1984. {
  1985. string emsg = commonHelper.KeepChinese(apires);
  1986. errmsg += emsg;
  1987. }
  1988. }
  1989. if (errmsg.Length > 0)
  1990. {
  1991. returnErrorMsg(errmsg);
  1992. return;
  1993. }
  1994. returnSuccessMsg("操作成功");
  1995. return;
  1996. }
  1997. returnErrorMsg("找不到记录");
  1998. }
  1999. }
  2000. public void upd_erp_transcustomer()
  2001. {
  2002. if (UrlPostParmsCheck("ctid"))
  2003. {
  2004. string eid = GetPostString("ctid");
  2005. int userid = GetPostInt("CustomerUserId");
  2006. CeErpTradeCell entity = null;
  2007. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2008. if (entity != null)
  2009. {
  2010. //string[] mlist = entity.seller_memo.Split('-');
  2011. //string sql = "select * from view_erpuser where id=" + userid;
  2012. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2013. //if (dt != null && dt.Rows.Count > 0)
  2014. //{
  2015. // string nmemo = "";
  2016. // for(int i = 0; i < mlist.Length - 1; i++)
  2017. // {
  2018. // nmemo += mlist[i];
  2019. // nmemo += "-";
  2020. // }
  2021. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2022. // entity.seller_memo = nmemo;
  2023. //}
  2024. entity.CustomerUserId = userid;
  2025. entity.Update();
  2026. returnSuccessMsg("操作成功!");
  2027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2028. return;
  2029. }
  2030. returnErrorMsg("找不到记录");
  2031. }
  2032. }
  2033. public void upd_erp_transdesigner()
  2034. {
  2035. if (UrlPostParmsCheck("ctid"))
  2036. {
  2037. string eids = GetPostString("ctid");
  2038. string[] ctidList = eids.Split(',');
  2039. int userid = GetPostInt("DesignUserId");
  2040. foreach (string ctid in ctidList)
  2041. {
  2042. CeErpTradeCell entity = null;
  2043. CeErpDesignerBill entitys = null;
  2044. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2045. entitys = CeErpDesignerBill.GetByTid(ctid);
  2046. if (entity != null)
  2047. {
  2048. if (entity.OrderState > 4)
  2049. {
  2050. continue;
  2051. }
  2052. //存在退款不能流转
  2053. if (entity.IsRefund > 0)
  2054. {
  2055. continue;
  2056. }
  2057. entity.DesignUserId = userid;
  2058. entity.WaitDesignTime = DateTime.Now;
  2059. entity.Update();
  2060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2061. }
  2062. }
  2063. returnSuccessMsg("操作成功!");
  2064. }
  2065. }
  2066. public void upd_erp_distributedesigner()
  2067. {
  2068. if (UrlPostParmsCheck("ctid"))
  2069. {
  2070. string eid = GetPostString("ctid");
  2071. int userid = GetPostInt("DesignUserId");
  2072. string[] idlist = eid.Split(',');
  2073. if (idlist.Length <= 0)
  2074. {
  2075. returnErrorMsg("订单不能为空");
  2076. return;
  2077. }
  2078. foreach (string ctid in idlist)
  2079. {
  2080. CeErpTradeCell entity = null;
  2081. CeErpDesignerBill entitys = null;
  2082. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2083. else continue;
  2084. if (entity != null)
  2085. {
  2086. if (userid == 2125 || userid == 3542)
  2087. { }
  2088. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2089. {
  2090. returnErrorMsg("金额错误的订单无法指派");
  2091. return;
  2092. }
  2093. if (entity.OrderState >= 5)
  2094. {
  2095. returnErrorMsg("已经设计完成无法指派");
  2096. return;
  2097. }
  2098. if (entity.OrderState == -1)
  2099. {
  2100. returnErrorMsg("审核中的订单无法指派");
  2101. return;
  2102. }
  2103. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2104. {
  2105. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2106. return;
  2107. }
  2108. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2109. {
  2110. returnErrorMsg("指派设计共创无法再次指派!");
  2111. return;
  2112. }
  2113. entity.OrderState = 3;
  2114. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2115. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2116. {
  2117. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2118. entity.SupplierId = suid;
  2119. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2120. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2121. }
  2122. if (userid == 2125 && entity.seller_memo != "")
  2123. {
  2124. apiDesign.API_GetPrintData_CreateOrder(entity);
  2125. }
  2126. if (userid == 3542 && entity.seller_memo != "")
  2127. {
  2128. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2129. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2130. if (response.msg != "设计共创:成功")
  2131. {
  2132. returnErrorMsg(response.msg);
  2133. return;
  2134. }
  2135. entity.DispatchSort = 2;
  2136. entity.OrderState = 3;
  2137. }
  2138. entity.DesignUserId = userid;
  2139. entity.WaitDesignTime = DateTime.Now;
  2140. entity.Update();
  2141. string name = commonHelper.getUserNameById(userid);
  2142. commonHelper.UpdateRelationOrder(entity.ctid);
  2143. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2144. }
  2145. }
  2146. returnSuccessMsg("操作成功!");
  2147. return;
  2148. }
  2149. }
  2150. public void get_erp_myorderlist()
  2151. {
  2152. DataStruct dStruct = GetPostStruct();
  2153. List<string> lw = new List<string>();
  2154. string tid = GetPostString("ctid");
  2155. if (tid.Length > 0)
  2156. {
  2157. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2158. }
  2159. else
  2160. {
  2161. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2162. }
  2163. //12-1 修改
  2164. string urgent = GetPostString("urgent");
  2165. string back = GetPostString("back");
  2166. string offlineSearch = GetPostString("offlineSearch");
  2167. if (!string.IsNullOrWhiteSpace(urgent))
  2168. {
  2169. if (urgent.Equals("true"))
  2170. {
  2171. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2172. }
  2173. }
  2174. if (!string.IsNullOrWhiteSpace(back))
  2175. {
  2176. if (back.Equals("true"))
  2177. {
  2178. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2179. }
  2180. }
  2181. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2182. {
  2183. if (offlineSearch.Equals("true"))
  2184. {
  2185. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2186. }
  2187. }
  2188. //end
  2189. string shopname = GetPostString("shopname");
  2190. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2191. string buyernick = GetPostString("buyer_nick");
  2192. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2193. string design = GetPostString("design");
  2194. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2195. string orderState = GetPostString("orderState");
  2196. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2197. string sellermemo = GetPostString("seller_memo");
  2198. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2199. string date1 = GetPostString("date1");
  2200. string date2 = GetPostString("date2");
  2201. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2202. if (dw.Length > 0) lw.Add(dw);
  2203. string price1 = GetPostString("price1");
  2204. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2205. string price2 = GetPostString("price2");
  2206. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2207. string urgency = GetPostString("urgency");
  2208. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2209. string after = GetPostString("after");
  2210. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2211. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2212. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2213. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2214. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2215. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2216. writeGridDataTableJson(dStruct.TotalCount, dt);
  2217. }
  2218. public void get_erp_myreturnorderlist()
  2219. {
  2220. DataStruct dStruct = GetPostStruct();
  2221. List<string> lw = new List<string>();
  2222. string tid = GetPostString("ctid");
  2223. if (tid.Length > 0)
  2224. {
  2225. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2226. }
  2227. else
  2228. {
  2229. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2230. }
  2231. string shopname = GetPostString("shopname");
  2232. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2233. string buyernick = GetPostString("buyer_nick");
  2234. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2235. string design = GetPostString("design");
  2236. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2237. string orderState = GetPostString("orderState");
  2238. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2239. string sellermemo = GetPostString("seller_memo");
  2240. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2241. string date1 = GetPostString("date1");
  2242. string date2 = GetPostString("date2");
  2243. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2244. if (dw.Length > 0) lw.Add(dw);
  2245. string price1 = GetPostString("price1");
  2246. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2247. string price2 = GetPostString("price2");
  2248. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2249. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2250. {
  2251. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2252. }
  2253. else
  2254. {
  2255. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2256. }
  2257. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2258. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2259. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2260. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2261. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2262. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2263. if (dt != null && dt.Rows.Count > 0)
  2264. {
  2265. foreach (DataRow dr in dt.Rows)
  2266. {
  2267. try
  2268. {
  2269. // 对象操作
  2270. if (dStruct.PageSize != 100000)
  2271. {
  2272. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2273. dr["gongchuang"] = response.code;
  2274. }
  2275. }
  2276. catch (NullReferenceException ex)
  2277. {
  2278. // 处理空引用异常
  2279. }
  2280. }
  2281. }
  2282. writeGridDataTableJson(dStruct.TotalCount, dt);
  2283. }
  2284. public void get_erp_myorderlist_pregather()
  2285. {
  2286. string date1 = GetPostString("date1");
  2287. string date2 = GetPostString("date2");
  2288. int userId = CurrentUser.UserID; //客服id
  2289. string orderWhere = "";
  2290. List<string> lw = new List<string>();
  2291. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2292. if (dw.Length > 0) lw.Add(dw);
  2293. lw.Add(string.Format("CustomerUserId={0}", userId));
  2294. lw.Add(string.Format("OrderState<9"));
  2295. orderWhere = string.Join(" and ", lw.ToArray());
  2296. string orderWhere2 = "";
  2297. List<string> lw2 = new List<string>();
  2298. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2299. if (dw2.Length > 0) lw2.Add(dw2);
  2300. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2301. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2302. string sql = string.Format("select *" +
  2303. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2304. "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 " +
  2305. "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 " +
  2306. "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");
  2307. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2308. //writeGridDataTableJson(dt.Rows.Count, dt);
  2309. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2310. }
  2311. public void upd_erp_publishorder()
  2312. {
  2313. if (UrlPostParmsCheck("ctid"))
  2314. {
  2315. string eid = GetPostString("ctid");
  2316. CeErpTradeCell entity = null;
  2317. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2318. if (entity != null)
  2319. {
  2320. entity.OrderState = 0; //发布后,变为待抢单
  2321. entity.Update();
  2322. commonHelper.UpdateRelationOrder(entity.ctid);
  2323. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2324. returnSuccessMsg("发布成功!");
  2325. return;
  2326. }
  2327. returnErrorMsg("找不到记录");
  2328. }
  2329. }
  2330. public void get_erp_my_tiporder()
  2331. {
  2332. StringBuilder sql = new StringBuilder();
  2333. int userId = 0;
  2334. if (CurrentUser != null) userId = CurrentUser.UserID;
  2335. string posCode = CurrentUser.UserPost.Post.Code;
  2336. string isTipedAfterSaleVerify = GetPostString("af");
  2337. DataTable dt = new DataTable();
  2338. if (posCode != "Supplier")
  2339. {
  2340. if (posCode == "CustomerService" || posCode == "Director")
  2341. {
  2342. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2343. }
  2344. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2345. {
  2346. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2347. }
  2348. else
  2349. {
  2350. string teamIds = CurrentUser.User.TeamIds;
  2351. if (teamIds == "")
  2352. {
  2353. teamIds = "0";
  2354. }
  2355. 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);
  2356. }
  2357. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2358. }
  2359. if (dt.Rows.Count <= 0)
  2360. {
  2361. string key = "aftersale_order_" + userId;
  2362. if (RedisHelper.HasKey(key))
  2363. {
  2364. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2365. dt.Columns.Add("ctid", typeof(string));
  2366. dt.Columns.Add("IsReadTag", typeof(int));
  2367. foreach (var i in list)
  2368. {
  2369. DataRow data = dt.NewRow();
  2370. data["ctid"] = i;
  2371. data["IsReadTag"] = 4;
  2372. dt.Rows.Add(data);
  2373. }
  2374. RedisHelper.StringDelete(key);
  2375. }
  2376. }
  2377. if (dt.Rows.Count <= 0)
  2378. {
  2379. sql = new StringBuilder();
  2380. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2381. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2382. }
  2383. if (posCode == "Supplier")
  2384. {
  2385. string ids = CurrentUser.User.pemVend;
  2386. if (ids != null && ids.Length > 0)
  2387. {
  2388. string[] ids_list = ids.Split(',');
  2389. foreach (var item in ids_list)
  2390. {
  2391. string key = "return_order_" + item;
  2392. if (RedisHelper.HasKey(key))
  2393. {
  2394. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2395. dt.Columns.Add("ctid", typeof(string));
  2396. dt.Columns.Add("IsReadTag", typeof(int));
  2397. foreach (var i in list)
  2398. {
  2399. DataRow data = dt.NewRow();
  2400. data["ctid"] = i;
  2401. data["IsReadTag"] = 1;
  2402. dt.Rows.Add(data);
  2403. }
  2404. RedisHelper.StringDelete(key);
  2405. }
  2406. }
  2407. }
  2408. if (dt.Rows.Count <= 0)
  2409. {
  2410. sql = new StringBuilder();
  2411. 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);
  2412. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2413. }
  2414. }
  2415. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2416. }
  2417. public void reset_erp_tiporder()
  2418. {
  2419. string ids = GetPostString("ids");
  2420. string[] ctidList = ids.Split(',');
  2421. foreach (string ctid in ctidList)
  2422. {
  2423. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2424. if (enty != null)
  2425. {
  2426. enty.IsReadTag = 0;
  2427. enty.Update();
  2428. }
  2429. }
  2430. returnSuccessMsg("成功!");
  2431. return;
  2432. }
  2433. public void get_erp_designlist()
  2434. {
  2435. DataStruct dStruct = GetPostStruct();
  2436. List<string> lw = new List<string>();
  2437. string tid = GetPostString("ctid");
  2438. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2439. string shopname = GetPostString("shopname");
  2440. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2441. string buyernick = GetPostString("buyer_nick");
  2442. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2443. string customer = GetPostString("customer");
  2444. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2445. string design = GetPostString("design");
  2446. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2447. string orderState = GetPostString("orderState");
  2448. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2449. lw.Add(string.Format("OrderState<6"));
  2450. string address = GetPostString("address");
  2451. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2452. string sellermemo = GetPostString("seller_memo");
  2453. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2454. string date1 = GetPostString("date1");
  2455. string date2 = GetPostString("date2");
  2456. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2457. if (dw.Length > 0) lw.Add(dw);
  2458. string apdate1 = GetPostString("apdate1");
  2459. string apdate2 = GetPostString("apdate2");
  2460. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2461. if (dwap.Length > 0) lw.Add(dwap);
  2462. string price1 = GetPostString("price1");
  2463. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2464. string price2 = GetPostString("price2");
  2465. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2466. string designTime = GetPostString("designtime");
  2467. if (designTime.Length > 0)
  2468. {
  2469. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2470. }
  2471. string usershop = CurrentUser.User.pemShop;
  2472. if (usershop.Length > 0)
  2473. {
  2474. lw.Add(string.Format("shopId in ({0})", usershop));
  2475. }
  2476. int myOrgid = CurrentUser.UserPost.OrgID;
  2477. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2478. if (myOrgCode.IndexOf("Designer") != -1)
  2479. {
  2480. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2481. {
  2482. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2483. }
  2484. else
  2485. {
  2486. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2487. }
  2488. }
  2489. else
  2490. {
  2491. string orgId = GetPostString("designerhd");
  2492. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2493. }
  2494. if (tid.Length > 0 || buyernick.Length > 0)
  2495. {
  2496. lw.Add(string.Format("OrderState >= 3"));
  2497. }
  2498. else
  2499. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2500. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2501. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2503. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2504. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2505. if (dt != null && dt.Rows.Count > 0)
  2506. {
  2507. foreach (DataRow dr in dt.Rows)
  2508. {
  2509. try
  2510. {
  2511. // 对象操作
  2512. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2513. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2514. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2515. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2516. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2517. if (dStruct.PageSize != 100000)
  2518. {
  2519. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2520. dr["gongchuang"] = response.code;
  2521. }
  2522. }
  2523. catch (NullReferenceException ex)
  2524. {
  2525. }
  2526. }
  2527. }
  2528. writeGridDataTableJson(dStruct.TotalCount, dt);
  2529. }
  2530. public void get_erp_mydesignlist()
  2531. {
  2532. DataStruct dStruct = GetPostStruct();
  2533. List<string> lw = new List<string>();
  2534. string tid = GetPostString("ctid");
  2535. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2536. string shopname = GetPostString("shopname");
  2537. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2538. string buyernick = GetPostString("buyer_nick");
  2539. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2540. string customer = GetPostString("customer");
  2541. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2542. string orderState = GetPostString("orderState");
  2543. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2544. //lw.Add(string.Format("OrderState<6"));
  2545. string date1 = GetPostString("date1");
  2546. string date2 = GetPostString("date2");
  2547. string dw = GetDateWhere("pay_time", date1, date2);
  2548. if (dw.Length > 0) lw.Add(dw);
  2549. string apdate1 = GetPostString("apdate1");
  2550. string apdate2 = GetPostString("apdate2");
  2551. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2552. if (dwap.Length > 0) lw.Add(dwap);
  2553. string price1 = GetPostString("price1");
  2554. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2555. string price2 = GetPostString("price2");
  2556. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2557. string olddownload = GetPostString("olddown");
  2558. if (olddownload == "1")
  2559. {
  2560. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2561. }
  2562. else if (olddownload == "2")
  2563. {
  2564. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2565. }
  2566. string sellermemo = GetPostString("seller_memo");
  2567. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2568. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2569. if (CurrentUser.User.TeamIds.Length > 0)
  2570. {
  2571. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2572. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2573. else
  2574. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2575. }
  2576. else
  2577. {
  2578. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2579. }
  2580. if (tid.Length <= 0)
  2581. {
  2582. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2583. }
  2584. lw.Add(string.Format("IsReturn!=3"));
  2585. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2586. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2587. string teamids = CurrentUser.User.TeamIds.ToString();
  2588. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2589. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2590. if (dt != null && dt.Rows.Count > 0)
  2591. {
  2592. foreach (DataRow dr in dt.Rows)
  2593. {
  2594. try
  2595. {
  2596. // 对象操作
  2597. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2598. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2599. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2600. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2601. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2602. if (dStruct.PageSize != 100000)
  2603. {
  2604. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2605. dr["gongchuang"] = response.code;
  2606. }
  2607. }
  2608. catch (NullReferenceException ex)
  2609. {
  2610. }
  2611. }
  2612. }
  2613. writeGridDataTableJson(dStruct.TotalCount, dt);
  2614. }
  2615. public void set_erp_startdesign()
  2616. {
  2617. if (UrlPostParmsCheck("ctid"))
  2618. {
  2619. string eid = GetPostString("ctid");
  2620. CeErpTradeCell entity = null;
  2621. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2622. if (entity != null)
  2623. {
  2624. if (entity.OrderState != 3)
  2625. {
  2626. returnErrorMsg("请刷新,订单已经设计了");
  2627. return;
  2628. }
  2629. entity.StartDesignTime = DateTime.Now;
  2630. entity.OrderState = 4;
  2631. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2632. {
  2633. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2634. entity.SupplierId = suid;
  2635. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2636. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2637. }
  2638. //entity.MakeSupplier = suname;
  2639. entity.Update();
  2640. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2641. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2642. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2643. commonHelper.getCytPrice(entity);
  2644. returnSuccessMsg("操作成功!");
  2645. return;
  2646. }
  2647. returnErrorMsg("找不到记录");
  2648. }
  2649. }
  2650. public void ins_erp_designselfmemo()
  2651. {
  2652. if (UrlPostParmsCheck("ctid"))
  2653. {
  2654. string eid = GetPostString("ctid");
  2655. string con = GetPostString("con");
  2656. CeErpTradeCell entity = null;
  2657. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2658. if (entity != null)
  2659. {
  2660. entity.DesignSelfMemo = con;
  2661. entity.Update();
  2662. returnSuccessMsg("操作成功!");
  2663. return;
  2664. }
  2665. returnErrorMsg("找不到记录");
  2666. }
  2667. }
  2668. public void ins_erp_designprice()
  2669. {
  2670. if (UrlPostParmsCheck("ctid"))
  2671. {
  2672. string eid = GetPostString("ctid");
  2673. int uid = CurrentUser.UserID;
  2674. string userName = CurrentUser.UserName;
  2675. CeErpTradeCell entity = null;
  2676. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2677. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2678. if (entitys == null)
  2679. {
  2680. entitys = new CeErpDesignerBill();
  2681. }
  2682. if (entity != null)
  2683. {
  2684. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2685. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2686. entity.StartDesignTime = DateTime.Now;
  2687. entity.OrderState = 4;
  2688. string suname = "";
  2689. if (entity.SupplierId == 0)
  2690. {
  2691. int sid = commonHelper.autoDistributeToSupplier(entity);
  2692. entity.SupplierId = sid;
  2693. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2694. }
  2695. entity.Update();
  2696. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2697. if (ceErpUserPost != null)
  2698. {
  2699. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2700. if (ceErpPost != null)
  2701. {
  2702. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2703. {
  2704. entitys.tid = entity.ctid;
  2705. entitys.oid = entity.tid;
  2706. entitys.uid = uid;
  2707. entitys.userName = userName;
  2708. entitys.designerType = 1;
  2709. entitys.designerTypeText = "内部设计师";
  2710. entitys.price = Convert.ToDouble(GetPostString("price"));
  2711. entitys.designNum = GetPostInt("designNum");
  2712. entitys.modifyNum = GetPostInt("modifyNum");
  2713. entitys.designSize = GetPostString("designSize");
  2714. entitys.modifySize = GetPostString("modifySize");
  2715. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2716. {
  2717. entitys.create_time = DateTime.Now;
  2718. entitys.create_u_id = uid;
  2719. entitys.create_u_name = userName;
  2720. entitys.Save();
  2721. }
  2722. else
  2723. {
  2724. entitys.update_time = DateTime.Now;
  2725. entitys.update_u_id = uid;
  2726. entitys.update_u_name = userName;
  2727. entitys.Update();
  2728. }
  2729. }
  2730. }
  2731. }
  2732. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2733. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2734. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2735. if (suname != "")
  2736. {
  2737. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2738. }
  2739. commonHelper.getCytPrice(entity);
  2740. returnSuccessMsg("操作成功!");
  2741. return;
  2742. }
  2743. returnErrorMsg("找不到记录");
  2744. }
  2745. }
  2746. public void upload_erp_filecomplete()
  2747. {
  2748. if (UrlPostParmsCheck("ctid"))
  2749. {
  2750. string eid = GetPostString("ctid");
  2751. CeErpTradeCell entity = null;
  2752. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2753. if (entity != null)
  2754. {
  2755. entity.OrderState = 5; //设计完成
  2756. entity.Update();
  2757. returnSuccessMsg(eid + "上传成功,设计完成!");
  2758. return;
  2759. }
  2760. returnErrorMsg("找不到订单记录");
  2761. }
  2762. }
  2763. public void get_erp_designovertimelist()
  2764. {
  2765. DataStruct dStruct = GetPostStruct();
  2766. List<string> lw = new List<string>();
  2767. string tid = GetPostString("ctid");
  2768. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2769. string shopname = GetPostString("shopname");
  2770. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2771. string buyernick = GetPostString("buyer_nick");
  2772. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2773. string ResponsibleMan = GetPostString("responsible");
  2774. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2775. string date1 = GetPostString("date1");
  2776. string date2 = GetPostString("date2");
  2777. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2778. if (dw.Length > 0) lw.Add(dw);
  2779. string price1 = GetPostString("price1");
  2780. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2781. string price2 = GetPostString("price2");
  2782. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2783. string orderState = GetPostString("orderState");
  2784. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2785. string sellermemo = GetPostString("seller_memo");
  2786. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2787. lw.Add(string.Format("UnusualTag=3"));
  2788. lw.Add(string.Format("IsRefund<={0}", 1));
  2789. dStruct.Order = "WaitDesignTime desc";
  2790. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2791. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2792. writeGridDataTableJson(dStruct.TotalCount, dt);
  2793. }
  2794. //设计管理 获取抢单大厅列表
  2795. public void get_erp_grabinglist()
  2796. {
  2797. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2798. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2799. bool oldOrder = false;
  2800. if (org != null)
  2801. {
  2802. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2803. }
  2804. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2805. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2806. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2807. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2808. //先处理订单数据
  2809. if (dt.Rows.Count > 0)
  2810. {
  2811. Dictionary<string, int> design = null;
  2812. int count = 0;
  2813. foreach (DataRow row in dt.Rows)
  2814. {
  2815. if (map.ContainsKey(row["ShopId"].ToString()))
  2816. {
  2817. map.TryGetValue(row["ShopId"].ToString(), out design);
  2818. }
  2819. else
  2820. {
  2821. design = new Dictionary<string, int>();
  2822. }
  2823. if (design.ContainsKey(row["ProductId"].ToString()))
  2824. {
  2825. design.TryGetValue(row["ProductId"].ToString(), out count);
  2826. }
  2827. count++;
  2828. design[row["ProductId"].ToString()] = count;
  2829. map[row["ShopId"].ToString()] = design;
  2830. }
  2831. }
  2832. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2833. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2834. //把店铺排序和技能排序分类
  2835. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2836. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2837. if (design_dt.Rows.Count > 0)
  2838. {
  2839. Dictionary<string, string> design = null;
  2840. List<string> shopIds = null;
  2841. foreach (DataRow row in design_dt.Rows)
  2842. {
  2843. if ("0".Equals(row["designId"].ToString()))
  2844. {
  2845. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2846. {
  2847. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2848. }
  2849. else
  2850. {
  2851. shopIds = new List<string>();
  2852. }
  2853. shopIds.Add(row["shopId"].ToString());
  2854. shop_orders[row["orders"].ToString()] = shopIds;
  2855. }
  2856. else
  2857. {
  2858. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2859. {
  2860. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2861. }
  2862. else
  2863. {
  2864. design = new Dictionary<string, string>();
  2865. }
  2866. design[row["orders"].ToString()] = row["designId"].ToString();
  2867. design_orders[row["shopId"].ToString()] = design;
  2868. }
  2869. }
  2870. //处理成key value后根据key排序
  2871. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2872. foreach (List<string> val in shop_orders.Values)
  2873. {
  2874. if (val != null)
  2875. {
  2876. foreach (string key in val)
  2877. {
  2878. if (design_orders.ContainsKey(key.ToString()))
  2879. {
  2880. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2881. }
  2882. }
  2883. }
  2884. }
  2885. }
  2886. //校验哪个优先级有订单
  2887. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2888. foreach (string key in shop_orders.Keys)
  2889. {
  2890. List<string> ids = null;
  2891. shop_orders.TryGetValue(key, out ids);
  2892. //id为shopid
  2893. foreach (string id in ids)
  2894. {
  2895. Dictionary<string, int> list = null;
  2896. Dictionary<string, string> desing = null;
  2897. map.TryGetValue(id, out list);
  2898. design_orders.TryGetValue(id, out desing);
  2899. if (list != null && desing != null)
  2900. {
  2901. foreach (var item in desing)
  2902. {
  2903. int count = 0;
  2904. if (list.ContainsKey(item.Value))
  2905. {
  2906. list.TryGetValue(item.Value, out count);
  2907. if (count > 0)
  2908. {
  2909. designIds[id] = item.Value;
  2910. break;
  2911. }
  2912. }
  2913. }
  2914. }
  2915. }
  2916. if (designIds.Count > 0)
  2917. {
  2918. break;
  2919. }
  2920. }
  2921. DataTable table = new DataTable();
  2922. table.Columns.Add("tid", typeof(string));
  2923. table.Columns.Add("ctid", typeof(string));
  2924. table.Columns.Add("seller_nick", typeof(string));
  2925. table.Columns.Add("productName", typeof(string));
  2926. table.Columns.Add("pay_time", typeof(string));
  2927. table.Columns.Add("seller_memo", typeof(string));
  2928. if (designIds.Count > 0)
  2929. {
  2930. string shopId = "";
  2931. string productId = "";
  2932. foreach (var designInfo in designIds)
  2933. {
  2934. shopId = designInfo.Key;
  2935. productId = designInfo.Value;
  2936. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2937. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2938. if (dt.Rows.Count > 0)
  2939. {
  2940. foreach (DataRow row in dt.Rows)
  2941. {
  2942. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  2943. {
  2944. DataRow data = table.NewRow();
  2945. data["ctid"] = row["ctid"].ToString();
  2946. data["tid"] = row["tid"].ToString();
  2947. data["seller_nick"] = ceErpShop.ShopName;
  2948. data["pay_time"] = row["pay_time"].ToString();
  2949. data["seller_memo"] = row["seller_memo"].ToString();
  2950. data["productName"] = ceErpProduct.PType;
  2951. table.Rows.Add(data);
  2952. }
  2953. }
  2954. }
  2955. }
  2956. }
  2957. writeGridDataTableJson(table.Rows.Count, table);
  2958. }
  2959. private object rushLockObject = new object();
  2960. public void set_erp_grabingorder()
  2961. {
  2962. if (UrlPostParmsCheck("ctid"))
  2963. {
  2964. int total = CurrentUser.User.Person.Total;
  2965. int userId = CurrentUser.User.ID;
  2966. int noFinish = CurrentUser.User.Person.NoFinish;
  2967. int finalization = CurrentUser.User.Person.Finalization;
  2968. string eids = GetPostString("ctid");
  2969. string key = "RushKey_" + userId;
  2970. int count = 0;
  2971. if (erpRedis.RedisHelper.KeyExists(key))
  2972. {
  2973. string redisCount = erpRedis.RedisHelper.StringGet(key);
  2974. if (redisCount != null)
  2975. {
  2976. count = Convert.ToInt32(redisCount);
  2977. }
  2978. }
  2979. if (count >= total)
  2980. {
  2981. returnErrorMsg("半小时内已经抢" + total + "单");
  2982. return;
  2983. }
  2984. string[] ctidlist = eids.Split(',');
  2985. if (count + ctidlist.Length > total)
  2986. {
  2987. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  2988. return;
  2989. }
  2990. int itag = 0;
  2991. lock (rushLockObject)
  2992. {
  2993. if (ctidlist.Length > 0)
  2994. {
  2995. string[] dtList = new string[ctidlist.Length];
  2996. for (int i = 0; i < ctidlist.Length; i++)
  2997. {
  2998. dtList[i] = "'" + ctidlist[i] + "'";
  2999. }
  3000. 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"));
  3001. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3002. if (dt_user.Rows.Count > 0)
  3003. {
  3004. int doing = 0;//未定稿
  3005. int finish = 0;//已完成
  3006. foreach (DataRow dr in dt_user.Rows)
  3007. {
  3008. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3009. {
  3010. doing++;
  3011. }
  3012. else
  3013. {
  3014. finish++;
  3015. }
  3016. }
  3017. if (doing >= noFinish)
  3018. {
  3019. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3020. return;
  3021. }
  3022. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3023. {
  3024. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3025. return;
  3026. }
  3027. }
  3028. //校验选择单子状态
  3029. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3030. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3031. if (dt.Rows.Count > 0)
  3032. {
  3033. List<string> list = new List<string>();
  3034. foreach (DataRow dr in dt.Rows)
  3035. {
  3036. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3037. {
  3038. list.Add(dr["ctid"].ToString());
  3039. }
  3040. }
  3041. if (list.Count > 0)
  3042. {
  3043. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3044. return;
  3045. }
  3046. }
  3047. foreach (string ctid in ctidlist)
  3048. {
  3049. CeErpTradeCell entity = null;
  3050. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3051. if (entity != null)
  3052. {
  3053. entity.OrderState = 3;
  3054. entity.DesignUserId = CurrentUser.UserID;
  3055. entity.WaitDesignTime = DateTime.Now;
  3056. entity.StartDesignTime = DateTime.Now;
  3057. entity.Update();
  3058. commonHelper.UpdateRelationOrder(entity.ctid);
  3059. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3061. itag++;
  3062. }
  3063. }
  3064. }
  3065. }
  3066. count += ctidlist.Length;
  3067. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3068. if (itag == 0)
  3069. returnErrorMsg("没有找到相关订单");
  3070. else
  3071. returnSuccessMsg("抢单成功!");
  3072. return;
  3073. }
  3074. }
  3075. public void get_erp_waitorderlist()
  3076. {
  3077. DataStruct dStruct = GetPostStruct();
  3078. List<string> lw = new List<string>();
  3079. string tid = GetPostString("ctid");
  3080. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3081. string shopname = GetPostString("shopname");
  3082. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3083. string buyernick = GetPostString("buyer_nick");
  3084. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3085. string customer = GetPostString("customer");
  3086. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3087. string design = GetPostString("design");
  3088. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3089. string orderState = GetPostString("orderState");
  3090. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3091. string supplier = GetPostString("supplier");
  3092. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3093. string sellermemo = GetPostString("seller_memo");
  3094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3095. string otherMemo = GetPostString("otherMemo");
  3096. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3097. string address = GetPostString("address");
  3098. 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));
  3099. string date1 = GetPostString("date1");
  3100. string date2 = GetPostString("date2");
  3101. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3102. if (dw.Length > 0) lw.Add(dw);
  3103. string price1 = GetPostString("price1");
  3104. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3105. string price2 = GetPostString("price2");
  3106. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3107. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3108. lw.Add(string.Format("IsSample != 2 "));
  3109. lw.Add(string.Format("OrderState = 5 "));
  3110. lw.Add(string.Format("IsRefund<={0}", 1));
  3111. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3112. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3113. string pagesize = GetPostString("pagesize");
  3114. if (pagesize != null)
  3115. {
  3116. dStruct.PageSize = 200;
  3117. }
  3118. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3119. foreach (DataRow dr in dt.Rows)
  3120. {
  3121. 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();
  3122. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3123. {
  3124. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3125. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3126. entity.SupplierId = suid;
  3127. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3128. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3129. entity.Update();
  3130. }
  3131. }
  3132. writeGridDataTableJson(dStruct.TotalCount, dt);
  3133. }
  3134. public void get_erp_supplierwaitorderlist()
  3135. {
  3136. DataStruct dStruct = GetPostStruct();
  3137. List<string> lw = new List<string>();
  3138. string tid = GetPostString("ctid");
  3139. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3140. string shopname = GetPostString("shopname");
  3141. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3142. string sellermemo = GetPostString("seller_memo");
  3143. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3144. string date1 = GetPostString("date1");
  3145. string date2 = GetPostString("date2");
  3146. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3147. if (dw.Length > 0) lw.Add(dw);
  3148. lw.Add(string.Format("OrderState = 5 "));
  3149. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3150. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3151. {
  3152. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3153. }
  3154. string supplier = GetPostString("supplier");
  3155. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3156. {
  3157. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3158. }
  3159. lw.Add(string.Format("IsRefund<={0}", 1));
  3160. dStruct.Order = "FinishDesignTime desc";
  3161. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3162. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3163. if (dt != null)
  3164. {
  3165. foreach (DataRow dr in dt.Rows)
  3166. {
  3167. 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();
  3168. }
  3169. }
  3170. writeGridDataTableJson(dStruct.TotalCount, dt);
  3171. }
  3172. public void upd_erp_verifytosupplier()
  3173. {
  3174. if (UrlPostParmsCheck("ctid"))
  3175. {
  3176. string eids = GetPostString("ctid");
  3177. CeErpTradeCell entity = null;
  3178. string[] eidsList = eids.Split(',');
  3179. if (eidsList.Length <= 0)
  3180. {
  3181. returnErrorMsg("订单号不能空");
  3182. return;
  3183. }
  3184. List<string> tLst = new List<string>();
  3185. foreach (string ctidstr in eidsList)
  3186. {
  3187. tLst.Add("'" + ctidstr + "'");
  3188. CeErpDataSendOrderInfo.createObject(ctidstr);
  3189. }
  3190. string needtids = string.Join(",", tLst.ToArray());
  3191. StringBuilder sql = new StringBuilder();
  3192. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3193. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3194. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3195. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3196. returnSuccessMsg("操作成功!");
  3197. return;
  3198. /**foreach (string ctidstr in eidsList)
  3199. {
  3200. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3201. if (entity != null)
  3202. {
  3203. if (entity.SupplierId == 0)
  3204. {
  3205. continue;
  3206. }
  3207. entity.IsVerifyToSupplier = true;
  3208. if (entity.IsReturn == 1) //1是供应商打回
  3209. {
  3210. entity.IsReturn = 0;
  3211. }
  3212. entity.FinishPlaceTime = DateTime.Now;
  3213. entity.PlaceUserId = CurrentUser.UserID;
  3214. entity.Update();
  3215. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3216. }
  3217. }
  3218. returnSuccessMsg("操作成功!");
  3219. return;**/
  3220. }
  3221. }
  3222. public void upd_erp_supplierback()
  3223. {
  3224. if (UrlPostParmsCheck("ctid"))
  3225. {
  3226. string eid = GetPostString("ctid");
  3227. string reason = GetPostString("returnreason");
  3228. CeErpTradeCell entity = null;
  3229. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3230. if (entity != null)
  3231. {
  3232. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3233. {
  3234. string key = "return_order_" + entity.SupplierId;
  3235. List<string> list = new List<string>();
  3236. if (RedisHelper.HasKey(key))
  3237. {
  3238. object data = RedisHelper.StringGet(key);
  3239. list = Convert.ToString(data).Split(',').ToList();
  3240. }
  3241. list.Add(eid);
  3242. RedisHelper.StringSet(key, string.Join(",", list));
  3243. }
  3244. entity.IsVerifyToSupplier = false;
  3245. entity.IsReturn = 1;
  3246. entity.ReturnTime = DateTime.Now;
  3247. entity.ReturnReason = reason;
  3248. if (entity.OrderState == 6)
  3249. {
  3250. entity.OrderState = 5;
  3251. }
  3252. entity.Update();
  3253. CeErpSukuraData.createInfo(entity.ctid, 5);
  3254. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3255. returnSuccessMsg("操作成功!");
  3256. return;
  3257. }
  3258. returnErrorMsg("找不到订单记录");
  3259. }
  3260. }
  3261. public void upd_erp_toaftersaleorder()
  3262. {
  3263. if (UrlPostParmsCheck("ctid"))
  3264. {
  3265. string eid = GetPostString("ctid");
  3266. string reason = GetPostString("returnreason");
  3267. CeErpTradeCell entity = null;
  3268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3269. if (entity != null)
  3270. {
  3271. if (entity.isAfterSaleOrder != 1)
  3272. {
  3273. returnErrorMsg("带S的售后单才能打回给售后");
  3274. return;
  3275. }
  3276. if (entity.OrderState >= 5)
  3277. {
  3278. returnErrorMsg("已经设计完成了不能打回给售后");
  3279. return;
  3280. }
  3281. entity.OrderState = 0;
  3282. entity.IsReturn = 3;
  3283. entity.ReturnTime = DateTime.Now;
  3284. entity.ReturnReason = reason;
  3285. entity.Update();
  3286. CeErpSukuraData.createInfo(entity.ctid, 5);
  3287. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3288. returnSuccessMsg("操作成功!");
  3289. return;
  3290. }
  3291. returnErrorMsg("找不到订单记录");
  3292. }
  3293. }
  3294. public void upd_erp_aftersaletodesign()
  3295. {
  3296. if (UrlPostParmsCheck("ctid"))
  3297. {
  3298. string eid = GetPostString("ctid");
  3299. CeErpTradeCell entity = null;
  3300. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3301. if (entity != null)
  3302. {
  3303. entity.OrderState = 3;
  3304. entity.IsReturn = 0;
  3305. entity.Update();
  3306. CeErpSukuraData.createInfo(entity.ctid, 5);
  3307. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3308. returnSuccessMsg("操作成功!");
  3309. return;
  3310. }
  3311. returnErrorMsg("找不到订单记录");
  3312. }
  3313. }
  3314. public void assign_erp_supplier()
  3315. {
  3316. if (UrlPostParmsCheck("ctid"))
  3317. {
  3318. string eids = GetPostString("ctid");
  3319. int sid = GetPostInt("SupplierName");
  3320. string fromTag = GetPostString("tag");
  3321. string[] eidList = eids.Split(',');
  3322. if (eidList.Length <= 0)
  3323. {
  3324. returnErrorMsg("指派不能为空");
  3325. return;
  3326. }
  3327. string errMsg = "";
  3328. string suname = commonHelper.getSupplierNameById(sid);
  3329. foreach (string ctid in eidList)
  3330. {
  3331. CeErpTradeCell entity = null;
  3332. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3333. if (entity != null)
  3334. {
  3335. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3336. {
  3337. errMsg += (ctid + "指派失败!!!");
  3338. continue;
  3339. }
  3340. entity.SupplierId = sid;
  3341. entity.Update();
  3342. commonHelper.UpdateRelationOrder(entity.ctid);
  3343. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3344. if (entity.OrderState >= 6)
  3345. {
  3346. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3347. //{
  3348. // string msl = entity.MakeSupplier;
  3349. // string[] mslist = msl.Split(',');
  3350. // 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);
  3351. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3352. //}
  3353. //else
  3354. //{
  3355. StringBuilder sql = new StringBuilder();
  3356. 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);
  3357. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3358. //}
  3359. }
  3360. }
  3361. else
  3362. {
  3363. continue;
  3364. }
  3365. }
  3366. if (errMsg.Length > 0)
  3367. {
  3368. returnErrorMsg(errMsg);
  3369. return;
  3370. }
  3371. returnSuccessMsg("操作成功!");
  3372. return;
  3373. }
  3374. }
  3375. public void assign_erp_makesupplier()
  3376. {
  3377. if (UrlPostParmsCheck("ctid"))
  3378. {
  3379. string eids = GetPostString("ctid");
  3380. string sname = GetPostString("SupplierName");
  3381. string[] eidList = eids.Split(',');
  3382. if (eidList.Length <= 0)
  3383. {
  3384. returnErrorMsg("指派不能为空");
  3385. return;
  3386. }
  3387. List<string> tLst = new List<string>();
  3388. foreach (string ctid in eidList)
  3389. {
  3390. CeErpTradeCell entity = null;
  3391. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3392. if (entity != null)
  3393. {
  3394. entity.MakeSupplier = sname;
  3395. entity.Update();
  3396. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3397. tLst.Add("'" + ctid + "'");
  3398. }
  3399. else
  3400. {
  3401. continue;
  3402. }
  3403. }
  3404. string ctids = string.Join(",", tLst.ToArray());
  3405. StringBuilder sql2 = new StringBuilder();
  3406. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3407. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3408. returnSuccessMsg("操作成功!");
  3409. return;
  3410. }
  3411. }
  3412. public void ins_erp_returnreason()
  3413. {
  3414. if (UrlPostParmsCheck("ctid"))
  3415. {
  3416. string eid = GetPostString("ctid");
  3417. CeErpTradeCell entity = null;
  3418. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3419. string userpost = CurrentUser.UserPost.Post.Code;
  3420. if (entity != null)
  3421. {
  3422. bool isPlace = false;
  3423. if (entity.OrderState > 6)
  3424. {
  3425. returnErrorMsg("已发货无法打回!");
  3426. return;
  3427. }
  3428. if (entity.OrderState == 6)
  3429. {
  3430. isPlace = true;
  3431. }
  3432. bool isNeedUpdateCell2 = false;
  3433. if (entity.OrderState >= 6)
  3434. {
  3435. isNeedUpdateCell2 = true;
  3436. }
  3437. int returnTag = 2;
  3438. if (userpost == "Supplier")
  3439. {
  3440. returnTag = 1;
  3441. }
  3442. if (entity.IsXianHuo == 0)
  3443. {
  3444. if (returnTag == 2)
  3445. {
  3446. int toType = GetPostInt("totype");
  3447. if (toType == 1)
  3448. {
  3449. entity.OrderState = 0;
  3450. entity.ReturnUserType = 1;
  3451. string clearman = GetPostString("clearman");
  3452. if (!string.IsNullOrEmpty(clearman))
  3453. {
  3454. entity.DesignUserId = 0;
  3455. }
  3456. }
  3457. else
  3458. {
  3459. entity.OrderState = 3;
  3460. entity.ReturnUserType = 2;
  3461. }
  3462. entity.IsReadTag = 1;
  3463. }
  3464. else if (returnTag == 1)
  3465. {
  3466. entity.OrderState = 5;
  3467. }
  3468. entity.IsVerifyToSupplier = false;
  3469. }
  3470. if (entity.IsXianHuo == 1)
  3471. {
  3472. entity.OrderState = 5;
  3473. }
  3474. entity.UnusualTag = 0;
  3475. entity.UnusualTime = null;
  3476. entity.UnusualCon = "";
  3477. entity.IsReturn = returnTag;
  3478. entity.ReturnTime = DateTime.Now;
  3479. entity.ReturnReason = GetPostString("returnreason");
  3480. entity.Update();
  3481. if (entity.OrderState == 3)
  3482. {
  3483. ApiVo apiVo = new ApiVo();
  3484. apiVo.orderNumber = entity.ctid;
  3485. apiVo.actionName = "rebutDesign";
  3486. apiVo.orderRemarks = entity.ReturnReason;
  3487. designHelper.API_WorkCore(apiVo);//rebutDesign
  3488. }
  3489. CeErpSukuraData.createInfo(entity.ctid, 5);
  3490. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3491. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3492. if (isPlace)
  3493. {
  3494. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3495. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3496. if (dth != null && dth.Rows.Count > 0)
  3497. {
  3498. dataSendOrderBean dataSendOrderBean = null;
  3499. foreach (DataRow item in dth.Rows)
  3500. {
  3501. try
  3502. {
  3503. dataSendOrderBean = new dataSendOrderBean();
  3504. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3505. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3506. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3507. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3508. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3509. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3510. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3511. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3512. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3513. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3514. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3515. dataSendOrderBean.Radio1723534706288 = "打回";
  3516. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3517. if (result != null)
  3518. {
  3519. if ("0".Equals(result.errcode))
  3520. {
  3521. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3522. }
  3523. else
  3524. {
  3525. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3526. }
  3527. }
  3528. }
  3529. catch (Exception ex)
  3530. {
  3531. }
  3532. }
  3533. }
  3534. }
  3535. if (isNeedUpdateCell2)
  3536. {
  3537. if (entity.MakeSupplier.IndexOf(",") != -1)
  3538. {
  3539. StringBuilder sql2 = new StringBuilder();
  3540. 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);
  3541. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3542. }
  3543. else
  3544. {
  3545. StringBuilder sql2 = new StringBuilder();
  3546. 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);
  3547. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3548. }
  3549. }
  3550. returnSuccessMsg("操作成功!");
  3551. return;
  3552. }
  3553. returnErrorMsg("找不到订单记录");
  3554. }
  3555. }
  3556. public void cyt_erp_returnreason()
  3557. {
  3558. if (UrlPostParmsCheck("ctid"))
  3559. {
  3560. string eid = GetPostString("ctid");
  3561. CeErpTradeCell entity = null;
  3562. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3563. string userpost = CurrentUser.UserPost.Post.Code;
  3564. if (entity != null)
  3565. {
  3566. if (entity.OrderState > 6)
  3567. {
  3568. returnErrorMsg("已发货无法打回!");
  3569. return;
  3570. }
  3571. JObject jsonObject = new JObject
  3572. {
  3573. { "Userid", "77886" },
  3574. { "Pwd", "lt666888" },
  3575. { "LTOrderId",eid }
  3576. };
  3577. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3578. JObject jsonObjects = JObject.Parse(response);
  3579. string msg = (string)jsonObjects["msg"];
  3580. if (msg != "取消成功")
  3581. {
  3582. returnErrorMsg(msg);
  3583. return;
  3584. }
  3585. bool isNeedUpdateCell2 = false;
  3586. if (entity.OrderState >= 6)
  3587. {
  3588. isNeedUpdateCell2 = true;
  3589. }
  3590. int returnTag = 2;
  3591. if (userpost == "Supplier")
  3592. {
  3593. returnTag = 1;
  3594. }
  3595. if (entity.IsXianHuo == 0)
  3596. {
  3597. if (returnTag == 2)
  3598. {
  3599. int toType = GetPostInt("totype");
  3600. if (toType == 1)
  3601. {
  3602. entity.OrderState = 0;
  3603. entity.ReturnUserType = 1;
  3604. }
  3605. else
  3606. {
  3607. entity.OrderState = 4;
  3608. entity.ReturnUserType = 2;
  3609. }
  3610. entity.IsReadTag = 1;
  3611. }
  3612. else if (returnTag == 1)
  3613. {
  3614. entity.OrderState = 5;
  3615. }
  3616. entity.IsVerifyToSupplier = false;
  3617. }
  3618. entity.UnusualTag = 0;
  3619. entity.UnusualTime = null;
  3620. entity.UnusualCon = "";
  3621. entity.IsReturn = returnTag;
  3622. entity.ReturnTime = DateTime.Now;
  3623. entity.ReturnReason = GetPostString("returnreason");
  3624. entity.Update();
  3625. if (entity.OrderState == 4)
  3626. {
  3627. ApiVo apiVo = new ApiVo();
  3628. apiVo.orderNumber = entity.ctid;
  3629. apiVo.actionName = "rebutDesign";
  3630. apiVo.orderRemarks = entity.ReturnReason;
  3631. designHelper.API_WorkCore(apiVo);//rebutDesign
  3632. }
  3633. CeErpSukuraData.createInfo(entity.ctid, 5);
  3634. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3635. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3636. if (isNeedUpdateCell2)
  3637. {
  3638. if (entity.MakeSupplier.IndexOf(",") != -1)
  3639. {
  3640. StringBuilder sql2 = new StringBuilder();
  3641. 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);
  3642. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3643. }
  3644. else
  3645. {
  3646. StringBuilder sql2 = new StringBuilder();
  3647. 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);
  3648. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3649. }
  3650. }
  3651. returnSuccessMsg("操作成功!");
  3652. return;
  3653. }
  3654. returnErrorMsg("找不到订单记录");
  3655. }
  3656. }
  3657. public void upd_erp_xianhuoreturntag()
  3658. {
  3659. if (UrlPostParmsCheck("ctid"))
  3660. {
  3661. string eids = GetPostString("ctid");
  3662. string[] ctids = eids.Split(',');
  3663. foreach (string ctid in ctids)
  3664. {
  3665. CeErpTradeCell entity = null;
  3666. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3667. if (entity != null)
  3668. {
  3669. entity.IsReturn = 0;
  3670. entity.Update();
  3671. CeErpSukuraData.createInfo(entity.ctid, 5);
  3672. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3673. }
  3674. }
  3675. returnSuccessMsg("操作成功!");
  3676. return;
  3677. }
  3678. }
  3679. public void get_erp_waitdeliverylist()
  3680. {
  3681. DataStruct dStruct = GetPostStruct();
  3682. List<string> lw = new List<string>();
  3683. string tid = GetPostString("ctid");
  3684. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3685. string shopname = GetPostString("shopname");
  3686. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3687. string buyernick = GetPostString("buyer_nick");
  3688. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3689. //if (tid.Length == 0 && buyernick.Length == 0)
  3690. //{
  3691. // lw.Add(string.Format("IsRefund<={0}", 1));
  3692. //}
  3693. string customer = GetPostString("customer");
  3694. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3695. string design = GetPostString("design");
  3696. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3697. string orderState = GetPostString("orderState");
  3698. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3699. string address = GetPostString("address");
  3700. 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));
  3701. string sellermemo = GetPostString("seller_memo");
  3702. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3703. string supplier = GetPostString("supplier");
  3704. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3705. string OrderArea = GetPostString("order_area");
  3706. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3707. string placedate1 = GetPostString("placedate1");
  3708. string placedate2 = GetPostString("placedate2");
  3709. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3710. if (fdw.Length > 0) lw.Add(fdw);
  3711. string price1 = GetPostString("price1");
  3712. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3713. string price2 = GetPostString("price2");
  3714. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3715. string unusualCon = GetPostString("unusualcon");
  3716. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3717. string otherMemo = GetPostString("otherMemo");
  3718. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3719. string posTag = CurrentUser.UserPost.Post.Code;
  3720. if (posTag == "Supplier")
  3721. {
  3722. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3723. }
  3724. lw.Add(string.Format("OrderState = 6 "));
  3725. lw.Add(string.Format("type != 'PDD' "));
  3726. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3727. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3728. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3729. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3730. writeGridDataTableJson(dStruct.TotalCount, dt);
  3731. }
  3732. public void get_erp_pddderiving()
  3733. {
  3734. DataStruct dStruct = GetPostStruct();
  3735. List<string> lw = new List<string>();
  3736. string tid = GetPostString("ctid");
  3737. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3738. string shopname = GetPostString("shopname");
  3739. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3740. string buyernick = GetPostString("buyer_nick");
  3741. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3742. //if (tid.Length == 0 && buyernick.Length == 0)
  3743. //{
  3744. // lw.Add(string.Format("IsRefund<={0}", 1));
  3745. //}
  3746. string customer = GetPostString("customer");
  3747. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3748. string design = GetPostString("design");
  3749. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3750. string orderState = GetPostString("orderState");
  3751. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3752. string address = GetPostString("address");
  3753. 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));
  3754. string sellermemo = GetPostString("seller_memo");
  3755. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3756. string supplier = GetPostString("supplier");
  3757. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3758. string OrderArea = GetPostString("order_area");
  3759. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3760. string placedate1 = GetPostString("placedate1");
  3761. string placedate2 = GetPostString("placedate2");
  3762. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3763. if (fdw.Length > 0) lw.Add(fdw);
  3764. string price1 = GetPostString("price1");
  3765. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3766. string price2 = GetPostString("price2");
  3767. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3768. string unusualCon = GetPostString("unusualcon");
  3769. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3770. string posTag = CurrentUser.UserPost.Post.Code;
  3771. if (posTag == "Supplier")
  3772. {
  3773. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3774. }
  3775. lw.Add(string.Format("OrderState = 6 "));
  3776. lw.Add(string.Format("type = 'PDD' "));
  3777. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3778. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3779. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3780. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3781. writeGridDataTableJson(dStruct.TotalCount, dt);
  3782. }
  3783. public void get_erp_jdderiving()
  3784. {
  3785. DataStruct dStruct = GetPostStruct();
  3786. List<string> lw = new List<string>();
  3787. string tid = GetPostString("ctid");
  3788. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3789. string shopname = GetPostString("shopname");
  3790. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3791. string buyernick = GetPostString("buyer_nick");
  3792. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3793. //if (tid.Length == 0 && buyernick.Length == 0)
  3794. //{
  3795. // lw.Add(string.Format("IsRefund<={0}", 1));
  3796. //}
  3797. string customer = GetPostString("customer");
  3798. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3799. string design = GetPostString("design");
  3800. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3801. string orderState = GetPostString("orderState");
  3802. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3803. string address = GetPostString("address");
  3804. 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));
  3805. string sellermemo = GetPostString("seller_memo");
  3806. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3807. string supplier = GetPostString("supplier");
  3808. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3809. string OrderArea = GetPostString("order_area");
  3810. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3811. string placedate1 = GetPostString("placedate1");
  3812. string placedate2 = GetPostString("placedate2");
  3813. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3814. if (fdw.Length > 0) lw.Add(fdw);
  3815. string price1 = GetPostString("price1");
  3816. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3817. string price2 = GetPostString("price2");
  3818. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3819. string unusualCon = GetPostString("unusualcon");
  3820. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3821. string posTag = CurrentUser.UserPost.Post.Code;
  3822. if (posTag == "Supplier")
  3823. {
  3824. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3825. }
  3826. lw.Add(string.Format("OrderState = 6 "));
  3827. lw.Add(string.Format("type = 'JD' "));
  3828. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3829. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3830. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3831. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3832. writeGridDataTableJson(dStruct.TotalCount, dt);
  3833. }
  3834. public void get_erp_demoorderlist()
  3835. {
  3836. DataStruct dStruct = GetPostStruct();
  3837. List<string> lw = new List<string>();
  3838. string tid = GetPostString("ctid");
  3839. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  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. string customer = GetPostString("customer");
  3845. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3846. string design = GetPostString("design");
  3847. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3848. string orderState = GetPostString("orderState");
  3849. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3850. string address = GetPostString("address");
  3851. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3852. string sellermemo = GetPostString("seller_memo");
  3853. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3854. string supplier = GetPostString("supplier");
  3855. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3856. string OrderArea = GetPostString("order_area");
  3857. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3858. string date1 = GetPostString("date1");
  3859. string date2 = GetPostString("date2");
  3860. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3861. if (dw.Length > 0) lw.Add(dw);
  3862. string price1 = GetPostString("price1");
  3863. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3864. string price2 = GetPostString("price2");
  3865. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3866. string posTag = CurrentUser.UserPost.Post.Code;
  3867. if (posTag == "Supplier")
  3868. {
  3869. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3870. }
  3871. //lw.Add(string.Format("OrderState = 6 "));
  3872. lw.Add(string.Format("IsSample={0}", 3));
  3873. lw.Add(string.Format("IsRefund<={0}", 1));
  3874. dStruct.Order = "pay_time desc";
  3875. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3876. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3877. writeGridDataTableJson(dStruct.TotalCount, dt);
  3878. }
  3879. public void save_erp_checkmemo()
  3880. {
  3881. if (UrlPostParmsCheck("ctid"))
  3882. {
  3883. string ctid = GetPostString("ctid");
  3884. CeErpTradeCell entity = null;
  3885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3886. if (entity != null)
  3887. {
  3888. entity.CheckMemo = GetPostString("CheckMemo");
  3889. entity.Update();
  3890. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3891. if (trade != null)
  3892. {
  3893. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3894. }
  3895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3896. returnSuccessMsg("保存成功!");
  3897. return;
  3898. }
  3899. returnErrorMsg("找不到记录");
  3900. }
  3901. }
  3902. public void get_erp_returnlist()
  3903. {
  3904. DataStruct dStruct = GetPostStruct();
  3905. List<string> lw = new List<string>();
  3906. string tid = GetPostString("ctid");
  3907. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3908. string shopname = GetPostString("shopname");
  3909. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3910. string buyernick = GetPostString("buyer_nick");
  3911. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3912. string customer = GetPostString("customer");
  3913. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3914. string design = GetPostString("design");
  3915. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3916. string orderState = GetPostString("orderState");
  3917. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3918. string address = GetPostString("address");
  3919. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3920. string sellermemo = GetPostString("seller_memo");
  3921. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3922. string supplier = GetPostString("supplier");
  3923. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3924. string date1 = GetPostString("date1");
  3925. string date2 = GetPostString("date2");
  3926. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3927. if (dw.Length > 0) lw.Add(dw);
  3928. string bdate1 = GetPostString("backdate1");
  3929. string bdate2 = GetPostString("backdate2");
  3930. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3931. if (dw_back.Length > 0) lw.Add(dw_back);
  3932. string price1 = GetPostString("price1");
  3933. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3934. string price2 = GetPostString("price2");
  3935. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3936. lw.Add(string.Format("IsReturn>0"));
  3937. lw.Add(string.Format("IsXianHuo=0"));
  3938. lw.Add(string.Format("IsReturn!=3"));
  3939. string backtype = GetPostString("backtype");
  3940. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3941. dStruct.Order = "FinishDesignTime desc";
  3942. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3943. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3944. writeGridDataTableJson(dStruct.TotalCount, dt);
  3945. }
  3946. public void get_erp_today_sumreturn()
  3947. {
  3948. DataStruct dStruct = GetPostStruct();
  3949. List<string> lw = new List<string>();
  3950. string bdate1 = GetPostString("returnTimeS");
  3951. string bdate2 = GetPostString("returnTimeE");
  3952. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3953. if (dw_back.Length > 0) lw.Add(dw_back);
  3954. lw.Add(string.Format("IsReturn=0"));
  3955. lw.Add(string.Format("IsXianHuo=0"));
  3956. string mainWhere = string.Join(" and ", lw.ToArray());
  3957. string sql = "";
  3958. if (dw_back.Length > 0)
  3959. {
  3960. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  3961. }
  3962. else
  3963. {
  3964. 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 + "'";
  3965. }
  3966. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3967. decimal total = 0, today_finish = 0;
  3968. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  3969. {
  3970. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  3971. }
  3972. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  3973. {
  3974. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  3975. }
  3976. var res = new
  3977. {
  3978. data = total,
  3979. data1 = today_finish,
  3980. };
  3981. string ro_jsond = JsonConvert.SerializeObject(res);
  3982. returnSuccess(ro_jsond);
  3983. return;
  3984. }
  3985. public void get_erp_allreturnlist()
  3986. {
  3987. DataStruct dStruct = GetPostStruct();
  3988. List<string> lw = new List<string>();
  3989. string tid = GetPostString("ctid");
  3990. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3991. string shopname = GetPostString("shopname");
  3992. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3993. string buyernick = GetPostString("buyer_nick");
  3994. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  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("address 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 date1 = GetPostString("date1");
  4008. string date2 = GetPostString("date2");
  4009. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4010. if (dw.Length > 0) lw.Add(dw);
  4011. string bdate1 = GetPostString("backdate1");
  4012. string bdate2 = GetPostString("backdate2");
  4013. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4014. if (dw_back.Length > 0) lw.Add(dw_back);
  4015. string price1 = GetPostString("price1");
  4016. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4017. string price2 = GetPostString("price2");
  4018. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4019. string backreason = GetPostString("backreason");
  4020. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4021. lw.Add(string.Format("IsXianHuo=0"));
  4022. lw.Add(string.Format("ReturnTime != ''"));
  4023. string backtype = GetPostString("backtype");
  4024. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4025. dStruct.Order = "FinishDesignTime desc";
  4026. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4027. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4028. writeGridDataTableJson(dStruct.TotalCount, dt);
  4029. }
  4030. public void get_erp_aftersalereturnlist()
  4031. {
  4032. DataStruct dStruct = GetPostStruct();
  4033. List<string> lw = new List<string>();
  4034. string tid = GetPostString("ctid");
  4035. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4036. string shopname = GetPostString("shopname");
  4037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4038. string buyernick = GetPostString("buyer_nick");
  4039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4040. string customer = GetPostString("customer");
  4041. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4042. string design = GetPostString("design");
  4043. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4044. string orderState = GetPostString("orderState");
  4045. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4046. string address = GetPostString("address");
  4047. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4048. string sellermemo = GetPostString("seller_memo");
  4049. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4050. string supplier = GetPostString("supplier");
  4051. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4052. string date1 = GetPostString("date1");
  4053. string date2 = GetPostString("date2");
  4054. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4055. if (dw.Length > 0) lw.Add(dw);
  4056. string bdate1 = GetPostString("backdate1");
  4057. string bdate2 = GetPostString("backdate2");
  4058. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4059. if (dw_back.Length > 0) lw.Add(dw_back);
  4060. string price1 = GetPostString("price1");
  4061. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4062. string price2 = GetPostString("price2");
  4063. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4064. lw.Add(string.Format("IsReturn=3"));
  4065. string backtype = GetPostString("backtype");
  4066. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4067. string backreason = GetPostString("backreason");
  4068. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4069. dStruct.Order = "ReturnTime desc";
  4070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4071. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4072. writeGridDataTableJson(dStruct.TotalCount, dt);
  4073. }
  4074. public void get_erp_xianhuoreturnlist()
  4075. {
  4076. DataStruct dStruct = GetPostStruct();
  4077. List<string> lw = new List<string>();
  4078. string tid = GetPostString("ctid");
  4079. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4080. string shopname = GetPostString("shopname");
  4081. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4082. string buyernick = GetPostString("buyer_nick");
  4083. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4084. string customer = GetPostString("customer");
  4085. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4086. string design = GetPostString("design");
  4087. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4088. string orderState = GetPostString("orderState");
  4089. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4090. string address = GetPostString("address");
  4091. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4092. string sellermemo = GetPostString("seller_memo");
  4093. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4094. string supplier = GetPostString("supplier");
  4095. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4096. string OrderArea = GetPostString("order_area");
  4097. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4098. string date1 = GetPostString("date1");
  4099. string date2 = GetPostString("date2");
  4100. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4101. if (dw.Length > 0) lw.Add(dw);
  4102. string price1 = GetPostString("price1");
  4103. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4104. string price2 = GetPostString("price2");
  4105. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4106. string posTag = CurrentUser.UserPost.Post.Code;
  4107. if (posTag == "Supplier")
  4108. {
  4109. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4110. }
  4111. lw.Add(string.Format("OrderState=6 "));
  4112. lw.Add(string.Format("IsXianHuo=1 "));
  4113. lw.Add(string.Format("IsReturn>0 "));
  4114. lw.Add(string.Format("IsReturn!=3"));
  4115. lw.Add(string.Format("IsRefund<={0}", 1));
  4116. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4117. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4118. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4119. writeGridDataTableJson(dStruct.TotalCount, dt);
  4120. }
  4121. public void set_erp_orderdelivery()
  4122. {
  4123. if (UrlPostParmsCheck("ctid"))
  4124. {
  4125. string eid = GetPostString("ctid");
  4126. CeErpTradeCell entity = null;
  4127. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4128. if (entity != null)
  4129. {
  4130. if (entity.OrderState >= 7)
  4131. {
  4132. returnErrorMsg("此单已发货,无需重复发货");
  4133. return;
  4134. }
  4135. if (entity.OrderState != 6)
  4136. {
  4137. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4138. return;
  4139. }
  4140. string shop = GetPostString("seller_nick");
  4141. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4142. string comName = GetPostString("comName");
  4143. string comCode = GetPostString("comCode");
  4144. string outSid = GetPostString("outSid");
  4145. string deliveryType = GetPostString("deliveryType");
  4146. string deliveryMemo = GetPostString("deliveryMemo");
  4147. outSid = outSid.Trim();
  4148. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4149. if (mainEn == null)
  4150. {
  4151. returnErrorMsg("找不到原始订单记录");
  4152. return;
  4153. }
  4154. bool isInitOrderDeliv = false;
  4155. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4156. {
  4157. isInitOrderDeliv = true;
  4158. }
  4159. string apires = "";
  4160. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4161. 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)
  4162. {
  4163. apires = "发货成功true";
  4164. }
  4165. else
  4166. {
  4167. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4168. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4169. }
  4170. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4171. {
  4172. entity.OrderState = 7;//发货后订单已发货
  4173. entity.OutSid = outSid;
  4174. entity.MemoOpt = 0;
  4175. entity.Update();
  4176. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4177. commonHelper.UpdateRelationOrder(entity.ctid);
  4178. //还要插入快递信息到 快递信息表
  4179. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4180. exinfo.tid = eid;
  4181. exinfo.out_sid = outSid;
  4182. exinfo.company_code = comCode;
  4183. exinfo.company_name = comName;
  4184. exinfo.delivery_memo = deliveryMemo;
  4185. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4186. exinfo.deliveryType = deliveryType;
  4187. exinfo.Create();
  4188. returnSuccessMsg("发货操作成功!");
  4189. commonHelper.UpdateRelationOrder(entity.ctid);
  4190. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4191. CeErpSukuraData.createInfo(entity.ctid, 4);
  4192. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4194. }
  4195. else
  4196. {
  4197. string errmsg = commonHelper.KeepChinese(apires);
  4198. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4199. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4200. }
  4201. return;
  4202. }
  4203. returnErrorMsg("找不到订单记录");
  4204. }
  4205. }
  4206. public void set_erp_multidelivery()
  4207. {
  4208. string eids = GetPostString("tids");
  4209. string[] eidList = eids.Split(',');
  4210. if (eidList.Length <= 0)
  4211. {
  4212. returnErrorMsg("发货不能为空");
  4213. return;
  4214. }
  4215. foreach (string ctid in eidList)
  4216. {
  4217. if (ctid.Length <= 0) continue;
  4218. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4219. if (expInfo != null)
  4220. {
  4221. StringBuilder sql = new StringBuilder();
  4222. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4223. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4224. if (dt.Rows.Count > 0)
  4225. {
  4226. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4227. {
  4228. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4229. expInfo.state = "异常";
  4230. expInfo.isMultiDelivery = 1;
  4231. expInfo.Update();
  4232. continue;
  4233. }
  4234. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4235. {
  4236. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4237. expInfo.state = "异常";
  4238. expInfo.Update();
  4239. continue;
  4240. }
  4241. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4242. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4243. bool isInitOrderDeliv = false;
  4244. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4245. {
  4246. isInitOrderDeliv = true;
  4247. expInfo.isMultiDelivery = 1;
  4248. }
  4249. if (ctid.IndexOf("N") != -1)
  4250. {
  4251. StringBuilder sqlbucha = new StringBuilder();
  4252. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4253. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4254. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4255. commonHelper.UpdateRelationOrder(ctid);
  4256. expInfo.delivery_memo = "发货成功";
  4257. expInfo.state = "发货成功";
  4258. expInfo.isMultiDelivery = 1;
  4259. expInfo.Update();
  4260. }
  4261. else
  4262. {
  4263. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4264. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4265. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4266. {
  4267. expInfo.delivery_memo = "发货成功";
  4268. expInfo.state = "发货成功";
  4269. expInfo.isMultiDelivery = 1;
  4270. expInfo.Update();
  4271. commonHelper.UpdateRelationOrder(ctid);
  4272. CeErpSukuraData.createInfo(ctid, 4);
  4273. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4274. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4275. }
  4276. else
  4277. {
  4278. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4279. expInfo.state = "异常";
  4280. expInfo.Update();
  4281. }
  4282. }
  4283. }
  4284. }
  4285. }
  4286. returnSuccessMsg("操作完成");
  4287. }
  4288. public void reset_erp_memoopt()
  4289. {
  4290. if (UrlPostParmsCheck("ctid"))
  4291. {
  4292. string eid = GetPostString("ctid");
  4293. CeErpTradeCell entity = null;
  4294. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4295. if (entity != null)
  4296. {
  4297. string stropt = "";
  4298. if (entity.MemoOpt == 1)
  4299. {
  4300. stropt = "“改稿”";
  4301. }
  4302. else if (entity.MemoOpt == 2)
  4303. {
  4304. stropt = "“定稿”";
  4305. }
  4306. else if (entity.MemoOpt == 3)
  4307. {
  4308. stropt = "“完成查货”";
  4309. CeErpSukuraData.createInfo(entity.ctid, 6);
  4310. }
  4311. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4312. entity.MemoOpt = 0;
  4313. entity.Update();
  4314. returnSuccessMsg("操作成功!");
  4315. return;
  4316. }
  4317. returnErrorMsg("找不到记录");
  4318. }
  4319. }
  4320. public void get_erp_deliveryunusual()
  4321. {
  4322. DataStruct dStruct = GetPostStruct();
  4323. List<string> lw = new List<string>();
  4324. string tid = GetPostString("ctid");
  4325. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4326. string shopname = GetPostString("shopname");
  4327. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4328. string buyernick = GetPostString("buyer_nick");
  4329. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4330. string customer = GetPostString("customer");
  4331. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4332. string design = GetPostString("design");
  4333. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4334. string sellermemo = GetPostString("seller_memo");
  4335. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4336. string supplier = GetPostString("supplier");
  4337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4338. string date1 = GetPostString("date1");
  4339. string date2 = GetPostString("date2");
  4340. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4341. if (dw.Length > 0) lw.Add(dw);
  4342. string placedate1 = GetPostString("placedate1");
  4343. string placedate2 = GetPostString("placedate2");
  4344. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4345. if (dw_place.Length > 0) lw.Add(dw_place);
  4346. string price1 = GetPostString("price1");
  4347. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4348. string price2 = GetPostString("price2");
  4349. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4350. string unusualCon = GetPostString("unusualcon");
  4351. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4352. string posTag = CurrentUser.UserPost.Post.Code;
  4353. if (posTag == "Supplier")
  4354. {
  4355. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4356. }
  4357. lw.Add(string.Format("OrderState = 6"));
  4358. lw.Add(string.Format("UnusualTag = 5"));
  4359. lw.Add(string.Format("IsRefund<={0}", 1));
  4360. dStruct.Order = "FinishPlaceTime desc";
  4361. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4362. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4363. writeGridDataTableJson(dStruct.TotalCount, dt);
  4364. }
  4365. public void get_erp_deliveryedlist()
  4366. {
  4367. DataStruct dStruct = GetPostStruct();
  4368. List<string> lw = new List<string>();
  4369. string tid = GetPostString("ctid");
  4370. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4371. string shopname = GetPostString("shopname");
  4372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4373. string buyernick = GetPostString("buyer_nick");
  4374. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4375. string customer = GetPostString("customer");
  4376. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4377. string design = GetPostString("design");
  4378. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4379. string sellermemo = GetPostString("seller_memo");
  4380. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4381. string logistics = GetPostString("logistics");
  4382. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4383. string date1 = GetPostString("date1");
  4384. string date2 = GetPostString("date2");
  4385. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4386. //if (dw.Length > 0) lw.Add(dw);
  4387. string placedate1 = GetPostString("placedate1");
  4388. string placedate2 = GetPostString("placedate2");
  4389. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4390. if (fdw.Length > 0) lw.Add(fdw);
  4391. string devdate1 = GetPostString("deliverydate1");
  4392. string devdate2 = GetPostString("deliverydate2");
  4393. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4394. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4395. string price1 = GetPostString("price1");
  4396. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4397. string price2 = GetPostString("price2");
  4398. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4399. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4400. {
  4401. if (tid.Length > 0)
  4402. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4403. if (buyernick.Length > 0)
  4404. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4405. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4406. if (dw.Length > 0) lw.Add(dw);
  4407. }
  4408. else
  4409. {
  4410. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4411. }
  4412. string posTag = CurrentUser.UserPost.Post.Code;
  4413. if (posTag == "Supplier")
  4414. {
  4415. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4416. }
  4417. else
  4418. {
  4419. string supplier = GetPostString("supplier");
  4420. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4421. }
  4422. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4423. lw.Add(string.Format("IsRefund!={0}", 2));
  4424. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4425. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4426. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4427. if (dt != null)
  4428. {
  4429. foreach (DataRow dr in dt.Rows)
  4430. {
  4431. 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();
  4432. }
  4433. }
  4434. writeGridDataTableJson(dStruct.TotalCount, dt);
  4435. }
  4436. public void get_erp_pdddeliveryed()
  4437. {
  4438. DataStruct dStruct = GetPostStruct();
  4439. List<string> lw = new List<string>();
  4440. string tid = GetPostString("ctid");
  4441. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4442. string shopname = GetPostString("shopname");
  4443. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4444. string buyernick = GetPostString("buyer_nick");
  4445. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4446. string customer = GetPostString("customer");
  4447. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4448. string design = GetPostString("design");
  4449. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4450. string sellermemo = GetPostString("seller_memo");
  4451. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4452. string logistics = GetPostString("logistics");
  4453. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4454. string date1 = GetPostString("date1");
  4455. string date2 = GetPostString("date2");
  4456. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4457. //if (dw.Length > 0) lw.Add(dw);
  4458. string placedate1 = GetPostString("placedate1");
  4459. string placedate2 = GetPostString("placedate2");
  4460. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4461. if (fdw.Length > 0) lw.Add(fdw);
  4462. string devdate1 = GetPostString("deliverydate1");
  4463. string devdate2 = GetPostString("deliverydate2");
  4464. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4465. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4466. string price1 = GetPostString("price1");
  4467. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4468. string price2 = GetPostString("price2");
  4469. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4470. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4471. {
  4472. if (tid.Length > 0)
  4473. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4474. if (buyernick.Length > 0)
  4475. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4476. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4477. if (dw.Length > 0) lw.Add(dw);
  4478. }
  4479. else
  4480. {
  4481. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4482. }
  4483. string posTag = CurrentUser.UserPost.Post.Code;
  4484. if (posTag == "Supplier")
  4485. {
  4486. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4487. }
  4488. else
  4489. {
  4490. string supplier = GetPostString("supplier");
  4491. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4492. }
  4493. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4494. lw.Add(string.Format("type = 'PDD' "));
  4495. lw.Add(string.Format("IsRefund!={0}", 2));
  4496. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4497. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4498. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4499. foreach (DataRow dr in dt.Rows)
  4500. {
  4501. 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();
  4502. }
  4503. writeGridDataTableJson(dStruct.TotalCount, dt);
  4504. }
  4505. public void get_erp_jddeliveryed()
  4506. {
  4507. DataStruct dStruct = GetPostStruct();
  4508. List<string> lw = new List<string>();
  4509. string tid = GetPostString("ctid");
  4510. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4511. string shopname = GetPostString("shopname");
  4512. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4513. string buyernick = GetPostString("buyer_nick");
  4514. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4515. string customer = GetPostString("customer");
  4516. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4517. string design = GetPostString("design");
  4518. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4519. string sellermemo = GetPostString("seller_memo");
  4520. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4521. string date1 = GetPostString("date1");
  4522. string date2 = GetPostString("date2");
  4523. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4524. //if (dw.Length > 0) lw.Add(dw);
  4525. string placedate1 = GetPostString("placedate1");
  4526. string placedate2 = GetPostString("placedate2");
  4527. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4528. if (fdw.Length > 0) lw.Add(fdw);
  4529. string devdate1 = GetPostString("deliverydate1");
  4530. string devdate2 = GetPostString("deliverydate2");
  4531. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4532. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4533. string price1 = GetPostString("price1");
  4534. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4535. string price2 = GetPostString("price2");
  4536. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4537. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4538. {
  4539. if (tid.Length > 0)
  4540. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4541. if (buyernick.Length > 0)
  4542. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4543. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4544. if (dw.Length > 0) lw.Add(dw);
  4545. }
  4546. else
  4547. {
  4548. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4549. }
  4550. string posTag = CurrentUser.UserPost.Post.Code;
  4551. if (posTag == "Supplier")
  4552. {
  4553. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4554. }
  4555. else
  4556. {
  4557. string supplier = GetPostString("supplier");
  4558. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4559. }
  4560. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4561. lw.Add(string.Format("type = 'JD' "));
  4562. lw.Add(string.Format("IsRefund!={0}", 2));
  4563. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4564. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4565. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4566. foreach (DataRow dr in dt.Rows)
  4567. {
  4568. 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();
  4569. }
  4570. writeGridDataTableJson(dStruct.TotalCount, dt);
  4571. }
  4572. public void get_erp_allplacelist()
  4573. {
  4574. DataStruct dStruct = GetPostStruct();
  4575. List<string> lw = new List<string>();
  4576. string tid = GetPostString("ctid");
  4577. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4578. string shopname = GetPostString("shopname");
  4579. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4580. string buyernick = GetPostString("buyer_nick");
  4581. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4582. string customer = GetPostString("customer");
  4583. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4584. string design = GetPostString("design");
  4585. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4586. string sellermemo = GetPostString("seller_memo");
  4587. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4588. string supplier = GetPostString("supplier");
  4589. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4590. string date1 = GetPostString("date1");
  4591. string date2 = GetPostString("date2");
  4592. string pldate1 = GetPostString("placedate1");
  4593. string pldate2 = GetPostString("placedate2");
  4594. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4595. //if (dw.Length > 0) lw.Add(dw);
  4596. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4597. {
  4598. if (tid.Length > 0)
  4599. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4600. if (buyernick.Length > 0)
  4601. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4602. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4603. if (dw.Length > 0) lw.Add(dw);
  4604. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4605. if (dw_place.Length > 0) lw.Add(dw_place);
  4606. }
  4607. else
  4608. {
  4609. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4610. {
  4611. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4612. }
  4613. }
  4614. string price1 = GetPostString("price1");
  4615. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4616. string price2 = GetPostString("price2");
  4617. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4618. string posTag = CurrentUser.UserPost.Post.Code;
  4619. if (posTag == "Supplier")
  4620. {
  4621. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4622. }
  4623. lw.Add(string.Format("OrderState >= 6"));
  4624. lw.Add(string.Format("IsSample != 2 "));
  4625. lw.Add(string.Format("isDianziOrder = 0 "));
  4626. //lw.Add(string.Format("IsRefund<={0}", 1));
  4627. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4628. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4629. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4630. foreach (DataRow dr in dt.Rows)
  4631. {
  4632. 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();
  4633. }
  4634. writeGridDataTableJson(dStruct.TotalCount, dt);
  4635. }
  4636. public void get_erp_financeallplacelist()
  4637. {
  4638. DataStruct dStruct = GetPostStruct();
  4639. List<string> lw = new List<string>();
  4640. string tid = GetPostString("ctid");
  4641. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4642. string shopname = GetPostString("shopname");
  4643. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4644. string buyernick = GetPostString("buyer_nick");
  4645. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4646. string customer = GetPostString("customer");
  4647. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4648. string design = GetPostString("design");
  4649. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4650. string sellermemo = GetPostString("seller_memo");
  4651. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4652. string supplier = GetPostString("supplier");
  4653. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4654. string date1 = GetPostString("date1");
  4655. string date2 = GetPostString("date2");
  4656. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4657. if (dw.Length > 0) lw.Add(dw);
  4658. string pldate1 = GetPostString("placedate1");
  4659. string pldate2 = GetPostString("placedate2");
  4660. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4661. if (dw_place.Length > 0) lw.Add(dw_place);
  4662. string price1 = GetPostString("price1");
  4663. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4664. string price2 = GetPostString("price2");
  4665. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4666. string posTag = CurrentUser.UserPost.Post.Code;
  4667. if (posTag == "Supplier")
  4668. {
  4669. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4670. }
  4671. //lw.Add(string.Format("OrderState >= 6"));
  4672. lw.Add(string.Format("IsSample != 2 "));
  4673. lw.Add(string.Format("isDianziOrder = 0 "));
  4674. //lw.Add(string.Format("IsRefund<={0}", 1));
  4675. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4676. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4677. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4678. foreach (DataRow dr in dt.Rows)
  4679. {
  4680. 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();
  4681. }
  4682. writeGridDataTableJson(dStruct.TotalCount, dt);
  4683. }
  4684. public void get_erp_expresslist()
  4685. {
  4686. int listtype = GetInt("ltype");
  4687. DataStruct dStruct = GetPostStruct();
  4688. List<string> lw = new List<string>();
  4689. string tid = GetPostString("tid");
  4690. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4691. string outsid = GetPostString("out_sid");
  4692. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4693. string importer = GetPostString("ImportUserName");
  4694. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4695. string file = GetPostString("import_file");
  4696. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4697. string printman = GetPostString("printman");
  4698. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4699. string date1 = GetPostString("date1");
  4700. string date2 = GetPostString("date2");
  4701. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4702. if (dw.Length > 0) lw.Add(dw);
  4703. string fdate1 = GetPostString("finishdate1");
  4704. string fdate2 = GetPostString("finishdate2");
  4705. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4706. if (fdw.Length > 0) lw.Add(fdw);
  4707. if (listtype == 1)
  4708. {
  4709. lw.Add(string.Format("importUserId !=0"));
  4710. }
  4711. string posTag = CurrentUser.UserPost.Post.Code;
  4712. if (posTag == "Supplier")
  4713. {
  4714. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4715. }
  4716. if (dStruct.PageSize != 100000)
  4717. {
  4718. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4719. }
  4720. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4721. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4722. writeGridDataTableJson(dStruct.TotalCount, dt);
  4723. }
  4724. public void set_erp_buchaorderdelivery()
  4725. {
  4726. if (UrlPostParmsCheck("ctid"))
  4727. {
  4728. string eid = GetPostString("ctid");
  4729. CeErpTradeCell entity = null;
  4730. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4731. if (entity != null)
  4732. {
  4733. if (entity.IsSample != 2)
  4734. {
  4735. returnErrorMsg("补差价单才能标记为已发货");
  4736. return;
  4737. }
  4738. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4739. entity.OrderState = 7;
  4740. entity.Update();
  4741. returnSuccessMsg("操作成功!");
  4742. return;
  4743. }
  4744. returnErrorMsg("找不到记录");
  4745. }
  4746. }
  4747. public void get_stdtemplates()
  4748. {
  4749. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4750. //string res = taobaoHelper.test();
  4751. string res = apiHelper.API_PrintTemplate();
  4752. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4753. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4754. {
  4755. int sidx = res.IndexOf("error_code");
  4756. int eidx = res.IndexOf("success");
  4757. string msg = res.Substring(sidx, eidx - sidx);
  4758. returnErrorMsg(msg);
  4759. return;
  4760. }
  4761. if (res.Length <= 0)
  4762. {
  4763. returnErrorMsg("模板数据为空!");
  4764. return;
  4765. }
  4766. ReturnSuccess(res);
  4767. }
  4768. public void cancel_print_order()
  4769. {
  4770. if (UrlPostParmsCheck("ctid"))
  4771. {
  4772. string ctid = GetPostString("ctid");
  4773. CeErpTradeCell entity = null;
  4774. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4775. if (entity != null)
  4776. {
  4777. string res = "";
  4778. string code = entity.LastBillWaybillCode;
  4779. if (code == "")
  4780. {
  4781. code = entity.OutSid;
  4782. }
  4783. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4784. XLog.SaveLog(0, "取消面单" + res);
  4785. }
  4786. }
  4787. }
  4788. public void set_erp_printwaybill()
  4789. {
  4790. if (UrlPostParmsCheck("ctid"))
  4791. {
  4792. string ctid = GetPostString("ctid");
  4793. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4794. string cpName = GetPostString("cpname");
  4795. string isTogether = GetPostString("together");
  4796. //var res_obj = new
  4797. //{
  4798. // restype = 1,
  4799. // 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\"}"
  4800. //};
  4801. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4802. //ReturnSuccess(ro_json);
  4803. //return;
  4804. bool isUseLastWayBillCode = false;
  4805. CeErpTradeCell entity = null;
  4806. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4807. if (entity != null)
  4808. {
  4809. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4810. {
  4811. isUseLastWayBillCode = true;
  4812. }
  4813. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4814. {
  4815. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4816. return;
  4817. }
  4818. }
  4819. string res = "";
  4820. Api_waybill_code_response_Obj fullObj = null;
  4821. string pData_str = "";
  4822. string curUseWayBillCode = "";
  4823. if (isUseLastWayBillCode == false)
  4824. {
  4825. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4826. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4827. if (res.IndexOf("failure") != -1)
  4828. {
  4829. //int idx = res.IndexOf("sub_message");
  4830. //int idx2 = res.IndexOf("flag");
  4831. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4832. string errMsgNeed = commonHelper.KeepChinese(res);
  4833. var res_objd = new
  4834. {
  4835. restype = 0,
  4836. data = "获取面单失败" + errMsgNeed
  4837. };
  4838. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4839. returnSuccess(ro_jsond);
  4840. if (res.IndexOf("停发") != -1)
  4841. {
  4842. entity.UnusualCon = "物流停发";
  4843. entity.Update();
  4844. }
  4845. //returnErrorMsg("获取面单失败,"+emsg);
  4846. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4847. return;
  4848. }
  4849. else if (res.IndexOf("errorMsg") != -1)
  4850. {
  4851. //int idx = res.IndexOf("errorMsg");
  4852. //int idx2 = res.IndexOf("}]}");
  4853. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4854. string errMsgNeed = commonHelper.KeepChinese(res);
  4855. var res_objf = new
  4856. {
  4857. restype = 0,
  4858. data = "获取面单失败2" + errMsgNeed
  4859. };
  4860. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4861. if (res.IndexOf("停发") != -1)
  4862. {
  4863. entity.UnusualCon = "物流停发";
  4864. entity.Update();
  4865. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4866. if (trade != null)
  4867. {
  4868. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4869. }
  4870. }
  4871. returnSuccess(ro_jsonf);
  4872. //returnErrorMsg("获取面单失败," + emsg);
  4873. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4874. return;
  4875. }
  4876. try
  4877. {
  4878. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4879. //res = res.Replace(" ", "");
  4880. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4881. }
  4882. catch (Exception ex)
  4883. {
  4884. XLog.SaveLog(0, "生成fullObj" + res);
  4885. var res_objf = new
  4886. {
  4887. restype = 0,
  4888. data = "生成fullObj发生错误" + ex.Message
  4889. };
  4890. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4891. returnSuccess(ro_jsonf);
  4892. return;
  4893. }
  4894. if (fullObj.response.data.content.Count > 0)
  4895. {
  4896. ContentItem codeObj = fullObj.response.data.content[0];
  4897. if (cpCode.IndexOf("SFFQ-") != -1)
  4898. {
  4899. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4900. }
  4901. else
  4902. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4903. curUseWayBillCode = codeObj.waybillCode;
  4904. }
  4905. else
  4906. {
  4907. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4908. var res_objf = new
  4909. {
  4910. restype = 0,
  4911. data = "生成fullObj找不到快递单号waybillCode"
  4912. };
  4913. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4914. returnSuccess(ro_jsonf);
  4915. return;
  4916. }
  4917. }
  4918. else
  4919. {
  4920. //使用上次打印的快递单号
  4921. if (cpCode == "SFFQ-LY")
  4922. {
  4923. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4924. }
  4925. else
  4926. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4927. curUseWayBillCode = entity.LastBillWaybillCode;
  4928. }
  4929. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4930. {
  4931. var res_obje = new
  4932. {
  4933. restype = 0,
  4934. data = "获取加密打印数据失败"
  4935. };
  4936. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4937. returnSuccess(ro_jsone);
  4938. entity.LastBillCpCode = cpCode;
  4939. entity.LastBillWaybillCode = curUseWayBillCode;
  4940. entity.Update();
  4941. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  4942. //returnErrorMsg("获取加密打印数据失败");
  4943. return;
  4944. }
  4945. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  4946. //string msg = "{\"data\":\""+pageUrl+"\"}";
  4947. string btnType = "";
  4948. if (entity != null)
  4949. {
  4950. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4951. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4952. //cpcode是 YTO-CAINIAO
  4953. //string comCode = cpCode.Split('-')[0].ToString();
  4954. string apires = "";
  4955. if (ctid.IndexOf("N") != -1)
  4956. {
  4957. apires = "发货成功";
  4958. }
  4959. else
  4960. {
  4961. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4962. }
  4963. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  4964. //打单后发货
  4965. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  4966. {
  4967. try
  4968. {
  4969. btnType = "待发货";
  4970. entity.OutSid = curUseWayBillCode;
  4971. entity.OrderState = 7;
  4972. entity.IsUrgency = false;
  4973. entity.LastBillCpCode = "";
  4974. entity.LastBillWaybillCode = "";
  4975. entity.FinishDeliveryTime = DateTime.Now;
  4976. entity.IsReturn = 0;
  4977. entity.MemoOpt = 0;
  4978. entity.Update();
  4979. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  4980. //还要插入快递信息到 快递信息表
  4981. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4982. exinfo.tid = entity.ctid;
  4983. exinfo.out_sid = entity.OutSid;
  4984. exinfo.company_code = cpCode;
  4985. exinfo.company_name = cpName;
  4986. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4987. exinfo.deliveryType = "发货成功";
  4988. exinfo.print_time = DateTime.Now;
  4989. exinfo.printUser = CurrentUser.UserName;
  4990. exinfo.Create();
  4991. commonHelper.UpdateRelationOrder(entity.ctid);
  4992. CeErpSukuraData.createInfo(ctid, 4);
  4993. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4994. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  4995. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4996. if (isTogether == "1")
  4997. {
  4998. StringBuilder sqlsb = new StringBuilder();
  4999. 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);
  5000. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5001. }
  5002. }
  5003. catch (Exception ex)
  5004. {
  5005. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5006. }
  5007. }
  5008. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5009. {
  5010. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5011. if (entity.OrderState == 6)
  5012. {
  5013. entity.OrderState = 7;
  5014. }
  5015. entity.FinishDeliveryTime = DateTime.Now;
  5016. btnType = "已发货";
  5017. entity.Update();
  5018. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5019. exinfo.tid = entity.ctid;
  5020. exinfo.out_sid = entity.OutSid;
  5021. exinfo.company_code = cpCode;
  5022. exinfo.company_name = cpName;
  5023. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5024. exinfo.deliveryType = "发货成功";
  5025. exinfo.print_time = DateTime.Now;
  5026. exinfo.printUser = CurrentUser.UserName;
  5027. exinfo.Create();
  5028. commonHelper.UpdateRelationOrder(entity.ctid);
  5029. CeErpSukuraData.createInfo(entity.ctid, 4);
  5030. if (isTogether == "1")
  5031. {
  5032. StringBuilder sqlsb = new StringBuilder();
  5033. 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);
  5034. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5035. }
  5036. //不处理
  5037. }
  5038. else
  5039. {
  5040. entity.LastBillCpCode = cpCode;
  5041. entity.LastBillWaybillCode = curUseWayBillCode;
  5042. entity.Update();
  5043. string errmsg = commonHelper.KeepChinese(apires);
  5044. var res_objz = new
  5045. {
  5046. restype = 0,
  5047. data = "打单后发货失败"
  5048. };
  5049. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5050. returnSuccess(ro_jsonz);
  5051. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5052. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5053. return;
  5054. }
  5055. }
  5056. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5057. var res_obj = new
  5058. {
  5059. restype = 1,
  5060. data = pData_str
  5061. };
  5062. string ro_json = JsonConvert.SerializeObject(res_obj);
  5063. ReturnSuccess(ro_json);
  5064. return;
  5065. }
  5066. }
  5067. private string GetUTF8String(byte[] vs)
  5068. {
  5069. throw new NotImplementedException();
  5070. }
  5071. public void set_erp_printwaybill_cn()
  5072. {
  5073. if (UrlPostParmsCheck("ctid"))
  5074. {
  5075. string ctid = GetPostString("ctid");
  5076. string cpCode = GetPostString("cpcode");
  5077. string cpName = GetPostString("cpname");
  5078. string tempUrl = GetPostString("tempurl");
  5079. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5080. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5081. //string res = taobaoHelper.test();
  5082. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5083. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5084. {
  5085. int sidx = res.IndexOf("errorMsg");
  5086. int eidx = res.IndexOf("}");
  5087. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5088. var res_objzxx = new
  5089. {
  5090. restype = 0,
  5091. data = msg
  5092. };
  5093. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5094. returnSuccess(ro_jsonzxx);
  5095. //returnErrorMsg(msg);
  5096. return;
  5097. }
  5098. int idx = res.IndexOf("waybillCode");
  5099. int idx2 = res.IndexOf("printData");
  5100. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5101. string eid = GetPostString("ctid");
  5102. CeErpTradeCell entity = null;
  5103. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5104. if (entity != null)
  5105. {
  5106. string osid = entity.OutSid;
  5107. entity.OutSid = osid + "," + outsid;
  5108. entity.FinishDeliveryTime = DateTime.Now;
  5109. entity.OrderState = 7;
  5110. entity.IsReturn = 0;
  5111. entity.Update();
  5112. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5113. exinfo.tid = entity.ctid;
  5114. exinfo.out_sid = outsid;
  5115. exinfo.company_code = cpCode;
  5116. exinfo.company_name = cpName;
  5117. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5118. exinfo.deliveryType = "发货成功";
  5119. exinfo.print_time = DateTime.Now;
  5120. exinfo.printUser = CurrentUser.UserName;
  5121. exinfo.Create();
  5122. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5123. }
  5124. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5125. var res_objz = new
  5126. {
  5127. restype = 1,
  5128. data = res
  5129. };
  5130. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5131. returnSuccess(ro_jsonz);
  5132. //ReturnSuccess(res);
  5133. }
  5134. }
  5135. ////打单,打印面单 获取面单号
  5136. //public void set_erp_printwaybill()
  5137. //{
  5138. // if (UrlPostParmsCheck("ctid"))
  5139. // {
  5140. // string ctid = GetPostString("ctid");
  5141. // string cpCode = GetPostString("cpcode");
  5142. // string tempUrl = GetPostString("tempurl");
  5143. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5144. // //string res = taobaoHelper.test();
  5145. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5146. // if (res.IndexOf("error_response") != -1)
  5147. // {
  5148. // int sidx = res.IndexOf("sub_msg");
  5149. // int eidx = res.IndexOf("request_id");
  5150. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5151. // returnErrorMsg(msg);
  5152. // return;
  5153. // }
  5154. // int idx = res.IndexOf("waybill_code");
  5155. // int idx2 = res.IndexOf("}]}");
  5156. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5157. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5158. // ReturnSuccess(res);
  5159. // }
  5160. //}
  5161. public void cancel_erp_aftersale()
  5162. {
  5163. if (UrlPostParmsCheck("ctid"))
  5164. {
  5165. string eid = GetPostString("ctid");
  5166. CeErpTradeCell entity = null;
  5167. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5168. if (entity != null)
  5169. {
  5170. //有过处理的售后,取消也不能删除 售 字,保留
  5171. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5172. {
  5173. entity.AfterSaleState = 4;
  5174. }
  5175. else
  5176. entity.AfterSaleState = 0;
  5177. entity.Update();
  5178. returnSuccessMsg("操作成功!");
  5179. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5180. return;
  5181. }
  5182. returnErrorMsg("找不到订单记录");
  5183. }
  5184. }
  5185. public void get_erp_aftersalelist()
  5186. {
  5187. DataStruct dStruct = GetPostStruct();
  5188. List<string> lw = new List<string>();
  5189. int st = GetInt("st");
  5190. string tid = GetPostString("ctid");
  5191. if (st == 3)
  5192. {
  5193. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5194. }
  5195. else
  5196. {
  5197. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5198. }
  5199. string shopname = GetPostString("shopname");
  5200. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5201. string buyernick = GetPostString("buyer_nick");
  5202. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5203. string sellermemo = GetPostString("seller_memo");
  5204. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5205. string orderState = GetPostString("orderState");
  5206. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5207. string afterState = GetPostString("afterstate");
  5208. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5209. string date1 = GetPostString("date1");
  5210. string date2 = GetPostString("date2");
  5211. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5212. if (dw.Length > 0) lw.Add(dw);
  5213. string price1 = GetPostString("price1");
  5214. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5215. string price2 = GetPostString("price2");
  5216. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5217. //lw.Add(string.Format("IsRefund!={0}", 1));
  5218. string reason = GetPostString("reason");
  5219. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5220. string method = GetPostString("method");
  5221. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5222. string handler = GetPostString("handler");
  5223. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5224. string handledate1 = GetPostString("handledate1");
  5225. string handledate2 = GetPostString("handledate2");
  5226. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5227. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5228. string finish1 = GetPostString("finishdate1");
  5229. string finish2 = GetPostString("finishdate2");
  5230. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5231. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5232. string afterdate1 = GetPostString("afterdate1");
  5233. string afterdate2 = GetPostString("afterdate2");
  5234. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5235. if (afterDate.Length > 0) lw.Add(afterDate);
  5236. string supplier = GetPostString("supplier");
  5237. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5238. string responsible = GetPostString("responsibleman");
  5239. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5240. string customer = GetPostString("customer");
  5241. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5242. string design = GetPostString("design");
  5243. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5244. string afterMemoType = GetPostString("aftermemotype");
  5245. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5246. string posCode = CurrentUser.UserPost.Post.Code;
  5247. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5248. //{
  5249. // string vstate = GetPostString("vstate");
  5250. // if (vstate.Length > 0)
  5251. // {
  5252. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5253. // }
  5254. // if (posCode == "Supplier")
  5255. // {
  5256. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5257. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5258. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5259. // }
  5260. // else
  5261. // {
  5262. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5263. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5264. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5265. // {
  5266. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5267. // }
  5268. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5269. // {
  5270. // int orgid = CurrentUser.UserPost.OrgID;
  5271. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5272. // }
  5273. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5274. // {
  5275. // string shopid = CurrentUser.User.pemShop;
  5276. // lw.Add(string.Format("shopId in ({0})", shopid));
  5277. // }
  5278. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5279. // //{
  5280. // // int org_id = CurrentUser.UserPost.OrgID;
  5281. // // lw.Add(string.Format("OrgID={0}", org_id));
  5282. // //}
  5283. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5284. // }
  5285. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5286. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5287. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5288. //}
  5289. if (st == 5)
  5290. {
  5291. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5292. {
  5293. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5294. {
  5295. string shopid = CurrentUser.User.pemShop;
  5296. lw.Add(string.Format("shopId in ({0})", shopid));
  5297. }
  5298. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5299. {
  5300. int mrOrgid = CurrentUser.UserPost.OrgID;
  5301. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5302. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5303. }
  5304. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5305. //{
  5306. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5307. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5308. //}
  5309. else
  5310. {
  5311. string userIdStr = "";
  5312. if (posCode == "CustomerService")
  5313. {
  5314. userIdStr = CurrentUser.UserID + "_k";
  5315. }
  5316. else if (posCode == "Designer" || posCode == "wxDesigner")
  5317. {
  5318. userIdStr = CurrentUser.UserID + "_s";
  5319. }
  5320. else if (posCode == "Place")
  5321. {
  5322. userIdStr = CurrentUser.UserID + "_x";
  5323. }
  5324. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5325. }
  5326. }
  5327. string placedate1 = GetPostString("placedate1");
  5328. string placedate2 = GetPostString("placedate2");
  5329. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5330. if (dwplace.Length > 0) lw.Add(dwplace);
  5331. string supState = GetPostString("supState");
  5332. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5333. string searchType = GetPostString("searchType");
  5334. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5335. {
  5336. lw.Add(string.Format("BackNum>1"));
  5337. }
  5338. lw.Add(string.Format("AfterSaleState>0"));
  5339. if (ex_psize > 0)
  5340. {
  5341. if (CurrentUser.UserPost.Post.Code == "Finance")
  5342. dStruct.Order = "pay_time desc";
  5343. else
  5344. dStruct.Order = "HandleTime desc";
  5345. }
  5346. else
  5347. dStruct.Order = "HandleTime desc";
  5348. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5349. DataTable dt = WebCache.GetData("view_test", dStruct);
  5350. writeGridDataTableJson(dStruct.TotalCount, dt);
  5351. }
  5352. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5353. //{
  5354. // lw.Add(string.Format("AfterSaleState=4"));
  5355. // string code = CurrentUser.UserPost.Post.Code;
  5356. // if (code == "CustomerService")
  5357. // {
  5358. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5359. // }
  5360. // else if (code == "Designer" || code == "DesignerMr")
  5361. // {
  5362. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5363. // }
  5364. // else if (code == "Place" || code == "PlaceMr")
  5365. // {
  5366. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5367. // }
  5368. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5369. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5370. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5371. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5372. //}
  5373. //else //处理中的售后,待处理和处理中合并
  5374. //{
  5375. // if (afterState.Length <= 0)
  5376. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5377. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5378. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5379. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5380. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5381. //}
  5382. }
  5383. public void get_erp_disagreeftersalelist()
  5384. {
  5385. DataStruct dStruct = GetPostStruct();
  5386. List<string> lw = new List<string>();
  5387. int st = 2;
  5388. string tid = GetPostString("ctid");
  5389. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5390. string shopname = GetPostString("shopname");
  5391. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5392. string buyernick = GetPostString("buyer_nick");
  5393. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5394. string sellermemo = GetPostString("seller_memo");
  5395. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5396. string orderState = GetPostString("orderState");
  5397. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5398. string afterState = GetPostString("afterstate");
  5399. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5400. string date1 = GetPostString("date1");
  5401. string date2 = GetPostString("date2");
  5402. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5403. if (dw.Length > 0) lw.Add(dw);
  5404. string price1 = GetPostString("price1");
  5405. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5406. string price2 = GetPostString("price2");
  5407. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5408. //lw.Add(string.Format("IsRefund!={0}", 1));
  5409. string reason = GetPostString("reason");
  5410. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5411. string method = GetPostString("method");
  5412. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5413. string handler = GetPostString("handler");
  5414. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5415. string handledate1 = GetPostString("handledate1");
  5416. string handledate2 = GetPostString("handledate2");
  5417. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5418. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5419. string afterdate1 = GetPostString("afterdate1");
  5420. string afterdate2 = GetPostString("afterdate2");
  5421. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5422. if (afterDate.Length > 0) lw.Add(afterDate);
  5423. string supplier = GetPostString("supplier");
  5424. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5425. string responsible = GetPostString("responsibleman");
  5426. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5427. string customer = GetPostString("customer");
  5428. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5429. string design = GetPostString("design");
  5430. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5431. string afterSaleMemo = GetPostString("afterSaleMemo");
  5432. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5433. string afterMemoType = GetPostString("aftermemotype");
  5434. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5435. string aftersakereason = GetPostString("aftersakereason");
  5436. if (aftersakereason.Length > 0)
  5437. {
  5438. if (aftersakereason == "1")
  5439. {
  5440. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5441. }
  5442. if (aftersakereason == "2")
  5443. {
  5444. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5445. }
  5446. }
  5447. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5448. string poscode = CurrentUser.UserPost.Post.Code;
  5449. if (poscode != "SysAdmin")
  5450. {
  5451. string shopid = CurrentUser.User.pemShop;
  5452. lw.Add(string.Format("shopId in ({0})", shopid));
  5453. }
  5454. string searchType = GetPostString("searchType");
  5455. if (searchType == "wait")
  5456. {
  5457. lw.Add(string.Format("HandleTime is null"));
  5458. }
  5459. if (searchType == "handling")
  5460. {
  5461. lw.Add(string.Format("HandleTime is not null "));
  5462. }
  5463. if (searchType == "back" || searchType == "puBack")
  5464. {
  5465. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5466. }
  5467. if (searchType == "reBack")
  5468. {
  5469. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5470. }
  5471. if (searchType == "moreBack")
  5472. {
  5473. lw.Add(string.Format("backNum > 1"));
  5474. }
  5475. lw.Add(string.Format("(AfterSaleState=5)"));
  5476. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5477. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5478. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5479. writeGridDataTableJson(dStruct.TotalCount, dt);
  5480. }
  5481. public void get_erp_handlingaftersalelist()
  5482. {
  5483. DataStruct dStruct = GetPostStruct();
  5484. List<string> lw = new List<string>();
  5485. int st = 2;
  5486. string tid = GetPostString("ctid");
  5487. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5488. string shopname = GetPostString("shopname");
  5489. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5490. string buyernick = GetPostString("buyer_nick");
  5491. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5492. string sellermemo = GetPostString("seller_memo");
  5493. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5494. string orderState = GetPostString("orderState");
  5495. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5496. string afterState = GetPostString("afterstate");
  5497. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5498. string date1 = GetPostString("date1");
  5499. string date2 = GetPostString("date2");
  5500. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5501. if (dw.Length > 0) lw.Add(dw);
  5502. string price1 = GetPostString("price1");
  5503. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5504. string price2 = GetPostString("price2");
  5505. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5506. //lw.Add(string.Format("IsRefund!={0}", 1));
  5507. string reason = GetPostString("reason");
  5508. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5509. string method = GetPostString("method");
  5510. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5511. string handler = GetPostString("handler");
  5512. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5513. string handledate1 = GetPostString("handledate1");
  5514. string handledate2 = GetPostString("handledate2");
  5515. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5516. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5517. string afterdate1 = GetPostString("afterdate1");
  5518. string afterdate2 = GetPostString("afterdate2");
  5519. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5520. if (afterDate.Length > 0) lw.Add(afterDate);
  5521. string supplier = GetPostString("supplier");
  5522. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5523. string responsible = GetPostString("responsibleman");
  5524. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5525. string customer = GetPostString("customer");
  5526. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5527. string design = GetPostString("design");
  5528. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5529. string afterSaleMemo = GetPostString("afterSaleMemo");
  5530. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5531. string afterMemoType = GetPostString("aftermemotype");
  5532. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5533. string afterresult = GetPostString("afterresult");
  5534. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5535. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5536. string poscode = CurrentUser.UserPost.Post.Code;
  5537. if (poscode != "SysAdmin")
  5538. {
  5539. string shopid = CurrentUser.User.pemShop;
  5540. lw.Add(string.Format("shopId in ({0})", shopid));
  5541. }
  5542. string searchType = GetPostString("searchType");
  5543. if (searchType == "wait")
  5544. {
  5545. lw.Add(string.Format("HandleTime is null"));
  5546. }
  5547. if (searchType == "documentary")
  5548. {
  5549. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5550. }
  5551. if (searchType == "handling")
  5552. {
  5553. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5554. }
  5555. if (searchType == "back" || searchType == "puBack")
  5556. {
  5557. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5558. }
  5559. if (searchType == "reBack")
  5560. {
  5561. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5562. }
  5563. if (afterState.Length <= 0)
  5564. {
  5565. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5566. }
  5567. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5568. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5569. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5570. writeGridDataTableJson(dStruct.TotalCount, dt);
  5571. }
  5572. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5573. //public void get_erp_back_handlingaftersalelist()
  5574. //{
  5575. // DataStruct dStruct = GetPostStruct();
  5576. // List<string> lw = new List<string>();
  5577. // string tid = GetPostString("ctid");
  5578. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5579. // string shopname = GetPostString("shopname");
  5580. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5581. // string buyernick = GetPostString("buyer_nick");
  5582. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5583. // string sellermemo = GetPostString("seller_memo");
  5584. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5585. // string orderState = GetPostString("orderState");
  5586. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5587. // string afterState = GetPostString("afterstate");
  5588. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5589. // string date1 = GetPostString("date1");
  5590. // string date2 = GetPostString("date2");
  5591. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5592. // if (dw.Length > 0) lw.Add(dw);
  5593. // string price1 = GetPostString("price1");
  5594. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5595. // string price2 = GetPostString("price2");
  5596. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5597. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5598. // string reason = GetPostString("reason");
  5599. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5600. // string method = GetPostString("method");
  5601. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5602. // string handler = GetPostString("handler");
  5603. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5604. // string handledate1 = GetPostString("handledate1");
  5605. // string handledate2 = GetPostString("handledate2");
  5606. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5607. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5608. // string afterdate1 = GetPostString("afterdate1");
  5609. // string afterdate2 = GetPostString("afterdate2");
  5610. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5611. // if (afterDate.Length > 0) lw.Add(afterDate);
  5612. // string supplier = GetPostString("supplier");
  5613. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5614. // string responsible = GetPostString("responsibleman");
  5615. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5616. // string customer = GetPostString("customer");
  5617. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5618. // string design = GetPostString("design");
  5619. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5620. // string afterMemoType = GetPostString("aftermemotype");
  5621. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5622. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5623. // if (afterState.Length <= 0)
  5624. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5625. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5626. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5627. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5628. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5629. //}
  5630. public void get_erp_aftersaleverifylist()
  5631. {
  5632. DataStruct dStruct = GetPostStruct();
  5633. List<string> lw = new List<string>();
  5634. string tid = GetPostString("ctid");
  5635. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5636. string shopname = GetPostString("shopname");
  5637. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5638. string buyernick = GetPostString("buyer_nick");
  5639. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5640. string sellermemo = GetPostString("seller_memo");
  5641. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5642. string orderState = GetPostString("orderState");
  5643. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5644. //lw.Add(string.Format("IsRefund!={0}", 1));
  5645. string reason = GetPostString("reason");
  5646. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5647. string method = GetPostString("method");
  5648. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5649. string handler = GetPostString("handler");
  5650. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5651. string handledate1 = GetPostString("handledate1");
  5652. string handledate2 = GetPostString("handledate2");
  5653. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5654. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5655. string finish1 = GetPostString("finishdate1");
  5656. string finish2 = GetPostString("finishdate2");
  5657. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5658. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5659. string supplier = GetPostString("supplier");
  5660. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5661. string responsible = GetPostString("responsibleman");
  5662. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5663. string posCode = CurrentUser.UserPost.Post.Code;
  5664. string vstate = GetPostString("vstate");
  5665. if (vstate.Length > 0)
  5666. {
  5667. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5668. }
  5669. if (posCode == "Supplier")
  5670. {
  5671. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5672. lw.Add(string.Format("VerifyState = 0"));
  5673. lw.Add("type = 1");
  5674. lw.Add(string.Format("AfterSaleState={0}", 3));
  5675. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5676. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5678. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5679. writeGridDataTableJson(dStruct.TotalCount, dt);
  5680. }
  5681. else if (posCode == "logistics")
  5682. {
  5683. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5684. lw.Add(string.Format("VerifyState = 0"));
  5685. lw.Add("type = 2");
  5686. lw.Add(string.Format("AfterSaleState={0}", 3));
  5687. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5688. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5689. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5690. writeGridDataTableJson(dStruct.TotalCount, dt);
  5691. }
  5692. else
  5693. {
  5694. lw.Add(string.Format("(AfterSaleState = 3)"));
  5695. string reasonState = GetPostString("reasonState");
  5696. lw.Add("type = 0");
  5697. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5698. || posCode == "Summarize" || posCode == "Finance")
  5699. {
  5700. if (reasonState == "2")
  5701. {
  5702. lw.Add("VerifyState = 3");
  5703. }
  5704. else if (reasonState == "1")
  5705. {
  5706. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5707. }
  5708. else
  5709. {
  5710. lw.Add("VerifyState in (0,3)");
  5711. }
  5712. //不加条件,可以看全部
  5713. }
  5714. 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")
  5715. {
  5716. int orgid = CurrentUser.UserPost.OrgID;
  5717. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5718. if (string.IsNullOrEmpty(manageOrgId))
  5719. {
  5720. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5721. }
  5722. else
  5723. {
  5724. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5725. }
  5726. if (reasonState == "1")
  5727. {
  5728. lw.Add("VerifyState = 3");
  5729. }
  5730. else if (reasonState == "2")
  5731. {
  5732. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5733. }
  5734. else
  5735. {
  5736. }
  5737. }
  5738. else
  5739. {
  5740. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5741. }
  5742. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5743. //{
  5744. // int org_id = CurrentUser.UserPost.OrgID;
  5745. // lw.Add(string.Format("OrgID={0}", org_id));
  5746. //}
  5747. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5748. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5749. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5750. writeGridDataTableJson(dStruct.TotalCount, dt);
  5751. }
  5752. }
  5753. public void get_erp_finishaftersalelist()
  5754. {
  5755. DataStruct dStruct = GetPostStruct();
  5756. List<string> lw = new List<string>();
  5757. int st = 4;
  5758. string tid = GetPostString("ctid");
  5759. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5760. string shopname = GetPostString("shopname");
  5761. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5762. //lw.Add(string.Format("IsRefund!={0}", 1));
  5763. string reason = GetPostString("reason");
  5764. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5765. string method = GetPostString("method");
  5766. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5767. string buyernick = GetPostString("buyer_nick");
  5768. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5769. string handler = GetPostString("handler");
  5770. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5771. string handledate1 = GetPostString("handledate1");
  5772. string handledate2 = GetPostString("handledate2");
  5773. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5774. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5775. string finish1 = GetPostString("finishdate1");
  5776. string finish2 = GetPostString("finishdate2");
  5777. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5778. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5779. string supplier = GetPostString("supplier");
  5780. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5781. string responsible = GetPostString("responsibleman");
  5782. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5783. string vstate = GetPostString("vstate");
  5784. if (vstate.Length > 0)
  5785. {
  5786. if ("3".Equals(vstate))
  5787. {
  5788. lw.Add(string.Format("IsTem=1"));
  5789. }
  5790. else
  5791. {
  5792. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5793. }
  5794. }
  5795. lw.Add(string.Format("AfterSaleState=4"));
  5796. string code = CurrentUser.UserPost.Post.Code;
  5797. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5798. {
  5799. //不加条件,可以看全部
  5800. }
  5801. else if (code == "Supplier")
  5802. {
  5803. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5804. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5805. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5806. }
  5807. else if (code == "logistics")
  5808. {
  5809. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5810. lw.Add("type = 2");
  5811. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5812. }
  5813. 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")
  5814. {
  5815. int orgid = CurrentUser.UserPost.OrgID;
  5816. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5817. if (string.IsNullOrEmpty(manageOrgIds))
  5818. {
  5819. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5820. }
  5821. else
  5822. {
  5823. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5824. }
  5825. }
  5826. else
  5827. {
  5828. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5829. }
  5830. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5831. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5832. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5833. writeGridDataTableJson(dStruct.TotalCount, dt);
  5834. }
  5835. public void handle_erp_aftersale()
  5836. {
  5837. if (UrlPostParmsCheck("ctid"))
  5838. {
  5839. string eid = GetPostString("ctid");
  5840. string responStr = GetPostString("AfterSaleResponsible");
  5841. if (responStr.Length <= 0)
  5842. {
  5843. returnErrorMsg("售后责任人不能为空");
  5844. return;
  5845. }
  5846. bool isDesign = false;
  5847. double designFree = 0.00;
  5848. int responsibleId = 0;
  5849. CeErpTradeCell entity = null;
  5850. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5851. if (entity != null)
  5852. {
  5853. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5854. string afterMethod = GetPostString("AfterSaleMethod");
  5855. if (isNeedNewOrder == 1)
  5856. {
  5857. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5858. bool ishav = true;
  5859. if (newentity == null)
  5860. {
  5861. newentity = entity.Clone() as CeErpTradeCell;
  5862. ishav = false;
  5863. newentity.ctid = "S_" + entity.ctid;
  5864. newentity.OrderState = 0;
  5865. }
  5866. //唯一标识
  5867. newentity.OrderSn = newentity.ctid;
  5868. /* string orderSn = dataHelper.getSaleOrderSn();
  5869. if (orderSn != "")
  5870. {
  5871. newentity.OrderSn = orderSn;
  5872. }*/
  5873. newentity.AfterSaleState = 0;
  5874. newentity.AfterSaleMethod = afterMethod;
  5875. if (!ishav)
  5876. {
  5877. string memo_str = newentity.seller_memo;
  5878. memo_str = memo_str.Replace("(", "(");
  5879. memo_str = memo_str.Replace(")", ")");
  5880. int sIndex = memo_str.IndexOf("(");
  5881. int eIndex = memo_str.IndexOf(")");
  5882. if (sIndex == -1 || eIndex == -1)
  5883. {
  5884. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5885. return;
  5886. }
  5887. string first = memo_str.Substring(0, sIndex + 1);
  5888. string memoCtid = newentity.OrderSn;
  5889. //if (memoCtid.IndexOf("C") != -1)
  5890. //{
  5891. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5892. //if (CIdx.IndexOf("+") != -1)
  5893. //{
  5894. //CIdx = "C" + CIdx.Split('+')[1];
  5895. //}
  5896. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5897. //}
  5898. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5899. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5900. string newMemo = first + memoCtid + last;
  5901. newentity.seller_memo = newMemo;
  5902. newentity.FinishPlaceTime = null;
  5903. newentity.UnusualTag = 0;
  5904. newentity.UnusualCon = "";
  5905. newentity.UnusualTime = null;
  5906. newentity.AfterSaleMemo = "";
  5907. newentity.AfterSaleMethod = afterMethod;
  5908. newentity.AfterSalePreTime = null;
  5909. newentity.AfterSaleReason = "";
  5910. newentity.AfterSaleResponsible = "";
  5911. newentity.AfterSaleState = 0;
  5912. newentity.AfterSaleTime = null;
  5913. newentity.AfterSaleUserId = 0;
  5914. newentity.AfterSaleSupplierState = 0;
  5915. newentity.LastBillWaybillCode = "";
  5916. newentity.LastBillCpCode = "";
  5917. newentity.FinishAfterSaleTime = null;
  5918. newentity.HandleTime = null;
  5919. newentity.IsSF = 0;
  5920. newentity.IsOldCustomer = 0;
  5921. newentity.UrgencyTime = null;
  5922. newentity.ResponsibleUserId = "";
  5923. newentity.IsVerifyToSupplier = false;
  5924. newentity.payment = 0;
  5925. newentity.CheckMemo = "";
  5926. newentity.OutSid = "";
  5927. newentity.CheckOrderTime = null;
  5928. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  5929. }
  5930. newentity.isAfterSaleOrder = 1;
  5931. newentity.IsRefund = 0;
  5932. string receiveMobile = GetPostString("receiver_mobile");
  5933. if (receiveMobile.Length > 0)
  5934. {
  5935. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  5936. if (trade != null)
  5937. {
  5938. trade.receiver_name = GetPostString("receiver_name");
  5939. trade.receiver_mobile = receiveMobile;
  5940. trade.receiver_state = GetPostString("receiver_state");
  5941. trade.receiver_city = GetPostString("receiver_city");
  5942. trade.receiver_district = GetPostString("receiver_district");
  5943. trade.receiver_address = GetPostString("receiver_address");
  5944. newentity.IsOffLineOrder = 1;
  5945. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  5946. }
  5947. }
  5948. string st = GetPostString("ToState");
  5949. if (st.Length > 0)
  5950. {
  5951. if (newentity.OrderState <= 3)
  5952. {
  5953. newentity.WaitDesignTime = DateTime.Now;
  5954. newentity.StartDesignTime = null;
  5955. newentity.FinishDesignTime = null;
  5956. newentity.OrderState = 3;
  5957. if (st == "下单员")
  5958. {
  5959. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  5960. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  5961. {
  5962. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  5963. }
  5964. }
  5965. else
  5966. {
  5967. newentity.WaitDesignTime = DateTime.Now;
  5968. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  5969. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  5970. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  5971. {
  5972. DataRow user = dt1.Rows[0];
  5973. //找主管
  5974. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  5975. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  5976. if (dt != null && dt.Rows.Count > 0)
  5977. {
  5978. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  5979. newentity.DesignUserId = designMr;
  5980. string key = "aftersale_order_" + designMr;
  5981. if (RedisHelper.HasKey(key))
  5982. {
  5983. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  5984. list.Add(newentity.ctid);
  5985. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  5986. }
  5987. }
  5988. //账号正常
  5989. if (user["State"].ToString() == "0")
  5990. {
  5991. newentity.DesignUserId = entity.DesignUserId;
  5992. string key = "aftersale_order_" + entity.DesignUserId;
  5993. if (RedisHelper.HasKey(key))
  5994. {
  5995. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  5996. list.Add(newentity.ctid);
  5997. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  5998. }
  5999. }
  6000. }
  6001. }
  6002. }
  6003. if (entity.IsXianHuo == 1)
  6004. {
  6005. newentity.OrderState = 6;
  6006. entity.FinishPlaceTime = DateTime.Now;
  6007. }
  6008. }
  6009. if (ishav)
  6010. {
  6011. newentity.Update();
  6012. }
  6013. else
  6014. {
  6015. newentity.Create();
  6016. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6017. }
  6018. if (st != "下单员")
  6019. {
  6020. designHelper.API_GetPrintData_CreateOrder(newentity);
  6021. }
  6022. }
  6023. //处理售后扩展
  6024. string resIdStr = GetPostString("ResponsibleUserId");
  6025. string refundFees = GetPostString("refundFrees");
  6026. int IsComplain = GetPostInt("isComplain");
  6027. int IsBad = GetPostInt("isBad");
  6028. string IsOriginal = GetPostString("isOriginal");
  6029. double diffResultPrice = GetPostDouble("diffResultPrice");
  6030. string textResult = GetPostString("textResult");
  6031. string supplierResponsible = GetPostString("supplierResponsible");
  6032. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6033. if (ceErpTradeAfterSaleExtend == null)
  6034. {
  6035. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6036. ceErpTradeAfterSaleExtend.tid = eid;
  6037. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6038. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6039. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6040. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6041. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6042. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6043. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6044. ceErpTradeAfterSaleExtend.Create();
  6045. }
  6046. else
  6047. {
  6048. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6049. {
  6050. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6051. }
  6052. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6053. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6054. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6055. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6056. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6057. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6058. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6059. ceErpTradeAfterSaleExtend.Update();
  6060. }
  6061. int gysid = GetPostInt("ResponsibleSupId");
  6062. entity.AfterSaleUserId = CurrentUser.UserID;
  6063. entity.ResponsibleUserId = resIdStr;
  6064. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6065. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6066. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6067. {
  6068. CeErpTradeResponsible.DelByTid(eid, -1);
  6069. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6070. int backNum = 0;
  6071. if (number != null)
  6072. {
  6073. backNum = number.BackNum;
  6074. }
  6075. char[] separator = { ',' };
  6076. string[] sArray = resIdStr.Split(separator);
  6077. string[] refundFreeList = { };
  6078. if (refundFees.Length > 0)
  6079. {
  6080. refundFreeList = refundFees.Split(separator);
  6081. }
  6082. int index = -1;
  6083. foreach (string i in sArray)
  6084. {
  6085. index++;
  6086. if (i.Length <= 0) continue;
  6087. char[] separator2 = { '_' };
  6088. string idstr = i.Split(separator2)[0];
  6089. string idtype = i.Split(separator2)[1];
  6090. double refudFree = 0;
  6091. if (refundFreeList.Length > 0)
  6092. {
  6093. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6094. }
  6095. if (idtype == "s")
  6096. {
  6097. isDesign = true;
  6098. designFree = refudFree;
  6099. }
  6100. int userId = Convert.ToInt32(idstr);
  6101. int type = 0;
  6102. if (idtype == "g")
  6103. {
  6104. type = 1;
  6105. }
  6106. if (idtype == "w")
  6107. {
  6108. type = 2;
  6109. }
  6110. if (idtype == "t")
  6111. {
  6112. type = 3;
  6113. }
  6114. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6115. if (ceErpTradeResponsible == null)
  6116. {
  6117. ceErpTradeResponsible = new CeErpTradeResponsible();
  6118. ceErpTradeResponsible.tid = eid;
  6119. ceErpTradeResponsible.UserId = userId;
  6120. ceErpTradeResponsible.createdTime = DateTime.Now;
  6121. ceErpTradeResponsible.type = type;
  6122. if (type == 1)
  6123. {
  6124. ceErpTradeResponsible.IsSup = 1;
  6125. }
  6126. if (type == 2)
  6127. {
  6128. ceErpTradeResponsible.IsFlow = 1;
  6129. }
  6130. }
  6131. ceErpTradeResponsible.RefundFee = refudFree;
  6132. ceErpTradeResponsible.VerifyState = 0;
  6133. if (userId == 2125 || idtype == "w")
  6134. {
  6135. ceErpTradeResponsible.VerifyState = 1;
  6136. }
  6137. if (idtype == "w" && userId == 101)
  6138. {
  6139. ceErpTradeResponsible.VerifyState = 0;
  6140. }
  6141. if (ceErpTradeResponsible.ID > 0)
  6142. {
  6143. ceErpTradeResponsible.Update();
  6144. }
  6145. else
  6146. {
  6147. ceErpTradeResponsible.Create();
  6148. }
  6149. if (isDesign)
  6150. {
  6151. responsibleId = ceErpTradeResponsible.ID;
  6152. }
  6153. }
  6154. CeErpTradeResponsible.NumByTid(backNum, eid);
  6155. }
  6156. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6157. if (ceErpTradeCellExtend != null)
  6158. {
  6159. ceErpTradeCellExtend.returnVisit = 0;
  6160. ceErpTradeCellExtend.Update();
  6161. }
  6162. if (entity.HandleTime != null)
  6163. {
  6164. if (entity.AfterSaleState == 1)
  6165. {
  6166. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6167. }
  6168. else
  6169. {
  6170. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6171. }
  6172. }
  6173. else
  6174. {
  6175. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6176. entity.HandleTime = DateTime.Now;
  6177. }
  6178. bool isCompale = false;
  6179. if (entity.AfterSaleState == 5)
  6180. {
  6181. isCompale = true;
  6182. entity.AfterSaleState = 3;
  6183. }
  6184. entity.AfterSaleSupplierState = 0;
  6185. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6186. {
  6187. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6188. }
  6189. string sImgs = GetPostString("img");
  6190. entity.AfterSaleSupplierImg = sImgs;
  6191. entity.supRefundType = GetPostString("supRefundType");
  6192. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6193. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6194. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6195. entity.AfterSaleMemoType = GetPostString("MemoType");
  6196. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6197. {
  6198. entity.AfterSaleSupplierState = 2;
  6199. }
  6200. string df = GetPostString("DeductFee");
  6201. if (df == "")
  6202. {
  6203. df = "0";
  6204. }
  6205. string rf = GetPostString("RefundFee");
  6206. if (rf == "")
  6207. {
  6208. rf = "0";
  6209. }
  6210. string pm = GetPostString("AfterSalePayment");
  6211. if (pm == "")
  6212. {
  6213. pm = "0";
  6214. }
  6215. entity.AfterSalePayment = Convert.ToDouble(pm);
  6216. entity.DeductFee = Convert.ToDouble(df);
  6217. entity.RefundFee = Convert.ToDouble(rf);
  6218. entity.Update();
  6219. string toState = GetPostString("ToState");
  6220. string original = GetPostString("isOriginal");
  6221. ApiVo apiVo = new ApiVo();
  6222. apiVo.orderNumber = entity.ctid;
  6223. apiVo.actionName = "afterDesign";
  6224. apiVo.orderRemarks = entity.AfterSaleMethod;
  6225. apiVo.reasonRemarks = entity.AfterSaleReason;
  6226. apiVo.isDesign = isDesign;
  6227. apiVo.designFree = designFree;
  6228. apiVo.responsibleId = responsibleId;
  6229. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6230. if (toState == "设计师")
  6231. {
  6232. apiVo.isOriginal = Convert.ToBoolean(original);
  6233. }
  6234. designHelper.API_WorkCore(apiVo);//afterDesign
  6235. CeErpMethod methodSql = new CeErpMethod();
  6236. methodSql.con = entity.AfterSaleMethod;
  6237. methodSql.addTime = DateTime.Now;
  6238. methodSql.Create();
  6239. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6240. CeErpMethod.ExecuteNonQuery(delsql);
  6241. if (isCompale)
  6242. {
  6243. aftersale_data_change(entity.ctid);
  6244. }
  6245. returnSuccessMsg("操作成功!");
  6246. return;
  6247. }
  6248. returnErrorMsg("找不到订单记录");
  6249. }
  6250. }
  6251. public void ins_erp_toresponsible()
  6252. {
  6253. if (UrlPostParmsCheck("ctid"))
  6254. {
  6255. string eid = GetPostString("ctid");
  6256. CeErpTradeCell entity = null;
  6257. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6258. if (entity != null)
  6259. {
  6260. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6261. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6262. {
  6263. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6264. return;
  6265. }
  6266. entity.AfterSalePreTime = DateTime.Now;
  6267. //预完成给售后主管审核客户问题直接完成
  6268. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null)
  6269. {
  6270. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6271. {
  6272. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6273. }
  6274. }
  6275. entity.AfterSaleState = 2;
  6276. entity.Update();
  6277. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6278. aftersale_data_change(entity.ctid);
  6279. returnSuccessMsg("操作成功!");
  6280. return;
  6281. }
  6282. returnErrorMsg("找不到订单记录");
  6283. }
  6284. }
  6285. public void cancel_erp_aftersaleanddelnew()
  6286. {
  6287. if (UrlPostParmsCheck("ctid"))
  6288. {
  6289. string eid = GetPostString("ctid");
  6290. CeErpTradeCell entity = null;
  6291. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6292. if (entity != null)
  6293. {
  6294. entity.AfterSaleState = 0;
  6295. entity.AfterSaleReason = "";
  6296. entity.AfterSaleMethod = "";
  6297. entity.AfterSaleMemo = "";
  6298. entity.AfterSaleResponsible = "";
  6299. entity.ResponsibleUserId = "";
  6300. entity.DeductFee = 0;
  6301. entity.RefundFee = 0;
  6302. entity.IsArbitrate = 0;
  6303. CeErpTradeResponsible.DelByTid(eid, -1);
  6304. entity.Update();
  6305. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6306. if (after != null)
  6307. {
  6308. if (after.OrderState < 5)
  6309. CeErpTradeCell.DelByCtid("S_" + eid);
  6310. }
  6311. returnSuccessMsg("操作成功!");
  6312. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6313. return;
  6314. }
  6315. returnErrorMsg("找不到订单记录");
  6316. }
  6317. }
  6318. public void get_erp_aftersale_pregather()
  6319. {
  6320. List<string> lw = new List<string>();
  6321. int st = GetInt("st");
  6322. string tid = GetPostString("ctid");
  6323. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6324. string shopname = GetPostString("shopname");
  6325. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6326. string buyernick = GetPostString("buyer_nick");
  6327. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6328. string sellermemo = GetPostString("seller_memo");
  6329. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6330. string orderState = GetPostString("orderState");
  6331. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6332. string reason = GetPostString("reason");
  6333. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6334. string method = GetPostString("method");
  6335. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6336. string handler = GetPostString("handler");
  6337. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6338. string handledate1 = GetPostString("handledate1");
  6339. string handledate2 = GetPostString("handledate2");
  6340. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6341. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6342. string supplier = GetPostString("supplier");
  6343. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6344. string responsible = GetPostString("responsibleman");
  6345. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6346. string customer = GetPostString("customer");
  6347. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6348. string design = GetPostString("design");
  6349. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6350. string afterMemoType = GetPostString("aftermemotype");
  6351. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6352. string afterSaleMemo = GetPostString("afterSaleMemo");
  6353. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6354. string afterresult = GetPostString("afterresult");
  6355. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6356. string poscode = CurrentUser.UserPost.Post.Code;
  6357. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6358. {
  6359. string shopid = CurrentUser.User.pemShop;
  6360. lw.Add(string.Format("shopId in ({0})", shopid));
  6361. }
  6362. var mainwhere = string.Join(" and ", lw.ToArray());
  6363. string ro_json = "";
  6364. string type = GetPostString("gather_type");
  6365. if (poscode == "AfterSale")
  6366. {
  6367. //处理中
  6368. if (type == "Handling")
  6369. {
  6370. 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) : ""));
  6371. DataTable dt = null;
  6372. try
  6373. {
  6374. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6375. }
  6376. catch (Exception e)
  6377. {
  6378. dt = new DataTable();
  6379. }
  6380. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6381. return;
  6382. }
  6383. if (type == "Wait")
  6384. {
  6385. //待处理
  6386. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6387. DataTable dt1 = null;
  6388. try
  6389. {
  6390. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6391. }
  6392. catch (Exception e)
  6393. {
  6394. dt1 = new DataTable();
  6395. }
  6396. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6397. return;
  6398. }
  6399. if (type == "back")
  6400. {
  6401. //打回
  6402. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6403. DataTable dt2 = null;
  6404. try
  6405. {
  6406. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6407. }
  6408. catch (Exception e)
  6409. {
  6410. dt2 = new DataTable();
  6411. }
  6412. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6413. return;
  6414. }
  6415. if (type == "preCompletion")
  6416. {
  6417. //预完成
  6418. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6419. DataTable dt3 = null;
  6420. try
  6421. {
  6422. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6423. }
  6424. catch (Exception e)
  6425. {
  6426. dt3 = new DataTable();
  6427. }
  6428. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6429. return;
  6430. }
  6431. if (type == "documentary")
  6432. {
  6433. //跟单中
  6434. 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) : ""));
  6435. DataTable dt4 = null;
  6436. try
  6437. {
  6438. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6439. }
  6440. catch (Exception e)
  6441. {
  6442. dt4 = new DataTable();
  6443. }
  6444. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6445. return;
  6446. }
  6447. if (type == "reBack")
  6448. {
  6449. //被打回
  6450. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6451. DataTable dt1 = null;
  6452. try
  6453. {
  6454. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6455. }
  6456. catch (Exception e)
  6457. {
  6458. dt1 = new DataTable();
  6459. }
  6460. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6461. return;
  6462. }
  6463. }
  6464. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6465. {
  6466. if (type == "puBack")
  6467. {
  6468. //退回
  6469. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6470. DataTable dt = null;
  6471. try
  6472. {
  6473. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6474. }
  6475. catch (Exception e)
  6476. {
  6477. dt = new DataTable();
  6478. }
  6479. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6480. return;
  6481. }
  6482. if (type == "reBack")
  6483. {
  6484. //打回
  6485. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6486. DataTable dt1 = null;
  6487. try
  6488. {
  6489. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6490. }
  6491. catch (Exception e)
  6492. {
  6493. dt1 = new DataTable();
  6494. }
  6495. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6496. return;
  6497. }
  6498. if (type == "examEd")
  6499. {
  6500. //已审核
  6501. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6502. DataTable dt2 = null;
  6503. try
  6504. {
  6505. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6506. }
  6507. catch (Exception e)
  6508. {
  6509. dt2 = new DataTable();
  6510. }
  6511. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6512. return;
  6513. }
  6514. if (type == "waitExam")
  6515. {
  6516. //待审核
  6517. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6518. DataTable dt3 = null;
  6519. try
  6520. {
  6521. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6522. }
  6523. catch (Exception e)
  6524. {
  6525. dt3 = new DataTable();
  6526. }
  6527. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6528. return;
  6529. }
  6530. if (type == "Handling")
  6531. {
  6532. //处理中
  6533. 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) : ""));
  6534. DataTable dt4 = null;
  6535. try
  6536. {
  6537. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6538. }
  6539. catch (Exception e)
  6540. {
  6541. dt4 = new DataTable();
  6542. }
  6543. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6544. return;
  6545. }
  6546. if (type == "Wait")
  6547. {
  6548. //待处理
  6549. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6550. DataTable dt5 = null;
  6551. try
  6552. {
  6553. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6554. }
  6555. catch (Exception e)
  6556. {
  6557. dt5 = new DataTable();
  6558. }
  6559. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6560. return;
  6561. }
  6562. if (type == "documentary")
  6563. {
  6564. //跟单中
  6565. 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) : ""));
  6566. DataTable dt6 = null;
  6567. try
  6568. {
  6569. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6570. }
  6571. catch (Exception e)
  6572. {
  6573. dt6 = new DataTable();
  6574. }
  6575. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6576. return;
  6577. }
  6578. }
  6579. returnSuccess(ro_json);
  6580. }
  6581. public void end_erp_aftersale()
  6582. {
  6583. if (UrlPostParmsCheck("ctid"))
  6584. {
  6585. string eid = GetPostString("ctid");
  6586. CeErpTradeCell entity = null;
  6587. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6588. if (entity != null)
  6589. {
  6590. string stype = GetPostString("stype");
  6591. string typeStr = stype;
  6592. entity.AfterSaleState = 4;
  6593. entity.FinishAfterSaleTime = DateTime.Now;
  6594. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6595. entity.Update();
  6596. ApiVo apiVo = new ApiVo();
  6597. apiVo.orderNumber = entity.ctid;
  6598. apiVo.actionName = "afterOver";
  6599. designHelper.API_WorkCore(apiVo); //afterOver
  6600. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6601. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6602. CeErpSukuraData.createInfo(entity.ctid, 8);
  6603. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6604. returnSuccessMsg("操作成功!");
  6605. return;
  6606. }
  6607. returnErrorMsg("找不到订单记录");
  6608. }
  6609. }
  6610. public void ins_erp_finishaftersale()
  6611. {
  6612. if (UrlPostParmsCheck("id"))
  6613. {
  6614. string eid = GetPostString("id");
  6615. CeErpTradeResponsible entity = null;
  6616. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6617. if (entity != null)
  6618. {
  6619. entity.VerifyState = 1;
  6620. entity.VerifyTime = DateTime.Now;
  6621. entity.Update();
  6622. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6623. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6624. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6625. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6626. if (dt.Rows.Count <= 0)
  6627. {
  6628. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6629. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6630. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6631. CeErpSukuraData.createInfo(entity.tid, 8);
  6632. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6633. {
  6634. CeErpDesignerBill.Del(entity.tid);
  6635. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6636. }
  6637. }
  6638. returnSuccessMsg("操作成功!");
  6639. return;
  6640. }
  6641. returnErrorMsg("找不到订单记录");
  6642. }
  6643. }
  6644. public void upd_erp_arbitrateaftersale()
  6645. {
  6646. if (UrlPostParmsCheck("id"))
  6647. {
  6648. string eid = GetPostString("id");
  6649. CeErpTradeResponsible entity = null;
  6650. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6651. if (entity != null)
  6652. {
  6653. entity.IsArbitrate = 1;
  6654. entity.ArbitradeMemo = GetPostString("reason");
  6655. entity.VerifyState = 2;
  6656. entity.Update();
  6657. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6658. if (tradecell != null)
  6659. {
  6660. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6661. tradecell.IsArbitrate = 1;
  6662. tradecell.Update();
  6663. }
  6664. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6665. returnSuccessMsg("操作成功!");
  6666. return;
  6667. }
  6668. returnErrorMsg("找不到订单记录");
  6669. }
  6670. }
  6671. public void upd_erp_backaftersale()
  6672. {
  6673. if (UrlPostParmsCheck("tid"))
  6674. {
  6675. string eid = GetPostString("tid");
  6676. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6677. int backNum = 0;
  6678. if (number != null)
  6679. {
  6680. backNum = number.BackNum;
  6681. }
  6682. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6683. CeErpTradeCell entity = null;
  6684. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6685. if (entity != null)
  6686. {
  6687. entity.AfterSaleBackReason = GetPostString("backreason");
  6688. entity.AfterSaleState = 1;
  6689. entity.AfterSaleSupplierState = 0;
  6690. entity.Update();
  6691. returnSuccessMsg("操作成功!");
  6692. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6693. return;
  6694. }
  6695. returnErrorMsg("找不到订单记录");
  6696. }
  6697. }
  6698. public void get_erp_supplieraftersalelist()
  6699. {
  6700. DataStruct dStruct = GetPostStruct();
  6701. List<string> lw = new List<string>();
  6702. string tid = GetPostString("ctid");
  6703. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6704. string shopname = GetPostString("shopname");
  6705. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6706. string buyernick = GetPostString("buyer_nick");
  6707. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6708. string sellermemo = GetPostString("seller_memo");
  6709. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6710. string orderState = GetPostString("orderState");
  6711. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6712. string afterState = GetPostString("afterstate");
  6713. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6714. string date1 = GetPostString("date1");
  6715. string date2 = GetPostString("date2");
  6716. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6717. if (dw.Length > 0) lw.Add(dw);
  6718. string price1 = GetPostString("price1");
  6719. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6720. string price2 = GetPostString("price2");
  6721. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6722. string reason = GetPostString("reason");
  6723. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6724. string method = GetPostString("method");
  6725. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6726. string handledate1 = GetPostString("handledate1");
  6727. string handledate2 = GetPostString("handledate2");
  6728. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6729. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6730. string handler = GetPostString("handler");
  6731. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6732. string afterdate1 = GetPostString("afterdate1");
  6733. string afterdate2 = GetPostString("afterdate2");
  6734. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6735. if (afterDate.Length > 0) lw.Add(afterDate);
  6736. string customer = GetPostString("customer");
  6737. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6738. string design = GetPostString("design");
  6739. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6740. string afterMemoType = GetPostString("aftermemotype");
  6741. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6742. string vstate = GetPostString("vstate");
  6743. if (vstate.Length > 0)
  6744. {
  6745. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6746. }
  6747. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6748. string supplier = GetPostString("supplier");
  6749. int supid = commonHelper.getSupplierIDByName(supplier);
  6750. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6751. string posCode = CurrentUser.UserPost.Post.Code;
  6752. if (posCode == "Supplier")
  6753. {
  6754. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6755. }
  6756. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6757. {
  6758. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6759. }
  6760. else
  6761. {
  6762. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6763. }
  6764. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6765. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6766. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6767. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6768. writeGridDataTableJson(dStruct.TotalCount, dt);
  6769. }
  6770. public void upd_erp_supverifyaftersale()
  6771. {
  6772. if (UrlPostParmsCheck("id"))
  6773. {
  6774. string id = GetPostString("id");
  6775. int st = GetPostInt("afterstate");
  6776. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6777. CeErpTradeCell entity = null;
  6778. if (ceErpTradeResponsible != null)
  6779. {
  6780. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6781. }
  6782. string afmemo = GetPostString("supmemo");
  6783. string image = GetPostString("image");
  6784. if (entity != null)
  6785. {
  6786. entity.AfterSaleSupplierState = st;
  6787. entity.AfterSaleSupplierMemo = afmemo;
  6788. entity.AfterSaleSupplierState = st;
  6789. if (st == 1)
  6790. {
  6791. ceErpTradeResponsible.VerifyState = 1;
  6792. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6793. ceErpTradeResponsible.Update();
  6794. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6795. if (isAll)
  6796. {
  6797. entity.AfterSaleState = 4;
  6798. entity.FinishAfterSaleTime = DateTime.Now;
  6799. }
  6800. }
  6801. else
  6802. {
  6803. CeErpTradeResponsible.dateByTid(entity.ctid);
  6804. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6805. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6806. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6807. if (num <= 1)
  6808. {
  6809. entity.AfterSaleState = 1;
  6810. }
  6811. else
  6812. {
  6813. entity.AfterSaleState = 5;
  6814. }
  6815. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6816. if (ceErpTradeAfterSaleExtend != null)
  6817. {
  6818. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6819. if (entity.AfterSaleState == 1)
  6820. {
  6821. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6822. }
  6823. else
  6824. {
  6825. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6826. }
  6827. ceErpTradeAfterSaleExtend.Update();
  6828. }
  6829. else
  6830. {
  6831. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6832. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6833. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6834. if (entity.AfterSaleState == 1)
  6835. {
  6836. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6837. }
  6838. else
  6839. {
  6840. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6841. }
  6842. ceErpTradeAfterSaleExtend.Create();
  6843. }
  6844. }
  6845. if (entity.AfterSaleState == 4)
  6846. {
  6847. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6848. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6849. {
  6850. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6851. }
  6852. ApiVo apiVo = new ApiVo();
  6853. apiVo.orderNumber = entity.ctid;
  6854. apiVo.actionName = "afterOver";
  6855. designHelper.API_WorkCore(apiVo); //afterOver
  6856. }
  6857. entity.Update();
  6858. returnSuccessMsg("操作成功!");
  6859. CeErpSukuraData.createInfo(entity.ctid, 8);
  6860. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6861. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6862. return;
  6863. }
  6864. returnErrorMsg("找不到订单记录");
  6865. }
  6866. }
  6867. public void upd_erp_masteraftersale()
  6868. {
  6869. if (UrlPostParmsCheck("id"))
  6870. {
  6871. string id = GetPostString("id");
  6872. int st = GetPostInt("afterstate");
  6873. string afmemo = GetPostString("supmemo");
  6874. string image = GetPostString("image");
  6875. string textResult = GetPostString("textResult");
  6876. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6877. if (ceErpTradeResponsible != null)
  6878. {
  6879. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6880. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6881. ceErpTradeResponsible.Update();
  6882. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6883. if (entity != null)
  6884. {
  6885. entity.AfterSaleSupplierState = st;
  6886. entity.AfterSaleSupplierMemo = afmemo;
  6887. if (st == 1)
  6888. {
  6889. }
  6890. else
  6891. {
  6892. CeErpTradeResponsible.dateByTid(entity.ctid);
  6893. //退回到售后
  6894. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6895. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6896. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6897. if (num <= 1)
  6898. {
  6899. entity.AfterSaleState = 1;
  6900. }
  6901. else
  6902. {
  6903. entity.AfterSaleState = 5;
  6904. }
  6905. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6906. if (ceErpTradeAfterSaleExtend != null)
  6907. {
  6908. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6909. if (entity.AfterSaleState == 1)
  6910. {
  6911. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6912. }
  6913. else
  6914. {
  6915. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6916. }
  6917. ceErpTradeAfterSaleExtend.Update();
  6918. }
  6919. else
  6920. {
  6921. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6922. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6923. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6924. if (entity.AfterSaleState == 1)
  6925. {
  6926. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6927. }
  6928. else
  6929. {
  6930. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6931. }
  6932. ceErpTradeAfterSaleExtend.Create();
  6933. }
  6934. }
  6935. entity.Update();
  6936. returnSuccessMsg("操作成功!");
  6937. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6938. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6939. return;
  6940. }
  6941. }
  6942. returnErrorMsg("找不到订单记录");
  6943. }
  6944. }
  6945. public void upd_erp_personaftersale()
  6946. {
  6947. if (UrlPostParmsCheck("id"))
  6948. {
  6949. string id = GetPostString("id");
  6950. int st = GetPostInt("afterstate");
  6951. string afmemo = GetPostString("supmemo");
  6952. string image = GetPostString("image");
  6953. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6954. if (ceErpTradeResponsible != null)
  6955. {
  6956. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  6957. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6958. ceErpTradeResponsible.Update();
  6959. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6960. if (entity != null)
  6961. {
  6962. entity.AfterSaleSupplierMemo = afmemo;
  6963. entity.AfterSaleSupplierState = st;
  6964. if (st == 1)
  6965. {
  6966. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6967. if (isAll)
  6968. {
  6969. entity.AfterSaleState = 4;
  6970. entity.FinishAfterSaleTime = DateTime.Now;
  6971. }
  6972. }
  6973. else
  6974. {
  6975. CeErpTradeResponsible.dateByTid(entity.ctid);
  6976. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6977. if (ceErpTradeAfterSaleExtend != null)
  6978. {
  6979. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6980. ceErpTradeAfterSaleExtend.Update();
  6981. }
  6982. else
  6983. {
  6984. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6985. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6986. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6987. ceErpTradeAfterSaleExtend.Create();
  6988. }
  6989. //退回到主管
  6990. //entity.AfterSaleState = 2;
  6991. }
  6992. if (entity.AfterSaleState == 4)
  6993. {
  6994. ApiVo apiVo = new ApiVo();
  6995. apiVo.orderNumber = entity.ctid;
  6996. apiVo.actionName = "afterOver";
  6997. designHelper.API_WorkCore(apiVo); //afterOver
  6998. }
  6999. entity.Update();
  7000. returnSuccessMsg("操作成功!");
  7001. CeErpSukuraData.createInfo(entity.ctid, 8);
  7002. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7003. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7004. return;
  7005. }
  7006. }
  7007. returnErrorMsg("找不到订单记录");
  7008. }
  7009. }
  7010. public void set_erp_supplierrefundtag()
  7011. {
  7012. if (UrlPostParmsCheck("ctid"))
  7013. {
  7014. string eid = GetPostString("ctid");
  7015. CeErpTradeCell entity = null;
  7016. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7017. if (entity != null)
  7018. {
  7019. entity.IsSupplierRefund = GetPostInt("tag");
  7020. entity.Update();
  7021. returnSuccessMsg("操作成功!");
  7022. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7023. return;
  7024. }
  7025. returnErrorMsg("找不到订单记录");
  7026. }
  7027. }
  7028. public void get_erp_refundlist()
  7029. {
  7030. DataStruct dStruct = GetPostStruct();
  7031. List<string> lw = new List<string>();
  7032. string tid = GetPostString("tid");
  7033. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7034. //string rid = GetPostString("refund_id");
  7035. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7036. string shopname = GetPostString("shopname");
  7037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7038. string buyernick = GetPostString("buyer_nick");
  7039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7040. string customer = GetPostString("customer");
  7041. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7042. string design = GetPostString("design");
  7043. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7044. string sellermemo = GetPostString("seller_memo");
  7045. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7046. //string date1 = GetPostString("date1");
  7047. //string date2 = GetPostString("date2");
  7048. //string dateType = GetPostString("dateType");
  7049. //if (dateType.Length > 0)
  7050. //{
  7051. // if (dateType == "1001") dateType = "0";
  7052. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7053. // if (searchDT.Count == 2)
  7054. // {
  7055. // date1 = searchDT[0].ToString();
  7056. // date2 = searchDT[1].ToString();
  7057. // }
  7058. //}
  7059. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7060. //if (dw.Length > 0) lw.Add(dw);
  7061. string redate1 = GetPostString("refunddate1");
  7062. string redate2 = GetPostString("refunddate2");
  7063. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7064. if (dwdate.Length > 0) lw.Add(dwdate);
  7065. string price1 = GetPostString("price1");
  7066. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7067. string price2 = GetPostString("price2");
  7068. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7069. string ispartrefund = GetPostString("ispartrefund");
  7070. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7071. string refundState = GetPostString("refundvstate");
  7072. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7073. int st = GetInt("st");
  7074. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7075. {
  7076. string responsible = GetPostString("responsibleman");
  7077. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7078. lw.Add(string.Format("RefundState>={0}", st));
  7079. string code = CurrentUser.UserPost.Post.Code;
  7080. if (code == "CustomerService")
  7081. {
  7082. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7083. }
  7084. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7085. {
  7086. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7087. }
  7088. else if (code == "Place" || code == "PlaceMr")
  7089. {
  7090. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7091. }
  7092. dStruct.Order = "RefundState asc,created desc";
  7093. }
  7094. else if (st == 10)
  7095. {
  7096. string responsible = GetPostString("responsibleman");
  7097. if (responsible == "空白")
  7098. {
  7099. lw.Add(string.Format("ResponsibleUserName = ''"));
  7100. }
  7101. else if (responsible.Length > 0)
  7102. {
  7103. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7104. }
  7105. lw.Add(string.Format("RefundState>=0"));
  7106. dStruct.Order = "created desc";
  7107. }
  7108. else
  7109. {
  7110. string responsible = GetPostString("responsibleman");
  7111. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7112. lw.Add(string.Format("RefundState={0}", st));
  7113. dStruct.Order = "created desc";
  7114. }
  7115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7116. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7117. dt.Columns.Add("refund_fees");
  7118. foreach (DataRow dr in dt.Rows)
  7119. {
  7120. String status = dr["status"].ToString();
  7121. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7122. {
  7123. dr["refund_fees"] = dr["refund_fee"];
  7124. }
  7125. else
  7126. {
  7127. dr["refund_fees"] = "0.0";
  7128. }
  7129. }
  7130. writeGridDataTableJson(dStruct.TotalCount, dt);
  7131. }
  7132. public void handle_erp_refundtag()
  7133. {
  7134. if (UrlPostParmsCheck("refund_id"))
  7135. {
  7136. string eid = GetPostString("refund_id");
  7137. string respMan = GetPostString("ResponsibleName");
  7138. if (respMan.Length <= 0)
  7139. {
  7140. returnErrorMsg("责任人不能为空");
  7141. return;
  7142. }
  7143. CeErpTradeRefund entity = null;
  7144. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7145. if (entity != null)
  7146. {
  7147. entity.ResponsibleUserName = respMan;
  7148. string userid = GetPostString("ResponsibleUserId");
  7149. if (userid.Length > 0)
  7150. {
  7151. entity.ResponsibleUserId = userid;
  7152. }
  7153. entity.Memo = GetPostString("Memo");
  7154. if (respMan.IndexOf("客服") != -1 ||
  7155. respMan.IndexOf("设计师") != -1 ||
  7156. respMan.IndexOf("下单员") != -1)
  7157. {
  7158. entity.RefundState = 2;
  7159. }
  7160. else
  7161. {
  7162. entity.RefundState = 3;
  7163. }
  7164. entity.modified = DateTime.Now;
  7165. entity.Update();
  7166. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7167. returnSuccessMsg("操作成功!");
  7168. return;
  7169. }
  7170. returnErrorMsg("找不到订单记录");
  7171. }
  7172. }
  7173. public void upd_erp_refundverify()
  7174. {
  7175. if (UrlPostParmsCheck("refund_id"))
  7176. {
  7177. string eid = GetPostString("refund_id");
  7178. CeErpTradeRefund entity = null;
  7179. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7180. if (entity != null)
  7181. {
  7182. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7183. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7184. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7185. {
  7186. entity.RefundState = 2;
  7187. }
  7188. else
  7189. {
  7190. entity.RefundState = 3;
  7191. }
  7192. entity.Update();
  7193. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7194. returnSuccessMsg("操作成功!");
  7195. return;
  7196. }
  7197. returnErrorMsg("找不到订单记录");
  7198. }
  7199. }
  7200. public void upd_erp_refundapprove()
  7201. {
  7202. if (UrlPostParmsCheck("refund_id"))
  7203. {
  7204. string eid = GetPostString("refund_id");
  7205. CeErpTradeRefund entity = null;
  7206. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7207. if (entity != null)
  7208. {
  7209. int apr = GetPostInt("approve");
  7210. if (apr == 0)
  7211. {
  7212. entity.RefundState = 1;
  7213. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7214. }
  7215. else if (apr == 1)
  7216. {
  7217. entity.RefundState = 3;
  7218. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7219. }
  7220. entity.modified = DateTime.Now;
  7221. entity.Update();
  7222. returnSuccessMsg("操作成功!");
  7223. return;
  7224. }
  7225. returnErrorMsg("找不到订单记录");
  7226. }
  7227. }
  7228. public void get_erp_billlist()
  7229. {
  7230. DataStruct dStruct = GetPostStruct();
  7231. List<string> lw = new List<string>();
  7232. string title = GetPostString("title");
  7233. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7234. string tid = GetPostString("tid");
  7235. string tids = GetPostString("tids");
  7236. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7237. if (tids.Length > 0)
  7238. {
  7239. tids = "'" + tids + "'";
  7240. tids = tids.Replace(",", "','");
  7241. lw.Add(string.Format("tid in ({0})", tids));
  7242. }
  7243. string shopname = GetPostString("shopname");
  7244. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7245. string buyernick = GetPostString("buyer_nick");
  7246. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7247. string customer = GetPostString("customer");
  7248. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7249. string date1 = GetPostString("date1");
  7250. string date2 = GetPostString("date2");
  7251. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7252. if (dw.Length > 0) lw.Add(dw);
  7253. string price1 = GetPostString("price1");
  7254. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7255. string price2 = GetPostString("price2");
  7256. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7257. string returndate1 = GetPostString("returndate1");
  7258. string returndate2 = GetPostString("returndate2");
  7259. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7260. if (dw1.Length > 0) lw.Add(dw1);
  7261. string billtype = GetPostString("billtype");
  7262. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7263. string billstate = GetPostString("billstate");
  7264. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7265. string usershop = CurrentUser.User.pemShop;
  7266. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7267. dStruct.Order = "createTime desc";
  7268. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7269. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7270. //foreach (DataRow dr in dt.Rows)
  7271. //{
  7272. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7273. //}
  7274. writeGridDataTableJson(dStruct.TotalCount, dt);
  7275. }
  7276. public void modify_erp_billinfo()
  7277. {
  7278. if (UrlPostParmsCheck("ID"))
  7279. {
  7280. string eid = GetPostString("ID");
  7281. CeErpBill bill_entity = null;
  7282. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7283. if (bill_entity != null)
  7284. {
  7285. bill_entity.tid = GetPostString("tid");
  7286. bill_entity.title = GetPostString("title");
  7287. bill_entity.tax = GetPostString("tax");
  7288. bill_entity.bank = GetPostString("bank");
  7289. bill_entity.bankac = GetPostString("bankac");
  7290. bill_entity.address = GetPostString("address");
  7291. bill_entity.phone = GetPostString("phone");
  7292. bill_entity.price = GetPostString("price");
  7293. bill_entity.productId = GetPostInt("ProductName");
  7294. bill_entity.num = GetPostInt("num");
  7295. bill_entity.unit = GetPostString("unit");
  7296. bill_entity.type = GetPostString("type");
  7297. bill_entity.sendType = GetPostString("SendType");
  7298. bill_entity.email = GetPostString("email");
  7299. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7300. bill_entity.shopName = GetPostString("ShopName");
  7301. bill_entity.applymemo = GetPostString("applymemo");
  7302. bill_entity.modifyTime = DateTime.Now;
  7303. bill_entity.createTime = DateTime.Now;
  7304. bill_entity.state = 0;
  7305. bill_entity.Update();
  7306. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7307. returnSuccessMsg("发票修改成功!");
  7308. return;
  7309. }
  7310. returnErrorMsg("找不到对应记录");
  7311. }
  7312. }
  7313. public void set_erp_invoicing()
  7314. {
  7315. if (UrlPostParmsCheck("id"))
  7316. {
  7317. try
  7318. {
  7319. string eid = GetPostString("id");
  7320. CeErpBill bill_entity = null;
  7321. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7322. if (bill_entity != null)
  7323. {
  7324. int ComId = GetPostInt("ComId");
  7325. //string memo = GetPostString("Memo");
  7326. int allInfo = GetPostInt("allinfo");
  7327. string clert = CurrentUser.User.Name;
  7328. //string detailValue = GetPostString("detailvalue");
  7329. string billId = bill_entity.billOrderId;
  7330. string[] billIdList = billId.Split(',');
  7331. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7332. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7333. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7334. {
  7335. billCount += 1;
  7336. }
  7337. if (billId.Length <= 0 || billIdList.Length != billCount)
  7338. {
  7339. bill_entity.billOrderId = "";
  7340. string prebill = "ltb";
  7341. for (int idx = 1; idx <= billCount; idx++)
  7342. {
  7343. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7344. string billoid = prebill + idx + dtstr;
  7345. bill_entity.billOrderId += billoid;
  7346. if (idx < billCount)
  7347. {
  7348. bill_entity.billOrderId += ",";
  7349. }
  7350. }
  7351. }
  7352. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7353. if (bill_entity.state == 5)
  7354. {
  7355. string errMsg = bill_entity.failerror;
  7356. string[] errlist = errMsg.Split('|');
  7357. string[] errTags = new string[errlist.Length];
  7358. for (int itag = 0; itag < errlist.Length; itag++)
  7359. {
  7360. if (errlist[itag].Length <= 0) continue;
  7361. errTags[itag] = errlist[itag].Split('&')[0];
  7362. }
  7363. for (int iii = 0; iii < errTags.Length; iii++)
  7364. {
  7365. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7366. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7367. if (billOrderList.Length >= erroBillOrderTag)
  7368. {
  7369. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7370. if (needModifyBillId.Length <= 19)
  7371. {
  7372. needModifyBillId = needModifyBillId + "1";
  7373. }
  7374. else
  7375. {
  7376. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7377. last = last + 1;
  7378. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7379. }
  7380. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7381. }
  7382. }
  7383. }
  7384. bool isHaveBillSucces = false;
  7385. string totalRes = "";
  7386. bill_entity.failerror = "";
  7387. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7388. {
  7389. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7390. totalRes += res;
  7391. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7392. {
  7393. isHaveBillSucces = true;
  7394. bill_entity.comId = ComId;
  7395. bill_entity.state = 1;
  7396. bill_entity.executeTime = DateTime.Now;
  7397. bill_entity.executeUser = clert;
  7398. }
  7399. else
  7400. {
  7401. bill_entity.state = 5;
  7402. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7403. }
  7404. }
  7405. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7406. bill_entity.Update();
  7407. if (isHaveBillSucces)
  7408. {
  7409. StringBuilder sql = new StringBuilder();
  7410. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7411. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7412. }
  7413. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7414. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7415. {
  7416. returnErrorMsg("开票失败");
  7417. }
  7418. else
  7419. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7420. return;
  7421. }
  7422. returnErrorMsg("找不到对应记录");
  7423. }
  7424. catch (Exception ex)
  7425. {
  7426. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7427. returnErrorMsg("操作失败");
  7428. }
  7429. }
  7430. }
  7431. public void get_erp_invoicing_back()
  7432. {
  7433. if (UrlPostParmsCheck("id"))
  7434. {
  7435. try
  7436. {
  7437. string id = GetPostString("id");
  7438. CeErpBill entiy = CeErpBill.Get(id);
  7439. if (entiy != null)
  7440. {
  7441. if (entiy.state == 0)
  7442. {
  7443. returnErrorMsg("发票还未开具");
  7444. return;
  7445. }
  7446. string[] billOrderList = entiy.billOrderId.Split(',');
  7447. int iTag = 0;
  7448. entiy.fplsh = "";
  7449. entiy.fpdm = "";
  7450. entiy.fphm = "";
  7451. foreach (string billOrderId in billOrderList)
  7452. {
  7453. iTag++;
  7454. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7455. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7456. {
  7457. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7458. try
  7459. {
  7460. Invoicing_get_response_Obj iObj = null;
  7461. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7462. if (iObj != null)
  7463. {
  7464. entiy.state = 2;
  7465. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7466. entiy.fpdm += iObj.list[0].c_fpdm;
  7467. entiy.fphm += iObj.list[0].c_fphm;
  7468. if (iTag < billOrderList.Length)
  7469. {
  7470. entiy.fplsh += ",";
  7471. entiy.fpdm += ",";
  7472. entiy.fphm += ",";
  7473. }
  7474. entiy.Update();
  7475. }
  7476. StringBuilder sql = new StringBuilder();
  7477. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7478. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7479. returnSuccessMsg("开票成功");
  7480. }
  7481. catch (Exception ex)
  7482. {
  7483. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7484. }
  7485. return;
  7486. }
  7487. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7488. {
  7489. var res_obj = new
  7490. {
  7491. data = "开票中"
  7492. };
  7493. string ro_json = JsonConvert.SerializeObject(res_obj);
  7494. returnSuccess(ro_json);
  7495. return;
  7496. }
  7497. else
  7498. {
  7499. int eidx = res.IndexOf("c_resultmsg");
  7500. int lidx = res.IndexOf("c_status");
  7501. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7502. entiy.state = 5;
  7503. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7504. entiy.Update();
  7505. returnErrorMsg("开票失败");
  7506. return;
  7507. }
  7508. }
  7509. }
  7510. }
  7511. catch (Exception ex)
  7512. {
  7513. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7514. }
  7515. return;
  7516. }
  7517. }
  7518. public void get_erp_invoicing()
  7519. {
  7520. if (UrlPostParmsCheck("id"))
  7521. {
  7522. try
  7523. {
  7524. string id = GetPostString("id");
  7525. CeErpBill entiy = CeErpBill.Get(id);
  7526. if (entiy != null)
  7527. {
  7528. if (entiy.state == 0)
  7529. {
  7530. returnErrorMsg("发票还未开具");
  7531. return;
  7532. }
  7533. if (entiy.sendType == "纸质发票")
  7534. {
  7535. if (entiy.img.Length <= 0)
  7536. {
  7537. returnErrorMsg("查无纸质发票");
  7538. return;
  7539. }
  7540. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7541. returnSuccess(returnres);
  7542. return;
  7543. }
  7544. string[] billOrderList = entiy.billOrderId.Split(',');
  7545. int iTag = 0;
  7546. string fpUrl = "";
  7547. entiy.fplsh = "";
  7548. entiy.fpdm = "";
  7549. entiy.fphm = "";
  7550. foreach (string billOrderId in billOrderList)
  7551. {
  7552. iTag++;
  7553. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7554. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7555. {
  7556. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7557. Invoicing_get_response_Obj iObj = null;
  7558. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7559. if (iObj != null)
  7560. {
  7561. //entiy.state = 2;
  7562. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7563. entiy.fpdm += iObj.list[0].c_fpdm;
  7564. entiy.fphm += iObj.list[0].c_fphm;
  7565. if (iTag < billOrderList.Length)
  7566. {
  7567. entiy.fplsh += ",";
  7568. entiy.fpdm += ",";
  7569. entiy.fphm += ",";
  7570. }
  7571. entiy.Update();
  7572. fpUrl += iObj.list[0].c_url + ",";
  7573. }
  7574. //returnSuccess(res);
  7575. StringBuilder sql = new StringBuilder();
  7576. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7577. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7578. }
  7579. else
  7580. {
  7581. int eidx = res.IndexOf("c_resultmsg");
  7582. //int lidx = res.IndexOf("c_status");
  7583. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7584. //开票失败
  7585. entiy.state = 5;
  7586. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7587. entiy.Update();
  7588. returnErrorMsg("开票失败");
  7589. return;
  7590. }
  7591. }
  7592. var returnObj = new
  7593. {
  7594. data = fpUrl
  7595. };
  7596. string ro_json = JsonConvert.SerializeObject(returnObj);
  7597. returnSuccess(ro_json);
  7598. }
  7599. }
  7600. catch (Exception ex)
  7601. {
  7602. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7603. }
  7604. return;
  7605. }
  7606. }
  7607. public void save_erp_billimg()
  7608. {
  7609. if (UrlPostParmsCheck("id"))
  7610. {
  7611. string eid = GetPostString("id");
  7612. CeErpBill bill_entity = null;
  7613. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7614. if (bill_entity != null)
  7615. {
  7616. bill_entity.img = GetPostString("img");
  7617. bill_entity.executeTime = DateTime.Now;
  7618. bill_entity.state = 2;
  7619. bill_entity.Update();
  7620. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7621. returnSuccessMsg("保存成功");
  7622. }
  7623. return;
  7624. }
  7625. }
  7626. public void upd_erp_billreturnback()
  7627. {
  7628. if (UrlPostParmsCheck("id"))
  7629. {
  7630. int eid = GetPostInt("id");
  7631. CeErpBill bill_entity = null;
  7632. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7633. if (bill_entity != null)
  7634. {
  7635. bill_entity.state = 3;
  7636. bill_entity.returnReason = GetPostString("reason");
  7637. bill_entity.Update();
  7638. returnSuccessMsg("驳回成功!");
  7639. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7640. }
  7641. return;
  7642. }
  7643. }
  7644. public void cancel_erp_bill()
  7645. {
  7646. if (UrlPostParmsCheck("id"))
  7647. {
  7648. int eid = GetPostInt("id");
  7649. int detailValue = GetPostInt("detailvalue");
  7650. CeErpBill bill_entity = null;
  7651. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7652. string cres = "";
  7653. string gres = "";
  7654. if (bill_entity != null)
  7655. {
  7656. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7657. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7658. {
  7659. int iTag = 0;
  7660. bill_entity.fplsh = "";
  7661. bill_entity.fpdm = "";
  7662. bill_entity.fphm = "";
  7663. foreach (string billOrderId in billOrderList)
  7664. {
  7665. iTag++;
  7666. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7667. if (gres.IndexOf("success") != -1)
  7668. {
  7669. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7670. Invoicing_get_response_Obj iObj = null;
  7671. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7672. if (iObj != null)
  7673. {
  7674. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7675. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7676. bill_entity.fphm += iObj.list[0].c_fphm;
  7677. if (iTag < billOrderList.Length)
  7678. {
  7679. bill_entity.fplsh += ",";
  7680. bill_entity.fpdm += ",";
  7681. bill_entity.fphm += ",";
  7682. }
  7683. bill_entity.Update();
  7684. }
  7685. }
  7686. else
  7687. {
  7688. returnErrorMsg(gres);
  7689. return;
  7690. }
  7691. }
  7692. }
  7693. if (bill_entity.sendType == "纸质发票")
  7694. {
  7695. //作废
  7696. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7697. //if (DateTime.Now.Month == extime.Month)
  7698. //{
  7699. //cres = taobaoHelper.cancel_invoicing(eid);
  7700. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7701. //{
  7702. bill_entity.state = 4;//已作废
  7703. bill_entity.Update();
  7704. returnSuccessMsg("发票已作废");
  7705. return;
  7706. //}
  7707. //else
  7708. //{
  7709. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7710. // bill_entity.Update();
  7711. // returnErrorMsg(cres);
  7712. // return;
  7713. //}
  7714. //}
  7715. //else
  7716. //{
  7717. // returnErrorMsg("纸质发票只能作废本月的发票");
  7718. // return;
  7719. //}
  7720. }
  7721. //红冲
  7722. int redTag = 0;
  7723. string[] fpdmList = bill_entity.fpdm.Split(',');
  7724. string[] fphmList = bill_entity.fphm.Split(',');
  7725. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7726. {
  7727. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7728. return;
  7729. }
  7730. foreach (string billOrderId in billOrderList)
  7731. {
  7732. redTag++;
  7733. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7734. cres += onecres;
  7735. cres += ",";
  7736. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7737. {
  7738. bill_entity.state = 4;//已作废
  7739. //bill_entity.Update();
  7740. //returnSuccessMsg("发票已红冲");
  7741. }
  7742. else if (onecres.IndexOf("重复冲红") != -1)
  7743. {
  7744. bill_entity.state = 4;//已作废
  7745. //bill_entity.Update();
  7746. //returnSuccessMsg("发票已红冲");
  7747. }
  7748. else
  7749. {
  7750. string errmsg = commonHelper.KeepChinese(onecres);
  7751. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7752. }
  7753. }
  7754. bill_entity.Update();
  7755. if (cres.IndexOf("失败") != -1)
  7756. returnErrorMsg("红冲失败");
  7757. else
  7758. returnSuccessMsg("发票已红冲");
  7759. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7760. return;
  7761. }
  7762. return;
  7763. }
  7764. }
  7765. public void del_erp_billorder()
  7766. {
  7767. if (UrlPostParmsCheck("id"))
  7768. {
  7769. string eid = GetPostString("id");
  7770. CeErpBill.Del(eid);
  7771. CeErpBill bill = CeErpBill.Get(eid);
  7772. if (bill != null)
  7773. {
  7774. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7775. }
  7776. returnSuccessMsg("删除成功");
  7777. }
  7778. }
  7779. public void finish_erp_bill()
  7780. {
  7781. if (UrlPostParmsCheck("ids"))
  7782. {
  7783. string eids = GetPostString("ids");
  7784. string[] list = eids.Split(',');
  7785. foreach (string eid in list)
  7786. {
  7787. CeErpBill bill = CeErpBill.Get(eid);
  7788. if (bill != null)
  7789. {
  7790. bill.state = 2;
  7791. bill.Update();
  7792. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7793. }
  7794. }
  7795. returnSuccessMsg("操作成功");
  7796. }
  7797. }
  7798. public void get_erp_returncash()
  7799. {
  7800. DataStruct dStruct = GetPostStruct();
  7801. List<string> lw = new List<string>();
  7802. string tid = GetPostString("tid");
  7803. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7804. string shopname = GetPostString("shopname");
  7805. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7806. string buyernick = GetPostString("buyer_nick");
  7807. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7808. string customer = GetPostString("customer");
  7809. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7810. string returndate1 = GetPostString("returndate1");
  7811. string returndate2 = GetPostString("returndate2");
  7812. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  7813. if (dw.Length > 0) lw.Add(dw);
  7814. string finishDate1 = GetPostString("finishdate1");
  7815. string finishDate2 = GetPostString("finishdate2");
  7816. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  7817. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7818. string returntype = GetPostString("returntype");
  7819. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7820. string returnvstate = GetPostString("returnvstate");
  7821. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7822. dStruct.Order = "created desc";
  7823. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7824. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7825. writeGridDataTableJson(dStruct.TotalCount, dt);
  7826. }
  7827. public void get_erp_staygoods()
  7828. {
  7829. DataStruct dStruct = GetPostStruct();
  7830. List<string> lw = new List<string>();
  7831. string tid = GetPostString("tid");
  7832. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7833. string shopname = GetPostString("shopname");
  7834. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7835. string wangwang = GetPostString("wangwang");
  7836. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7837. string customer = GetPostString("customer");
  7838. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7839. string returndate1 = GetPostString("returndate1");
  7840. string returndate2 = GetPostString("returndate2");
  7841. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7842. if (dw.Length > 0) lw.Add(dw);
  7843. string finishDate1 = GetPostString("finishdate1");
  7844. string finishDate2 = GetPostString("finishdate2");
  7845. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7846. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7847. string returnvstate = GetPostString("returnvstate");
  7848. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  7849. string persuadetype = GetPostString("persuadetype");
  7850. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  7851. string customerOrg = GetPostString("customerOrg");
  7852. if (customerOrg.Length > 0)
  7853. {
  7854. lw.Add(string.Format("OrgID = {0}", customerOrg));
  7855. }
  7856. dStruct.Order = "creata_time desc";
  7857. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7858. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  7859. writeGridDataTableJson(dStruct.TotalCount, dt);
  7860. }
  7861. public void upd_erp_staygoods()
  7862. {
  7863. if (UrlPostParmsCheck("id"))
  7864. {
  7865. int eid = GetPostInt("id");
  7866. CeErpStayGoods entity = null;
  7867. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7868. if (entity != null)
  7869. {
  7870. entity.audit_type = 1;
  7871. entity.audit_time = DateTime.Now;
  7872. entity.audit_u_id = CurrentUser.UserID;
  7873. entity.audit_u_name = CurrentUser.UserName;
  7874. entity.Update();
  7875. returnSuccessMsg("审核成功!");
  7876. return;
  7877. }
  7878. returnErrorMsg("找不到订单记录");
  7879. }
  7880. }
  7881. public void upd_erp_stayGoodsback()
  7882. {
  7883. if (UrlPostParmsCheck("id"))
  7884. {
  7885. int eid = GetPostInt("id");
  7886. CeErpStayGoods entity = null;
  7887. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7888. if (entity != null)
  7889. {
  7890. entity.audit_text = GetPostString("reason");
  7891. entity.audit_type = 2;
  7892. entity.audit_time = DateTime.Now;
  7893. entity.audit_u_id = CurrentUser.UserID;
  7894. entity.audit_u_name = CurrentUser.UserName;
  7895. entity.Update();
  7896. returnSuccessMsg("退回成功!");
  7897. return;
  7898. }
  7899. returnErrorMsg("找不到订单记录");
  7900. }
  7901. }
  7902. public void upd_erp_returncashverify()
  7903. {
  7904. if (UrlPostParmsCheck("ID"))
  7905. {
  7906. int eid = GetPostInt("ID");
  7907. CeErpReturnCash entity = null;
  7908. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7909. if (entity != null)
  7910. {
  7911. entity.cashstate = 1;
  7912. entity.verifytime = DateTime.Now;
  7913. entity.verifyuserid = CurrentUser.UserID;
  7914. entity.Update();
  7915. returnSuccessMsg("审核成功!");
  7916. return;
  7917. }
  7918. returnErrorMsg("找不到订单记录");
  7919. }
  7920. }
  7921. public void upd_all_erp_returncashverify()
  7922. {
  7923. if (UrlPostParmsCheck("ID"))
  7924. {
  7925. String[] list = GetPostString("ID").Split(',');
  7926. CeErpReturnCash entity = null;
  7927. for (int i = 0; i < list.Length; i++)
  7928. {
  7929. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  7930. if (entity != null)
  7931. {
  7932. if (entity.cashstate == 1)
  7933. {
  7934. returnErrorMsg("已审核过的订单不需要在审核!");
  7935. return;
  7936. }
  7937. entity.cashstate = 1;
  7938. entity.verifytime = DateTime.Now;
  7939. entity.verifyuserid = CurrentUser.UserID;
  7940. entity.Update();
  7941. }
  7942. }
  7943. returnSuccessMsg("审核成功!");
  7944. return;
  7945. }
  7946. }
  7947. public void upd_erp_returncashback()
  7948. {
  7949. if (UrlPostParmsCheck("ID"))
  7950. {
  7951. int eid = GetPostInt("ID");
  7952. CeErpReturnCash entity = null;
  7953. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7954. if (entity != null)
  7955. {
  7956. entity.backreason = GetPostString("reason");
  7957. entity.cashstate = 2;
  7958. entity.verifytime = DateTime.Now;
  7959. entity.verifyuserid = CurrentUser.UserID;
  7960. entity.Update();
  7961. returnSuccessMsg("退回成功!");
  7962. return;
  7963. }
  7964. returnErrorMsg("找不到订单记录");
  7965. }
  7966. }
  7967. public void upd_erp_returnprice()
  7968. {
  7969. if (UrlPostParmsCheck("ID"))
  7970. {
  7971. int eid = GetPostInt("ID");
  7972. CeErpReturnCash entity = null;
  7973. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7974. if (entity != null)
  7975. {
  7976. if (entity.cashstate == 1)
  7977. {
  7978. returnErrorMsg("审核通过了不能改");
  7979. return;
  7980. }
  7981. entity.returnprice = GetPostDouble("returnprice");
  7982. entity.Update();
  7983. returnSuccessMsg("修改成功!");
  7984. return;
  7985. }
  7986. returnErrorMsg("找不到订单记录");
  7987. }
  7988. }
  7989. public void del_erp_returncash()
  7990. {
  7991. if (UrlPostParmsCheck("ID"))
  7992. {
  7993. int eid = GetPostInt("ID");
  7994. CeErpReturnCash.Del(eid);
  7995. returnSuccessMsg("操作成功");
  7996. return;
  7997. }
  7998. }
  7999. public void test_for_do_sql()
  8000. {
  8001. string sql = GetPostString("sqlstr");
  8002. if (sql.Length > 0)
  8003. {
  8004. try
  8005. {
  8006. DbHelper.DbConn.ExecuteNonQuery(sql);
  8007. var res_obj = new
  8008. {
  8009. data = "成功",
  8010. };
  8011. string ro_json = JsonConvert.SerializeObject(res_obj);
  8012. returnSuccess(ro_json);
  8013. }
  8014. catch (Exception ex)
  8015. {
  8016. var res_obj = new
  8017. {
  8018. data = ex.Message,
  8019. };
  8020. string ro_json = JsonConvert.SerializeObject(res_obj);
  8021. returnSuccess(ro_json);
  8022. }
  8023. }
  8024. }
  8025. public void get_user_info()
  8026. {
  8027. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8028. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8029. }
  8030. public void get_total_data()
  8031. {
  8032. int userId = CurrentUser.UserID;
  8033. string sql = "";
  8034. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8035. {
  8036. 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);
  8037. }
  8038. else
  8039. {
  8040. 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 " +
  8041. "(select ID from CE_ErpUser where ID = {0}) d " +
  8042. "left join " +
  8043. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8044. ") a on d.ID = a.id left join " +
  8045. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8046. ") b on a.id = b.id1 left join" +
  8047. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8048. ") c on a.id = c.id2;", userId);
  8049. }
  8050. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8051. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8052. }
  8053. public void get_date_area_total_data2()
  8054. {
  8055. int userId = CurrentUser.UserID;
  8056. string date_type = GetPostString("timetype");
  8057. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8058. string sql = "";
  8059. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8060. {
  8061. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8062. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8063. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8064. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8065. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8066. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8067. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8068. ") a on e.ID = a.id left join " +
  8069. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8070. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8071. ") b on a.id = b.id1 " +
  8072. "left join " +
  8073. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8074. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8075. ") c on a.id = c.id2 " +
  8076. "left join " +
  8077. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8078. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8079. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8080. }
  8081. else
  8082. {
  8083. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8084. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8085. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8086. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8087. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8088. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8089. ") a on e.ID = a.id left join " +
  8090. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8091. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8092. ") c on a.id = c.id2 " +
  8093. "left join " +
  8094. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8095. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8096. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8097. }
  8098. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8099. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8100. }
  8101. public void get_date_area_total_data()
  8102. {
  8103. int userId = CurrentUser.UserID;
  8104. string date_type = GetPostString("timetype");
  8105. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8106. string date1 = searchDT[0].ToString();
  8107. string date2 = searchDT[1].ToString();
  8108. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8109. {
  8110. SqlParameter[] sqlParameter ={
  8111. new SqlParameter("@userId", SqlDbType.Int,4),
  8112. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8113. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8114. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8115. };
  8116. sqlParameter[0].Value = userId;
  8117. sqlParameter[1].Value = date1;
  8118. sqlParameter[2].Value = date2;
  8119. sqlParameter[3].Direction = ParameterDirection.Output;
  8120. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8121. string res = sqlParameter[3].Value.ToString();
  8122. var res_obj = new
  8123. {
  8124. data = res
  8125. };
  8126. string ro_json = JsonConvert.SerializeObject(res_obj);
  8127. returnSuccess(ro_json);
  8128. }
  8129. else
  8130. {
  8131. SqlParameter[] sqlParameter ={
  8132. new SqlParameter("@userId", SqlDbType.Int,4),
  8133. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8134. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8135. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8136. };
  8137. sqlParameter[0].Value = userId;
  8138. sqlParameter[1].Value = date1;
  8139. sqlParameter[2].Value = date2;
  8140. sqlParameter[3].Direction = ParameterDirection.Output;
  8141. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8142. string res = sqlParameter[3].Value.ToString();
  8143. var res_obj = new
  8144. {
  8145. data = res
  8146. };
  8147. string ro_json = JsonConvert.SerializeObject(res_obj);
  8148. returnSuccess(ro_json);
  8149. }
  8150. //writeGridDataViewJson(dt.Rows.Count, dv);
  8151. }
  8152. public void get_order_list()
  8153. {
  8154. string strFields = GetPostString("paraFields");
  8155. string strOrder = GetPostString("paraOrder");
  8156. string strWhere = GetPostString("paraWhere");
  8157. string strPageSize = GetPostString("paraPageSize");
  8158. DataStruct dStruct = GetPostStruct();
  8159. dStruct.PageSize = int.Parse(strPageSize);
  8160. dStruct.Fileds = strFields;
  8161. dStruct.Order = strOrder;
  8162. dStruct.MainWhere = strWhere;
  8163. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8164. writeGridDataTableJson(dStruct.TotalCount, dt);
  8165. }
  8166. ////获取待开始订单列表
  8167. //public void get_wait_design_order_list()
  8168. //{
  8169. // string date_type = GetPostString("date_type");
  8170. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8171. // DataStruct dStruct = GetPostStruct();
  8172. // dStruct.PageSize = 1000;
  8173. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8174. // List<string> lw = new List<string>();
  8175. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8176. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8177. // dStruct.Order = "WaitDesignTime asc";
  8178. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8179. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8180. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8181. //}
  8182. //获取完成单量排名
  8183. public void get_finish_order_count_ranking()
  8184. {
  8185. /* string date_type = GetPostString("date_type");
  8186. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8187. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8188. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8189. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8190. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8191. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8192. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8193. writeGridDataTableJson(0, new DataTable());
  8194. }
  8195. public void get_finish_order_amount_ranking()
  8196. {
  8197. /*string date_type = GetPostString("date_type");
  8198. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8199. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8200. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8201. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8202. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8203. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8204. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8205. writeGridDataTableJson(0, new DataTable());
  8206. }
  8207. public void get_finish_refund_count_ranking()
  8208. {
  8209. string date_type = GetPostString("date_type");
  8210. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8211. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8212. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8213. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8214. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8215. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8216. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8217. writeGridDataTableJson(dt.Rows.Count, dt);
  8218. }
  8219. public void get_finish_refund_amount_ranking()
  8220. {
  8221. string date_type = GetPostString("date_type");
  8222. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8223. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8224. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8225. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8226. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8227. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8228. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8229. writeGridDataTableJson(dt.Rows.Count, dt);
  8230. }
  8231. public void set_erp_finishorder_director()
  8232. {
  8233. if (UrlPostParmsCheck("ctid"))
  8234. {
  8235. string eid = GetPostString("ctid");
  8236. CeErpTradeCell entity = null;
  8237. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8238. if (entity != null)
  8239. {
  8240. entity.OrderState = 8;
  8241. entity.Update();
  8242. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8243. returnSuccessMsg("操作成功!");
  8244. return;
  8245. }
  8246. returnErrorMsg("找不到记录");
  8247. }
  8248. }
  8249. public void get_erp_placeregistlist()
  8250. {
  8251. DataStruct dStruct = GetPostStruct();
  8252. List<string> lw = new List<string>();
  8253. string outsid = GetPostString("outsid");
  8254. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8255. string memo = GetPostString("memo");
  8256. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8257. string filename = GetPostString("filename");
  8258. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8259. string islate = GetPostString("islate");
  8260. if (islate.Length > 0)
  8261. {
  8262. if (islate == "1")
  8263. lw.Add(string.Format("OutLate>0"));
  8264. else
  8265. lw.Add(string.Format("OutLate=0"));
  8266. }
  8267. string placedate1 = GetPostString("placedate1");
  8268. string placedate2 = GetPostString("placedate2");
  8269. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8270. if (dw.Length > 0) lw.Add(dw);
  8271. string deliveryDate1 = GetPostString("deliverydate1");
  8272. string deliveryDate2 = GetPostString("deliverydate2");
  8273. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8274. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8275. dStruct.Order = "ID desc";
  8276. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8277. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8278. writeGridDataTableJson(dStruct.TotalCount, dt);
  8279. }
  8280. public void ins_erp_placeregist()
  8281. {
  8282. if (UrlPostParmsCheck("id"))
  8283. {
  8284. string eid = GetPostString("id");
  8285. CeErpPlaceRegister entity = null;
  8286. if (eid == "0")//新增
  8287. {
  8288. entity = new CeErpPlaceRegister();
  8289. string xdTime = GetPostString("placeTime");
  8290. if (xdTime.Length > 0)
  8291. {
  8292. entity.PlactTime = Convert.ToDateTime(xdTime);
  8293. }
  8294. string fhTime = GetPostString("deliveryTime");
  8295. if (fhTime.Length > 0)
  8296. {
  8297. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8298. }
  8299. string preTime = GetPostString("preOutTime");
  8300. if (preTime.Length > 0)
  8301. {
  8302. entity.PreOutTime = Convert.ToDateTime(preTime);
  8303. }
  8304. entity.DeliveryCount = GetPostInt("deliveryCount");
  8305. entity.ReceiveCount = GetPostInt("receiveCount");
  8306. entity.OutSid = GetPostString("outSid");
  8307. entity.FileName = GetPostString("fileName");
  8308. entity.Memo = GetPostString("memo");
  8309. entity.AddUserId = CurrentUser.UserID;
  8310. entity.CreateTime = DateTime.Now;
  8311. entity.Img = GetPostString("img");
  8312. entity.Supplier = GetPostInt("supplier");
  8313. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8314. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8315. {
  8316. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8317. DateTime dt2 = (DateTime)entity.PreOutTime;
  8318. TimeSpan span = dt1.Subtract(dt2);
  8319. if (span.Days > 0)
  8320. {
  8321. entity.OutLate = span.Days;
  8322. }
  8323. }
  8324. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8325. entity.Create();
  8326. returnSuccessMsg("添加成功!");
  8327. return;
  8328. }
  8329. else //修改
  8330. {
  8331. entity = CeErpPlaceRegister.Get(eid);
  8332. if (entity != null)
  8333. {
  8334. string xdTime = GetPostString("placeTime");
  8335. if (xdTime.Length > 0)
  8336. {
  8337. entity.PlactTime = Convert.ToDateTime(xdTime);
  8338. }
  8339. string fhTime = GetPostString("deliveryTime");
  8340. if (fhTime.Length > 0)
  8341. {
  8342. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8343. }
  8344. string preTime = GetPostString("preOutTime");
  8345. if (preTime.Length > 0)
  8346. {
  8347. entity.PreOutTime = Convert.ToDateTime(preTime);
  8348. }
  8349. entity.DeliveryCount = GetPostInt("deliveryCount");
  8350. entity.ReceiveCount = GetPostInt("receiveCount");
  8351. if (entity.DeliveryCount == entity.ReceiveCount)
  8352. {
  8353. entity.CurState = "已完成";
  8354. }
  8355. else
  8356. {
  8357. entity.CurState = "未完成";
  8358. }
  8359. entity.OutSid = GetPostString("outSid");
  8360. entity.FileName = GetPostString("fileName");
  8361. entity.Memo = GetPostString("memo");
  8362. entity.Img = GetPostString("img");
  8363. entity.Supplier = GetPostInt("supplier");
  8364. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8365. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8366. {
  8367. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8368. DateTime dt2 = (DateTime)entity.PreOutTime;
  8369. TimeSpan span = dt1.Subtract(dt2);
  8370. if (span.Days > 0)
  8371. {
  8372. entity.OutLate = span.Days;
  8373. }
  8374. }
  8375. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8376. entity.Update();
  8377. returnSuccessMsg("修改成功");
  8378. return;
  8379. }
  8380. returnErrorMsg("找不到对应的记录");
  8381. return;
  8382. }
  8383. }
  8384. returnErrorMsg("缺少必要参数");
  8385. }
  8386. public void del_erp_placeregist()
  8387. {
  8388. string eid = GetPostString("id");
  8389. CeErpPlaceRegister.Del(eid);
  8390. returnSuccessMsg("删除成功!");
  8391. return;
  8392. }
  8393. public void ins_erp_placeregistbyorder()
  8394. {
  8395. string ctid = GetPostString("ctid");
  8396. if (ctid.Length > 0)
  8397. {
  8398. StringBuilder sql = new StringBuilder();
  8399. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8400. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8401. if (dt.Rows.Count > 0)
  8402. {
  8403. foreach (DataRow dr in dt.Rows)
  8404. {
  8405. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8406. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8407. entity.AddUserId = CurrentUser.UserID;
  8408. entity.tid = dr["tid"].ToString();
  8409. entity.Did = Convert.ToString(dr["ctid"]);
  8410. entity.splitTag = dr["SplitTag"].ToString();
  8411. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8412. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8413. if (pre_ctid.Length > 0)
  8414. {
  8415. sellmemo = sellmemo.Replace(pre_ctid, "");
  8416. }
  8417. sellmemo = sellmemo.Replace("[", "");
  8418. sellmemo = sellmemo.Replace("]", "");
  8419. entity.FileName = sellmemo;
  8420. string count = dr["ProductCount"].ToString();
  8421. int usecount = commonHelper.getIntCountFromString(count);
  8422. entity.DeliveryCount = usecount;
  8423. entity.CurState = "未完成";
  8424. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8425. {
  8426. entity.Supplier = 24;//dl手提袋定制
  8427. }
  8428. else
  8429. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8430. entity.CreateTime = DateTime.Now;
  8431. entity.Create();
  8432. }
  8433. returnSuccessMsg("操作成功");
  8434. return;
  8435. }
  8436. returnErrorMsg("没有找到对应订单");
  8437. return;
  8438. }
  8439. returnErrorMsg("缺少订单编号");
  8440. return;
  8441. }
  8442. public void get_erp_persuadelist()
  8443. {
  8444. DataStruct dStruct = GetPostStruct();
  8445. List<string> lw = new List<string>();
  8446. string ctid = GetPostString("ctid");
  8447. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8448. string shopname = GetPostString("shopname");
  8449. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8450. string buyernick = GetPostString("buyer_nick");
  8451. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8452. string customer = GetPostString("customer");
  8453. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8454. string returndate1 = GetPostString("returndate1");
  8455. string returndate2 = GetPostString("returndate2");
  8456. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8457. if (dw.Length > 0) lw.Add(dw);
  8458. string finishDate1 = GetPostString("finishdate1");
  8459. string finishDate2 = GetPostString("finishdate2");
  8460. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8461. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8462. string persuadetype = GetPostString("persuadetype");
  8463. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8464. string returnvstate = GetPostString("returnvstate");
  8465. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8466. dStruct.Order = "created desc";
  8467. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8468. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8469. writeGridDataTableJson(dStruct.TotalCount, dt);
  8470. }
  8471. public void upd_erp_returnpersuadeback()
  8472. {
  8473. if (UrlPostParmsCheck("ID"))
  8474. {
  8475. int eid = GetPostInt("ID");
  8476. CeErpPersuade entity = null;
  8477. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8478. if (entity != null)
  8479. {
  8480. entity.backreason = GetPostString("reason");
  8481. entity.pstate = 2;
  8482. entity.verifytime = DateTime.Now;
  8483. entity.verifyuserid = CurrentUser.UserID;
  8484. entity.Update();
  8485. returnSuccessMsg("退回成功!");
  8486. return;
  8487. }
  8488. returnErrorMsg("找不到订单记录");
  8489. }
  8490. }
  8491. public void upd_erp_returnpersuadeverify()
  8492. {
  8493. if (UrlPostParmsCheck("ID"))
  8494. {
  8495. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8496. {
  8497. returnErrorMsg("暂无权限审核");
  8498. return;
  8499. }
  8500. int eid = GetPostInt("ID");
  8501. CeErpPersuade entity = null;
  8502. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8503. if (entity != null)
  8504. {
  8505. entity.pstate = 1;
  8506. entity.verifytime = DateTime.Now;
  8507. entity.verifyuserid = CurrentUser.UserID;
  8508. entity.Update();
  8509. returnSuccessMsg("审核成功!");
  8510. return;
  8511. }
  8512. returnErrorMsg("找不到订单记录");
  8513. }
  8514. }
  8515. public void del_erp_persuade()
  8516. {
  8517. if (UrlPostParmsCheck("ID"))
  8518. {
  8519. int eid = GetPostInt("ID");
  8520. CeErpPersuade.Del(eid);
  8521. returnSuccessMsg("操作成功");
  8522. return;
  8523. }
  8524. }
  8525. public void get_erp_oldcustoupload()
  8526. {
  8527. DataStruct dStruct = GetPostStruct();
  8528. List<string> lw = new List<string>();
  8529. string buyernick = GetPostString("buyer_nick");
  8530. if (buyernick.Length > 0)
  8531. {
  8532. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8533. }
  8534. else
  8535. return;
  8536. dStruct.Order = "pay_time desc";
  8537. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8538. DataTable dt = null;
  8539. dt = WebCache.GetData("view_erptradecell", dStruct);
  8540. writeGridDataTableJson(dStruct.TotalCount, dt);
  8541. }
  8542. public void get_erp_checkorderlist()
  8543. {
  8544. DataStruct dStruct = GetPostStruct();
  8545. List<string> lw = new List<string>();
  8546. string tid = GetPostString("ctid");
  8547. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8548. string shopname = GetPostString("shopname");
  8549. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8550. string buyernick = GetPostString("buyer_nick");
  8551. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8552. string customer = GetPostString("customer");
  8553. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8554. string design = GetPostString("design");
  8555. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8556. string orderState = GetPostString("orderState");
  8557. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8558. string address = GetPostString("address");
  8559. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8560. string sellermemo = GetPostString("seller_memo");
  8561. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8562. string supplier = GetPostString("supplier");
  8563. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8564. {
  8565. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8566. }
  8567. else
  8568. {
  8569. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8570. }
  8571. string checkst = GetPostString("checkstate");
  8572. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8573. string date1 = GetPostString("date1");
  8574. string date2 = GetPostString("date2");
  8575. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8576. if (dw.Length > 0) lw.Add(dw);
  8577. string placedate1 = GetPostString("placedate1");
  8578. string placedate2 = GetPostString("placedate2");
  8579. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8580. if (fdw.Length > 0) lw.Add(fdw);
  8581. string price1 = GetPostString("price1");
  8582. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8583. string price2 = GetPostString("price2");
  8584. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8585. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8586. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8587. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8588. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8589. writeGridDataTableJson(dStruct.TotalCount, dt);
  8590. }
  8591. public void ins_erp_startCheck()
  8592. {
  8593. if (UrlPostParmsCheck("ctid"))
  8594. {
  8595. string eid = GetPostString("ctid");
  8596. CeErpTradeCell entity = null;
  8597. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8598. if (entity != null)
  8599. {
  8600. entity.MemoOpt = 4;
  8601. entity.Update();
  8602. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8603. CeErpSukuraData.createInfo(entity.ctid, 6);
  8604. returnSuccessMsg("操作成功!");
  8605. return;
  8606. }
  8607. returnErrorMsg("找不到记录");
  8608. }
  8609. }
  8610. public void upd_erp_sendXlw()
  8611. {
  8612. if (UrlPostParmsCheck("ctid"))
  8613. {
  8614. string eid = GetPostString("ctid");
  8615. CeErpTradeCell entity = null;
  8616. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8617. if (entity != null)
  8618. {
  8619. if (entity.IsSendGift == 1)
  8620. {
  8621. returnErrorMsg("请勿重复标记");
  8622. return;
  8623. }
  8624. entity.IsSendGift = 1;
  8625. entity.Update();
  8626. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8627. returnSuccessMsg("操作成功!");
  8628. return;
  8629. }
  8630. returnErrorMsg("找不到记录");
  8631. }
  8632. }
  8633. public void cancel_sendXlw()
  8634. {
  8635. if (UrlPostParmsCheck("ctid"))
  8636. {
  8637. string eid = GetPostString("ctid");
  8638. CeErpTradeCell entity = null;
  8639. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8640. if (entity != null)
  8641. {
  8642. if (entity.IsSendGift == 0)
  8643. {
  8644. returnErrorMsg("未标记小礼物");
  8645. return;
  8646. }
  8647. entity.IsSendGift = 0;
  8648. entity.Update();
  8649. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8650. returnSuccessMsg("操作成功!");
  8651. return;
  8652. }
  8653. returnErrorMsg("找不到记录");
  8654. }
  8655. }
  8656. public void get_erp_designbill()
  8657. {
  8658. DataStruct dStruct = GetPostStruct();
  8659. List<string> lw = new List<string>();
  8660. int isMy = GetInt("my");
  8661. if (isMy == 1)
  8662. {
  8663. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8664. }
  8665. string tid = GetPostString("tid");
  8666. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8667. string userName = GetPostString("design");
  8668. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8669. string price1 = GetPostString("price1");
  8670. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8671. string price2 = GetPostString("price2");
  8672. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8673. string rePrice1 = GetPostString("rePrice1");
  8674. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8675. string rePrice2 = GetPostString("rePrice2");
  8676. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8677. string designerType = GetPostString("designerType");
  8678. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8679. string orderState = GetPostString("orderState");
  8680. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8681. string endTime1 = GetPostString("endTime1");
  8682. string endTime2 = GetPostString("endTime2");
  8683. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8684. if (dw.Length > 0) lw.Add(dw);
  8685. string isDk = GetPostString("isDk");
  8686. if (isDk == "1")
  8687. {
  8688. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8689. }
  8690. else if (isDk == "0")
  8691. {
  8692. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8693. }
  8694. dStruct.Order = "oid, create_time desc";
  8695. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8696. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8697. writeGridDataTableJson(dStruct.TotalCount, dt);
  8698. }
  8699. public void upd_erp_designerbill()
  8700. {
  8701. if (UrlPostParmsCheck("ID"))
  8702. {
  8703. string eid = GetPostString("ID");
  8704. CeErpDesignerBill entity = null;
  8705. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8706. if (entity != null)
  8707. {
  8708. if (GetPostDouble("designerpirce") > 0)
  8709. {
  8710. entity.realPrice = GetPostDouble("designerpirce");
  8711. entity.update_time = DateTime.Now;
  8712. entity.update_u_id = CurrentUser.UserID;
  8713. entity.update_u_name = CurrentUser.UserName;
  8714. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8715. entity.Update();
  8716. returnSuccessMsg("操作成功!");
  8717. return;
  8718. }
  8719. else
  8720. {
  8721. entity.price = GetPostDouble("price");
  8722. entity.update_time = DateTime.Now;
  8723. entity.update_u_id = CurrentUser.UserID;
  8724. entity.update_u_name = CurrentUser.UserName;
  8725. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8726. entity.Update();
  8727. returnSuccessMsg("操作成功!");
  8728. return;
  8729. }
  8730. }
  8731. returnErrorMsg("找不到记录");
  8732. }
  8733. }
  8734. public void audit_erp_designerbill()
  8735. {
  8736. if (UrlPostParmsCheck("ID"))
  8737. {
  8738. string eid = GetPostString("ID");
  8739. CeErpDesignerBill entity = null;
  8740. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8741. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8742. if (entity != null)
  8743. {
  8744. entity.realPrice = GetPostDouble("designerpirce");
  8745. entity.update_time = DateTime.Now;
  8746. entity.update_u_id = CurrentUser.UserID;
  8747. entity.update_u_name = CurrentUser.UserName;
  8748. entity.isAudit = 1;
  8749. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8750. entity.Update();
  8751. if (orderEntity != null)
  8752. {
  8753. orderEntity.IsReadTag = 3;
  8754. orderEntity.Update();
  8755. }
  8756. returnSuccessMsg("操作成功!");
  8757. return;
  8758. }
  8759. returnErrorMsg("找不到记录");
  8760. }
  8761. }
  8762. public void all_audit_erp_designerbill()
  8763. {
  8764. if (UrlPostParmsCheck("idList"))
  8765. {
  8766. string[] list = GetPostString("idList").Split(',');
  8767. CeErpDesignerBill entity = null;
  8768. for (int i = 0; i < list.Length; i++)
  8769. {
  8770. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8771. if (entity == null) return;
  8772. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8773. if (orderEntity == null) return;
  8774. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8775. entity.update_time = DateTime.Now;
  8776. entity.update_u_id = CurrentUser.UserID;
  8777. entity.update_u_name = CurrentUser.UserName;
  8778. entity.isAudit = 1;
  8779. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8780. entity.Update();
  8781. orderEntity.IsReadTag = 3;
  8782. orderEntity.Update();
  8783. }
  8784. returnSuccessMsg("操作成功!");
  8785. return;
  8786. }
  8787. }
  8788. public void get_erp_sameorders()
  8789. {
  8790. if (UrlPostParmsCheck("ctid"))
  8791. {
  8792. string eid = GetPostString("ctid");
  8793. CeErpTradeCell entity = null;
  8794. entity = CeErpTradeCell.GetByCtid(eid);
  8795. if (entity != null)
  8796. {
  8797. StringBuilder sql = new StringBuilder();
  8798. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8799. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8800. var res = new
  8801. {
  8802. data = dt.Rows.Count
  8803. };
  8804. string ro_jsond = JsonConvert.SerializeObject(res);
  8805. returnSuccess(ro_jsond);
  8806. return;
  8807. }
  8808. returnErrorMsg("未找到订单");
  8809. return;
  8810. }
  8811. returnErrorMsg("缺少必要的参数");
  8812. }
  8813. public void get_erp_islasthavesameorder()
  8814. {
  8815. if (UrlPostParmsCheck("ctid"))
  8816. {
  8817. string eid = GetPostString("ctid");
  8818. string[] ctidList = eid.Split(',');
  8819. StringBuilder sql = new StringBuilder();
  8820. string tisCtid = "";
  8821. foreach (string ctid in ctidList)
  8822. {
  8823. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8824. if (entity != null)
  8825. {
  8826. sql = new StringBuilder();
  8827. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8828. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8829. if (dth.Rows.Count > 0)
  8830. {
  8831. tisCtid += entity.ctid;
  8832. tisCtid += ",";
  8833. }
  8834. }
  8835. }
  8836. if (tisCtid.Length > 0)
  8837. {
  8838. var res = new
  8839. {
  8840. data = tisCtid
  8841. };
  8842. string ro_jsond = JsonConvert.SerializeObject(res);
  8843. returnSuccess(ro_jsond);
  8844. }
  8845. else
  8846. {
  8847. var res = new
  8848. {
  8849. data = ""
  8850. };
  8851. string ro_jsond = JsonConvert.SerializeObject(res);
  8852. returnSuccess(ro_jsond);
  8853. }
  8854. return;
  8855. }
  8856. returnErrorMsg("缺少必要的参数");
  8857. }
  8858. public void file_client_down_url()
  8859. {
  8860. if (!UrlPostParmsCheck("userId"))
  8861. {
  8862. returnErrorMsg("缺少必要的参数");
  8863. }
  8864. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  8865. }
  8866. public void checkout_form_data()
  8867. {
  8868. if (!UrlPostParmsCheck("tid"))
  8869. {
  8870. returnErrorMsg("缺少必要的参数");
  8871. }
  8872. string tid = GetPostString("tid");
  8873. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  8874. if (ceErpOrderFormData != null)
  8875. {
  8876. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  8877. returnSuccess(ro_jsond);
  8878. return;
  8879. }
  8880. returnErrorMsg("尚未有文件!");
  8881. }
  8882. public void back_supplier_audit()
  8883. {
  8884. int userId = CurrentUser.UserID;
  8885. StringBuilder sql = new StringBuilder();
  8886. 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);
  8887. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8888. if (dt.Rows.Count > 0)
  8889. {
  8890. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8891. }
  8892. else
  8893. {
  8894. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8895. }
  8896. }
  8897. public void back_supplier_query()
  8898. {
  8899. string eid = GetPostString("ctid");
  8900. if (eid != "")
  8901. {
  8902. StringBuilder sql = new StringBuilder();
  8903. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  8904. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8905. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8906. }
  8907. else
  8908. {
  8909. returnErrorMsg("找不到订单记录");
  8910. return;
  8911. }
  8912. }
  8913. public void verified_to_order()
  8914. {
  8915. int userId = CurrentUser.UserID;
  8916. StringBuilder sql = new StringBuilder();
  8917. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  8918. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8919. if (dt.Rows.Count > 0)
  8920. {
  8921. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8922. }
  8923. else
  8924. {
  8925. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8926. }
  8927. }
  8928. public void upd_supplier_audit()
  8929. {
  8930. if (UrlPostParmsCheck("ctid"))
  8931. {
  8932. string eid = GetPostString("ctid");
  8933. string reason = GetPostString("returnreason");
  8934. CeErpTradeCell entity = null;
  8935. CeWithdraw withdraw = null;
  8936. withdraw = CeWithdraw.GetByTid(eid);
  8937. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8938. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  8939. {
  8940. if (withdraw != null)
  8941. {
  8942. if (!withdraw.userid.Equals(CurrentUser.UserID))
  8943. {
  8944. returnSuccessMsg("您没有权限操作!");
  8945. return;
  8946. }
  8947. else
  8948. {
  8949. if (reason.Equals("1"))
  8950. {
  8951. if (entity.OrderState == -1)
  8952. {
  8953. if (entity.FinishPlaceTime == null)
  8954. {
  8955. entity.OrderState = 2;
  8956. }
  8957. else
  8958. {
  8959. entity.OrderState = 6;
  8960. }
  8961. }
  8962. entity.Update();
  8963. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  8964. if (withdraw != null)
  8965. {
  8966. withdraw.status = int.Parse(reason);
  8967. withdraw.Update();
  8968. }
  8969. returnSuccessMsg("操作成功!");
  8970. return;
  8971. }
  8972. else
  8973. {
  8974. withdraw.status = int.Parse(reason);
  8975. withdraw.acknowledgingtime = DateTime.Now;
  8976. withdraw.Update();
  8977. returnSuccessMsg("查看详细请点击线下订单查询");
  8978. return;
  8979. }
  8980. }
  8981. }
  8982. // 第一个字符是 'N'
  8983. }
  8984. if (eid[0] != 'N')
  8985. {
  8986. }
  8987. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  8988. {
  8989. entity.IsVerifyToSupplier = false;
  8990. entity.IsReturn = 1;
  8991. entity.ReturnTime = DateTime.Now;
  8992. entity.ReturnReason = reason;
  8993. if (entity.OrderState == 6)
  8994. {
  8995. entity.OrderState = 5;
  8996. }
  8997. entity.Update();
  8998. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  8999. if (withdraw != null)
  9000. {
  9001. withdraw.status = int.Parse(reason);
  9002. withdraw.Update();
  9003. }
  9004. returnSuccessMsg("操作成功!");
  9005. return;
  9006. }
  9007. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9008. {
  9009. ;
  9010. if (withdraw != null)
  9011. {
  9012. withdraw.status = int.Parse(reason);
  9013. withdraw.acknowledgingtime = DateTime.Now;
  9014. withdraw.Update();
  9015. returnSuccessMsg("供应商取消撤回!");
  9016. return;
  9017. }
  9018. }
  9019. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9020. {
  9021. if (entity.OrderState == -1)
  9022. {
  9023. if (entity.FinishPlaceTime == null)
  9024. {
  9025. entity.OrderState = 2;
  9026. }
  9027. else
  9028. {
  9029. entity.OrderState = 3;
  9030. }
  9031. commonHelper.getCytPrice(entity);
  9032. }
  9033. entity.Update();
  9034. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9035. if (withdraw != null)
  9036. {
  9037. withdraw.status = int.Parse(reason);
  9038. withdraw.Update();
  9039. }
  9040. returnSuccessMsg("操作成功!");
  9041. return;
  9042. }
  9043. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9044. {
  9045. if (withdraw == null)
  9046. {
  9047. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9048. return;
  9049. }
  9050. }
  9051. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9052. {
  9053. if (withdraw != null)
  9054. {
  9055. withdraw.status = int.Parse(reason);
  9056. withdraw.acknowledgingtime = DateTime.Now;
  9057. withdraw.Update();
  9058. returnSuccessMsg("查看详细请点击线下订单查询");
  9059. return;
  9060. }
  9061. }
  9062. return;
  9063. }
  9064. }
  9065. //校验报价
  9066. public void refund_order_tip()
  9067. {
  9068. int userid = CurrentUser.UserID;
  9069. int sectionId = CurrentUser.UserPost.OrgID;
  9070. StringBuilder sql = new StringBuilder();
  9071. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9072. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9073. List<string> ids = new List<string>();
  9074. if (dth.Rows.Count > 0)
  9075. {
  9076. foreach (DataRow dr in dth.Rows)
  9077. {
  9078. ids.Add(dr["ID"].ToString());
  9079. }
  9080. try
  9081. {
  9082. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9083. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9084. }
  9085. catch (Exception ex)
  9086. {
  9087. }
  9088. }
  9089. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9090. }
  9091. public void refund_order_Design()
  9092. {
  9093. int userid = CurrentUser.UserID;
  9094. int sectionId = CurrentUser.UserPost.OrgID;
  9095. StringBuilder sql = new StringBuilder();
  9096. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9097. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9098. List<string> ids = new List<string>();
  9099. if (dth.Rows.Count > 0)
  9100. {
  9101. foreach (DataRow dr in dth.Rows)
  9102. {
  9103. ids.Add(dr["ID"].ToString());
  9104. }
  9105. try
  9106. {
  9107. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9108. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9109. }
  9110. catch (Exception ex)
  9111. {
  9112. }
  9113. }
  9114. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9115. }
  9116. public void change_order_info()
  9117. {
  9118. int userid = CurrentUser.UserID;
  9119. StringBuilder sql = new StringBuilder();
  9120. 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);
  9121. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9122. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9123. }
  9124. public void change_win_mome()
  9125. {
  9126. if (UrlPostParmsCheck("id,ctid"))
  9127. {
  9128. string id = GetPostString("id");
  9129. string ctid = GetPostString("ctid");
  9130. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9131. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9132. if (ce == null || ceErpMessageTip == null)
  9133. {
  9134. returnSuccessMsg("未找到对应的订单!");
  9135. return;
  9136. }
  9137. int type = GetPostInt("type");
  9138. string content = GetPostString("content");
  9139. if (type == 0)
  9140. {
  9141. content = content.Replace("(", "(");
  9142. content = content.Replace(")", ")");
  9143. string check = MidStrEx(content, "(", ")").Trim();
  9144. if (string.IsNullOrEmpty(check))
  9145. {
  9146. returnSuccessMsg("文件名格式不正确");
  9147. return;
  9148. }
  9149. }
  9150. ce.seller_memo = content;
  9151. ce.Update();
  9152. ceErpMessageTip.isVisit = true;
  9153. ceErpMessageTip.Update();
  9154. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9155. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9156. ApiVo apiVo = new ApiVo();
  9157. apiVo.orderNumber = ce.ctid;
  9158. apiVo.actionName = "demandDesign";
  9159. apiVo.orderRemarks = content;
  9160. apiVo.demandExamine = type + 1;
  9161. designHelper.API_WorkCore(apiVo);//demandDesign
  9162. returnSuccessMsg("修改成功!");
  9163. }
  9164. }
  9165. public static string MidStrEx(string sourse, string startstr, string endstr)
  9166. {
  9167. string result = string.Empty;
  9168. int startindex, endindex;
  9169. try
  9170. {
  9171. startindex = sourse.IndexOf(startstr);
  9172. if (startindex == -1)
  9173. return result;
  9174. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9175. endindex = tmpstr.IndexOf(endstr);
  9176. if (endindex == -1)
  9177. return result;
  9178. result = tmpstr.Remove(endindex);
  9179. }
  9180. catch (Exception ex)
  9181. {
  9182. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9183. }
  9184. return result;
  9185. }
  9186. public void refund_order_list()
  9187. {
  9188. int userid = CurrentUser.UserID;
  9189. int sectionId = CurrentUser.UserPost.OrgID;
  9190. StringBuilder sql = new StringBuilder();
  9191. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9192. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9193. DataStruct dStruct = GetPostStruct();
  9194. DataTable dt = null;
  9195. List<string> ids = new List<string>();
  9196. List<string> tids = new List<string>();
  9197. if (dth.Rows.Count > 0)
  9198. {
  9199. foreach (DataRow dr in dth.Rows)
  9200. {
  9201. tids.Add("'" + dr["tid"].ToString() + "'");
  9202. ids.Add(dr["id"].ToString());
  9203. }
  9204. try
  9205. {
  9206. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9207. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9208. List<string> lw = new List<string>();
  9209. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9210. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9211. dt = WebCache.GetData("view_orderlist", dStruct);
  9212. }
  9213. catch (Exception ex)
  9214. {
  9215. }
  9216. }
  9217. writeGridDataTableJson(dStruct.TotalCount, dt);
  9218. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9219. }
  9220. //新增
  9221. public void order_batch_downloads()
  9222. {
  9223. string ceid = GetPostString("tid");
  9224. String[] tid = ceid.Split(',');
  9225. order_batch_caiyingtong(tid);
  9226. /* (string success, string errors) = UploadFiles(tid);
  9227. returnSuccessMsg(success + errors);*/
  9228. return;
  9229. }
  9230. //报价接口
  9231. public void Get_To_Quote()
  9232. {
  9233. string ceid = GetPostString("ctid");
  9234. if (ceid != null)
  9235. {
  9236. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9237. if (entity != null)
  9238. {
  9239. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9240. double price = 0;
  9241. if (cp == null)
  9242. {
  9243. JObject jsonObject12 = new JObject
  9244. {
  9245. { "UserId", "77886" },
  9246. { "Pwd", "lt666888" },
  9247. { "Filename", entity.seller_memo }
  9248. };
  9249. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9250. JObject jsonObjects1 = JObject.Parse(response1);
  9251. string ms1g = (string)jsonObjects1["msg"];
  9252. if (ms1g == "报价成功")
  9253. {
  9254. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9255. string data = (string)jsonObject1["price"];
  9256. 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 + "');";
  9257. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9258. returnSuccessMsg("获取报价成功:" + data);
  9259. price = Convert.ToDouble(data);
  9260. }
  9261. else
  9262. {
  9263. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9264. return;
  9265. }
  9266. }
  9267. String[] beizhu = entity.seller_memo.Split('-');
  9268. String chanp = "";
  9269. if (beizhu.Length > 0)
  9270. {
  9271. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9272. }
  9273. else
  9274. {
  9275. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9276. }
  9277. JObject jsonObject = new JObject
  9278. {
  9279. { "UserId", "77886" },
  9280. { "Pwd", "lt666888" },
  9281. { "Filename", chanp }
  9282. };
  9283. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9284. JObject jsonObjects = JObject.Parse(response);
  9285. string msg = (string)jsonObjects["msg"];
  9286. if (msg == "报价成功")
  9287. {
  9288. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9289. string data = (string)jsonObject1["price"];
  9290. 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 + "');";
  9291. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9292. returnSuccessMsg("获取报价成功:" + data);
  9293. price = Convert.ToDouble(data);
  9294. }
  9295. else
  9296. {
  9297. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9298. return;
  9299. }
  9300. if (price > 0)
  9301. {
  9302. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9303. if (ceErpTradeCellExtend == null)
  9304. {
  9305. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9306. ceErpTradeCellExtend.ctid = entity.ctid;
  9307. ceErpTradeCellExtend.payment_cyt = price;
  9308. ceErpTradeCellExtend.Create();
  9309. }
  9310. else
  9311. {
  9312. ceErpTradeCellExtend.payment_cyt = price;
  9313. ceErpTradeCellExtend.Update();
  9314. }
  9315. }
  9316. return;
  9317. }
  9318. }
  9319. else
  9320. {
  9321. returnErrorMsg("请至少选择一条数据");
  9322. return;
  9323. }
  9324. }
  9325. //新增
  9326. public void order_To_Supplier()
  9327. {
  9328. string ceid = GetPostString("tid");
  9329. String[] tid = ceid.Split(',');
  9330. if (tid.Length > 0)
  9331. {
  9332. try
  9333. {
  9334. for (int i = 0; i < tid.Length; i++)
  9335. {
  9336. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9337. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9338. entity.SupplierId = suid;
  9339. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9340. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9341. entity.Update();
  9342. }
  9343. }
  9344. catch (Exception ex)
  9345. {
  9346. returnErrorMsg("自动匹配供应商失败");
  9347. return;
  9348. }
  9349. }
  9350. else
  9351. {
  9352. returnErrorMsg("请至少选择一条数据");
  9353. return;
  9354. }
  9355. returnSuccessMsg("自动匹配供应商成功");
  9356. return;
  9357. }
  9358. public (string, string) UploadFiles(string[] urls)
  9359. {
  9360. string success = "";
  9361. string errors = "";
  9362. int userid = CurrentUser.UserID;
  9363. foreach (string url in urls)
  9364. {
  9365. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9366. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9367. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9368. {
  9369. JObject jsonObject = new JObject
  9370. {
  9371. { "Userid", "77886" },
  9372. { "pwd", "cyt86435015" },
  9373. { "content", base64FileContent },
  9374. { "ext", Path.GetExtension(fileName) }
  9375. };
  9376. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9377. JObject jsonObjects = JObject.Parse(response);
  9378. string msg = (string)jsonObjects["msg"];
  9379. if (msg.Equals("上传成功"))
  9380. {
  9381. success += url + " 上传成功";
  9382. }
  9383. else
  9384. {
  9385. errors += url + " 上传失败";
  9386. }
  9387. }
  9388. else
  9389. {
  9390. errors += url + " 格式出现问题";
  9391. }
  9392. }
  9393. if (urls.Length == 0)
  9394. {
  9395. return (success, errors);
  9396. }
  9397. return (success, errors);
  9398. }
  9399. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9400. {
  9401. return true; //总是接受
  9402. }
  9403. public static string HttpPost(string url, string param = null)
  9404. {
  9405. HttpWebRequest request;
  9406. //如果是发送HTTPS请求
  9407. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9408. {
  9409. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9410. request = WebRequest.Create(url) as HttpWebRequest;
  9411. request.ProtocolVersion = HttpVersion.Version10;
  9412. }
  9413. else
  9414. {
  9415. request = WebRequest.Create(url) as HttpWebRequest;
  9416. }
  9417. request.Method = "POST";
  9418. request.ContentType = "application/json";
  9419. request.Accept = "*/*";
  9420. request.Timeout = 120000;
  9421. request.AllowAutoRedirect = false;
  9422. StreamWriter requestStream = null;
  9423. WebResponse response = null;
  9424. string responseStr = null;
  9425. try
  9426. {
  9427. requestStream = new StreamWriter(request.GetRequestStream());
  9428. requestStream.Write(param);
  9429. requestStream.Close();
  9430. response = request.GetResponse();
  9431. if (response != null)
  9432. {
  9433. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9434. responseStr = reader.ReadToEnd();
  9435. reader.Close();
  9436. }
  9437. }
  9438. catch (Exception ex)
  9439. {
  9440. return ex.Message;
  9441. }
  9442. finally
  9443. {
  9444. request = null;
  9445. requestStream = null;
  9446. response = null;
  9447. }
  9448. return responseStr;
  9449. }
  9450. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9451. {
  9452. string base64FileContent;
  9453. string fileName;
  9454. using (WebClient webClient = new WebClient())
  9455. {
  9456. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9457. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9458. {
  9459. using (Stream stream = response.GetResponseStream())
  9460. {
  9461. using (MemoryStream memoryStream = new MemoryStream())
  9462. {
  9463. stream.CopyTo(memoryStream);
  9464. byte[] fileBytes = memoryStream.ToArray();
  9465. base64FileContent = Convert.ToBase64String(fileBytes);
  9466. fileName = response.Headers["Content-Disposition"];
  9467. if (!string.IsNullOrEmpty(fileName))
  9468. {
  9469. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9470. if (index >= 0)
  9471. {
  9472. fileName = fileName.Substring(index + 9).Trim('\"');
  9473. }
  9474. }
  9475. else
  9476. {
  9477. fileName = Path.GetFileName(downloadUrl);
  9478. }
  9479. }
  9480. }
  9481. }
  9482. }
  9483. return (fileName, base64FileContent);
  9484. }
  9485. //新增
  9486. public void order_batch_caiyingtong(string[] downloadUrls)
  9487. {
  9488. try
  9489. {
  9490. //遍历文件
  9491. DataStruct dStruct = GetPostStruct();
  9492. DataTable dt = null;
  9493. int userid = CurrentUser.UserID;
  9494. List<string> ids = new List<string>();//失败组
  9495. List<string> tids = new List<string>();
  9496. using (WebClient webClient = new WebClient())
  9497. {
  9498. foreach (var url in downloadUrls)
  9499. {
  9500. try
  9501. {
  9502. tids.Add("'" + url + "'");
  9503. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9504. if (entity != null)
  9505. {
  9506. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9507. if (cp == null)
  9508. {
  9509. JObject jsonObject = new JObject
  9510. {
  9511. { "Userid", "77886" },
  9512. { "pwd", "lt666888" },
  9513. { "Filename",entity.seller_memo }
  9514. };
  9515. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9516. JObject jsonObjects = JObject.Parse(response);
  9517. string msg = (string)jsonObjects["msg"];
  9518. if (msg == "报价成功")
  9519. {
  9520. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9521. DownloadAndConvertToBase64(url1);
  9522. }
  9523. else
  9524. {
  9525. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9526. }
  9527. }
  9528. else
  9529. {
  9530. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9531. JObject jsonObject = new JObject
  9532. {
  9533. { "Userid", "77886" },
  9534. { "pwd", "lt666888" },
  9535. { "Filename",chanp }
  9536. };
  9537. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9538. JObject jsonObjects = JObject.Parse(response);
  9539. string msg = (string)jsonObjects["msg"];
  9540. if (msg == "报价成功")
  9541. {
  9542. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9543. DownloadAndConvertToBase64(url1);
  9544. }
  9545. else
  9546. {
  9547. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9548. }
  9549. }
  9550. }
  9551. // 上传文件到FTP
  9552. }
  9553. catch (Exception ex)
  9554. {
  9555. Console.WriteLine($"An error occurred: {ex.Message}");
  9556. }
  9557. }
  9558. List<string> lw = new List<string>();
  9559. lw.Add(string.Format("( OrderState < 6 )"));
  9560. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9562. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9563. if (dt.Rows.Count > 0)
  9564. {
  9565. foreach (DataRow dr in dt.Rows)
  9566. {
  9567. ids.Add(dr["ctid"].ToString());
  9568. }
  9569. }
  9570. String ErrorMsgs = "";
  9571. foreach (String id in ids)
  9572. {
  9573. ErrorMsgs += id + ",";
  9574. }
  9575. if (ErrorMsgs.Length > 1)
  9576. {
  9577. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9578. }
  9579. if (ErrorMsgs.Length < 1)
  9580. {
  9581. ErrorMsgs = "上传成功";
  9582. returnSuccessMsg(ErrorMsgs);
  9583. }
  9584. else
  9585. {
  9586. returnErrorMsg("以下订单" + ErrorMsgs);
  9587. }
  9588. }
  9589. // 删除文件夹及其内容
  9590. /* Directory.Delete(localDirectory, true);*/
  9591. }
  9592. catch { }
  9593. }
  9594. public void get_center_data()
  9595. {
  9596. int userId = CurrentUser.UserID;
  9597. string postCode = CurrentUser.UserPost.Post.Code;
  9598. List<string> lw = new List<string>();
  9599. List<string> ww = new List<string>();
  9600. DateTime currentTime = DateTime.Now;
  9601. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9602. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9603. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9604. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9605. string sql = " SELECT ";
  9606. string startTime = "2023-10-01 11:22:31";
  9607. //设计
  9608. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9609. {
  9610. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9611. 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));
  9612. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9613. 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));
  9614. }
  9615. //客服
  9616. else if (postCode == "CustomerService" || postCode == "Director")
  9617. {
  9618. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9619. 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));
  9620. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9621. 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));
  9622. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9623. 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));
  9624. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9625. 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));
  9626. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9627. 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));
  9628. }
  9629. //售后
  9630. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9631. {
  9632. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9633. 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));
  9634. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9635. 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));
  9636. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9637. 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));
  9638. }
  9639. //下单部
  9640. else if (postCode == "Place" || postCode == "PlaceMr")
  9641. {
  9642. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9643. 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));
  9644. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9645. 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));
  9646. }
  9647. //车间
  9648. else if (postCode == "Supplier")
  9649. {
  9650. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9651. 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));
  9652. }
  9653. DataTable dt = new DataTable();
  9654. if (lw.Count > 0)
  9655. {
  9656. sql += string.Join(" , ", lw);
  9657. sql += " FROM ";
  9658. sql += string.Join(" , ", ww);
  9659. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9660. }
  9661. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9662. }
  9663. public void get_center_data_list()
  9664. {
  9665. int userId = CurrentUser.UserID;
  9666. string postCode = CurrentUser.UserPost.Post.Code;
  9667. string shopIds = CurrentUser.User.pemShop;
  9668. DataStruct dStruct = GetPostStruct();
  9669. List<string> lw = new List<string>();
  9670. DateTime currentTime = DateTime.Now;
  9671. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9672. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9673. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9674. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9675. string startTime = "2023-10-01 11:22:31";
  9676. int order_type = GetPostInt("order_type");
  9677. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9678. {
  9679. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9680. if (order_type == 0)
  9681. {
  9682. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9683. }
  9684. else if (order_type == 3)
  9685. {
  9686. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9687. }
  9688. else
  9689. {
  9690. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9691. }
  9692. }
  9693. //客服
  9694. if (postCode == "CustomerService" || postCode == "Director")
  9695. {
  9696. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9697. if (order_type == 0)
  9698. {
  9699. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9700. }
  9701. else if (order_type == 1)
  9702. {
  9703. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9704. }
  9705. else if (order_type == 2)
  9706. {
  9707. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9708. }
  9709. else if (order_type == 3)
  9710. {
  9711. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9712. }
  9713. else if (order_type == 4)
  9714. {
  9715. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9716. }
  9717. else
  9718. {
  9719. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9720. }
  9721. }
  9722. //售后
  9723. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9724. {
  9725. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9726. if (shopIds != "")
  9727. {
  9728. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9729. }
  9730. if (order_type == 2)
  9731. {
  9732. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9733. }
  9734. else if (order_type == 4)
  9735. {
  9736. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9737. }
  9738. else if (order_type == 5)
  9739. {
  9740. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9741. }
  9742. else
  9743. {
  9744. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9745. }
  9746. }
  9747. //下单部
  9748. if (postCode == "Place" || postCode == "PlaceMr")
  9749. {
  9750. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9751. if (shopIds != "")
  9752. {
  9753. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9754. }
  9755. else if (order_type == 1)
  9756. {
  9757. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9758. }
  9759. else if (order_type == 2)
  9760. {
  9761. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9762. }
  9763. else
  9764. {
  9765. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9766. }
  9767. }
  9768. //车间
  9769. if (postCode == "Supplier")
  9770. {
  9771. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9772. if (order_type == 5)
  9773. {
  9774. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9775. }
  9776. else
  9777. {
  9778. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9779. }
  9780. }
  9781. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9782. dStruct.Fileds = "tid,ctid";
  9783. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9784. writeGridDataTableJson(dStruct.TotalCount, dt);
  9785. }
  9786. public void aftersale_audit_master()
  9787. {
  9788. if (UrlPostParmsCheck("ctid"))
  9789. {
  9790. string ctid = GetPostString("ctid");
  9791. if (ctid.Length > 0)
  9792. {
  9793. bool result = aftersale_data_change(ctid);
  9794. if (result)
  9795. {
  9796. returnSuccessMsg("修改成功!");
  9797. return;
  9798. }
  9799. }
  9800. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9801. }
  9802. }
  9803. public void aftersale_batch_audit_master()
  9804. {
  9805. if (UrlPostParmsCheck("ctids"))
  9806. {
  9807. string ctids = GetPostString("ctids");
  9808. if (ctids.Length > 0)
  9809. {
  9810. List<string> list = new List<string>();
  9811. string[] ctid_list = ctids.Split(',');
  9812. foreach (var item in ctid_list)
  9813. {
  9814. bool result = aftersale_data_change(item);
  9815. if (!result)
  9816. {
  9817. list.Add(item);
  9818. }
  9819. }
  9820. if (list.Count > 0)
  9821. {
  9822. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9823. return;
  9824. }
  9825. returnSuccessMsg("修改成功!");
  9826. return;
  9827. }
  9828. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9829. }
  9830. }
  9831. public bool aftersale_data_change(string ctid)
  9832. {
  9833. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9834. if (ceErpTradeCell != null)
  9835. {
  9836. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9837. ceErpTradeCell.AfterSaleSupplierState = 0;
  9838. StringBuilder sql = new StringBuilder();
  9839. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9840. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9841. 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 == "不理赔")
  9842. {
  9843. CeErpTradeResponsible.DelByTid(ctid, 1);
  9844. ceErpTradeCell.AfterSaleSupplierState = 1;
  9845. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9846. ceErpTradeCell.AfterSaleState = 4;
  9847. }
  9848. else
  9849. {
  9850. ceErpTradeCell.AfterSaleState = 3;
  9851. }
  9852. bool needCyt = false;
  9853. if (dt != null)
  9854. {
  9855. if (dt.Rows.Count == 1)
  9856. {
  9857. bool isEnd = false;
  9858. foreach (DataRow dr in dt.Rows)
  9859. {
  9860. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9861. {
  9862. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9863. isEnd = true;
  9864. }
  9865. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  9866. {
  9867. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9868. isEnd = true;
  9869. }
  9870. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9871. {
  9872. needCyt = true;
  9873. }
  9874. }
  9875. if (isEnd)
  9876. {
  9877. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9878. ceErpTradeCell.AfterSaleState = 4;
  9879. ceErpTradeCell.AfterSaleSupplierState = 1;
  9880. }
  9881. }
  9882. else
  9883. {
  9884. bool isAll = true;
  9885. foreach (DataRow dr in dt.Rows)
  9886. {
  9887. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9888. {
  9889. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9890. continue;
  9891. }
  9892. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  9893. {
  9894. string path = "";
  9895. int OrgID = 0;
  9896. if (!Convert.IsDBNull(dr["OrgPath"]))
  9897. {
  9898. path = dr["OrgPath"].ToString();
  9899. }
  9900. if (!Convert.IsDBNull(dr["OrgID"]))
  9901. {
  9902. OrgID = Convert.ToInt32(dr["OrgID"]);
  9903. }
  9904. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  9905. {
  9906. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9907. continue;
  9908. }
  9909. }
  9910. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9911. {
  9912. needCyt = true;
  9913. }
  9914. isAll = false;
  9915. }
  9916. if (isAll)
  9917. {
  9918. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9919. ceErpTradeCell.AfterSaleState = 4;
  9920. ceErpTradeCell.AfterSaleSupplierState = 1;
  9921. }
  9922. }
  9923. }
  9924. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  9925. {
  9926. commonHelper.sendCytAfterSale(ceErpTradeCell);
  9927. }
  9928. if (ceErpTradeCell.AfterSaleState == 4)
  9929. {
  9930. ApiVo apiVo = new ApiVo();
  9931. apiVo.orderNumber = ceErpTradeCell.ctid;
  9932. apiVo.actionName = "afterOver";
  9933. designHelper.API_WorkCore(apiVo); //afterOver
  9934. }
  9935. ceErpTradeCell.Update();
  9936. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  9937. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  9938. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  9939. return true;
  9940. }
  9941. return false;
  9942. }
  9943. public void get_erp_wechatorder()
  9944. {
  9945. DataStruct dStruct = GetPostStruct();
  9946. List<string> lw = new List<string>();
  9947. string tid = GetPostString("tid");
  9948. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9949. string shopname = GetPostString("shopname");
  9950. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9951. string buyernick = GetPostString("buyer_nick");
  9952. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9953. string customer = GetPostString("customer");
  9954. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9955. string returndate1 = GetPostString("returndate1");
  9956. string returndate2 = GetPostString("returndate2");
  9957. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9958. if (dw.Length > 0) lw.Add(dw);
  9959. string finishDate1 = GetPostString("finishdate1");
  9960. string finishDate2 = GetPostString("finishdate2");
  9961. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9962. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9963. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  9964. dStruct.Order = "created desc";
  9965. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9966. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  9967. writeGridDataTableJson(dStruct.TotalCount, dt);
  9968. }
  9969. public void get_erp_wechatlist_sumprice()
  9970. {
  9971. DataStruct dStruct = GetPostStruct();
  9972. List<string> lw = new List<string>();
  9973. string tid = GetPostString("tid");
  9974. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9975. string shopname = GetPostString("shopname");
  9976. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9977. string buyernick = GetPostString("buyer_nick");
  9978. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9979. string customer = GetPostString("customer");
  9980. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9981. string returndate1 = GetPostString("returndate1");
  9982. string returndate2 = GetPostString("returndate2");
  9983. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9984. if (dw.Length > 0) lw.Add(dw);
  9985. string finishDate1 = GetPostString("finishdate1");
  9986. string finishDate2 = GetPostString("finishdate2");
  9987. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9988. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9989. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  9990. string mainWhere = string.Join(" and ", lw.ToArray());
  9991. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  9992. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  9993. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  9994. decimal total = 0;
  9995. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  9996. {
  9997. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  9998. }
  9999. var res = new
  10000. {
  10001. data = total
  10002. };
  10003. string ro_jsond = JsonConvert.SerializeObject(res);
  10004. returnSuccess(ro_jsond);
  10005. return;
  10006. }
  10007. public void get_erp_qr_waitdeliverylist()
  10008. {
  10009. DataStruct dStruct = GetPostStruct();
  10010. List<string> lw = new List<string>();
  10011. string tid = GetPostString("ctid");
  10012. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10013. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10014. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10015. var res_objz = new
  10016. {
  10017. restype = 1,
  10018. data = dt
  10019. };
  10020. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10021. returnSuccess(ro_jsonz);
  10022. }
  10023. public void get_erp_yield_list()
  10024. {
  10025. DataStruct dStruct = GetPostStruct();
  10026. List<string> lw = new List<string>();
  10027. string tid = GetPostString("ctid");
  10028. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10029. string shopname = GetPostString("shopname");
  10030. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10031. string buyernick = GetPostString("buyer_nick");
  10032. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10033. //if (tid.Length == 0 && buyernick.Length == 0)
  10034. //{
  10035. // lw.Add(string.Format("IsRefund<={0}", 1));
  10036. //}
  10037. string customer = GetPostString("customer");
  10038. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10039. string design = GetPostString("design");
  10040. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10041. string orderState = GetPostString("orderState");
  10042. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10043. string address = GetPostString("address");
  10044. 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));
  10045. string sellermemo = GetPostString("seller_memo");
  10046. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10047. string supplier = GetPostString("supplier");
  10048. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10049. string OrderArea = GetPostString("order_area");
  10050. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10051. string placedate1 = GetPostString("placedate1");
  10052. string placedate2 = GetPostString("placedate2");
  10053. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10054. if (fdw.Length > 0) lw.Add(fdw);
  10055. string price1 = GetPostString("price1");
  10056. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10057. string price2 = GetPostString("price2");
  10058. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10059. string unusualCon = GetPostString("unusualcon");
  10060. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10061. string posTag = CurrentUser.UserPost.Post.Code;
  10062. if (posTag == "Supplier")
  10063. {
  10064. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10065. }
  10066. lw.Add(string.Format("OrderState = 6 "));
  10067. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10068. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10069. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10070. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10071. writeGridDataTableJson(dStruct.TotalCount, dt);
  10072. }
  10073. public void change_erp_sup_state()
  10074. {
  10075. if (UrlPostParmsCheck("ctid"))
  10076. {
  10077. string ctid = GetPostString("ctid");
  10078. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10079. if (ceErpTradeCell != null)
  10080. {
  10081. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10082. if (ceErpTradeCellExtend == null)
  10083. {
  10084. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10085. ceErpTradeCellExtend.ctid = ctid;
  10086. ceErpTradeCellExtend.SupState = 1;
  10087. ceErpTradeCellExtend.Create();
  10088. }
  10089. else
  10090. {
  10091. ceErpTradeCellExtend.SupState = 1;
  10092. ceErpTradeCellExtend.Update();
  10093. }
  10094. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10095. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10096. return;
  10097. }
  10098. returnErrorMsg("找不到订单");
  10099. }
  10100. }
  10101. public void supplier_all_downs()
  10102. {
  10103. if (UrlPostParmsCheck("tids"))
  10104. {
  10105. string tids = GetPostString("tids");
  10106. if (tids != null && tids.Length > 0)
  10107. {
  10108. StringBuilder sql = new StringBuilder();
  10109. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10110. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10111. sql = new StringBuilder();
  10112. 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, "下载设计文件");
  10113. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10114. string[] list = tids.Split(',');
  10115. foreach (string ctid in list)
  10116. {
  10117. CeErpSukuraData.createInfo(ctid, 3);
  10118. }
  10119. designHelper.api_approveDesign(tids); //approveDesign
  10120. returnSuccessMsg("下载成功!");
  10121. return;
  10122. }
  10123. returnErrorMsg("下载订单更新失败");
  10124. }
  10125. }
  10126. public void uploaderFileSuccess()
  10127. {
  10128. if (UrlPostParmsCheck("fileName"))
  10129. {
  10130. string fileName = GetPostString("fileName");
  10131. ApiVo apiVo = new ApiVo();
  10132. apiVo.orderNumber = fileName;
  10133. apiVo.actionName = "finishDesign";
  10134. designHelper.API_WorkCore(apiVo);//finishDesign
  10135. returnSuccessMsg("");
  10136. }
  10137. }
  10138. public void get_sample2_order()
  10139. {
  10140. if (UrlPostParmsCheck("ctid"))
  10141. {
  10142. string ctid = GetPostString("ctid");
  10143. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10144. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10145. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10146. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10147. double total = 0.0;
  10148. double order_price = 0.0;
  10149. if (dt_bu.Rows.Count > 0)
  10150. {
  10151. foreach (DataRow dr in dt_bu.Rows)
  10152. {
  10153. total += Convert.ToDouble(dr["payment"]);
  10154. }
  10155. }
  10156. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10157. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10158. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10159. string tid = ctid.Replace("S_", "");
  10160. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10161. double paymant = 0.0;
  10162. if (entity != null)
  10163. {
  10164. paymant = entity.payment;
  10165. }
  10166. string return_reason = "";
  10167. if (dt_after != null && dt_after.Rows.Count > 0)
  10168. {
  10169. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10170. }
  10171. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10172. }
  10173. }
  10174. public void get_erp_design_status()
  10175. {
  10176. string designName = GetPostString("designName");
  10177. DataStruct dStruct = GetPostStruct();
  10178. if (designName.Length > 0)
  10179. {
  10180. 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";
  10181. sql_user += " and Name like '%" + designName + "%'";
  10182. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10183. List<string> ids_list = new List<string>();
  10184. if (user_table.Rows.Count > 0)
  10185. {
  10186. foreach (DataRow item in user_table.Rows)
  10187. {
  10188. ids_list.Add(item["id"].ToString());
  10189. string ids_s = item["TeamIds"].ToString();
  10190. if (ids_s.Length > 0)
  10191. {
  10192. ids_list.AddRange(ids_s.Split(','));
  10193. }
  10194. }
  10195. }
  10196. HashSet<string> set = new HashSet<string>(ids_list);
  10197. ids_list = set.ToList();
  10198. if (ids_list.Count > 0)
  10199. {
  10200. 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));
  10201. dStruct.MainWhere = sql;
  10202. DataTable dt = null;
  10203. dt = WebCache.GetData("view_ErpUser", dStruct);
  10204. writeGridDataTableJson(dStruct.TotalCount, dt);
  10205. }
  10206. }
  10207. }
  10208. public void change_erp_order_price()
  10209. {
  10210. string ctid = GetPostString("ctid");
  10211. double price = GetPostDouble("price");
  10212. if (ctid.Length > 0)
  10213. {
  10214. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10215. if (ceErpTradeCellExtend == null)
  10216. {
  10217. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10218. ceErpTradeCellExtend.ctid = ctid;
  10219. ceErpTradeCellExtend.payment_cyt = price;
  10220. ceErpTradeCellExtend.Create();
  10221. }
  10222. else
  10223. {
  10224. ceErpTradeCellExtend.payment_cyt = price;
  10225. ceErpTradeCellExtend.Update();
  10226. }
  10227. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10228. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10229. {
  10230. ceErpDataSendOrderInfo.isSync = false;
  10231. ceErpDataSendOrderInfo.Update();
  10232. }
  10233. if (ceErpDataSendOrderInfo == null)
  10234. {
  10235. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10236. ceErpDataSendOrderInfo.isSync = false;
  10237. ceErpDataSendOrderInfo.ctid = ctid;
  10238. ceErpDataSendOrderInfo.Create();
  10239. }
  10240. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10241. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10242. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10243. if (dth != null && dth.Rows.Count > 0)
  10244. {
  10245. dataSendOrderBean dataSendOrderBean = null;
  10246. foreach (DataRow item in dth.Rows)
  10247. {
  10248. try
  10249. {
  10250. dataSendOrderBean = new dataSendOrderBean();
  10251. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10252. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10253. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10254. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10255. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10256. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10257. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10258. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10259. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10260. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10261. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10262. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10263. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10264. if (result != null)
  10265. {
  10266. if ("0".Equals(result.errcode))
  10267. {
  10268. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10269. }
  10270. else
  10271. {
  10272. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10273. }
  10274. }
  10275. }
  10276. catch (Exception ex)
  10277. {
  10278. }
  10279. }
  10280. }
  10281. returnSuccessMsg("修改成功!");
  10282. return;
  10283. }
  10284. returnErrorMsg("找不到订单");
  10285. }
  10286. public void find_he_together()
  10287. {
  10288. string ctid = GetPostString("ctid");
  10289. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10290. List<string> list = new List<string>();
  10291. if (ceErpTradeCell != null)
  10292. {
  10293. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10294. {
  10295. 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);
  10296. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10297. if (table != null && table.Rows.Count > 0)
  10298. {
  10299. foreach (TableRow row in table.Rows)
  10300. {
  10301. }
  10302. }
  10303. }
  10304. }
  10305. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10306. }
  10307. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10308. {
  10309. //chy----19
  10310. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10311. //GD-CYT-----64
  10312. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10313. //ZHX----3
  10314. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10315. //JK----97
  10316. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10317. //ZT----70
  10318. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10319. //LHCY-----98
  10320. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10321. //XD-----90
  10322. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10323. //CYCY-----14
  10324. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10325. };
  10326. //其他改名
  10327. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10328. {
  10329. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10330. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10331. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10332. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10333. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10334. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10335. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10336. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10337. };
  10338. //不统计
  10339. List<int> no_suppliers = new List<int>()
  10340. {
  10341. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10342. };
  10343. //配件单
  10344. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10345. {
  10346. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10347. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10348. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10349. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10350. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10351. {"旗杆",new List<string>(){ "班旗" } },
  10352. {"牙签",new List<string>(){ "不干胶" } }
  10353. };
  10354. public void get_place_order_data()
  10355. {
  10356. string date1 = GetPostString("date1");
  10357. string date2 = GetPostString("date2");
  10358. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10359. DateTime start = DateTime.Parse(starttime);
  10360. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10361. DateTime end = DateTime.Parse(endtime);
  10362. if (date1 != null && date1.Length > 0)
  10363. {
  10364. DateTime dateTime = DateTime.Parse(date1);
  10365. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10366. start = DateTime.Parse(starttime);
  10367. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10368. end = DateTime.Parse(endtime);
  10369. }
  10370. if (date2 != null && date2.Length > 0)
  10371. {
  10372. DateTime dateTime = DateTime.Parse(date2);
  10373. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10374. end = DateTime.Parse(endtime);
  10375. }
  10376. 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);
  10377. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10378. //不干胶-----1,卡片-----29
  10379. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10380. foreach (DataRow row in data.Rows)
  10381. {
  10382. int productId = Convert.ToInt32(row["ProductId"]);
  10383. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10384. if (no_suppliers.Contains(supplierId))
  10385. {
  10386. continue;
  10387. }
  10388. string seller_memo = row["seller_memo"].ToString();
  10389. bool ispj = false;//是否配件单
  10390. bool isfirst = true;//第一个配
  10391. maps.Keys.ForEach(key =>
  10392. {
  10393. //备注包含配件
  10394. if (seller_memo.Contains(key) && isfirst)
  10395. {
  10396. List<string> list = maps[key];
  10397. ispj = true;
  10398. isfirst = false;
  10399. for (int i = 0; i < list.Count; i++)
  10400. {
  10401. if (seller_memo.Contains(list[i]))
  10402. {
  10403. ispj = false;
  10404. break;
  10405. }
  10406. }
  10407. }
  10408. });
  10409. if (ispj)
  10410. {
  10411. continue;
  10412. }
  10413. seller_memo = seller_memo.Replace("UV", "uv");
  10414. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10415. //吊牌归到卡片
  10416. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10417. seller_memo = seller_memo.Replace("卡套", "卡片");
  10418. seller_memo = seller_memo.Replace("封套", "卡片");
  10419. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10420. seller_memo = seller_memo.Replace("腰封", "卡片");
  10421. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10422. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10423. seller_memo = seller_memo.Replace("横幅", "条幅");
  10424. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10425. string map_key = "";
  10426. string type = "";
  10427. if (supplierMap.ContainsKey(supplierId))
  10428. {
  10429. foreach (var kvp in supplierMap[supplierId])
  10430. {
  10431. if (seller_memo.Contains(kvp.Key))
  10432. {
  10433. map_key = kvp.Value;
  10434. type = kvp.Value;
  10435. break;
  10436. }
  10437. }
  10438. }
  10439. if (map_key == "")
  10440. {
  10441. type = "其他";
  10442. map_key = "其他";
  10443. }
  10444. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10445. {
  10446. map_key = suppliers[supplierId];
  10447. }
  10448. if (supplierId == 70)
  10449. {
  10450. supplierId = 70;
  10451. }
  10452. map_key += "_" + row["SupplierName"].ToString();
  10453. Dictionary<string, int> map = null;
  10454. if (other_map.ContainsKey(map_key))
  10455. {
  10456. other_map.TryGetValue(map_key, out map);
  10457. }
  10458. else
  10459. {
  10460. map = new Dictionary<string, int>();
  10461. map.Add("dayDev", 0);//当天出货
  10462. map.Add("dayTotal", 0);//下单总数
  10463. map.Add("payTotal", 0);//500以上
  10464. map.Add("today", 0);//当天出货数量
  10465. map.Add("unusua", 0);//异常数
  10466. other_map.Add(map_key, map);
  10467. other_map.TryGetValue(map_key, out map);
  10468. }
  10469. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10470. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10471. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10472. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10473. {
  10474. map["dayTotal"]++;
  10475. if (supplierId == 97)
  10476. {
  10477. supplierId = 97;
  10478. }
  10479. }
  10480. if (Convert.ToDecimal(row["payment"]) >= 500)
  10481. {
  10482. map["payTotal"]++;
  10483. }
  10484. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10485. {
  10486. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10487. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10488. {
  10489. map["today"]++;
  10490. }
  10491. }
  10492. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10493. {
  10494. map["unusua"]++;
  10495. }
  10496. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10497. //GD-CYT-----64
  10498. DateTime two = palceTimeStart.AddHours(14);
  10499. DateTime three = palceTimeStart.AddHours(15);
  10500. DateTime four = palceTimeStart.AddHours(16);
  10501. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10502. {
  10503. //下午四点前 500-1000
  10504. string count = row["ProductCount"].ToString();
  10505. if (count != null && count.Length > 0)
  10506. {
  10507. int productCount = commonHelper.getPlaceProductCount(count);
  10508. if (productCount >= 500 && productCount <= 1000)
  10509. {
  10510. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10511. {
  10512. map["dayDev"]++;
  10513. }
  10514. }
  10515. }
  10516. }
  10517. //UV
  10518. else if ("uv".Equals(type))
  10519. {
  10520. //ZT----70
  10521. //ZHX----3
  10522. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10523. {
  10524. map["dayDev"]++;
  10525. }
  10526. //JK----97
  10527. //HZX----105
  10528. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10529. {
  10530. map["dayDev"]++;
  10531. if (supplierId == 97)
  10532. {
  10533. supplierId = 97;
  10534. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10535. }
  10536. }
  10537. }
  10538. //帆布---52|条幅---27
  10539. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10540. {
  10541. //LHCY-----98
  10542. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10543. {
  10544. map["dayDev"]++;
  10545. }
  10546. }
  10547. //条幅
  10548. else if ("条幅".Equals(type))
  10549. {
  10550. //XD-----90
  10551. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10552. {
  10553. map["dayDev"]++;
  10554. }
  10555. }
  10556. //桌布
  10557. else if ("桌布".Equals(type))
  10558. {
  10559. //XD-----90
  10560. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10561. {
  10562. map["dayDev"]++;
  10563. }
  10564. }
  10565. //DL---10
  10566. //AYTW---119
  10567. //FS-CYT-DY ----80
  10568. //JK----97
  10569. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10570. {
  10571. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10572. {
  10573. map["dayDev"]++;
  10574. }
  10575. }
  10576. }
  10577. DataTable dt = new DataTable();
  10578. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10579. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10580. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10581. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10582. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10583. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10584. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10585. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10586. other_map.Keys.ForEach(key =>
  10587. {
  10588. DataRow dr = dt.NewRow();
  10589. Dictionary<string, int> map = other_map[key];
  10590. string[] key_list = key.Split('_');
  10591. dr[0] = key_list[0];
  10592. dr[1] = key_list[1];
  10593. if (key_list.Length > 2)
  10594. {
  10595. dr[1] += "(" + key_list[2] + ")";
  10596. }
  10597. dr[2] = map["dayTotal"];
  10598. dr[3] = map["payTotal"];
  10599. dr[4] = map["today"];
  10600. dr[5] = map["unusua"];
  10601. dr[6] = map["dayDev"];
  10602. double rate = 0.00;
  10603. if (map["dayDev"] > 0)
  10604. {
  10605. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10606. }
  10607. dr[7] = rate.ToString();
  10608. dt.Rows.Add(dr);
  10609. });
  10610. DataView dv = new DataView(dt);
  10611. dv.Sort = "SupplierName";
  10612. //dv.Sort = "AllOrder desc";
  10613. DataTable dtNew = dv.ToTable();
  10614. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10615. }
  10616. public void check_order_desing_info()
  10617. {
  10618. string ctid = GetPostString("ctid");
  10619. if (!string.IsNullOrEmpty(ctid))
  10620. {
  10621. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10622. if (ceErpTradeCell != null)
  10623. {
  10624. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10625. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10626. return;
  10627. }
  10628. returnErrorMsg("找不到订单");
  10629. return;
  10630. }
  10631. returnErrorMsg("找不到订单");
  10632. }
  10633. public void get_timeout_detail()
  10634. {
  10635. string poscode = CurrentUser.UserPost.Post.Code;
  10636. DataStruct dStruct = GetPostStruct();
  10637. List<string> lw = new List<string>();
  10638. string id = GetPostString("id");
  10639. string pay_date1 = GetPostString("pay_date1");
  10640. string pay_date2 = GetPostString("pay_date2");
  10641. int type = GetPostInt("type");
  10642. if (type == 0)
  10643. {
  10644. if (pay_date1.Length > 0)
  10645. {
  10646. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10647. }
  10648. if (pay_date2.Length > 0)
  10649. {
  10650. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10651. }
  10652. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10653. }
  10654. if (type == 1)
  10655. {
  10656. if (pay_date1.Length > 0)
  10657. {
  10658. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10659. }
  10660. if (pay_date2.Length > 0)
  10661. {
  10662. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10663. }
  10664. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10665. }
  10666. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10667. DataTable dt = null;
  10668. dt = WebCache.GetData("view_orderlist", dStruct);
  10669. writeGridDataTableJson(dStruct.TotalCount, dt);
  10670. }
  10671. public void saveUrgentChargePrice()
  10672. {
  10673. string ctid = GetPostString("ctid");
  10674. if (!string.IsNullOrEmpty(ctid))
  10675. {
  10676. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10677. if (ceErpTradeCell != null)
  10678. {
  10679. double price = GetPostDouble("price");
  10680. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10681. if (ceErpTradeCellExtend == null)
  10682. {
  10683. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10684. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10685. }
  10686. ceErpTradeCellExtend.urgentCharge = price;
  10687. if (ceErpTradeCellExtend.ID > 0)
  10688. {
  10689. ceErpTradeCellExtend.Update();
  10690. }
  10691. else
  10692. {
  10693. ceErpTradeCellExtend.Save();
  10694. }
  10695. returnSuccessMsg("修改成功!");
  10696. return;
  10697. }
  10698. returnErrorMsg("找不到订单");
  10699. return;
  10700. }
  10701. returnErrorMsg("找不到订单");
  10702. }
  10703. public void finish_erp_order()
  10704. {
  10705. string ctid = GetPostString("ctid");
  10706. if (!string.IsNullOrEmpty(ctid))
  10707. {
  10708. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10709. {
  10710. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10711. if (ceErpTradeCell != null)
  10712. {
  10713. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10714. ceErpTradeCell.Update();
  10715. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10716. returnSuccessMsg("修改成功!");
  10717. return;
  10718. }
  10719. }
  10720. }
  10721. returnErrorMsg("找不到订单");
  10722. }
  10723. public void get_trade_order_list()
  10724. {
  10725. string tid = GetPostString("tid");
  10726. if (!string.IsNullOrEmpty(tid))
  10727. {
  10728. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10729. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10730. writeGridDataTableJson(data.Rows.Count, data);
  10731. return;
  10732. }
  10733. returnErrorMsg("找不到订单");
  10734. }
  10735. public void save_cell_spu()
  10736. {
  10737. string ctid = GetPostString("ctid");
  10738. string spu_id = GetPostString("spu_id");
  10739. if (!string.IsNullOrEmpty(ctid))
  10740. {
  10741. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10742. if (ceErpTradeCellExtend == null)
  10743. {
  10744. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10745. ceErpTradeCellExtend.ctid = ctid;
  10746. }
  10747. ceErpTradeCellExtend.spu_id = spu_id;
  10748. if (ceErpTradeCellExtend.ID == 0)
  10749. {
  10750. ceErpTradeCellExtend.Create();
  10751. }
  10752. else
  10753. {
  10754. ceErpTradeCellExtend.Update();
  10755. }
  10756. returnSuccessMsg("修改成功!");
  10757. return;
  10758. }
  10759. returnErrorMsg("找不到订单");
  10760. }
  10761. public void change_express_info()
  10762. {
  10763. string ctid = GetPostString("ctid");
  10764. string transNo = GetPostString("transNo");
  10765. string transCom = GetPostString("transCom");
  10766. if (!string.IsNullOrEmpty(ctid))
  10767. {
  10768. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10769. if (ceErpTradeCellExtend == null)
  10770. {
  10771. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10772. ceErpTradeCellExtend.ctid = ctid;
  10773. }
  10774. ceErpTradeCellExtend.modExpressNo = transNo;
  10775. ceErpTradeCellExtend.modExpressCom = transCom;
  10776. ceErpTradeCellExtend.readMod = 2;
  10777. if (ceErpTradeCellExtend.ID == 0)
  10778. {
  10779. ceErpTradeCellExtend.Create();
  10780. }
  10781. else
  10782. {
  10783. ceErpTradeCellExtend.Update();
  10784. }
  10785. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10786. returnSuccessMsg("修改成功!");
  10787. return;
  10788. }
  10789. returnErrorMsg("找不到订单");
  10790. }
  10791. public void get_change_express_list()
  10792. {
  10793. DataStruct dStruct = GetPostStruct();
  10794. List<string> lw = new List<string>();
  10795. int st = 2;
  10796. string tid = GetPostString("ctid");
  10797. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10798. string shopname = GetPostString("shopname");
  10799. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10800. string buyernick = GetPostString("buyer_nick");
  10801. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10802. string sellermemo = GetPostString("seller_memo");
  10803. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10804. string supplier = GetPostString("supplier");
  10805. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10806. string customer = GetPostString("customer");
  10807. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10808. string design = GetPostString("design");
  10809. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10810. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10811. string poscode = CurrentUser.UserPost.Post.Code;
  10812. if (poscode != "SysAdmin")
  10813. {
  10814. string shopid = CurrentUser.User.pemShop;
  10815. lw.Add(string.Format("shopId in ({0})", shopid));
  10816. }
  10817. lw.Add("readMod = 2");
  10818. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10819. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10820. writeGridDataTableJson(dStruct.TotalCount, dt);
  10821. }
  10822. public void deal_express_complete()
  10823. {
  10824. string ctid = GetPostString("ctid");
  10825. if (!string.IsNullOrEmpty(ctid))
  10826. {
  10827. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10828. if (ceErpTradeCellExtend == null)
  10829. {
  10830. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10831. ceErpTradeCellExtend.ctid = ctid;
  10832. }
  10833. ceErpTradeCellExtend.readMod = 1;
  10834. if (ceErpTradeCellExtend.ID == 0)
  10835. {
  10836. ceErpTradeCellExtend.Create();
  10837. }
  10838. else
  10839. {
  10840. ceErpTradeCellExtend.Update();
  10841. }
  10842. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10843. returnSuccessMsg("修改成功!");
  10844. return;
  10845. }
  10846. returnErrorMsg("找不到订单");
  10847. }
  10848. public void aftersale_return_visit()
  10849. {
  10850. string ctid = GetPostString("ctid");
  10851. if (!string.IsNullOrEmpty(ctid))
  10852. {
  10853. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10854. if (ceErpTradeCellExtend == null)
  10855. {
  10856. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10857. ceErpTradeCellExtend.ctid = ctid;
  10858. }
  10859. ceErpTradeCellExtend.returnVisit = 1;
  10860. if (ceErpTradeCellExtend.ID == 0)
  10861. {
  10862. ceErpTradeCellExtend.Create();
  10863. }
  10864. else
  10865. {
  10866. ceErpTradeCellExtend.Update();
  10867. }
  10868. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  10869. if (ceErpTradeAfterSaleExtend != null)
  10870. {
  10871. ceErpTradeAfterSaleExtend.TextResult = "";
  10872. ceErpTradeAfterSaleExtend.Update();
  10873. }
  10874. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  10875. returnSuccessMsg("修改成功!");
  10876. return;
  10877. }
  10878. returnErrorMsg("找不到订单");
  10879. }
  10880. public void orderPlaceInfo()
  10881. {
  10882. string ctids = GetPostString("ctids");
  10883. string[] list = ctids.Split(',');
  10884. foreach (string ctid in list)
  10885. {
  10886. CeErpSukuraData.createInfo(ctid, 3);
  10887. }
  10888. designHelper.api_approveDesign(ctids); //approveDesign
  10889. returnSuccessMsg("");
  10890. }
  10891. }
  10892. }