sync.order.cs 613 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. namespace SiteCore.Handler
  48. {
  49. public partial class sync
  50. {
  51. public void get_erp_orderlist()
  52. {
  53. string poscode = CurrentUser.UserPost.Post.Code;
  54. DataStruct dStruct = GetPostStruct();
  55. //apiHelper.Api_SyncOrderByTime("598825");
  56. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  57. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  58. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  59. //banniuApiHelper.sendLogisticsInfo(null);
  60. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  61. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  62. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  63. //int sid = commonHelper.autoDistributeToSupplier(entity);
  64. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  65. //tmcHelper.Api_TmcTradeMsg("{\r\n \"content\": {\r\n \"businessType\": \"GUARANTEE\",\r\n \"buyerMemo\": \"\",\r\n \"consolidateType\": \"\",\r\n \"createTime\": 1744882656361,\r\n \"deliveryType\": \"OFFLINE\",\r\n \"discountFee\": 0.0,\r\n \"flag\": \"NONE\",\r\n \"latestDeliveryTime\": 1744882656361,\r\n \"lines\": [\r\n {\r\n \"mark2\": [],\r\n \"num\": 4,\r\n \"outerId\": \"\",\r\n \"payment\": 60.0,\r\n \"picUrl\": \"https://img.alicdn.com/bao/uploaded/i4/2209226402185/O1CN011Zh53V1S0mQKgHJyF_!!4611686018427382153-0-item_pic.jpg\",\r\n \"platServiceFee\": 0.0,\r\n \"price\": 10.0,\r\n \"refOlId\": \"1111122222333338942\",\r\n \"refSkuId\": \"0\",\r\n \"refSpuId\": \"908453435193\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellPrice\": 10.0,\r\n \"singleFee\": 10.0,\r\n \"standards\": \"测试内部\",\r\n \"status\": \"NOT_SHIPPED\",\r\n \"title\": \"【老客户订单2】测试老客户订单内部\",\r\n \"totalFee\": 60.0,\r\n \"totalPrice\": 60.0,\r\n \"totalSellPrice\": 60.0\r\n }\r\n ],\r\n \"logisticsOrderNo\": \"\",\r\n \"mark2\": [],\r\n \"modifyTime\": 1744882656361,\r\n \"openBuyerId\": \"AAG1RHraABkUZRPgSx3g7Eam\",\r\n \"openBuyerNick\": \"0**\",\r\n \"openSellerNick\": \"海角七旗舰店\",\r\n \"orderSource\": \"SYNC\",\r\n \"orderTime\": 1744882656361,\r\n \"payTime\": 1744882656361,\r\n \"payment\": 100.0,\r\n \"platServiceFee\": 0.0,\r\n \"posCode\": \"HJQ\",\r\n \"posId\": 663281,\r\n \"postFee\": 0.0,\r\n \"props\": {\r\n \"payType\": \"ALI_PAY\",\r\n \"govSubsidyAmount\": 0\r\n },\r\n \"receivedPayment\": 0.0,\r\n \"receiverCity\": \"龙岩市\",\r\n \"receiverCountry\": \"中国\",\r\n \"receiverDistrict\": \"新罗区\",\r\n \"receiverId\": \"d1b65912ef886228ac4ada4b65055e52$\",\r\n \"receiverState\": \"福建省\",\r\n \"receiverTown\": \"西陂街道\",\r\n \"refOid\": \"1111122222333338942\",\r\n \"refType\": \"TB\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellerMemo\": \"\",\r\n \"serviceFee\": 0.0,\r\n \"status\": \"NOT_SHIPPED\",\r\n \"totalFee\": 100.0,\r\n \"totalPrice\": 100.0,\r\n \"totalSellPrice\": 100.0,\r\n \"type\": \"SALE\"\r\n }\r\n}");
  66. //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}}");
  67. /*string sql = "SELECT spuId,tid FROM [dbo].[CE_ErpTradeSpu]";
  68. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  69. DataTable dataTable = dataSet == null ? new DataTable() : dataSet.Tables[0];
  70. foreach (DataRow dr in dataTable.Rows)
  71. {
  72. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByTid(dr["tid"].ToString());
  73. CeErpTradeOrder ceErpTradeOrder = CeErpTradeOrder.GetBySpuId(dr["spuId"].ToString());
  74. CeErpTradeSpu ceErpTradeSpu = CeErpTradeSpu.GetBySpuId(dr["spuId"].ToString());
  75. dataSendSpuBean bean = new dataSendSpuBean();
  76. bean.ShortText1728890680485 = ceErpTradeOrder.title;
  77. bean.ShortText1728890649488 = dr["spuId"].ToString();
  78. bean.shopId = ceErpTradeCell.ShopId.ToString();
  79. ceErpTradeSpu.shopId = ceErpTradeCell.ShopId;
  80. bean.Date1728891156995 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  81. dataResponseVo response = dataHelper.sendSpuInfo(bean);
  82. if (response != null)
  83. {
  84. if ("0".Equals(response.errcode))
  85. {
  86. ceErpTradeSpu.isSync = true;
  87. }
  88. else
  89. {
  90. ceErpTradeSpu.message = response.errmsg;
  91. }
  92. }
  93. ceErpTradeSpu.Update();
  94. }*/
  95. List<string> lw = new List<string>();
  96. string tid = GetPostString("ctid");
  97. string date1 = GetPostString("date1");
  98. //12-1 修改
  99. string urgent = GetPostString("urgent");
  100. string back = GetPostString("back");
  101. string offlineSearch = GetPostString("offlineSearch");
  102. int paramsCount = 0;
  103. if (!string.IsNullOrWhiteSpace(urgent))
  104. {
  105. if (urgent.Equals("true"))
  106. {
  107. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  108. }
  109. }
  110. if (!string.IsNullOrWhiteSpace(back))
  111. {
  112. if (back.Equals("true"))
  113. {
  114. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  115. }
  116. }
  117. if (!string.IsNullOrWhiteSpace(offlineSearch))
  118. {
  119. if (offlineSearch.Equals("true"))
  120. {
  121. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  122. }
  123. }
  124. //end
  125. string date2 = GetPostString("date2");
  126. string buyernick = GetPostString("buyer_nick");
  127. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  128. {
  129. if (tid.Length <= 0 && buyernick.Length <= 0)
  130. {
  131. return;
  132. }
  133. }
  134. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  135. {
  136. if (tid.Length > 0)
  137. {
  138. string select_tid = getTidByCtid(tid);
  139. lw.Add(string.Format("tid='{0}'", select_tid));
  140. }
  141. if (buyernick.Length > 0)
  142. {
  143. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  144. }
  145. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  146. if (dw.Length > 0)
  147. {
  148. lw.Add(dw);
  149. }
  150. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  151. {
  152. string usershop = CurrentUser.User.pemShop;
  153. lw.Add(string.Format("ShopId in ({0})", usershop));
  154. }
  155. }
  156. else
  157. {
  158. if (ex_psize == 0)
  159. {
  160. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  161. }
  162. if (PKey != "admin")
  163. {
  164. string usershop = CurrentUser.User.pemShop;
  165. lw.Add(string.Format("ShopId in ({0})", usershop));
  166. paramsCount++;
  167. }
  168. }
  169. string uploaddate1 = GetPostString("uploaddate1");
  170. string uploaddate2 = GetPostString("uploaddate2");
  171. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  172. if (update.Length > 0) lw.Add(update);
  173. string deliverydate1 = GetPostString("deliverydate1");
  174. string deliverydate2 = GetPostString("deliverydate2");
  175. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  176. if (deliverydate.Length > 0)
  177. {
  178. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  179. };
  180. string shopname = GetPostString("shopname");
  181. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  182. string addwechat = GetPostString("addwechat");
  183. if (addwechat.Length > 0)
  184. {
  185. int addWt = Convert.ToInt32(addwechat);
  186. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  187. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  188. }
  189. string customer = GetPostString("customer");
  190. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  191. string design = GetPostString("design");
  192. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  193. string orderState = GetPostString("orderState");
  194. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  195. string address = GetPostString("address");
  196. 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));
  197. string sellermemo = GetPostString("seller_memo");
  198. if (sellermemo.Length > 0)
  199. {
  200. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  201. }
  202. string backReason = GetPostString("backReason");
  203. if (backReason.Length > 0)
  204. {
  205. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  206. }
  207. string apdate1 = GetPostString("apdate1");
  208. string apdate2 = GetPostString("apdate2");
  209. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  210. if (dwap.Length > 0) lw.Add(dwap);
  211. string price1 = GetPostString("price1");
  212. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  213. string price2 = GetPostString("price2");
  214. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  215. string isoldcustomer = GetPostString("isoldcus");
  216. string spudata = GetPostString("spudata");
  217. if ("0".Equals(spudata))
  218. {
  219. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  220. }
  221. if ("1".Equals(spudata))
  222. {
  223. lw.Add(string.Format("spu_id <> ''"));
  224. }
  225. string finishdate1 = GetPostString("finishdate1");
  226. string finishdate2 = GetPostString("finishdate2");
  227. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  228. bool isFinish = false;
  229. if (finishdate.Length > 0)
  230. {
  231. lw.Add(finishdate);
  232. isFinish = true;
  233. paramsCount++;
  234. }
  235. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  236. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  237. if (ex_psize > 0)
  238. {
  239. int UserID = CurrentUser.UserID;
  240. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  241. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  242. {
  243. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  244. }
  245. dStruct.Order = "pay_time desc";
  246. }
  247. string isNew = GetPostString("isNew");
  248. if (isNew == "true")
  249. {
  250. lw.Add(string.Format("IsNew = {0}", 1));
  251. }
  252. string overtime = GetPostString("overtime");
  253. if (overtime == "1")
  254. {
  255. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  256. }
  257. String usePost = CurrentUser.UserPost.Post.Code;
  258. if (usePost.Equals("Operation") == true)
  259. {
  260. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  261. }
  262. else
  263. {
  264. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  265. }
  266. //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";
  267. if (dStruct.PageSize == 100000)
  268. {
  269. dStruct.Order = "";
  270. }
  271. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  272. DataTable dt = null;
  273. string tablename = "view_orderlist";
  274. if (isFinish)
  275. {
  276. tablename = "view_orderlist_end";
  277. }
  278. dt = WebCache.GetData(tablename, dStruct);
  279. if (dt != null && dt.Rows.Count > 0)
  280. {
  281. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  282. foreach (DataRow dr in dt.Rows)
  283. {
  284. try
  285. {
  286. if (dr["refund_fees"] != null)
  287. {
  288. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  289. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  290. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  291. if (payment == refund_fees)
  292. {
  293. dr["refund_fees"] = Math.Round(refund_fees, 2);
  294. }
  295. else if (refund_fees == total_fee)
  296. {
  297. dr["refund_fees"] = payment;
  298. }
  299. else
  300. {
  301. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  302. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  303. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  304. }
  305. }
  306. // 对象操作
  307. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  308. ceErpTradeCell.ctid = dr["ctid"].ToString();
  309. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  310. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  311. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  312. if (dStruct.PageSize != 100000)
  313. {
  314. if (dr["DispatchSort"].ToString() == "2")
  315. {
  316. dr["gongchuang"] = 200;
  317. }
  318. else
  319. {
  320. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  321. dr["gongchuang"] = response.code;
  322. }
  323. }
  324. }
  325. catch (NullReferenceException ex)
  326. {
  327. // 处理空引用异常
  328. dr["refund_fees"] = "0.00";
  329. }
  330. }
  331. }
  332. writeGridDataTableJson(dStruct.TotalCount, dt);
  333. }
  334. public void get_erp_orderlist_sumprice()
  335. {
  336. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  337. return;
  338. List<string> lw = new List<string>();
  339. string tid = GetPostString("ctid");
  340. string date1 = GetPostString("date1");
  341. string date2 = GetPostString("date2");
  342. if (tid.Length > 0 || date1.Length > 0)
  343. {
  344. lw.Add(string.Format("ctid like '%{0}%'", tid));
  345. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  346. if (dw.Length > 0) lw.Add(dw);
  347. }
  348. else
  349. {
  350. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  351. }
  352. string shopname = GetPostString("shopname");
  353. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  354. string buyernick = GetPostString("buyer_nick");
  355. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  356. string customer = GetPostString("customer");
  357. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  358. string design = GetPostString("design");
  359. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  360. string orderState = GetPostString("orderState");
  361. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  362. string address = GetPostString("address");
  363. 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));
  364. string sellermemo = GetPostString("seller_memo");
  365. if (sellermemo.Length > 0)
  366. {
  367. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  368. }
  369. string apdate1 = GetPostString("apdate1");
  370. string apdate2 = GetPostString("apdate2");
  371. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  372. if (dwap.Length > 0) lw.Add(dwap);
  373. string price1 = GetPostString("price1");
  374. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  375. string price2 = GetPostString("price2");
  376. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  377. string isoldcustomer = GetPostString("isoldcus");
  378. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  379. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  380. if (PKey != "admin")
  381. {
  382. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  383. lw.Add(string.Format("shopId in ({0})", usershop));
  384. }
  385. //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";
  386. string mainWhere = string.Join(" and ", lw.ToArray());
  387. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  388. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  389. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  390. decimal total = 0;
  391. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  392. {
  393. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  394. }
  395. var res = new
  396. {
  397. data = total
  398. };
  399. string ro_jsond = JsonConvert.SerializeObject(res);
  400. returnSuccess(ro_jsond);
  401. return;
  402. }
  403. public void get_erp_CustomerServiceGather()
  404. {
  405. string userWhere = "", orderWhere = "";
  406. List<string> lw = new List<string>();
  407. string customer = GetPostString("customer");
  408. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  409. string shopname = GetPostString("shopname");
  410. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  411. string date1 = GetPostString("date1");
  412. string date2 = GetPostString("date2");
  413. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  414. if (dw.Length > 0) lw.Add(dw);
  415. orderWhere = string.Join(" and ", lw.ToArray());
  416. 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 " +
  417. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  418. "left join " +
  419. "( " +
  420. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  421. ") as b on a.ID = b.CustomerUserId " +
  422. "left join " +
  423. "( " +
  424. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  425. ") as d on a.ID = d.CustomerUserId " +
  426. "left join " +
  427. "( " +
  428. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  429. ") as e on a.ID = e.CustomerUserId " +
  430. "left join " +
  431. "( " +
  432. " select CustomerUserId, RefundCount, RefundSum from " +
  433. " ( " +
  434. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  435. " from CE_ErpTradeRefund a " +
  436. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  437. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  438. " group by CustomerUserId " +
  439. " ) as a " +
  440. ") as f on a.ID = f.CustomerUserId " +
  441. "where a.PostCode = 'CustomerService'",
  442. userWhere, orderWhere);
  443. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  444. writeGridDataTableJson(dt.Rows.Count, dt);
  445. //writeGridDataTableJson(dt.Rows.Count, dt);
  446. }
  447. //设计汇总
  448. public void get_erp_DesignerGather()
  449. {
  450. string userWhere = "", orderWhere = "";
  451. List<string> lw = new List<string>();
  452. string Designer = GetPostString("designer");
  453. int org = GetPostInt("org");
  454. if (Designer.Length > 0)
  455. {
  456. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  457. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  458. }
  459. else if (org > 0)
  460. {
  461. userWhere = string.Format(" where OrgID ={0}", org);
  462. }
  463. string shopname = GetPostString("shopname");
  464. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  465. string state = GetPostString("state");
  466. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  467. string OrderArea = GetPostString("order_area");
  468. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  469. string date1 = GetPostString("date1");
  470. string date2 = GetPostString("date2");
  471. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  472. if (dw.Length > 0) lw.Add(dw);
  473. string UpDate1 = GetPostString("UpDate1");
  474. string UpDate2 = GetPostString("UpDate2");
  475. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  476. if (dw.Length > 0) lw.Add(dw);
  477. orderWhere = string.Join(" and ", lw.ToArray());
  478. 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 (" +
  479. "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 " +
  480. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  481. "left join " +
  482. "( " +
  483. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  484. ") as b on a.ID = b.DesignUserId " +
  485. "left join " +
  486. "( " +
  487. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  488. ") as d on a.ID = d.DesignUserId " +
  489. "left join " +
  490. "( " +
  491. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  492. ") as e on a.ID = e.DesignUserId " +
  493. "left join " +
  494. "( " +
  495. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  496. ") as g on a.ID = g.DesignUserId " +
  497. "left join " +
  498. "( " +
  499. " select CustomerUserId, RefundCount, RefundSum from " +
  500. " ( " +
  501. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  502. " from CE_ErpTradeRefund a " +
  503. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  504. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  505. " group by CustomerUserId " +
  506. " ) as a " +
  507. ") as f on a.ID = f.CustomerUserId " +
  508. "where a.PostCode = 'Designer') as z",
  509. userWhere, orderWhere);
  510. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  511. writeGridDataTableJson(dt.Rows.Count, dt);
  512. }
  513. //删除tradecell的订单
  514. public void del_erp_cellorder()
  515. {
  516. if (UrlPostParmsCheck("ctid"))
  517. {
  518. string eid = GetPostString("ctid");
  519. CeErpTradeCell.DelByCtid(eid);
  520. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  521. returnSuccessMsg("删除成功");
  522. }
  523. }
  524. public void clear_erp_refundstate()
  525. {
  526. if (UrlPostParmsCheck("ids"))
  527. {
  528. string eids = GetPostString("ids");
  529. string[] ctidList = eids.Split(',');
  530. foreach (string ctid in ctidList)
  531. {
  532. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  533. if (entity != null)
  534. {
  535. entity.IsRefund = 0;
  536. entity.Update();
  537. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  538. }
  539. else
  540. continue;
  541. }
  542. returnSuccessMsg("操作成功");
  543. return;
  544. }
  545. returnErrorMsg("缺少必要参数");
  546. }
  547. public void set_erp_urgency()
  548. {
  549. if (UrlPostParmsCheck("ctid"))
  550. {
  551. string eid = GetPostString("ctid");
  552. CeErpTradeCell entity = null;
  553. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  554. if (entity != null)
  555. {
  556. string utime = GetPostString("urgencytime");
  557. if (utime.Length > 0)
  558. {
  559. entity.UrgencyTime = Convert.ToDateTime(utime);
  560. }
  561. else
  562. {
  563. returnErrorMsg("请选择加急时间");
  564. return;
  565. }
  566. if (entity.OrderState <= 4)
  567. {
  568. //entity.seller_memo = entity.seller_memo + "-加急";
  569. string smemo = entity.seller_memo;
  570. int kindex = smemo.IndexOf(")");
  571. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  572. if (lastoneStr != "-")
  573. {
  574. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  575. }
  576. string prememo = smemo.Substring(0, kindex + 2);
  577. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  578. int lastkindex = lastmemo.IndexOf("(");
  579. DateTime urgtime = Convert.ToDateTime(utime);
  580. string newlastmemo = "";
  581. if (lastkindex == 0)
  582. {
  583. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  584. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  585. }
  586. else
  587. {
  588. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  589. }
  590. entity.seller_memo = prememo + newlastmemo;
  591. }
  592. entity.IsUrgency = true;
  593. entity.UpdateTime = DateTime.Now;
  594. entity.Update();
  595. ApiVo apiVo = new ApiVo();
  596. apiVo.orderNumber = entity.ctid;
  597. apiVo.actionName = "changeDesign";
  598. apiVo.orderRemarks = entity.seller_memo;
  599. apiVo.remarkSign = 3;
  600. designHelper.API_WorkCore(apiVo); //changeDesign
  601. CeErpSukuraData.createInfo(entity.ctid, 7);
  602. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  603. returnSuccessMsg("设置成功!");
  604. return;
  605. }
  606. returnErrorMsg("找不到记录");
  607. }
  608. }
  609. public void set_erp_reset()
  610. {
  611. if (UrlPostParmsCheck("ctid"))
  612. {
  613. string eid = GetPostString("ctid");
  614. CeErpTradeCell entity = null;
  615. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  616. if (entity != null)
  617. {
  618. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  619. {
  620. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  621. {
  622. returnErrorMsg("财务要求已下单已发货无法重置");
  623. return;
  624. }
  625. }
  626. entity.IsUrgency = false;
  627. entity.seller_memo = "";
  628. entity.OtherMemo = "";
  629. entity.OrderState = 0;
  630. entity.IsReturn = 0;
  631. //entity.IsRefund = 0;
  632. entity.MemoOpt = 0;
  633. entity.AfterSaleState = 0;
  634. entity.AfterSaleResponsible = "";
  635. entity.AfterSaleUserId = 0;
  636. entity.IsNeedBill = 0;
  637. entity.CustomerUserId = 0;
  638. entity.DesignUserId = 0;
  639. entity.SupplierId = 0;
  640. entity.PlaceUserId = 0;
  641. entity.ptid = "";
  642. entity.IsSample = 0;
  643. entity.IsXianHuo = 0;
  644. entity.isDianziOrder = 0;
  645. entity.DispatchSort = 0;
  646. entity.FinishPlaceTime = null;
  647. entity.Update();
  648. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  649. if (trade != null)
  650. {
  651. trade.seller_memo = "";
  652. trade.Update();
  653. }
  654. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  655. returnSuccessMsg("重置成功!");
  656. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  657. if (desginBill != null)
  658. {
  659. desginBill.isDel = 1;
  660. desginBill.Update();
  661. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  662. }
  663. ApiVo apiVo = new ApiVo();
  664. apiVo.orderNumber = entity.ctid;
  665. apiVo.actionName = "resetDesign";
  666. designHelper.API_WorkCore(apiVo);//resetDesign
  667. return;
  668. }
  669. returnErrorMsg("找不到记录");
  670. }
  671. }
  672. public void save_erp_sellermemo()
  673. {
  674. if (UrlPostParmsCheck("ctid"))
  675. {
  676. string ctid = GetPostString("ctid");
  677. CeErpTradeCell entity = null;
  678. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  679. if (entity != null)
  680. {
  681. string memo = GetPostString("seller_memo");
  682. memo = memo.Replace(" ", "");
  683. if (memo.Contains("补差"))
  684. {
  685. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  686. return;
  687. }
  688. if (entity.seller_memo != memo)
  689. {
  690. if (entity.IsSample == 2)
  691. {
  692. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  693. return;
  694. }
  695. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  696. {
  697. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  698. {
  699. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  700. return;
  701. }
  702. }
  703. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  704. }
  705. commonHelper.getCytPrice(entity);
  706. int memoopt = GetPostInt("MemoOpt");
  707. Boolean ismemoopt = false;
  708. if (memoopt > 0)
  709. {
  710. string stropt = "";
  711. if (memoopt == 1)
  712. {
  713. stropt = "“改稿”";
  714. ismemoopt = true;
  715. }
  716. else if (memoopt == 2)
  717. {
  718. stropt = "“定稿”";
  719. }
  720. else if (memoopt == 3)
  721. {
  722. stropt = "“查货”";
  723. CeErpSukuraData.createInfo(entity.ctid, 6);
  724. }
  725. entity.MemoOpt = Convert.ToInt32(memoopt);
  726. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  727. }
  728. if (entity.OrderState < 5)
  729. {
  730. memo = memo.Replace("(", "(");
  731. memo = memo.Replace(")", ")");
  732. }
  733. entity.seller_memo = memo;
  734. entity.UpdateTime = DateTime.Now;
  735. entity.Update();
  736. ApiVo apiVo = new ApiVo();
  737. apiVo.orderNumber = entity.ctid;
  738. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  739. apiVo.orderRemarks = memo;
  740. apiVo.remarkSign = memoopt;
  741. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  742. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  743. returnSuccessMsg("保存成功!");
  744. return;
  745. }
  746. returnErrorMsg("找不到记录");
  747. }
  748. }
  749. public void ins_erp_checkorder()
  750. {
  751. if (UrlPostParmsCheck("ctid"))
  752. {
  753. string ctid = GetPostString("ctid");
  754. CeErpTradeCell entity = null;
  755. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  756. if (entity != null)
  757. {
  758. if (entity.OrderState < 6)
  759. {
  760. returnErrorMsg("下单完成后才可查货");
  761. return;
  762. }
  763. /*if (entity.OrderState > 6)
  764. {
  765. returnErrorMsg("订单已发货");
  766. return;
  767. }*/
  768. if (entity.FinishPlaceTime != null)
  769. {
  770. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  771. {
  772. returnErrorMsg("下单时间不足,无法查货");
  773. return;
  774. }
  775. }
  776. entity.MemoOpt = 3;
  777. entity.CheckOrderTime = DateTime.Now;
  778. entity.UpdateTime = DateTime.Now;
  779. entity.Update();
  780. CeErpSukuraData.createInfo(entity.ctid, 6);
  781. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  782. returnSuccessMsg("操作成功!");
  783. return;
  784. }
  785. returnErrorMsg("找不到记录");
  786. }
  787. }
  788. public void save_erp_othermemo()
  789. {
  790. if (UrlPostParmsCheck("ctid"))
  791. {
  792. string ctid = GetPostString("ctid");
  793. CeErpTradeCell entity = null;
  794. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  795. if (entity != null)
  796. {
  797. entity.OtherMemo = GetPostString("otherMemo");
  798. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  799. {
  800. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  801. StringBuilder sql = new StringBuilder();
  802. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  803. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  804. if (dt != null && dt.Rows.Count > 0)
  805. {
  806. foreach (DataRow dr in dt.Rows)
  807. {
  808. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  809. {
  810. //品类一直
  811. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  812. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  813. if (ceErpSampleCustomer == null)
  814. {
  815. ceErpSampleCustomer = new CeErpSampleCustomer();
  816. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  817. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  818. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  819. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  820. ceErpSampleCustomer.shopId = entity.ShopId;
  821. }
  822. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  823. ceErpSampleCustomer.lastTid = entity.tid;
  824. if (ceErpSampleCustomer.ID > 0)
  825. {
  826. ceErpSampleCustomer.Update();
  827. }
  828. else
  829. {
  830. ceErpSampleCustomer.Create();
  831. }
  832. }
  833. }
  834. }
  835. }
  836. //if (entity.IsOldCustomer == 1)
  837. //{
  838. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  839. //{
  840. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  841. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  842. //}
  843. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  844. //{
  845. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  846. // {
  847. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  848. // {
  849. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  850. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  851. // }
  852. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  853. // {
  854. // entity.OrderState = 2;
  855. // entity.DesignUserId = 0;
  856. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  857. // }
  858. // else
  859. // {
  860. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  861. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  862. // }
  863. // }
  864. //}
  865. //}
  866. entity.Update();
  867. returnSuccessMsg("保存成功!");
  868. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  869. return;
  870. }
  871. returnErrorMsg("找不到记录");
  872. }
  873. }
  874. public void save_erp_customermemo()
  875. {
  876. if (UrlPostParmsCheck("ctid"))
  877. {
  878. string ctid = GetPostString("ctid");
  879. CeErpTradeCell entity = null;
  880. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  881. if (entity != null)
  882. {
  883. entity.CustomerMemo = GetPostString("CustomerMemo");
  884. entity.Update();
  885. ApiVo apiVo = new ApiVo();
  886. apiVo.orderNumber = entity.ctid;
  887. apiVo.actionName = "followRemarks";
  888. apiVo.orderRemarks = entity.CustomerMemo;
  889. designHelper.API_WorkCore(apiVo);//followRemarks
  890. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  891. returnSuccessMsg("保存成功!");
  892. return;
  893. }
  894. returnErrorMsg("找不到记录");
  895. }
  896. }
  897. public void upd_erp_addmemotag()
  898. {
  899. if (UrlPostParmsCheck("ctid"))
  900. {
  901. ;
  902. string eid = GetPostString("ctid");
  903. string sfTagstr = GetPostString("memotag");
  904. CeErpTradeCell entity = null;
  905. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  906. if (entity != null)
  907. {
  908. ApiVo apiVo = new ApiVo();
  909. if (entity.OrderState == 0)
  910. {
  911. returnErrorMsg("请先领单");
  912. return;
  913. }
  914. //撤销顺丰
  915. if (sfTagstr == "撤销顺丰")
  916. {
  917. entity.IsSF = 0;
  918. string reMsg = "";
  919. string oldmemo = entity.seller_memo;
  920. if (entity.OrderState < 5)
  921. {
  922. oldmemo = oldmemo.Replace("顺丰到付", "");
  923. oldmemo = oldmemo.Replace("顺丰寄付", "");
  924. entity.seller_memo = oldmemo;
  925. }
  926. else
  927. {
  928. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  929. {
  930. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  931. }
  932. }
  933. entity.Update();
  934. apiVo.orderNumber = entity.ctid;
  935. apiVo.actionName = "orderRemarks";
  936. apiVo.orderRemarks = entity.seller_memo;
  937. apiVo.isSf = entity.IsSF.ToString();
  938. designHelper.API_WorkCore(apiVo);//orderRemarks
  939. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  940. returnSuccessMsg("撤销成功!" + reMsg);
  941. return;
  942. }
  943. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  944. {
  945. //string oldmemo = entity.seller_memo;
  946. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  947. string sfStr = GetPostString("memotag");
  948. string smemo = entity.seller_memo;
  949. int kindex = smemo.IndexOf(")");
  950. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  951. if (lastoneStr != "-")
  952. {
  953. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  954. }
  955. string prememo = smemo.Substring(0, kindex + 2);
  956. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  957. int lastkindex = lastmemo.IndexOf("(");
  958. string newlastmemo = "";
  959. if (lastkindex == 0)
  960. {
  961. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  962. newlastmemo = "(" + sfStr + "." + useLastmemo;
  963. }
  964. else
  965. {
  966. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  967. }
  968. entity.seller_memo = prememo + newlastmemo;
  969. }
  970. string sfTagMSg = "";
  971. if (sfTagstr == "顺丰寄付")
  972. {
  973. entity.IsSF = 1;
  974. sfTagMSg = "顺丰寄付";
  975. }
  976. else if (sfTagstr == "顺丰到付")
  977. {
  978. entity.IsSF = 2;
  979. sfTagMSg = "顺丰到付";
  980. }
  981. entity.Update();
  982. apiVo = new ApiVo();
  983. apiVo.orderNumber = entity.ctid;
  984. apiVo.actionName = "orderRemarks";
  985. apiVo.orderRemarks = entity.seller_memo;
  986. apiVo.isSf = entity.IsSF.ToString();
  987. designHelper.API_WorkCore(apiVo);//orderRemarks
  988. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  989. returnSuccessMsg("标记成功!");
  990. return;
  991. }
  992. returnErrorMsg("找不到记录");
  993. }
  994. }
  995. public void upd_erp_ordertag()
  996. {
  997. if (UrlPostParmsCheck("ctid"))
  998. {
  999. string eid = GetPostString("ctid");
  1000. CeErpTradeCell entity = null;
  1001. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1002. if (entity != null)
  1003. {
  1004. int tag = GetPostInt("wechattag");
  1005. //if(tag==4 && entity.IsSample == 2)
  1006. //{
  1007. // returnErrorMsg("补差价单不能标记微信单");
  1008. // return;
  1009. //}
  1010. entity.wechatTag = tag;
  1011. entity.Update();
  1012. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1013. if (tag == 1)
  1014. {
  1015. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1016. if (cash == null)
  1017. {
  1018. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1019. cash = new CeErpReturnCash();
  1020. cash.tid = entity.tid;
  1021. cash.seller_nick = main.seller_nick;
  1022. cash.payment = trade.payment;
  1023. cash.buyer_nick = main.buyer_nick;
  1024. cash.cashstate = 0;
  1025. cash.rtype = "微信返现";
  1026. cash.returnprice = 0;
  1027. cash.created = DateTime.Now;
  1028. cash.con = "订单标记微信单";
  1029. cash.img = "";
  1030. cash.applyuserid = CurrentUser.UserID;
  1031. cash.Create();
  1032. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1033. }
  1034. else
  1035. {
  1036. cash.cashstate = 0;
  1037. cash.Update();
  1038. }
  1039. CeErpSukuraData.createInfo(entity.ctid, 9);
  1040. }
  1041. else if (tag == 2)
  1042. {
  1043. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1044. if (cash == null)
  1045. {
  1046. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1047. cash = new CeErpReturnCash();
  1048. cash.tid = entity.tid;
  1049. cash.seller_nick = main.seller_nick;
  1050. cash.payment = trade.payment;
  1051. cash.buyer_nick = main.buyer_nick;
  1052. cash.cashstate = 0;
  1053. cash.rtype = "推购返现";
  1054. cash.returnprice = 5;
  1055. cash.created = DateTime.Now;
  1056. cash.con = "订单标记推购单";
  1057. cash.img = "";
  1058. cash.applyuserid = CurrentUser.UserID;
  1059. cash.Create();
  1060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1061. }
  1062. else
  1063. {
  1064. cash.cashstate = 0;
  1065. cash.Update();
  1066. }
  1067. CeErpSukuraData.createInfo(entity.ctid, 9);
  1068. }
  1069. else if (tag == 3)
  1070. {
  1071. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1072. if (pers == null)
  1073. {
  1074. pers = new CeErpPersuade();
  1075. pers.ctid = entity.ctid;
  1076. pers.pstate = 0;
  1077. pers.created = DateTime.Now;
  1078. pers.applyuserid = CurrentUser.UserID;
  1079. pers.Create();
  1080. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1081. }
  1082. else
  1083. {
  1084. pers.pstate = 0;
  1085. pers.Update();
  1086. }
  1087. }
  1088. else if (tag == 4 || tag == 5)
  1089. {
  1090. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1091. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1092. if (pers == null)
  1093. {
  1094. pers = new CeErpStayGoods();
  1095. pers.t_id = entity.tid;
  1096. pers.status = "待审核";
  1097. pers.audit_type = 0;
  1098. if (tag == 4)
  1099. {
  1100. pers.stay_type = "微信推购";
  1101. }
  1102. else
  1103. {
  1104. pers.stay_type = "旺旺推购";
  1105. }
  1106. if (entity.IsXianHuo == 0)
  1107. {
  1108. pers.product_id = entity.ProductId;
  1109. }
  1110. pers.wangwang = main.buyer_nick;
  1111. pers.shop_name = main.seller_nick;
  1112. pers.creata_time = DateTime.Now;
  1113. pers.create_u_id = CurrentUser.UserID;
  1114. pers.create_u_name = CurrentUser.UserName;
  1115. pers.Create();
  1116. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1117. }
  1118. else
  1119. {
  1120. pers.audit_type = 0;
  1121. pers.Update();
  1122. }
  1123. CeErpSukuraData.createInfo(entity.ctid, 10);
  1124. }
  1125. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1126. returnSuccessMsg("标记成功!");
  1127. return;
  1128. }
  1129. returnErrorMsg("找不到记录");
  1130. }
  1131. }
  1132. public void upd_erp_ordertag_cancel()
  1133. {
  1134. if (UrlPostParmsCheck("ctid"))
  1135. {
  1136. string eid = GetPostString("ctid");
  1137. CeErpTradeCell entity = null;
  1138. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1139. if (entity != null)
  1140. {
  1141. entity.wechatTag = 0;
  1142. entity.Update();
  1143. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1144. if (pers != null)
  1145. {
  1146. pers.status = "取消推购";
  1147. pers.audit_type = 3;
  1148. pers.Update();
  1149. }
  1150. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1151. returnSuccessMsg("标记成功!");
  1152. return;
  1153. }
  1154. returnErrorMsg("找不到记录");
  1155. }
  1156. }
  1157. public void upd_erp_addweichattag()
  1158. {
  1159. if (UrlPostParmsCheck("ctid"))
  1160. {
  1161. ;
  1162. string eid = GetPostString("ctid");
  1163. CeErpTradeCell entity = null;
  1164. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1165. if (entity != null)
  1166. {
  1167. if (entity.IsAddWechat > 0)
  1168. {
  1169. returnErrorMsg("此单已经标记过了");
  1170. return;
  1171. }
  1172. 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);
  1173. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1174. if (dt.Rows.Count > 0)
  1175. {
  1176. entity.IsAddWechat = 2;
  1177. }
  1178. else
  1179. {
  1180. entity.IsAddWechat = 1;
  1181. }
  1182. entity.Update();
  1183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1184. returnSuccessMsg("标记成功!");
  1185. return;
  1186. }
  1187. returnErrorMsg("找不到记录");
  1188. }
  1189. }
  1190. public void upd_erp_getmyorder()
  1191. {
  1192. if (UrlPostParmsCheck("ctid"))
  1193. {
  1194. ;
  1195. string eid = GetPostString("ctid");
  1196. CeErpTradeCell entity = null;
  1197. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1198. if (entity != null)
  1199. {
  1200. if (entity.ctid.IndexOf("C") != -1)
  1201. {
  1202. StringBuilder sql = new StringBuilder();
  1203. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1204. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1205. if (dt.Rows.Count > 0)
  1206. {
  1207. decimal total = 0;
  1208. foreach (DataRow dr in dt.Rows)
  1209. {
  1210. total += Convert.ToDecimal(dr["payment"]);
  1211. }
  1212. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1213. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1214. {
  1215. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1216. return;
  1217. }
  1218. }
  1219. }
  1220. if (entity.OrderState == -1)
  1221. {
  1222. returnErrorMsg("待审核订单无法领取!");
  1223. return;
  1224. }
  1225. entity.CustomerUserId = CurrentUser.UserID;
  1226. if (entity.OrderState < 2)
  1227. {
  1228. entity.OrderState = 2;
  1229. if (entity.ShopId != 0)
  1230. {
  1231. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1232. }
  1233. }
  1234. entity.UpdateTime = DateTime.Now;
  1235. entity.Update();
  1236. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1237. returnSuccessMsg("领单成功!");
  1238. return;
  1239. }
  1240. returnErrorMsg("找不到记录");
  1241. }
  1242. }
  1243. public void getmyorder_from_init()
  1244. {
  1245. if (UrlPostParmsCheck("ctid"))
  1246. {
  1247. string eid = GetPostString("ctid");
  1248. CeErpTradeCell entity = null;
  1249. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1250. if (entity != null)
  1251. {
  1252. string sellerMemo = GetPostString("sellerMemo");
  1253. if (sellerMemo.Length > 0)
  1254. {
  1255. entity.seller_memo = sellerMemo;
  1256. }
  1257. string oterhMemo = GetPostString("otherMemo");
  1258. if (oterhMemo.Length > 0)
  1259. {
  1260. entity.OtherMemo = oterhMemo;
  1261. }
  1262. int urg = GetPostInt("urgency");
  1263. entity.IsUrgency = (urg == 1 ? true : false);
  1264. int wechat = GetPostInt("wechat");
  1265. int command = GetPostInt("command");
  1266. if (wechat == 1)
  1267. {
  1268. entity.wechatTag = 1;
  1269. }
  1270. if (command == 1)
  1271. {
  1272. entity.wechatTag = 2;
  1273. }
  1274. string pPro = GetPostString("pprofession");
  1275. if (pPro.Length > 0)
  1276. {
  1277. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1278. string spro = GetPostString("profession");
  1279. if (spro.Length > 0)
  1280. {
  1281. entity.ProfessionId = Convert.ToInt32(spro);
  1282. }
  1283. }
  1284. string proId = GetPostString("productId");
  1285. if (proId.Length > 0)
  1286. {
  1287. entity.ProductId = Convert.ToInt32(proId);
  1288. }
  1289. entity.Material = GetPostString("material");
  1290. entity.Craft = GetPostString("craft");
  1291. entity.CustomerUserId = CurrentUser.UserID;
  1292. if (entity.OrderState < 2)
  1293. {
  1294. entity.OrderState = 2;
  1295. if (entity.ShopId != 0)
  1296. {
  1297. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1298. }
  1299. }
  1300. entity.Update();
  1301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1302. returnSuccessMsg("领单成功!");
  1303. return;
  1304. }
  1305. returnErrorMsg("找不到记录");
  1306. }
  1307. }
  1308. public void upd_erp_setrelationorder()
  1309. {
  1310. if (UrlPostParmsCheck("ctid"))
  1311. {
  1312. ;
  1313. string eid = GetPostString("ctid");
  1314. string ftid = GetPostString("ftid");
  1315. CeErpTradeCell entity = null;
  1316. CeErpTradeCell fentity = null;
  1317. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1318. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1319. if (fentity == null)
  1320. {
  1321. returnErrorMsg("找不到关联的主订单");
  1322. return;
  1323. }
  1324. if (entity != null)
  1325. {
  1326. if (entity.OrderState >= 5)
  1327. {
  1328. returnErrorMsg("本单已经设计完成无法关联");
  1329. return;
  1330. }
  1331. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1332. {
  1333. returnErrorMsg("线下单续审核后才能关联!");
  1334. return;
  1335. }
  1336. entity.ptid = ftid;
  1337. entity.OrderState = fentity.OrderState;
  1338. //entity.status = fentity.status;
  1339. entity.CustomerUserId = fentity.CustomerUserId;
  1340. entity.DesignUserId = fentity.DesignUserId;
  1341. entity.seller_memo = "补差价单:" + ftid;
  1342. entity.IsSample = 2;
  1343. entity.Update();
  1344. ApiVo apiVo = new ApiVo();
  1345. apiVo.orderNumber = ftid;
  1346. apiVo.payment = entity.payment;
  1347. apiVo.actionName = "repairDesign";
  1348. designHelper.API_WorkCore(apiVo);//repairDesign
  1349. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1350. returnSuccessMsg("关联成功!");
  1351. return;
  1352. }
  1353. else
  1354. returnErrorMsg("找不到记录");
  1355. }
  1356. }
  1357. public void download_erp_neworder()
  1358. {
  1359. string seller = GetPostString("seller_nick");
  1360. string tid = GetPostString("tid");
  1361. if (seller.Length <= 0 || tid.Length <= 0)
  1362. {
  1363. returnErrorMsg("数据错误");
  1364. }
  1365. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1366. //{
  1367. // returnErrorMsg("找不到店铺Sessionkey");
  1368. //}
  1369. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1370. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1371. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1372. if (res.IndexOf("refOid") == -1)
  1373. {
  1374. returnErrorMsg("下载订单数据失败");
  1375. return;
  1376. }
  1377. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1378. returnSuccessMsg("下载完成");
  1379. //tmcHelper.createNewOrder(res);
  1380. //CeErpTrade entr = null;
  1381. //entr = CeErpTrade.Get(tid);
  1382. //if (entr != null)
  1383. //{
  1384. // returnSuccess("下载成功");
  1385. // //下载成功之后,Cell表生成对应的订单;
  1386. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1387. //}
  1388. //else
  1389. //{
  1390. // returnErrorMsg("下载失败或者创建订单失败");
  1391. //}
  1392. }
  1393. public void set_erp_atersale()
  1394. {
  1395. if (UrlPostParmsCheck("ctid"))
  1396. {
  1397. string eid = GetPostString("ctid");
  1398. string reason = GetPostString("AfterSaleReason");
  1399. CeErpTradeCell entity = null;
  1400. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1401. if (entity != null)
  1402. {
  1403. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1404. {
  1405. returnErrorMsg("此订单已经在售后");
  1406. return;
  1407. }
  1408. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1409. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1410. entity.AfterSaleTime = DateTime.Now;
  1411. entity.Update();
  1412. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1413. returnSuccessMsg("转售后成功!");
  1414. return;
  1415. }
  1416. returnErrorMsg("找不到记录");
  1417. }
  1418. }
  1419. public void set_erp_withdraw()
  1420. {
  1421. if (UrlPostParmsCheck("ctid"))
  1422. {
  1423. try
  1424. {
  1425. string eid = GetPostString("ctid");//商品id
  1426. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1427. CeWithdraw ceWithdrawSelect = null;
  1428. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1429. if (ceWithdrawSelect != null)
  1430. {
  1431. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1432. {
  1433. ceWithdrawSelect.status = -1;
  1434. ceWithdrawSelect.Update();
  1435. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1436. returnSuccessMsg("重新发起审核成功");
  1437. return;
  1438. }
  1439. else
  1440. {
  1441. returnSuccessMsg("请勿重复申请!");
  1442. return;
  1443. }
  1444. }
  1445. else
  1446. {
  1447. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1448. if (string.IsNullOrEmpty(CustomerUserId))
  1449. {
  1450. CustomerUserId = "-1";
  1451. }
  1452. int Userid = CurrentUser.UserID;//用户id
  1453. CeWithdraw ceWithdraw = new CeWithdraw();
  1454. ceWithdraw.tid = eid;
  1455. ceWithdraw.userid = Userid;
  1456. ceWithdraw.providerid = CustomerUserId;
  1457. ceWithdraw.status = 3;
  1458. ceWithdraw.creationtime = DateTime.Now;
  1459. ceWithdraw.Create();
  1460. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1461. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1462. return;
  1463. }
  1464. }
  1465. catch
  1466. {
  1467. returnErrorMsg("申请撤回订单失败");
  1468. return;
  1469. }
  1470. }
  1471. }
  1472. public void ins_erp_billinfo()
  1473. {
  1474. if (UrlPostParmsCheck("ctid"))
  1475. {
  1476. string eid = GetPostString("ctid");
  1477. CeErpTradeCell entity = null;
  1478. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1479. if (entity != null)
  1480. {
  1481. CeErpBill bill = CeErpBill.GetByTid(eid);
  1482. bool isHave = false;
  1483. if (bill != null)
  1484. {
  1485. isHave = true;
  1486. if (bill.state != 4)
  1487. {
  1488. returnErrorMsg("此单已经申请过发票了");
  1489. return;
  1490. }
  1491. }
  1492. if (entity.IsNeedBill == 0)
  1493. {
  1494. entity.IsNeedBill = 1;
  1495. }
  1496. entity.Update();
  1497. string errjson = "";
  1498. try
  1499. {
  1500. CeErpBill bill_entity = new CeErpBill();
  1501. bill_entity.tid = entity.tid;
  1502. bill_entity.title = GetPostString("title");
  1503. string taxstr = GetPostString("tax");
  1504. taxstr = taxstr.Replace(" ", "");
  1505. bill_entity.tax = taxstr;
  1506. bill_entity.bank = GetPostString("bank");
  1507. string bankacstr = GetPostString("bankac");
  1508. bankacstr = bankacstr.Replace(" ", "");
  1509. bill_entity.bankac = bankacstr;
  1510. bill_entity.address = GetPostString("address");
  1511. bill_entity.phone = GetPostString("phone");
  1512. bill_entity.price = GetPostString("price");
  1513. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1514. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1515. {
  1516. billCount += 1;
  1517. }
  1518. string prebill = "ltb";
  1519. for (int idx = 1; idx <= billCount; idx++)
  1520. {
  1521. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1522. string billoid = prebill + idx + dtstr;
  1523. bill_entity.billOrderId += billoid;
  1524. if (idx < billCount)
  1525. {
  1526. bill_entity.billOrderId += ",";
  1527. }
  1528. }
  1529. bill_entity.productId = GetPostInt("ProductName");
  1530. bill_entity.num = GetPostInt("num");
  1531. bill_entity.unit = GetPostString("unit");
  1532. bill_entity.type = GetPostString("type");
  1533. bill_entity.sendType = GetPostString("SendType");
  1534. bill_entity.email = GetPostString("email");
  1535. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1536. bill_entity.shopName = GetPostString("ShopName");
  1537. bill_entity.applymemo = GetPostString("applyMemo");
  1538. bill_entity.createTime = DateTime.Now;
  1539. bill_entity.state = 0;
  1540. bill_entity.userId = CurrentUser.UserID;
  1541. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1542. bill_entity.Create();
  1543. }
  1544. catch (Exception ex)
  1545. {
  1546. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1547. returnErrorMsg("创建发票出错!");
  1548. return;
  1549. }
  1550. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1551. returnSuccessMsg("发票申请成功!");
  1552. return;
  1553. }
  1554. returnErrorMsg("找不到记录");
  1555. }
  1556. }
  1557. public void ins_erp_neworder()
  1558. {
  1559. if (UrlPostParmsCheck("receiver_name"))
  1560. {
  1561. CeErpTrade entity = new CeErpTrade();
  1562. string plat_form = GetPostString("platform");
  1563. string preStr = "N_";
  1564. if (plat_form == "拼多多")
  1565. {
  1566. preStr = "P_";
  1567. }
  1568. else if (plat_form == "阿里巴巴")
  1569. {
  1570. preStr = "A_";
  1571. }
  1572. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1573. entity.seller_nick = GetPostString("seller_nick");
  1574. entity.buyer_nick = GetPostString("buyer_nick");
  1575. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1576. entity.total_fee = entity.payment;
  1577. entity.pay_time = DateTime.Now;
  1578. entity.status = "NOT_SHIPPED";
  1579. entity.receiver_name = GetPostString("receiver_name");
  1580. entity.receiver_mobile = GetPostString("receiver_mobile");
  1581. entity.receiver_state = GetPostString("receiver_state");
  1582. entity.receiver_city = GetPostString("receiver_city");
  1583. entity.receiver_district = GetPostString("receiver_district");
  1584. entity.receiver_address = GetPostString("receiver_address");
  1585. if (entity.receiver_state == "" || entity.receiver_city == "")
  1586. {
  1587. returnErrorMsg("收件地址不能为空");
  1588. return;
  1589. }
  1590. int shopId = 0;
  1591. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1592. if (nShop != null)
  1593. {
  1594. shopId = nShop.ID;
  1595. }
  1596. if (shopId != 34 && entity.payment == 0)
  1597. {
  1598. returnErrorMsg("公司自用的单金额才能为0");
  1599. return;
  1600. }
  1601. entity.Create();
  1602. CeErpTradeCell entitycell = new CeErpTradeCell();
  1603. entitycell.ctid = entity.tid;
  1604. entitycell.tid = entity.tid;
  1605. entitycell.ShopId = shopId;
  1606. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1607. entitycell.OrderState = 0;
  1608. entitycell.pay_time = entity.pay_time;
  1609. entitycell.IsOffLineOrder = 1;
  1610. entitycell.Create();
  1611. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1612. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1613. return;
  1614. }
  1615. }
  1616. public void ins_erp_neworder2()
  1617. {
  1618. if (UrlPostParmsCheck("receiver_name"))
  1619. {
  1620. //string plat_form = GetPostString("platform");
  1621. string preStr = "X_";
  1622. string memo = GetPostString("memo");
  1623. string productId = GetPostString("productId");
  1624. string primg = GetPostString("proofimg");
  1625. string sellerNick = GetPostString("seller_nick");
  1626. string addFrom = GetPostString("addfrom");
  1627. if (addFrom == "1")
  1628. {
  1629. preStr = "N_";
  1630. }
  1631. int shopId = 0;
  1632. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1633. if (nShop != null)
  1634. {
  1635. shopId = nShop.ID;
  1636. }
  1637. else
  1638. {
  1639. returnErrorMsg("找不到对应店铺");
  1640. return;
  1641. }
  1642. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1643. {
  1644. returnErrorMsg("必须上传付款凭证");
  1645. return;
  1646. }
  1647. CeErpTrade entity = new CeErpTrade();
  1648. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1649. entity.seller_nick = sellerNick;
  1650. entity.buyer_nick = GetPostString("buyer_nick");
  1651. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1652. entity.total_fee = entity.payment;
  1653. entity.pay_time = DateTime.Now;
  1654. entity.status = "NOT_SHIPPED";
  1655. entity.receiver_name = GetPostString("receiver_name");
  1656. entity.receiver_mobile = GetPostString("receiver_mobile");
  1657. entity.receiver_state = GetPostString("receiver_state");
  1658. entity.receiver_city = GetPostString("receiver_city");
  1659. entity.receiver_district = GetPostString("receiver_district");
  1660. entity.receiver_address = GetPostString("receiver_address");
  1661. entity.seller_memo = memo;
  1662. entity.orderFrom = 20;
  1663. entity.orderType = 15;
  1664. if (entity.receiver_state == "" || entity.receiver_city == "")
  1665. {
  1666. returnErrorMsg("收件地址不能为空");
  1667. return;
  1668. }
  1669. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1670. {
  1671. returnErrorMsg("公司自用的单金额才能为0");
  1672. return;
  1673. }
  1674. entity.Create();
  1675. string toWhere = GetPostString("towhere");
  1676. CeErpTradeCell entitycell = new CeErpTradeCell();
  1677. entitycell.ctid = entity.tid;
  1678. //唯一标识
  1679. entitycell.OrderSn = entity.tid;
  1680. string orderSn = dataHelper.getSaleOrderSn();
  1681. if (orderSn != "")
  1682. {
  1683. entitycell.OrderSn = orderSn;
  1684. }
  1685. entitycell.tid = entity.tid;
  1686. //if (preStr == "X_")
  1687. //{
  1688. entitycell.IsOffLineOrder = 1;
  1689. //}
  1690. entitycell.CustomerUserId = CurrentUser.UserID;
  1691. entitycell.PayProofImg = primg;
  1692. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1693. entitycell.ProductId = Convert.ToInt32(productId);
  1694. entitycell.ShopId = shopId;
  1695. entitycell.UpdateTime = DateTime.Now;
  1696. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1697. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1698. {
  1699. entitycell.IsXianHuo = 1;
  1700. }
  1701. entitycell.pay_time = entity.pay_time;
  1702. if (toWhere == "1")
  1703. {
  1704. entitycell.OrderState = 2;
  1705. }
  1706. else
  1707. {
  1708. entitycell.OrderState = 6;
  1709. entitycell.FinishPlaceTime = entitycell.pay_time;
  1710. }
  1711. if (shopId == 94)
  1712. {
  1713. entitycell.OrderState = 4;
  1714. entitycell.WaitDesignTime = entitycell.pay_time;
  1715. entitycell.StartDesignTime = entitycell.pay_time;
  1716. entitycell.DesignUserId = 218;
  1717. }
  1718. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1719. {
  1720. entitycell.OrderState = -1;//修改12-5
  1721. CeWithdraw ceWithdraw = new CeWithdraw();
  1722. ceWithdraw.tid = entity.tid;
  1723. ceWithdraw.providerid = "-1";
  1724. ceWithdraw.status = -1;
  1725. ceWithdraw.creationtime = DateTime.Now;
  1726. ceWithdraw.userid = 1337;
  1727. ceWithdraw.Create();
  1728. }
  1729. entitycell.Create();
  1730. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1731. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1732. {
  1733. addPlaceRegist(entitycell, CurrentUser.UserID);
  1734. }
  1735. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1736. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1737. return;
  1738. }
  1739. }
  1740. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1741. {
  1742. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1743. entity.PlactTime = tradecell.pay_time;
  1744. entity.AddUserId = userid;
  1745. entity.FileName = tradecell.seller_memo;
  1746. entity.Supplier = 24;
  1747. entity.CreateTime = DateTime.Now;
  1748. entity.Did = tradecell.ctid;
  1749. entity.tid = tradecell.tid;
  1750. entity.splitTag = tradecell.SplitTag;
  1751. entity.CurState = "未完成";
  1752. entity.Create();
  1753. }
  1754. public void get_erp_offlinelist()
  1755. {
  1756. DataStruct dStruct = GetPostStruct();
  1757. List<string> lw = new List<string>();
  1758. string tid = GetPostString("ctid");
  1759. string date1 = GetPostString("date1");
  1760. string date2 = GetPostString("date2");
  1761. if (tid.Length > 0 || date1.Length > 0)
  1762. {
  1763. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1764. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1765. if (dw.Length > 0) lw.Add(dw);
  1766. }
  1767. else
  1768. {
  1769. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1770. }
  1771. string shopname = GetPostString("shopname");
  1772. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1773. string buyernick = GetPostString("buyer_nick");
  1774. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1775. string customer = GetPostString("customer");
  1776. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1777. string design = GetPostString("design");
  1778. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1779. string orderState = GetPostString("orderState");
  1780. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1781. string address = GetPostString("address");
  1782. 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));
  1783. string sellermemo = GetPostString("seller_memo");
  1784. if (sellermemo.Length > 0)
  1785. {
  1786. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1787. }
  1788. string price1 = GetPostString("price1");
  1789. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1790. string price2 = GetPostString("price2");
  1791. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1792. //if (PKey != "admin")
  1793. //{
  1794. // string usershop = CurrentUser.User.pemShop;
  1795. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1796. //}
  1797. //if (ex_psize > 0)
  1798. //{
  1799. dStruct.Order = "pay_time desc";
  1800. //}
  1801. //else
  1802. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1803. lw.Add(string.Format("IsOffLineOrder=1"));
  1804. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1805. DataTable dt = null;
  1806. dt = WebCache.GetData("view_erptradecell", dStruct);
  1807. writeGridDataTableJson(dStruct.TotalCount, dt);
  1808. }
  1809. public void get_erp_returncashrecord()
  1810. {
  1811. DataStruct dStruct = GetPostStruct();
  1812. List<string> lw = new List<string>();
  1813. string tid = GetPostString("ctid");
  1814. if (tid.Length > 0)
  1815. {
  1816. lw.Add(string.Format("tid like '%{0}%'", tid));
  1817. dStruct.Order = "id desc";
  1818. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1819. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1820. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1821. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1822. return;
  1823. }
  1824. returnErrorMsg("id数据错误!");
  1825. }
  1826. public void ins_erp_returncashrecord()
  1827. {
  1828. if (UrlPostParmsCheck("tid"))
  1829. {
  1830. string tid = GetPostString("tid");
  1831. string retype = GetPostString("type");
  1832. StringBuilder sql = new StringBuilder();
  1833. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1834. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1835. if (dt.Rows.Count > 0)
  1836. {
  1837. returnErrorMsg("相同返现类型记录已存在");
  1838. return;
  1839. }
  1840. CeErpReturnCash entity = new CeErpReturnCash();
  1841. entity.tid = tid;
  1842. entity.seller_nick = GetPostString("seller_nick");
  1843. string pment = GetPostString("payment");
  1844. if (pment.Length > 0)
  1845. {
  1846. entity.payment = Convert.ToDouble(pment);
  1847. }
  1848. entity.buyer_nick = GetPostString("buyer_nick");
  1849. entity.cashstate = 0;
  1850. entity.rtype = retype;
  1851. string rPrice = GetPostString("returnprice");
  1852. if (rPrice.Length > 0)
  1853. {
  1854. entity.returnprice = Convert.ToDouble(rPrice);
  1855. }
  1856. entity.created = DateTime.Now;
  1857. entity.con = GetPostString("con");
  1858. entity.img = GetPostString("img");
  1859. entity.applyuserid = CurrentUser.UserID;
  1860. entity.Create();
  1861. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1862. returnSuccessMsg("操作成功!");
  1863. return;
  1864. }
  1865. }
  1866. public void set_erp_predelivery()
  1867. {
  1868. if (UrlPostParmsCheck("ctid"))
  1869. {
  1870. string eid = GetPostString("ctid");
  1871. CeErpTradeCell entity = null;
  1872. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1873. if (entity != null)
  1874. {
  1875. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1876. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1877. //{
  1878. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1879. // return;
  1880. //}
  1881. entity.IsPreDelivery = 1;
  1882. entity.Update();
  1883. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1884. returnSuccessMsg("预发货成功!");
  1885. return;
  1886. //string shop = GetPostString("seller_nick");
  1887. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1888. //string comName = GetPostString("comName");
  1889. //string comCode = GetPostString("comCode");
  1890. //string outSid = GetPostString("outSid");//运单号
  1891. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1892. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1893. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1894. //string apires = "";
  1895. //if (deliveryType == "虚拟发货")
  1896. //{
  1897. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1898. //}
  1899. //else
  1900. //{
  1901. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1902. //}
  1903. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1904. ////{
  1905. //if (apires.IndexOf("发货成功") != -1)
  1906. //{
  1907. // if (deliveryType != "虚拟发货")
  1908. // {
  1909. // //还要插入快递信息到 快递信息表
  1910. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1911. // exinfo.tid = eid;
  1912. // exinfo.out_sid = outSid;
  1913. // exinfo.company_code = comCode;
  1914. // exinfo.company_name = comName;
  1915. // exinfo.delivery_memo = deliveryMemo;
  1916. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1917. // exinfo.deliveryType = deliveryType;
  1918. // exinfo.Create();
  1919. // }
  1920. // returnSuccessMsg("发货成功!");
  1921. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1922. //}
  1923. //else
  1924. //{
  1925. // returnErrorMsg("淘宝发货失败!!");
  1926. //}
  1927. //return;
  1928. }
  1929. returnErrorMsg("找不到订单记录");
  1930. }
  1931. }
  1932. public void get_erp_unusuallist()
  1933. {
  1934. DataStruct dStruct = GetPostStruct();
  1935. List<string> lw = new List<string>();
  1936. string tid = GetPostString("ctid");
  1937. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1938. string shopname = GetPostString("shopname");
  1939. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1940. string buyernick = GetPostString("buyer_nick");
  1941. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1942. string ResponsibleMan = GetPostString("responsible");
  1943. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1944. string date1 = GetPostString("date1");
  1945. string date2 = GetPostString("date2");
  1946. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1947. if (dw.Length > 0) lw.Add(dw);
  1948. string price1 = GetPostString("price1");
  1949. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1950. string price2 = GetPostString("price2");
  1951. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1952. string orderState = GetPostString("orderState");
  1953. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1954. string sellermemo = GetPostString("seller_memo");
  1955. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1956. lw.Add(string.Format("UnusualTag > 0"));
  1957. lw.Add(string.Format("IsRefund<={0}", 1));
  1958. dStruct.Order = "pay_time desc";
  1959. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1960. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1961. writeGridDataTableJson(dStruct.TotalCount, dt);
  1962. }
  1963. public void set_erp_unusualtonomal()
  1964. {
  1965. if (UrlPostParmsCheck("ctid"))
  1966. {
  1967. string eid = GetPostString("ctid");
  1968. CeErpTradeCell entity = null;
  1969. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1970. if (entity != null)
  1971. {
  1972. entity.UnusualTag = -1;
  1973. entity.Update();
  1974. returnSuccessMsg("忽略成功!");
  1975. return;
  1976. }
  1977. returnErrorMsg("找不到记录");
  1978. }
  1979. }
  1980. public void ins_erp_unusualreason()
  1981. {
  1982. if (UrlPostParmsCheck("ctid"))
  1983. {
  1984. string eid = GetPostString("ctid");
  1985. CeErpTradeCell entity = null;
  1986. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1987. if (entity != null)
  1988. {
  1989. entity.MemoOpt = 4;
  1990. entity.UnusualCon = GetPostString("con");
  1991. entity.Update();
  1992. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1993. if (trade != null)
  1994. {
  1995. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1996. }
  1997. //查货是否超时
  1998. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1999. if (ceErpTradeCellExtend == null)
  2000. {
  2001. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2002. ceErpTradeCellExtend.ctid = entity.ctid;
  2003. }
  2004. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2005. {
  2006. ceErpTradeCellExtend.CheckOut += 1;
  2007. }
  2008. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2009. if (ceErpTradeCellExtend.ID > 0)
  2010. {
  2011. ceErpTradeCellExtend.Update();
  2012. }
  2013. else
  2014. {
  2015. ceErpTradeCellExtend.Create();
  2016. }
  2017. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2018. returnSuccessMsg("操作成功!");
  2019. return;
  2020. }
  2021. returnErrorMsg("找不到记录");
  2022. }
  2023. }
  2024. public void upd_erp_sampleorder()
  2025. {
  2026. if (UrlPostParmsCheck("ctid"))
  2027. {
  2028. string eid = GetPostString("ctid");
  2029. string[] eArr = eid.Split(',');
  2030. if (eArr.Length > 1)
  2031. {
  2032. List<string> eLst = new List<string>();
  2033. for (int i = 0; i < eArr.Length; i++)
  2034. {
  2035. eLst.Add("'" + eArr[i] + "'");
  2036. }
  2037. eid = string.Join(",", eLst.ToArray());
  2038. }
  2039. else
  2040. {
  2041. eid = "'" + eid + "'";
  2042. }
  2043. StringBuilder sql = new StringBuilder();
  2044. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2045. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2046. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2047. if (dt.Rows.Count > 0)
  2048. {
  2049. string errmsg = "";
  2050. foreach (DataRow dr in dt.Rows)
  2051. {
  2052. StringBuilder sqlsb = new StringBuilder();
  2053. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2054. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2055. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2056. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2057. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2058. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2059. {
  2060. continue;
  2061. }
  2062. else
  2063. {
  2064. string emsg = commonHelper.KeepChinese(apires);
  2065. errmsg += emsg;
  2066. }
  2067. }
  2068. if (errmsg.Length > 0)
  2069. {
  2070. returnErrorMsg(errmsg);
  2071. return;
  2072. }
  2073. returnSuccessMsg("操作成功");
  2074. return;
  2075. }
  2076. returnErrorMsg("找不到记录");
  2077. }
  2078. }
  2079. public void upd_erp_transcustomer()
  2080. {
  2081. if (UrlPostParmsCheck("ctid"))
  2082. {
  2083. string eid = GetPostString("ctid");
  2084. int userid = GetPostInt("CustomerUserId");
  2085. CeErpTradeCell entity = null;
  2086. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2087. if (entity != null)
  2088. {
  2089. //string[] mlist = entity.seller_memo.Split('-');
  2090. //string sql = "select * from view_erpuser where id=" + userid;
  2091. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2092. //if (dt != null && dt.Rows.Count > 0)
  2093. //{
  2094. // string nmemo = "";
  2095. // for(int i = 0; i < mlist.Length - 1; i++)
  2096. // {
  2097. // nmemo += mlist[i];
  2098. // nmemo += "-";
  2099. // }
  2100. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2101. // entity.seller_memo = nmemo;
  2102. //}
  2103. entity.CustomerUserId = userid;
  2104. entity.Update();
  2105. returnSuccessMsg("操作成功!");
  2106. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2107. return;
  2108. }
  2109. returnErrorMsg("找不到记录");
  2110. }
  2111. }
  2112. public void upd_erp_transdesigner()
  2113. {
  2114. if (UrlPostParmsCheck("ctid"))
  2115. {
  2116. string eids = GetPostString("ctid");
  2117. string[] ctidList = eids.Split(',');
  2118. int userid = GetPostInt("DesignUserId");
  2119. foreach (string ctid in ctidList)
  2120. {
  2121. CeErpTradeCell entity = null;
  2122. CeErpDesignerBill entitys = null;
  2123. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2124. entitys = CeErpDesignerBill.GetByTid(ctid);
  2125. if (entity != null)
  2126. {
  2127. if (entity.OrderState > 4)
  2128. {
  2129. continue;
  2130. }
  2131. //存在退款不能流转
  2132. if (entity.IsRefund > 0)
  2133. {
  2134. continue;
  2135. }
  2136. entity.DesignUserId = userid;
  2137. entity.WaitDesignTime = DateTime.Now;
  2138. entity.Update();
  2139. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2140. }
  2141. }
  2142. returnSuccessMsg("操作成功!");
  2143. }
  2144. }
  2145. public void upd_erp_distributedesigner()
  2146. {
  2147. if (UrlPostParmsCheck("ctid"))
  2148. {
  2149. string eid = GetPostString("ctid");
  2150. int userid = GetPostInt("DesignUserId");
  2151. string[] idlist = eid.Split(',');
  2152. if (idlist.Length <= 0)
  2153. {
  2154. returnErrorMsg("订单不能为空");
  2155. return;
  2156. }
  2157. foreach (string ctid in idlist)
  2158. {
  2159. CeErpTradeCell entity = null;
  2160. CeErpDesignerBill entitys = null;
  2161. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2162. else continue;
  2163. if (entity != null)
  2164. {
  2165. if (userid == 2125 || userid == 3542)
  2166. { }
  2167. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2168. {
  2169. returnErrorMsg("金额错误的订单无法指派");
  2170. return;
  2171. }
  2172. if (entity.OrderState >= 5)
  2173. {
  2174. returnErrorMsg("已经设计完成无法指派");
  2175. return;
  2176. }
  2177. if (entity.OrderState == -1)
  2178. {
  2179. returnErrorMsg("审核中的订单无法指派");
  2180. return;
  2181. }
  2182. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2183. {
  2184. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2185. return;
  2186. }
  2187. //157赖橙帆 159林晨
  2188. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479)
  2189. {
  2190. returnErrorMsg("指派设计共创无法再次指派!");
  2191. return;
  2192. }
  2193. entity.OrderState = 3;
  2194. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2195. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2196. {
  2197. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2198. entity.SupplierId = suid;
  2199. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2200. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2201. }
  2202. if (userid == 2125 && entity.seller_memo != "")
  2203. {
  2204. apiDesign.API_GetPrintData_CreateOrder(entity);
  2205. }
  2206. if (userid == 3542 && entity.seller_memo != "")
  2207. {
  2208. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2209. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2210. if (response.msg != "设计共创:成功")
  2211. {
  2212. returnErrorMsg(response.msg);
  2213. return;
  2214. }
  2215. entity.DispatchSort = 2;
  2216. }
  2217. else
  2218. {
  2219. if (entity.DispatchSort == 2)
  2220. {
  2221. ApiVo apiVo = new ApiVo();
  2222. apiVo.actionName = "closeDesign";
  2223. apiVo.orderNumber = entity.ctid;
  2224. designHelper.API_WorkCore(apiVo);//closeDesign
  2225. }
  2226. entity.DispatchSort = 0;
  2227. }
  2228. entity.DesignUserId = userid;
  2229. entity.WaitDesignTime = DateTime.Now;
  2230. entity.UpdateTime = DateTime.Now;
  2231. entity.Update();
  2232. string name = commonHelper.getUserNameById(userid);
  2233. commonHelper.UpdateRelationOrder(entity.ctid);
  2234. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2235. }
  2236. }
  2237. returnSuccessMsg("操作成功!");
  2238. return;
  2239. }
  2240. }
  2241. public string getTidByCtid(string ctid)
  2242. {
  2243. string tid = "";
  2244. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2245. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2246. if (dataTable != null && dataTable.Rows.Count > 0)
  2247. {
  2248. tid = dataTable.Rows[0]["tid"].ToString();
  2249. }
  2250. return tid;
  2251. }
  2252. public List<string> getTidByCtidLike(string ctid)
  2253. {
  2254. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2255. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2256. List<string> list = new List<string>();
  2257. if (dataTable != null && dataTable.Rows.Count > 0)
  2258. {
  2259. foreach (DataRow item in dataTable.Rows)
  2260. {
  2261. list.Add("'" + item["tid"].ToString() + "'");
  2262. }
  2263. }
  2264. return list;
  2265. }
  2266. public void get_erp_myorderlist()
  2267. {
  2268. DataStruct dStruct = GetPostStruct();
  2269. List<string> lw = new List<string>();
  2270. string tid = GetPostString("ctid");
  2271. if (tid.Length > 0)
  2272. {
  2273. string select_tid = getTidByCtid(tid);
  2274. lw.Add(string.Format("tid='{0}'", select_tid));
  2275. }
  2276. else
  2277. {
  2278. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2279. }
  2280. //12-1 修改
  2281. string urgent = GetPostString("urgent");
  2282. string back = GetPostString("back");
  2283. string offlineSearch = GetPostString("offlineSearch");
  2284. if (!string.IsNullOrWhiteSpace(urgent))
  2285. {
  2286. if (urgent.Equals("true"))
  2287. {
  2288. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2289. }
  2290. }
  2291. if (!string.IsNullOrWhiteSpace(back))
  2292. {
  2293. if (back.Equals("true"))
  2294. {
  2295. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2296. }
  2297. }
  2298. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2299. {
  2300. if (offlineSearch.Equals("true"))
  2301. {
  2302. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2303. }
  2304. }
  2305. //end
  2306. string shopname = GetPostString("shopname");
  2307. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2308. string buyernick = GetPostString("buyer_nick");
  2309. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2310. string design = GetPostString("design");
  2311. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2312. string orderState = GetPostString("orderState");
  2313. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2314. string sellermemo = GetPostString("seller_memo");
  2315. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2316. string date1 = GetPostString("date1");
  2317. string date2 = GetPostString("date2");
  2318. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2319. if (dw.Length > 0) lw.Add(dw);
  2320. string price1 = GetPostString("price1");
  2321. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2322. string price2 = GetPostString("price2");
  2323. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2324. string urgency = GetPostString("urgency");
  2325. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2326. string after = GetPostString("after");
  2327. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2328. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2329. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2330. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2331. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2332. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2333. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2334. if (dt != null && dt.Rows.Count > 0)
  2335. {
  2336. foreach (DataRow dr in dt.Rows)
  2337. {
  2338. try
  2339. {
  2340. // 对象操作
  2341. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2342. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2343. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2344. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2345. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2346. if (dStruct.PageSize != 100000)
  2347. {
  2348. if (dr["DispatchSort"].ToString() == "2")
  2349. {
  2350. dr["gongchuang"] = 200;
  2351. }
  2352. else
  2353. {
  2354. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2355. dr["gongchuang"] = response.code;
  2356. }
  2357. }
  2358. }
  2359. catch (NullReferenceException ex)
  2360. {
  2361. }
  2362. }
  2363. }
  2364. writeGridDataTableJson(dStruct.TotalCount, dt);
  2365. }
  2366. public void get_erp_myreturnorderlist()
  2367. {
  2368. DataStruct dStruct = GetPostStruct();
  2369. List<string> lw = new List<string>();
  2370. string tid = GetPostString("ctid");
  2371. if (tid.Length > 0)
  2372. {
  2373. string select_tid = getTidByCtid(tid);
  2374. lw.Add(string.Format("tid='{0}'", select_tid));
  2375. }
  2376. else
  2377. {
  2378. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2379. }
  2380. string shopname = GetPostString("shopname");
  2381. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2382. string buyernick = GetPostString("buyer_nick");
  2383. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2384. string design = GetPostString("design");
  2385. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2386. string orderState = GetPostString("orderState");
  2387. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2388. string sellermemo = GetPostString("seller_memo");
  2389. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2390. string date1 = GetPostString("date1");
  2391. string date2 = GetPostString("date2");
  2392. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2393. if (dw.Length > 0) lw.Add(dw);
  2394. string price1 = GetPostString("price1");
  2395. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2396. string price2 = GetPostString("price2");
  2397. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2398. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2399. {
  2400. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2401. }
  2402. else
  2403. {
  2404. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2405. }
  2406. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2407. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2408. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2409. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2410. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2411. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2412. if (dt != null && dt.Rows.Count > 0)
  2413. {
  2414. foreach (DataRow dr in dt.Rows)
  2415. {
  2416. try
  2417. {
  2418. // 对象操作
  2419. if (dStruct.PageSize != 100000)
  2420. {
  2421. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2422. dr["gongchuang"] = response.code;
  2423. }
  2424. }
  2425. catch (NullReferenceException ex)
  2426. {
  2427. // 处理空引用异常
  2428. }
  2429. }
  2430. }
  2431. writeGridDataTableJson(dStruct.TotalCount, dt);
  2432. }
  2433. public void get_erp_myorderlist_pregather()
  2434. {
  2435. string date1 = GetPostString("date1");
  2436. string date2 = GetPostString("date2");
  2437. int userId = CurrentUser.UserID; //客服id
  2438. string orderWhere = "";
  2439. List<string> lw = new List<string>();
  2440. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2441. if (dw.Length > 0) lw.Add(dw);
  2442. lw.Add(string.Format("CustomerUserId={0}", userId));
  2443. lw.Add(string.Format("OrderState<9"));
  2444. orderWhere = string.Join(" and ", lw.ToArray());
  2445. string orderWhere2 = "";
  2446. List<string> lw2 = new List<string>();
  2447. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2448. if (dw2.Length > 0) lw2.Add(dw2);
  2449. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2450. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2451. string sql = string.Format("select *" +
  2452. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2453. "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 " +
  2454. "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 " +
  2455. "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");
  2456. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2457. //writeGridDataTableJson(dt.Rows.Count, dt);
  2458. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2459. }
  2460. public void upd_erp_publishorder()
  2461. {
  2462. if (UrlPostParmsCheck("ctid"))
  2463. {
  2464. string eid = GetPostString("ctid");
  2465. CeErpTradeCell entity = null;
  2466. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2467. if (entity != null)
  2468. {
  2469. entity.OrderState = 0; //发布后,变为待抢单
  2470. entity.Update();
  2471. commonHelper.UpdateRelationOrder(entity.ctid);
  2472. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2473. returnSuccessMsg("发布成功!");
  2474. return;
  2475. }
  2476. returnErrorMsg("找不到记录");
  2477. }
  2478. }
  2479. public void get_erp_my_tiporder()
  2480. {
  2481. StringBuilder sql = new StringBuilder();
  2482. int userId = 0;
  2483. if (CurrentUser != null) userId = CurrentUser.UserID;
  2484. string posCode = CurrentUser.UserPost.Post.Code;
  2485. string isTipedAfterSaleVerify = GetPostString("af");
  2486. DataTable dt = new DataTable();
  2487. if (posCode != "Supplier")
  2488. {
  2489. if (posCode == "CustomerService" || posCode == "Director")
  2490. {
  2491. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2492. }
  2493. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2494. {
  2495. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2496. }
  2497. else
  2498. {
  2499. string teamIds = CurrentUser.User.TeamIds;
  2500. if (teamIds == "")
  2501. {
  2502. teamIds = "0";
  2503. }
  2504. 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);
  2505. }
  2506. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2507. }
  2508. if (dt.Rows.Count <= 0)
  2509. {
  2510. string key = "aftersale_order_" + userId;
  2511. if (RedisHelper.HasKey(key))
  2512. {
  2513. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2514. dt.Columns.Add("ctid", typeof(string));
  2515. dt.Columns.Add("IsReadTag", typeof(int));
  2516. foreach (var i in list)
  2517. {
  2518. DataRow data = dt.NewRow();
  2519. data["ctid"] = i;
  2520. data["IsReadTag"] = 4;
  2521. dt.Rows.Add(data);
  2522. }
  2523. RedisHelper.StringDelete(key);
  2524. }
  2525. }
  2526. if (dt.Rows.Count <= 0)
  2527. {
  2528. sql = new StringBuilder();
  2529. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2530. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2531. }
  2532. if (posCode == "Supplier")
  2533. {
  2534. string ids = CurrentUser.User.pemVend;
  2535. if (ids != null && ids.Length > 0)
  2536. {
  2537. string[] ids_list = ids.Split(',');
  2538. foreach (var item in ids_list)
  2539. {
  2540. string key = "return_order_" + item;
  2541. if (RedisHelper.HasKey(key))
  2542. {
  2543. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2544. dt.Columns.Add("ctid", typeof(string));
  2545. dt.Columns.Add("IsReadTag", typeof(int));
  2546. foreach (var i in list)
  2547. {
  2548. DataRow data = dt.NewRow();
  2549. data["ctid"] = i;
  2550. data["IsReadTag"] = 1;
  2551. dt.Rows.Add(data);
  2552. }
  2553. RedisHelper.StringDelete(key);
  2554. }
  2555. }
  2556. }
  2557. if (dt.Rows.Count <= 0)
  2558. {
  2559. sql = new StringBuilder();
  2560. 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);
  2561. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2562. }
  2563. }
  2564. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2565. }
  2566. public void reset_erp_tiporder()
  2567. {
  2568. string ids = GetPostString("ids");
  2569. string[] ctidList = ids.Split(',');
  2570. foreach (string ctid in ctidList)
  2571. {
  2572. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2573. if (enty != null)
  2574. {
  2575. enty.IsReadTag = 0;
  2576. enty.Update();
  2577. }
  2578. }
  2579. returnSuccessMsg("成功!");
  2580. return;
  2581. }
  2582. public void get_erp_designlist()
  2583. {
  2584. DataStruct dStruct = GetPostStruct();
  2585. List<string> lw = new List<string>();
  2586. string tid = GetPostString("ctid");
  2587. if (tid.Length > 0)
  2588. {
  2589. string select_tid = getTidByCtid(tid);
  2590. lw.Add(string.Format("tid='{0}'", select_tid));
  2591. }
  2592. string shopname = GetPostString("shopname");
  2593. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2594. string buyernick = GetPostString("buyer_nick");
  2595. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2596. string customer = GetPostString("customer");
  2597. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2598. string design = GetPostString("design");
  2599. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2600. string orderState = GetPostString("orderState");
  2601. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2602. lw.Add(string.Format("OrderState<6"));
  2603. string address = GetPostString("address");
  2604. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2605. string sellermemo = GetPostString("seller_memo");
  2606. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2607. string date1 = GetPostString("date1");
  2608. string date2 = GetPostString("date2");
  2609. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2610. if (dw.Length > 0) lw.Add(dw);
  2611. string apdate1 = GetPostString("apdate1");
  2612. string apdate2 = GetPostString("apdate2");
  2613. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2614. if (dwap.Length > 0) lw.Add(dwap);
  2615. string price1 = GetPostString("price1");
  2616. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2617. string price2 = GetPostString("price2");
  2618. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2619. string designTime = GetPostString("designtime");
  2620. if (designTime.Length > 0)
  2621. {
  2622. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2623. }
  2624. string usershop = CurrentUser.User.pemShop;
  2625. if (usershop.Length > 0)
  2626. {
  2627. lw.Add(string.Format("shopId in ({0})", usershop));
  2628. }
  2629. int myOrgid = CurrentUser.UserPost.OrgID;
  2630. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2631. if (myOrgCode.IndexOf("Designer") != -1)
  2632. {
  2633. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2634. {
  2635. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2636. }
  2637. else
  2638. {
  2639. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2640. }
  2641. }
  2642. else
  2643. {
  2644. string orgId = GetPostString("designerhd");
  2645. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2646. }
  2647. if (tid.Length > 0 || buyernick.Length > 0)
  2648. {
  2649. lw.Add(string.Format("OrderState >= 3"));
  2650. }
  2651. else
  2652. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2653. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2654. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2655. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2656. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2657. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2658. if (dt != null && dt.Rows.Count > 0)
  2659. {
  2660. foreach (DataRow dr in dt.Rows)
  2661. {
  2662. try
  2663. {
  2664. // 对象操作
  2665. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2666. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2667. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2668. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2669. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2670. if (dStruct.PageSize != 100000)
  2671. {
  2672. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2673. dr["gongchuang"] = response.code;
  2674. }
  2675. }
  2676. catch (NullReferenceException ex)
  2677. {
  2678. }
  2679. }
  2680. }
  2681. writeGridDataTableJson(dStruct.TotalCount, dt);
  2682. }
  2683. public void get_erp_mydesignlist()
  2684. {
  2685. DataStruct dStruct = GetPostStruct();
  2686. List<string> lw = new List<string>();
  2687. string tid = GetPostString("ctid");
  2688. if (tid.Length > 0)
  2689. {
  2690. string select_tid = getTidByCtid(tid);
  2691. lw.Add(string.Format("tid='{0}'", select_tid));
  2692. }
  2693. string shopname = GetPostString("shopname");
  2694. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2695. string buyernick = GetPostString("buyer_nick");
  2696. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2697. string customer = GetPostString("customer");
  2698. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2699. string orderState = GetPostString("orderState");
  2700. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2701. //lw.Add(string.Format("OrderState<6"));
  2702. string date1 = GetPostString("date1");
  2703. string date2 = GetPostString("date2");
  2704. string dw = GetDateWhere("pay_time", date1, date2);
  2705. if (dw.Length > 0) lw.Add(dw);
  2706. string apdate1 = GetPostString("apdate1");
  2707. string apdate2 = GetPostString("apdate2");
  2708. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2709. if (dwap.Length > 0) lw.Add(dwap);
  2710. string price1 = GetPostString("price1");
  2711. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2712. string price2 = GetPostString("price2");
  2713. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2714. string olddownload = GetPostString("olddown");
  2715. if (olddownload == "1")
  2716. {
  2717. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2718. }
  2719. else if (olddownload == "2")
  2720. {
  2721. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2722. }
  2723. string sellermemo = GetPostString("seller_memo");
  2724. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2725. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2726. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2727. {
  2728. if (CurrentUser.User.TeamIds.Length > 0)
  2729. {
  2730. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2731. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2732. else
  2733. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2734. }
  2735. else
  2736. {
  2737. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2738. }
  2739. }
  2740. if (tid.Length <= 0)
  2741. {
  2742. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2743. }
  2744. lw.Add(string.Format("IsReturn!=3"));
  2745. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2746. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2747. string teamids = CurrentUser.User.TeamIds.ToString();
  2748. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2749. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2750. if (dt != null && dt.Rows.Count > 0)
  2751. {
  2752. foreach (DataRow dr in dt.Rows)
  2753. {
  2754. try
  2755. {
  2756. // 对象操作
  2757. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2758. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2759. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2760. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2761. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2762. if (dStruct.PageSize != 100000)
  2763. {
  2764. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2765. dr["gongchuang"] = response.code;
  2766. }
  2767. }
  2768. catch (NullReferenceException ex)
  2769. {
  2770. }
  2771. }
  2772. }
  2773. writeGridDataTableJson(dStruct.TotalCount, dt);
  2774. }
  2775. public void set_erp_startdesign()
  2776. {
  2777. if (UrlPostParmsCheck("ctid"))
  2778. {
  2779. string eid = GetPostString("ctid");
  2780. CeErpTradeCell entity = null;
  2781. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2782. if (entity != null)
  2783. {
  2784. if (entity.OrderState != 3)
  2785. {
  2786. returnErrorMsg("请刷新,订单已经设计了");
  2787. return;
  2788. }
  2789. entity.StartDesignTime = DateTime.Now;
  2790. entity.OrderState = 4;
  2791. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2792. {
  2793. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2794. entity.SupplierId = suid;
  2795. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2796. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2797. }
  2798. entity.UpdateTime = DateTime.Now;
  2799. //entity.MakeSupplier = suname;
  2800. entity.Update();
  2801. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2803. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2804. commonHelper.getCytPrice(entity);
  2805. returnSuccessMsg("操作成功!");
  2806. return;
  2807. }
  2808. returnErrorMsg("找不到记录");
  2809. }
  2810. }
  2811. public void ins_erp_designselfmemo()
  2812. {
  2813. if (UrlPostParmsCheck("ctid"))
  2814. {
  2815. string eid = GetPostString("ctid");
  2816. string con = GetPostString("con");
  2817. CeErpTradeCell entity = null;
  2818. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2819. if (entity != null)
  2820. {
  2821. entity.DesignSelfMemo = con;
  2822. entity.Update();
  2823. returnSuccessMsg("操作成功!");
  2824. return;
  2825. }
  2826. returnErrorMsg("找不到记录");
  2827. }
  2828. }
  2829. public void ins_erp_designprice()
  2830. {
  2831. if (UrlPostParmsCheck("ctid"))
  2832. {
  2833. string eid = GetPostString("ctid");
  2834. int uid = CurrentUser.UserID;
  2835. string userName = CurrentUser.UserName;
  2836. CeErpTradeCell entity = null;
  2837. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2838. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2839. if (entitys == null)
  2840. {
  2841. entitys = new CeErpDesignerBill();
  2842. }
  2843. if (entity != null)
  2844. {
  2845. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2846. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2847. entity.StartDesignTime = DateTime.Now;
  2848. entity.OrderState = 4;
  2849. string suname = "";
  2850. if (entity.SupplierId == 0)
  2851. {
  2852. int sid = commonHelper.autoDistributeToSupplier(entity);
  2853. entity.SupplierId = sid;
  2854. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2855. }
  2856. entity.Update();
  2857. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2858. if (ceErpUserPost != null)
  2859. {
  2860. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2861. if (ceErpPost != null)
  2862. {
  2863. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2864. {
  2865. entitys.tid = entity.ctid;
  2866. entitys.oid = entity.tid;
  2867. entitys.uid = uid;
  2868. entitys.userName = userName;
  2869. entitys.designerType = 1;
  2870. entitys.designerTypeText = "内部设计师";
  2871. entitys.price = Convert.ToDouble(GetPostString("price"));
  2872. entitys.designNum = GetPostInt("designNum");
  2873. entitys.modifyNum = GetPostInt("modifyNum");
  2874. entitys.designSize = GetPostString("designSize");
  2875. entitys.modifySize = GetPostString("modifySize");
  2876. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2877. {
  2878. entitys.create_time = DateTime.Now;
  2879. entitys.create_u_id = uid;
  2880. entitys.create_u_name = userName;
  2881. entitys.Save();
  2882. }
  2883. else
  2884. {
  2885. entitys.update_time = DateTime.Now;
  2886. entitys.update_u_id = uid;
  2887. entitys.update_u_name = userName;
  2888. entitys.Update();
  2889. }
  2890. }
  2891. }
  2892. }
  2893. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2895. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2896. if (suname != "")
  2897. {
  2898. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2899. }
  2900. commonHelper.getCytPrice(entity);
  2901. returnSuccessMsg("操作成功!");
  2902. return;
  2903. }
  2904. returnErrorMsg("找不到记录");
  2905. }
  2906. }
  2907. public void upload_erp_filecomplete()
  2908. {
  2909. if (UrlPostParmsCheck("ctid"))
  2910. {
  2911. string eid = GetPostString("ctid");
  2912. CeErpTradeCell entity = null;
  2913. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2914. if (entity != null)
  2915. {
  2916. entity.OrderState = 5; //设计完成
  2917. entity.Update();
  2918. returnSuccessMsg(eid + "上传成功,设计完成!");
  2919. return;
  2920. }
  2921. returnErrorMsg("找不到订单记录");
  2922. }
  2923. }
  2924. public void get_erp_designovertimelist()
  2925. {
  2926. DataStruct dStruct = GetPostStruct();
  2927. List<string> lw = new List<string>();
  2928. string tid = GetPostString("ctid");
  2929. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2930. string shopname = GetPostString("shopname");
  2931. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2932. string buyernick = GetPostString("buyer_nick");
  2933. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2934. string ResponsibleMan = GetPostString("responsible");
  2935. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2936. string date1 = GetPostString("date1");
  2937. string date2 = GetPostString("date2");
  2938. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2939. if (dw.Length > 0) lw.Add(dw);
  2940. string price1 = GetPostString("price1");
  2941. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2942. string price2 = GetPostString("price2");
  2943. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2944. string orderState = GetPostString("orderState");
  2945. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2946. string sellermemo = GetPostString("seller_memo");
  2947. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2948. lw.Add(string.Format("UnusualTag=3"));
  2949. lw.Add(string.Format("IsRefund<={0}", 1));
  2950. dStruct.Order = "WaitDesignTime desc";
  2951. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2952. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2953. writeGridDataTableJson(dStruct.TotalCount, dt);
  2954. }
  2955. //设计管理 获取抢单大厅列表
  2956. public void get_erp_grabinglist()
  2957. {
  2958. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2959. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2960. bool oldOrder = false;
  2961. if (org != null)
  2962. {
  2963. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2964. }
  2965. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2966. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2967. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2968. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2969. //先处理订单数据
  2970. if (dt.Rows.Count > 0)
  2971. {
  2972. Dictionary<string, int> design = null;
  2973. int count = 0;
  2974. foreach (DataRow row in dt.Rows)
  2975. {
  2976. if (map.ContainsKey(row["ShopId"].ToString()))
  2977. {
  2978. map.TryGetValue(row["ShopId"].ToString(), out design);
  2979. }
  2980. else
  2981. {
  2982. design = new Dictionary<string, int>();
  2983. }
  2984. if (design.ContainsKey(row["ProductId"].ToString()))
  2985. {
  2986. design.TryGetValue(row["ProductId"].ToString(), out count);
  2987. }
  2988. count++;
  2989. design[row["ProductId"].ToString()] = count;
  2990. map[row["ShopId"].ToString()] = design;
  2991. }
  2992. }
  2993. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2994. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2995. //把店铺排序和技能排序分类
  2996. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2997. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2998. if (design_dt.Rows.Count > 0)
  2999. {
  3000. Dictionary<string, string> design = null;
  3001. List<string> shopIds = null;
  3002. foreach (DataRow row in design_dt.Rows)
  3003. {
  3004. if ("0".Equals(row["designId"].ToString()))
  3005. {
  3006. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3007. {
  3008. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3009. }
  3010. else
  3011. {
  3012. shopIds = new List<string>();
  3013. }
  3014. shopIds.Add(row["shopId"].ToString());
  3015. shop_orders[row["orders"].ToString()] = shopIds;
  3016. }
  3017. else
  3018. {
  3019. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3020. {
  3021. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3022. }
  3023. else
  3024. {
  3025. design = new Dictionary<string, string>();
  3026. }
  3027. design[row["orders"].ToString()] = row["designId"].ToString();
  3028. design_orders[row["shopId"].ToString()] = design;
  3029. }
  3030. }
  3031. //处理成key value后根据key排序
  3032. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3033. foreach (List<string> val in shop_orders.Values)
  3034. {
  3035. if (val != null)
  3036. {
  3037. foreach (string key in val)
  3038. {
  3039. if (design_orders.ContainsKey(key.ToString()))
  3040. {
  3041. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3042. }
  3043. }
  3044. }
  3045. }
  3046. }
  3047. //校验哪个优先级有订单
  3048. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3049. foreach (string key in shop_orders.Keys)
  3050. {
  3051. List<string> ids = null;
  3052. shop_orders.TryGetValue(key, out ids);
  3053. //id为shopid
  3054. foreach (string id in ids)
  3055. {
  3056. Dictionary<string, int> list = null;
  3057. Dictionary<string, string> desing = null;
  3058. map.TryGetValue(id, out list);
  3059. design_orders.TryGetValue(id, out desing);
  3060. if (list != null && desing != null)
  3061. {
  3062. foreach (var item in desing)
  3063. {
  3064. int count = 0;
  3065. if (list.ContainsKey(item.Value))
  3066. {
  3067. list.TryGetValue(item.Value, out count);
  3068. if (count > 0)
  3069. {
  3070. designIds[id] = item.Value;
  3071. break;
  3072. }
  3073. }
  3074. }
  3075. }
  3076. }
  3077. if (designIds.Count > 0)
  3078. {
  3079. break;
  3080. }
  3081. }
  3082. DataTable table = new DataTable();
  3083. table.Columns.Add("tid", typeof(string));
  3084. table.Columns.Add("ctid", typeof(string));
  3085. table.Columns.Add("seller_nick", typeof(string));
  3086. table.Columns.Add("productName", typeof(string));
  3087. table.Columns.Add("pay_time", typeof(string));
  3088. table.Columns.Add("seller_memo", typeof(string));
  3089. if (designIds.Count > 0)
  3090. {
  3091. string shopId = "";
  3092. string productId = "";
  3093. foreach (var designInfo in designIds)
  3094. {
  3095. shopId = designInfo.Key;
  3096. productId = designInfo.Value;
  3097. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3098. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3099. if (dt.Rows.Count > 0)
  3100. {
  3101. foreach (DataRow row in dt.Rows)
  3102. {
  3103. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3104. {
  3105. DataRow data = table.NewRow();
  3106. data["ctid"] = row["ctid"].ToString();
  3107. data["tid"] = row["tid"].ToString();
  3108. data["seller_nick"] = ceErpShop.ShopName;
  3109. data["pay_time"] = row["pay_time"].ToString();
  3110. data["seller_memo"] = row["seller_memo"].ToString();
  3111. data["productName"] = ceErpProduct.PType;
  3112. table.Rows.Add(data);
  3113. }
  3114. }
  3115. }
  3116. }
  3117. }
  3118. writeGridDataTableJson(table.Rows.Count, table);
  3119. }
  3120. private object rushLockObject = new object();
  3121. public void set_erp_grabingorder()
  3122. {
  3123. if (UrlPostParmsCheck("ctid"))
  3124. {
  3125. int total = CurrentUser.User.Person.Total;
  3126. int userId = CurrentUser.User.ID;
  3127. int noFinish = CurrentUser.User.Person.NoFinish;
  3128. int finalization = CurrentUser.User.Person.Finalization;
  3129. string eids = GetPostString("ctid");
  3130. string key = "RushKey_" + userId;
  3131. int count = 0;
  3132. if (erpRedis.RedisHelper.KeyExists(key))
  3133. {
  3134. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3135. if (redisCount != null)
  3136. {
  3137. count = Convert.ToInt32(redisCount);
  3138. }
  3139. }
  3140. if (count >= total)
  3141. {
  3142. returnErrorMsg("半小时内已经抢" + total + "单");
  3143. return;
  3144. }
  3145. string[] ctidlist = eids.Split(',');
  3146. if (count + ctidlist.Length > total)
  3147. {
  3148. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3149. return;
  3150. }
  3151. int itag = 0;
  3152. lock (rushLockObject)
  3153. {
  3154. if (ctidlist.Length > 0)
  3155. {
  3156. string[] dtList = new string[ctidlist.Length];
  3157. for (int i = 0; i < ctidlist.Length; i++)
  3158. {
  3159. dtList[i] = "'" + ctidlist[i] + "'";
  3160. }
  3161. 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"));
  3162. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3163. if (dt_user.Rows.Count > 0)
  3164. {
  3165. int doing = 0;//未定稿
  3166. int finish = 0;//已完成
  3167. foreach (DataRow dr in dt_user.Rows)
  3168. {
  3169. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3170. {
  3171. doing++;
  3172. }
  3173. else
  3174. {
  3175. finish++;
  3176. }
  3177. }
  3178. if (doing >= noFinish)
  3179. {
  3180. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3181. return;
  3182. }
  3183. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3184. {
  3185. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3186. return;
  3187. }
  3188. }
  3189. //校验选择单子状态
  3190. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3191. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3192. if (dt.Rows.Count > 0)
  3193. {
  3194. List<string> list = new List<string>();
  3195. foreach (DataRow dr in dt.Rows)
  3196. {
  3197. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3198. {
  3199. list.Add(dr["ctid"].ToString());
  3200. }
  3201. }
  3202. if (list.Count > 0)
  3203. {
  3204. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3205. return;
  3206. }
  3207. }
  3208. foreach (string ctid in ctidlist)
  3209. {
  3210. CeErpTradeCell entity = null;
  3211. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3212. if (entity != null)
  3213. {
  3214. entity.OrderState = 3;
  3215. entity.DesignUserId = CurrentUser.UserID;
  3216. entity.WaitDesignTime = DateTime.Now;
  3217. entity.StartDesignTime = DateTime.Now;
  3218. entity.Update();
  3219. commonHelper.UpdateRelationOrder(entity.ctid);
  3220. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3221. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3222. itag++;
  3223. }
  3224. }
  3225. }
  3226. }
  3227. count += ctidlist.Length;
  3228. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3229. if (itag == 0)
  3230. returnErrorMsg("没有找到相关订单");
  3231. else
  3232. returnSuccessMsg("抢单成功!");
  3233. return;
  3234. }
  3235. }
  3236. public void get_erp_waitorderlist()
  3237. {
  3238. DataStruct dStruct = GetPostStruct();
  3239. List<string> lw = new List<string>();
  3240. string tid = GetPostString("ctid");
  3241. if (tid.Length > 0)
  3242. {
  3243. string select_tid = getTidByCtid(tid);
  3244. lw.Add(string.Format("tid='{0}'", select_tid));
  3245. }
  3246. string shopname = GetPostString("shopname");
  3247. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3248. string buyernick = GetPostString("buyer_nick");
  3249. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3250. string customer = GetPostString("customer");
  3251. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3252. string design = GetPostString("design");
  3253. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3254. string orderState = GetPostString("orderState");
  3255. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3256. string supplier = GetPostString("supplier");
  3257. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3258. string sellermemo = GetPostString("seller_memo");
  3259. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3260. string otherMemo = GetPostString("otherMemo");
  3261. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3262. string address = GetPostString("address");
  3263. 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));
  3264. string date1 = GetPostString("date1");
  3265. string date2 = GetPostString("date2");
  3266. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3267. if (dw.Length > 0) lw.Add(dw);
  3268. string price1 = GetPostString("price1");
  3269. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3270. string price2 = GetPostString("price2");
  3271. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3272. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3273. lw.Add(string.Format("IsSample != 2 "));
  3274. lw.Add(string.Format("OrderState = 5 "));
  3275. lw.Add(string.Format("IsRefund<={0}", 1));
  3276. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3277. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3278. string pagesize = GetPostString("pagesize");
  3279. if (pagesize != null)
  3280. {
  3281. dStruct.PageSize = 200;
  3282. }
  3283. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3284. if (dt != null)
  3285. {
  3286. foreach (DataRow dr in dt.Rows)
  3287. {
  3288. 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();
  3289. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3290. {
  3291. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3292. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3293. entity.SupplierId = suid;
  3294. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3295. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3296. entity.Update();
  3297. }
  3298. }
  3299. }
  3300. writeGridDataTableJson(dStruct.TotalCount, dt);
  3301. }
  3302. public void get_erp_supplierwaitorderlist()
  3303. {
  3304. DataStruct dStruct = GetPostStruct();
  3305. List<string> lw = new List<string>();
  3306. string tid = GetPostString("ctid");
  3307. if (tid.Length > 0)
  3308. {
  3309. string select_tid = getTidByCtid(tid);
  3310. lw.Add(string.Format("tid='{0}'", select_tid));
  3311. }
  3312. string shopname = GetPostString("shopname");
  3313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3314. string sellermemo = GetPostString("seller_memo");
  3315. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3316. string date1 = GetPostString("date1");
  3317. string date2 = GetPostString("date2");
  3318. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3319. if (dw.Length > 0) lw.Add(dw);
  3320. lw.Add(string.Format("OrderState = 5 "));
  3321. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3322. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3323. {
  3324. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3325. }
  3326. string supplier = GetPostString("supplier");
  3327. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3328. {
  3329. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3330. }
  3331. lw.Add(string.Format("IsRefund<={0}", 1));
  3332. dStruct.Order = "FinishDesignTime desc";
  3333. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3334. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3335. if (dt != null)
  3336. {
  3337. foreach (DataRow dr in dt.Rows)
  3338. {
  3339. 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();
  3340. }
  3341. }
  3342. writeGridDataTableJson(dStruct.TotalCount, dt);
  3343. }
  3344. public void upd_erp_verifytosupplier()
  3345. {
  3346. if (UrlPostParmsCheck("ctid"))
  3347. {
  3348. string eids = GetPostString("ctid");
  3349. CeErpTradeCell entity = null;
  3350. string[] eidsList = eids.Split(',');
  3351. if (eidsList.Length <= 0)
  3352. {
  3353. returnErrorMsg("订单号不能空");
  3354. return;
  3355. }
  3356. List<string> tLst = new List<string>();
  3357. foreach (string ctidstr in eidsList)
  3358. {
  3359. tLst.Add("'" + ctidstr + "'");
  3360. CeErpDataSendOrderInfo.createObject(ctidstr);
  3361. }
  3362. string needtids = string.Join(",", tLst.ToArray());
  3363. StringBuilder sql = new StringBuilder();
  3364. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3365. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3366. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3367. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3368. returnSuccessMsg("操作成功!");
  3369. return;
  3370. /**foreach (string ctidstr in eidsList)
  3371. {
  3372. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3373. if (entity != null)
  3374. {
  3375. if (entity.SupplierId == 0)
  3376. {
  3377. continue;
  3378. }
  3379. entity.IsVerifyToSupplier = true;
  3380. if (entity.IsReturn == 1) //1是供应商打回
  3381. {
  3382. entity.IsReturn = 0;
  3383. }
  3384. entity.FinishPlaceTime = DateTime.Now;
  3385. entity.PlaceUserId = CurrentUser.UserID;
  3386. entity.Update();
  3387. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3388. }
  3389. }
  3390. returnSuccessMsg("操作成功!");
  3391. return;**/
  3392. }
  3393. }
  3394. public void upd_erp_supplierback()
  3395. {
  3396. if (UrlPostParmsCheck("ctid"))
  3397. {
  3398. string eid = GetPostString("ctid");
  3399. string reason = GetPostString("returnreason");
  3400. CeErpTradeCell entity = null;
  3401. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3402. if (entity != null)
  3403. {
  3404. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3405. {
  3406. string key = "return_order_" + entity.SupplierId;
  3407. List<string> list = new List<string>();
  3408. if (RedisHelper.HasKey(key))
  3409. {
  3410. object data = RedisHelper.StringGet(key);
  3411. list = Convert.ToString(data).Split(',').ToList();
  3412. }
  3413. list.Add(eid);
  3414. RedisHelper.StringSet(key, string.Join(",", list));
  3415. }
  3416. entity.IsVerifyToSupplier = false;
  3417. entity.IsReturn = 1;
  3418. entity.ReturnTime = DateTime.Now;
  3419. entity.ReturnReason = reason;
  3420. if (entity.OrderState == 6)
  3421. {
  3422. entity.OrderState = 5;
  3423. }
  3424. entity.Update();
  3425. CeErpSukuraData.createInfo(entity.ctid, 5);
  3426. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3427. returnSuccessMsg("操作成功!");
  3428. return;
  3429. }
  3430. returnErrorMsg("找不到订单记录");
  3431. }
  3432. }
  3433. public void upd_erp_toaftersaleorder()
  3434. {
  3435. if (UrlPostParmsCheck("ctid"))
  3436. {
  3437. string eid = GetPostString("ctid");
  3438. string reason = GetPostString("returnreason");
  3439. CeErpTradeCell entity = null;
  3440. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3441. if (entity != null)
  3442. {
  3443. if (entity.isAfterSaleOrder != 1)
  3444. {
  3445. returnErrorMsg("带S的售后单才能打回给售后");
  3446. return;
  3447. }
  3448. if (entity.OrderState >= 5)
  3449. {
  3450. returnErrorMsg("已经设计完成了不能打回给售后");
  3451. return;
  3452. }
  3453. entity.OrderState = 0;
  3454. entity.IsReturn = 3;
  3455. entity.ReturnTime = DateTime.Now;
  3456. entity.UpdateTime = DateTime.Now;
  3457. entity.ReturnReason = reason;
  3458. entity.Update();
  3459. CeErpSukuraData.createInfo(entity.ctid, 5);
  3460. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3461. returnSuccessMsg("操作成功!");
  3462. return;
  3463. }
  3464. returnErrorMsg("找不到订单记录");
  3465. }
  3466. }
  3467. public void upd_erp_aftersaletodesign()
  3468. {
  3469. if (UrlPostParmsCheck("ctid"))
  3470. {
  3471. string eid = GetPostString("ctid");
  3472. CeErpTradeCell entity = null;
  3473. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3474. if (entity != null)
  3475. {
  3476. entity.OrderState = 3;
  3477. entity.IsReturn = 0;
  3478. entity.UpdateTime = DateTime.Now;
  3479. entity.Update();
  3480. CeErpSukuraData.createInfo(entity.ctid, 5);
  3481. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3482. returnSuccessMsg("操作成功!");
  3483. return;
  3484. }
  3485. returnErrorMsg("找不到订单记录");
  3486. }
  3487. }
  3488. public void assign_erp_supplier()
  3489. {
  3490. if (UrlPostParmsCheck("ctid"))
  3491. {
  3492. string eids = GetPostString("ctid");
  3493. int sid = GetPostInt("SupplierName");
  3494. string fromTag = GetPostString("tag");
  3495. string[] eidList = eids.Split(',');
  3496. if (eidList.Length <= 0)
  3497. {
  3498. returnErrorMsg("指派不能为空");
  3499. return;
  3500. }
  3501. string errMsg = "";
  3502. string suname = commonHelper.getSupplierNameById(sid);
  3503. foreach (string ctid in eidList)
  3504. {
  3505. CeErpTradeCell entity = null;
  3506. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3507. if (entity != null)
  3508. {
  3509. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3510. {
  3511. errMsg += (ctid + "指派失败!!!");
  3512. continue;
  3513. }
  3514. entity.SupplierId = sid;
  3515. entity.Update();
  3516. commonHelper.UpdateRelationOrder(entity.ctid);
  3517. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3518. if (entity.OrderState >= 6)
  3519. {
  3520. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3521. //{
  3522. // string msl = entity.MakeSupplier;
  3523. // string[] mslist = msl.Split(',');
  3524. // 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);
  3525. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3526. //}
  3527. //else
  3528. //{
  3529. StringBuilder sql = new StringBuilder();
  3530. 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);
  3531. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3532. //}
  3533. }
  3534. }
  3535. else
  3536. {
  3537. continue;
  3538. }
  3539. }
  3540. if (errMsg.Length > 0)
  3541. {
  3542. returnErrorMsg(errMsg);
  3543. return;
  3544. }
  3545. returnSuccessMsg("操作成功!");
  3546. return;
  3547. }
  3548. }
  3549. public void assign_erp_makesupplier()
  3550. {
  3551. if (UrlPostParmsCheck("ctid"))
  3552. {
  3553. string eids = GetPostString("ctid");
  3554. string sname = GetPostString("SupplierName");
  3555. string[] eidList = eids.Split(',');
  3556. if (eidList.Length <= 0)
  3557. {
  3558. returnErrorMsg("指派不能为空");
  3559. return;
  3560. }
  3561. List<string> tLst = new List<string>();
  3562. foreach (string ctid in eidList)
  3563. {
  3564. CeErpTradeCell entity = null;
  3565. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3566. if (entity != null)
  3567. {
  3568. entity.MakeSupplier = sname;
  3569. entity.Update();
  3570. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3571. tLst.Add("'" + ctid + "'");
  3572. }
  3573. else
  3574. {
  3575. continue;
  3576. }
  3577. }
  3578. string ctids = string.Join(",", tLst.ToArray());
  3579. StringBuilder sql2 = new StringBuilder();
  3580. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3581. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3582. returnSuccessMsg("操作成功!");
  3583. return;
  3584. }
  3585. }
  3586. public void ins_erp_returnreason()
  3587. {
  3588. if (UrlPostParmsCheck("ctid"))
  3589. {
  3590. string eid = GetPostString("ctid");
  3591. CeErpTradeCell entity = null;
  3592. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3593. string userpost = CurrentUser.UserPost.Post.Code;
  3594. if (entity != null)
  3595. {
  3596. bool isPlace = false;
  3597. if (entity.OrderState > 6)
  3598. {
  3599. returnErrorMsg("已发货无法打回!");
  3600. return;
  3601. }
  3602. if (entity.OrderState == 6)
  3603. {
  3604. isPlace = true;
  3605. }
  3606. bool isNeedUpdateCell2 = false;
  3607. if (entity.OrderState >= 6)
  3608. {
  3609. isNeedUpdateCell2 = true;
  3610. }
  3611. int returnTag = 2;
  3612. if (userpost == "Supplier")
  3613. {
  3614. returnTag = 1;
  3615. }
  3616. int toType = GetPostInt("totype");
  3617. string fromType = "3";
  3618. if (entity.OrderState < 5)
  3619. {
  3620. fromType = "3";
  3621. }
  3622. else
  3623. {
  3624. fromType = "4";
  3625. }
  3626. if (entity.IsXianHuo == 0)
  3627. {
  3628. if (returnTag == 2)
  3629. {
  3630. if (toType == 1)
  3631. {
  3632. entity.OrderState = 0;
  3633. entity.ReturnUserType = 1;
  3634. string clearman = GetPostString("clearman");
  3635. if (!string.IsNullOrEmpty(clearman))
  3636. {
  3637. entity.DesignUserId = 0;
  3638. }
  3639. }
  3640. else
  3641. {
  3642. entity.OrderState = 3;
  3643. entity.ReturnUserType = 2;
  3644. }
  3645. entity.IsReadTag = 1;
  3646. }
  3647. else if (returnTag == 1)
  3648. {
  3649. entity.OrderState = 5;
  3650. }
  3651. entity.IsVerifyToSupplier = false;
  3652. }
  3653. if (entity.IsXianHuo == 1)
  3654. {
  3655. entity.OrderState = 5;
  3656. }
  3657. entity.UnusualTag = 0;
  3658. entity.UnusualTime = null;
  3659. entity.UnusualCon = "";
  3660. entity.IsReturn = returnTag;
  3661. entity.ReturnTime = DateTime.Now;
  3662. entity.UpdateTime = DateTime.Now;
  3663. entity.ReturnReason = GetPostString("returnreason");
  3664. entity.Update();
  3665. if (entity.OrderState == 3)
  3666. {
  3667. ApiVo apiVo = new ApiVo();
  3668. apiVo.orderNumber = entity.ctid;
  3669. apiVo.actionName = "rebutDesign";
  3670. apiVo.orderRemarks = entity.ReturnReason;
  3671. designHelper.API_WorkCore(apiVo);//rebutDesign
  3672. }
  3673. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3674. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3675. {
  3676. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3677. }
  3678. CeErpSukuraData.createInfo(entity.ctid, 5);
  3679. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3680. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3681. if (isPlace)
  3682. {
  3683. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3684. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3685. if (dth != null && dth.Rows.Count > 0)
  3686. {
  3687. dataSendOrderBean dataSendOrderBean = null;
  3688. foreach (DataRow item in dth.Rows)
  3689. {
  3690. try
  3691. {
  3692. dataSendOrderBean = new dataSendOrderBean();
  3693. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3694. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3695. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3696. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3697. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3698. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3699. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3700. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3701. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3702. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3703. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3704. dataSendOrderBean.Radio1723534706288 = "打回";
  3705. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3706. if (result != null)
  3707. {
  3708. if ("0".Equals(result.errcode))
  3709. {
  3710. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3711. }
  3712. else
  3713. {
  3714. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3715. }
  3716. }
  3717. }
  3718. catch (Exception ex)
  3719. {
  3720. }
  3721. }
  3722. }
  3723. }
  3724. if (isNeedUpdateCell2)
  3725. {
  3726. if (entity.MakeSupplier.IndexOf(",") != -1)
  3727. {
  3728. StringBuilder sql2 = new StringBuilder();
  3729. 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);
  3730. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3731. }
  3732. else
  3733. {
  3734. StringBuilder sql2 = new StringBuilder();
  3735. 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);
  3736. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3737. }
  3738. }
  3739. returnSuccessMsg("操作成功!");
  3740. return;
  3741. }
  3742. returnErrorMsg("找不到订单记录");
  3743. }
  3744. }
  3745. public void cyt_erp_returnreason()
  3746. {
  3747. if (UrlPostParmsCheck("ctid"))
  3748. {
  3749. string eid = GetPostString("ctid");
  3750. CeErpTradeCell entity = null;
  3751. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3752. string userpost = CurrentUser.UserPost.Post.Code;
  3753. if (entity != null)
  3754. {
  3755. if (entity.OrderState > 6)
  3756. {
  3757. returnErrorMsg("已发货无法打回!");
  3758. return;
  3759. }
  3760. JObject jsonObject = new JObject
  3761. {
  3762. { "Userid", "77886" },
  3763. { "Pwd", "lt666888" },
  3764. { "LTOrderId",eid }
  3765. };
  3766. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3767. JObject jsonObjects = JObject.Parse(response);
  3768. string msg = (string)jsonObjects["msg"];
  3769. if (msg != "取消成功")
  3770. {
  3771. returnErrorMsg(msg);
  3772. return;
  3773. }
  3774. bool isNeedUpdateCell2 = false;
  3775. if (entity.OrderState >= 6)
  3776. {
  3777. isNeedUpdateCell2 = true;
  3778. }
  3779. int returnTag = 2;
  3780. if (userpost == "Supplier")
  3781. {
  3782. returnTag = 1;
  3783. }
  3784. if (entity.IsXianHuo == 0)
  3785. {
  3786. if (returnTag == 2)
  3787. {
  3788. int toType = GetPostInt("totype");
  3789. if (toType == 1)
  3790. {
  3791. entity.OrderState = 0;
  3792. entity.ReturnUserType = 1;
  3793. }
  3794. else
  3795. {
  3796. entity.OrderState = 4;
  3797. entity.ReturnUserType = 2;
  3798. }
  3799. entity.IsReadTag = 1;
  3800. }
  3801. else if (returnTag == 1)
  3802. {
  3803. entity.OrderState = 5;
  3804. }
  3805. entity.IsVerifyToSupplier = false;
  3806. }
  3807. entity.UnusualTag = 0;
  3808. entity.UnusualTime = null;
  3809. entity.UnusualCon = "";
  3810. entity.IsReturn = returnTag;
  3811. entity.ReturnTime = DateTime.Now;
  3812. entity.ReturnReason = GetPostString("returnreason");
  3813. entity.Update();
  3814. if (entity.OrderState == 4)
  3815. {
  3816. ApiVo apiVo = new ApiVo();
  3817. apiVo.orderNumber = entity.ctid;
  3818. apiVo.actionName = "rebutDesign";
  3819. apiVo.orderRemarks = entity.ReturnReason;
  3820. designHelper.API_WorkCore(apiVo);//rebutDesign
  3821. }
  3822. CeErpSukuraData.createInfo(entity.ctid, 5);
  3823. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3825. if (isNeedUpdateCell2)
  3826. {
  3827. if (entity.MakeSupplier.IndexOf(",") != -1)
  3828. {
  3829. StringBuilder sql2 = new StringBuilder();
  3830. 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);
  3831. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3832. }
  3833. else
  3834. {
  3835. StringBuilder sql2 = new StringBuilder();
  3836. 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);
  3837. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3838. }
  3839. }
  3840. returnSuccessMsg("操作成功!");
  3841. return;
  3842. }
  3843. returnErrorMsg("找不到订单记录");
  3844. }
  3845. }
  3846. public void upd_erp_xianhuoreturntag()
  3847. {
  3848. if (UrlPostParmsCheck("ctid"))
  3849. {
  3850. string eids = GetPostString("ctid");
  3851. string[] ctids = eids.Split(',');
  3852. foreach (string ctid in ctids)
  3853. {
  3854. CeErpTradeCell entity = null;
  3855. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3856. if (entity != null)
  3857. {
  3858. entity.IsReturn = 0;
  3859. entity.Update();
  3860. CeErpSukuraData.createInfo(entity.ctid, 5);
  3861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3862. }
  3863. }
  3864. returnSuccessMsg("操作成功!");
  3865. return;
  3866. }
  3867. }
  3868. public void get_erp_waitdeliverylist()
  3869. {
  3870. DataStruct dStruct = GetPostStruct();
  3871. List<string> lw = new List<string>();
  3872. string tid = GetPostString("ctid");
  3873. if (tid.Length > 0)
  3874. {
  3875. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3876. if (tid.Length > 5)
  3877. {
  3878. List<string> tids = getTidByCtidLike(tid);
  3879. if (tids.Count > 0 && tids.Count < 10)
  3880. {
  3881. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3882. }
  3883. }
  3884. lw.Add(tid_sql);
  3885. }
  3886. string shopname = GetPostString("shopname");
  3887. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3888. string buyernick = GetPostString("buyer_nick");
  3889. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3890. //if (tid.Length == 0 && buyernick.Length == 0)
  3891. //{
  3892. // lw.Add(string.Format("IsRefund<={0}", 1));
  3893. //}
  3894. string customer = GetPostString("customer");
  3895. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3896. string design = GetPostString("design");
  3897. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3898. string orderState = GetPostString("orderState");
  3899. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3900. string address = GetPostString("address");
  3901. 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));
  3902. string sellermemo = GetPostString("seller_memo");
  3903. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3904. string supplier = GetPostString("supplier");
  3905. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3906. string OrderArea = GetPostString("order_area");
  3907. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3908. string placedate1 = GetPostString("placedate1");
  3909. string placedate2 = GetPostString("placedate2");
  3910. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3911. if (fdw.Length > 0) lw.Add(fdw);
  3912. string price1 = GetPostString("price1");
  3913. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3914. string price2 = GetPostString("price2");
  3915. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3916. string unusualCon = GetPostString("unusualcon");
  3917. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3918. string otherMemo = GetPostString("otherMemo");
  3919. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3920. string posTag = CurrentUser.UserPost.Post.Code;
  3921. if (posTag == "Supplier")
  3922. {
  3923. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3924. }
  3925. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3926. lw.Add(string.Format("type != 'PDD' "));
  3927. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3928. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3929. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3930. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3931. writeGridDataTableJson(dStruct.TotalCount, dt);
  3932. }
  3933. public void get_erp_changedeliverylist()
  3934. {
  3935. DataStruct dStruct = GetPostStruct();
  3936. List<string> lw = new List<string>();
  3937. string tid = GetPostString("ctid");
  3938. if (tid.Length > 0)
  3939. {
  3940. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3941. if (tid.Length > 5)
  3942. {
  3943. List<string> tids = getTidByCtidLike(tid);
  3944. if (tids.Count > 0 && tids.Count < 10)
  3945. {
  3946. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3947. }
  3948. }
  3949. lw.Add(tid_sql);
  3950. }
  3951. string shopname = GetPostString("shopname");
  3952. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3953. string buyernick = GetPostString("buyer_nick");
  3954. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3955. //if (tid.Length == 0 && buyernick.Length == 0)
  3956. //{
  3957. // lw.Add(string.Format("IsRefund<={0}", 1));
  3958. //}
  3959. string customer = GetPostString("customer");
  3960. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3961. string design = GetPostString("design");
  3962. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3963. string orderState = GetPostString("orderState");
  3964. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3965. string address = GetPostString("address");
  3966. 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));
  3967. string sellermemo = GetPostString("seller_memo");
  3968. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3969. string supplier = GetPostString("supplier");
  3970. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3971. string OrderArea = GetPostString("order_area");
  3972. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3973. string placedate1 = GetPostString("placedate1");
  3974. string placedate2 = GetPostString("placedate2");
  3975. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3976. if (fdw.Length > 0) lw.Add(fdw);
  3977. string price1 = GetPostString("price1");
  3978. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3979. string price2 = GetPostString("price2");
  3980. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3981. string unusualCon = GetPostString("unusualcon");
  3982. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3983. string otherMemo = GetPostString("otherMemo");
  3984. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3985. string posTag = CurrentUser.UserPost.Post.Code;
  3986. if (posTag == "Supplier")
  3987. {
  3988. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3989. }
  3990. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3991. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3992. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3993. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3994. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3995. /*if (tid.Length > 0)
  3996. {
  3997. List<string> tids = new List<string>();
  3998. if (dt != null && dt.Rows.Count > 0)
  3999. {
  4000. foreach (DataRow item in dt.Rows)
  4001. {
  4002. tids.Add("'" + item["tid"] + "'");
  4003. }
  4004. }
  4005. if (tids.Count > 0)
  4006. {
  4007. lw.RemoveAt(0);
  4008. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4009. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4010. dt = WebCache.GetData("view_erptradecell", dStruct);
  4011. }
  4012. }*/
  4013. writeGridDataTableJson(dStruct.TotalCount, dt);
  4014. }
  4015. public void get_erp_pddderiving()
  4016. {
  4017. DataStruct dStruct = GetPostStruct();
  4018. List<string> lw = new List<string>();
  4019. string tid = GetPostString("ctid");
  4020. if (tid.Length > 0)
  4021. {
  4022. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4023. if (tid.Length > 5)
  4024. {
  4025. List<string> tids = getTidByCtidLike(tid);
  4026. if (tids.Count > 0 && tids.Count < 10)
  4027. {
  4028. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4029. }
  4030. }
  4031. lw.Add(tid_sql);
  4032. }
  4033. string shopname = GetPostString("shopname");
  4034. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4035. string buyernick = GetPostString("buyer_nick");
  4036. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4037. //if (tid.Length == 0 && buyernick.Length == 0)
  4038. //{
  4039. // lw.Add(string.Format("IsRefund<={0}", 1));
  4040. //}
  4041. string customer = GetPostString("customer");
  4042. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4043. string design = GetPostString("design");
  4044. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4045. string orderState = GetPostString("orderState");
  4046. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4047. string address = GetPostString("address");
  4048. 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));
  4049. string sellermemo = GetPostString("seller_memo");
  4050. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4051. string supplier = GetPostString("supplier");
  4052. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4053. string OrderArea = GetPostString("order_area");
  4054. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4055. string placedate1 = GetPostString("placedate1");
  4056. string placedate2 = GetPostString("placedate2");
  4057. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4058. if (fdw.Length > 0) lw.Add(fdw);
  4059. string price1 = GetPostString("price1");
  4060. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4061. string price2 = GetPostString("price2");
  4062. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4063. string unusualCon = GetPostString("unusualcon");
  4064. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4065. string posTag = CurrentUser.UserPost.Post.Code;
  4066. if (posTag == "Supplier")
  4067. {
  4068. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4069. }
  4070. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4071. lw.Add(string.Format("type = 'PDD' "));
  4072. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4073. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4074. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4075. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4076. /*if (tid.Length > 0)
  4077. {
  4078. List<string> tids = new List<string>();
  4079. if (dt != null && dt.Rows.Count > 0)
  4080. {
  4081. foreach (DataRow item in dt.Rows)
  4082. {
  4083. tids.Add("'" + item["tid"] + "'");
  4084. }
  4085. }
  4086. if (tids.Count > 0)
  4087. {
  4088. lw.RemoveAt(0);
  4089. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4090. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4091. dt = WebCache.GetData("view_erptradecell", dStruct);
  4092. }
  4093. }*/
  4094. writeGridDataTableJson(dStruct.TotalCount, dt);
  4095. }
  4096. public void get_erp_jdderiving()
  4097. {
  4098. DataStruct dStruct = GetPostStruct();
  4099. List<string> lw = new List<string>();
  4100. string tid = GetPostString("ctid");
  4101. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4102. string shopname = GetPostString("shopname");
  4103. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4104. string buyernick = GetPostString("buyer_nick");
  4105. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4106. //if (tid.Length == 0 && buyernick.Length == 0)
  4107. //{
  4108. // lw.Add(string.Format("IsRefund<={0}", 1));
  4109. //}
  4110. string customer = GetPostString("customer");
  4111. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4112. string design = GetPostString("design");
  4113. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4114. string orderState = GetPostString("orderState");
  4115. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4116. string address = GetPostString("address");
  4117. 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));
  4118. string sellermemo = GetPostString("seller_memo");
  4119. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4120. string supplier = GetPostString("supplier");
  4121. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4122. string OrderArea = GetPostString("order_area");
  4123. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4124. string placedate1 = GetPostString("placedate1");
  4125. string placedate2 = GetPostString("placedate2");
  4126. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4127. if (fdw.Length > 0) lw.Add(fdw);
  4128. string price1 = GetPostString("price1");
  4129. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4130. string price2 = GetPostString("price2");
  4131. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4132. string unusualCon = GetPostString("unusualcon");
  4133. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4134. string posTag = CurrentUser.UserPost.Post.Code;
  4135. if (posTag == "Supplier")
  4136. {
  4137. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4138. }
  4139. lw.Add(string.Format("OrderState = 6 "));
  4140. lw.Add(string.Format("type = 'JD' "));
  4141. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4142. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4143. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4144. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4145. writeGridDataTableJson(dStruct.TotalCount, dt);
  4146. }
  4147. public void get_erp_demoorderlist()
  4148. {
  4149. DataStruct dStruct = GetPostStruct();
  4150. List<string> lw = new List<string>();
  4151. string tid = GetPostString("ctid");
  4152. if (tid.Length > 0)
  4153. {
  4154. string select_tid = getTidByCtid(tid);
  4155. lw.Add(string.Format("tid='{0}'", select_tid));
  4156. }
  4157. string shopname = GetPostString("shopname");
  4158. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4159. string buyernick = GetPostString("buyer_nick");
  4160. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4161. string customer = GetPostString("customer");
  4162. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4163. string design = GetPostString("design");
  4164. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4165. string orderState = GetPostString("orderState");
  4166. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4167. string address = GetPostString("address");
  4168. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4169. string sellermemo = GetPostString("seller_memo");
  4170. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4171. string supplier = GetPostString("supplier");
  4172. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4173. string OrderArea = GetPostString("order_area");
  4174. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4175. string date1 = GetPostString("date1");
  4176. string date2 = GetPostString("date2");
  4177. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4178. if (dw.Length > 0) lw.Add(dw);
  4179. string price1 = GetPostString("price1");
  4180. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4181. string price2 = GetPostString("price2");
  4182. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4183. string posTag = CurrentUser.UserPost.Post.Code;
  4184. if (posTag == "Supplier")
  4185. {
  4186. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4187. }
  4188. //lw.Add(string.Format("OrderState = 6 "));
  4189. lw.Add(string.Format("IsSample={0}", 3));
  4190. lw.Add(string.Format("IsRefund<={0}", 1));
  4191. dStruct.Order = "pay_time desc";
  4192. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4193. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4194. writeGridDataTableJson(dStruct.TotalCount, dt);
  4195. }
  4196. public void save_erp_checkmemo()
  4197. {
  4198. if (UrlPostParmsCheck("ctid"))
  4199. {
  4200. string ctid = GetPostString("ctid");
  4201. CeErpTradeCell entity = null;
  4202. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4203. if (entity != null)
  4204. {
  4205. entity.CheckMemo = GetPostString("CheckMemo");
  4206. entity.Update();
  4207. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4208. if (trade != null)
  4209. {
  4210. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4211. }
  4212. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4213. returnSuccessMsg("保存成功!");
  4214. return;
  4215. }
  4216. returnErrorMsg("找不到记录");
  4217. }
  4218. }
  4219. public void get_erp_returnlist()
  4220. {
  4221. DataStruct dStruct = GetPostStruct();
  4222. List<string> lw = new List<string>();
  4223. string tid = GetPostString("ctid");
  4224. if (tid.Length > 0)
  4225. {
  4226. string select_tid = getTidByCtid(tid);
  4227. lw.Add(string.Format("tid='{0}'", select_tid));
  4228. }
  4229. string shopname = GetPostString("shopname");
  4230. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4231. string buyernick = GetPostString("buyer_nick");
  4232. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4233. string customer = GetPostString("customer");
  4234. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4235. string design = GetPostString("design");
  4236. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4237. string orderState = GetPostString("orderState");
  4238. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4239. string address = GetPostString("address");
  4240. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4241. string sellermemo = GetPostString("seller_memo");
  4242. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4243. string supplier = GetPostString("supplier");
  4244. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4245. string date1 = GetPostString("date1");
  4246. string date2 = GetPostString("date2");
  4247. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4248. if (dw.Length > 0) lw.Add(dw);
  4249. string bdate1 = GetPostString("backdate1");
  4250. string bdate2 = GetPostString("backdate2");
  4251. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4252. if (dw_back.Length > 0) lw.Add(dw_back);
  4253. string price1 = GetPostString("price1");
  4254. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4255. string price2 = GetPostString("price2");
  4256. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4257. lw.Add(string.Format("IsReturn>0"));
  4258. lw.Add(string.Format("IsXianHuo=0"));
  4259. lw.Add(string.Format("IsReturn!=3"));
  4260. string backtype = GetPostString("backtype");
  4261. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4262. dStruct.Order = "FinishDesignTime desc";
  4263. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4264. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4265. writeGridDataTableJson(dStruct.TotalCount, dt);
  4266. }
  4267. public void get_erp_today_sumreturn()
  4268. {
  4269. DataStruct dStruct = GetPostStruct();
  4270. List<string> lw = new List<string>();
  4271. string bdate1 = GetPostString("returnTimeS");
  4272. string bdate2 = GetPostString("returnTimeE");
  4273. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4274. if (dw_back.Length > 0) lw.Add(dw_back);
  4275. lw.Add(string.Format("IsReturn=0"));
  4276. lw.Add(string.Format("IsXianHuo=0"));
  4277. string mainWhere = string.Join(" and ", lw.ToArray());
  4278. string sql = "";
  4279. if (dw_back.Length > 0)
  4280. {
  4281. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4282. }
  4283. else
  4284. {
  4285. 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 + "'";
  4286. }
  4287. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4288. decimal total = 0, today_finish = 0;
  4289. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4290. {
  4291. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4292. }
  4293. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4294. {
  4295. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4296. }
  4297. var res = new
  4298. {
  4299. data = total,
  4300. data1 = today_finish,
  4301. };
  4302. string ro_jsond = JsonConvert.SerializeObject(res);
  4303. returnSuccess(ro_jsond);
  4304. return;
  4305. }
  4306. public void get_erp_allreturnlist()
  4307. {
  4308. DataStruct dStruct = GetPostStruct();
  4309. List<string> lw = new List<string>();
  4310. string tid = GetPostString("ctid");
  4311. if (tid.Length > 0)
  4312. {
  4313. string select_tid = getTidByCtid(tid);
  4314. lw.Add(string.Format("tid='{0}'", select_tid));
  4315. }
  4316. string shopname = GetPostString("shopname");
  4317. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4318. string buyernick = GetPostString("buyer_nick");
  4319. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4320. string customer = GetPostString("customer");
  4321. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4322. string design = GetPostString("design");
  4323. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4324. string orderState = GetPostString("orderState");
  4325. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4326. string address = GetPostString("address");
  4327. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4328. string sellermemo = GetPostString("seller_memo");
  4329. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4330. string supplier = GetPostString("supplier");
  4331. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4332. string date1 = GetPostString("date1");
  4333. string date2 = GetPostString("date2");
  4334. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4335. if (dw.Length > 0) lw.Add(dw);
  4336. string bdate1 = GetPostString("backdate1");
  4337. string bdate2 = GetPostString("backdate2");
  4338. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4339. if (dw_back.Length > 0) lw.Add(dw_back);
  4340. string price1 = GetPostString("price1");
  4341. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4342. string price2 = GetPostString("price2");
  4343. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4344. string backreason = GetPostString("backreason");
  4345. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4346. lw.Add(string.Format("IsXianHuo=0"));
  4347. lw.Add(string.Format("ReturnTime != ''"));
  4348. string backtype = GetPostString("backtype");
  4349. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4350. dStruct.Order = "FinishDesignTime desc";
  4351. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4352. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4353. writeGridDataTableJson(dStruct.TotalCount, dt);
  4354. }
  4355. public void get_erp_aftersalereturnlist()
  4356. {
  4357. DataStruct dStruct = GetPostStruct();
  4358. List<string> lw = new List<string>();
  4359. string tid = GetPostString("ctid");
  4360. if (tid.Length > 0)
  4361. {
  4362. string select_tid = getTidByCtid(tid);
  4363. lw.Add(string.Format("tid='{0}'", select_tid));
  4364. }
  4365. string shopname = GetPostString("shopname");
  4366. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4367. string buyernick = GetPostString("buyer_nick");
  4368. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4369. string customer = GetPostString("customer");
  4370. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4371. string design = GetPostString("design");
  4372. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4373. string orderState = GetPostString("orderState");
  4374. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4375. string address = GetPostString("address");
  4376. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4377. string sellermemo = GetPostString("seller_memo");
  4378. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4379. string supplier = GetPostString("supplier");
  4380. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4381. string date1 = GetPostString("date1");
  4382. string date2 = GetPostString("date2");
  4383. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4384. if (dw.Length > 0) lw.Add(dw);
  4385. string bdate1 = GetPostString("backdate1");
  4386. string bdate2 = GetPostString("backdate2");
  4387. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4388. if (dw_back.Length > 0) lw.Add(dw_back);
  4389. string price1 = GetPostString("price1");
  4390. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4391. string price2 = GetPostString("price2");
  4392. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4393. lw.Add(string.Format("IsReturn=3"));
  4394. string backtype = GetPostString("backtype");
  4395. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4396. string backreason = GetPostString("backreason");
  4397. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4398. dStruct.Order = "ReturnTime desc";
  4399. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4400. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4401. writeGridDataTableJson(dStruct.TotalCount, dt);
  4402. }
  4403. public void get_erp_xianhuoreturnlist()
  4404. {
  4405. DataStruct dStruct = GetPostStruct();
  4406. List<string> lw = new List<string>();
  4407. string tid = GetPostString("ctid");
  4408. if (tid.Length > 0)
  4409. {
  4410. string select_tid = getTidByCtid(tid);
  4411. lw.Add(string.Format("tid='{0}'", select_tid));
  4412. }
  4413. string shopname = GetPostString("shopname");
  4414. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4415. string buyernick = GetPostString("buyer_nick");
  4416. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4417. string customer = GetPostString("customer");
  4418. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4419. string design = GetPostString("design");
  4420. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4421. string orderState = GetPostString("orderState");
  4422. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4423. string address = GetPostString("address");
  4424. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4425. string sellermemo = GetPostString("seller_memo");
  4426. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4427. string supplier = GetPostString("supplier");
  4428. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4429. string OrderArea = GetPostString("order_area");
  4430. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4431. string date1 = GetPostString("date1");
  4432. string date2 = GetPostString("date2");
  4433. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4434. if (dw.Length > 0) lw.Add(dw);
  4435. string price1 = GetPostString("price1");
  4436. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4437. string price2 = GetPostString("price2");
  4438. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4439. string posTag = CurrentUser.UserPost.Post.Code;
  4440. if (posTag == "Supplier")
  4441. {
  4442. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4443. }
  4444. lw.Add(string.Format("OrderState=6 "));
  4445. lw.Add(string.Format("IsXianHuo=1 "));
  4446. lw.Add(string.Format("IsReturn>0 "));
  4447. lw.Add(string.Format("IsReturn!=3"));
  4448. lw.Add(string.Format("IsRefund<={0}", 1));
  4449. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4450. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4451. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4452. writeGridDataTableJson(dStruct.TotalCount, dt);
  4453. }
  4454. public void set_erp_orderdelivery()
  4455. {
  4456. if (UrlPostParmsCheck("ctid"))
  4457. {
  4458. string eid = GetPostString("ctid");
  4459. CeErpTradeCell entity = null;
  4460. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4461. if (entity != null)
  4462. {
  4463. if (entity.OrderState >= 7)
  4464. {
  4465. returnErrorMsg("此单已发货,无需重复发货");
  4466. return;
  4467. }
  4468. if (entity.OrderState != 6)
  4469. {
  4470. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4471. return;
  4472. }
  4473. string shop = GetPostString("seller_nick");
  4474. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4475. string comName = GetPostString("comName");
  4476. string comCode = GetPostString("comCode");
  4477. string outSid = GetPostString("outSid");
  4478. string deliveryType = GetPostString("deliveryType");
  4479. string deliveryMemo = GetPostString("deliveryMemo");
  4480. outSid = outSid.Trim();
  4481. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4482. if (mainEn == null)
  4483. {
  4484. returnErrorMsg("找不到原始订单记录");
  4485. return;
  4486. }
  4487. bool isInitOrderDeliv = false;
  4488. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4489. {
  4490. isInitOrderDeliv = true;
  4491. }
  4492. string apires = "";
  4493. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4494. 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)
  4495. {
  4496. apires = "发货成功true";
  4497. }
  4498. else
  4499. {
  4500. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4501. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4502. }
  4503. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4504. {
  4505. entity.OrderState = 7;//发货后订单已发货
  4506. entity.OutSid = outSid;
  4507. entity.MemoOpt = 0;
  4508. entity.UpdateTime = DateTime.Now;
  4509. entity.FinishDeliveryTime = DateTime.Now;
  4510. entity.Update();
  4511. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4512. commonHelper.UpdateRelationOrder(entity.ctid);
  4513. //还要插入快递信息到 快递信息表
  4514. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4515. exinfo.tid = eid;
  4516. exinfo.out_sid = outSid;
  4517. exinfo.company_code = comCode;
  4518. exinfo.company_name = comName;
  4519. exinfo.delivery_memo = deliveryMemo;
  4520. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4521. exinfo.deliveryType = deliveryType;
  4522. exinfo.Create();
  4523. returnSuccessMsg("发货操作成功!");
  4524. commonHelper.UpdateRelationOrder(entity.ctid);
  4525. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4526. CeErpSukuraData.createInfo(entity.ctid, 4);
  4527. if (entity.SupplierId == 64)
  4528. {
  4529. commonHelper.sendCytExpress(exinfo);
  4530. }
  4531. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4532. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4533. }
  4534. else
  4535. {
  4536. string errmsg = commonHelper.KeepChinese(apires);
  4537. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4538. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4539. }
  4540. return;
  4541. }
  4542. returnErrorMsg("找不到订单记录");
  4543. }
  4544. }
  4545. public void set_erp_multidelivery()
  4546. {
  4547. string eids = GetPostString("tids");
  4548. string[] eidList = eids.Split(',');
  4549. if (eidList.Length <= 0)
  4550. {
  4551. returnErrorMsg("发货不能为空");
  4552. return;
  4553. }
  4554. foreach (string ctid in eidList)
  4555. {
  4556. if (ctid.Length <= 0) continue;
  4557. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4558. if (expInfo != null)
  4559. {
  4560. StringBuilder sql = new StringBuilder();
  4561. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4562. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4563. if (dt.Rows.Count > 0)
  4564. {
  4565. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4566. {
  4567. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4568. expInfo.state = "异常";
  4569. expInfo.isMultiDelivery = 1;
  4570. expInfo.Update();
  4571. continue;
  4572. }
  4573. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4574. {
  4575. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4576. expInfo.state = "异常";
  4577. expInfo.Update();
  4578. continue;
  4579. }
  4580. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4581. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4582. bool isInitOrderDeliv = false;
  4583. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4584. {
  4585. isInitOrderDeliv = true;
  4586. expInfo.isMultiDelivery = 1;
  4587. }
  4588. if (ctid.IndexOf("N") != -1)
  4589. {
  4590. StringBuilder sqlbucha = new StringBuilder();
  4591. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4592. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4593. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4594. commonHelper.UpdateRelationOrder(ctid);
  4595. expInfo.delivery_memo = "发货成功";
  4596. expInfo.state = "发货成功";
  4597. expInfo.isMultiDelivery = 1;
  4598. expInfo.Update();
  4599. }
  4600. else
  4601. {
  4602. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4603. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4604. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4605. {
  4606. expInfo.delivery_memo = "发货成功";
  4607. expInfo.state = "发货成功";
  4608. expInfo.isMultiDelivery = 1;
  4609. expInfo.Update();
  4610. commonHelper.UpdateRelationOrder(ctid);
  4611. CeErpSukuraData.createInfo(ctid, 4);
  4612. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4613. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4614. }
  4615. else
  4616. {
  4617. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4618. expInfo.state = "异常";
  4619. expInfo.Update();
  4620. }
  4621. }
  4622. }
  4623. }
  4624. }
  4625. returnSuccessMsg("操作完成");
  4626. }
  4627. public void reset_erp_memoopt()
  4628. {
  4629. if (UrlPostParmsCheck("ctid"))
  4630. {
  4631. string eid = GetPostString("ctid");
  4632. CeErpTradeCell entity = null;
  4633. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4634. if (entity != null)
  4635. {
  4636. string stropt = "";
  4637. if (entity.MemoOpt == 1)
  4638. {
  4639. stropt = "“改稿”";
  4640. }
  4641. else if (entity.MemoOpt == 2)
  4642. {
  4643. stropt = "“定稿”";
  4644. }
  4645. else if (entity.MemoOpt == 3)
  4646. {
  4647. stropt = "“完成查货”";
  4648. CeErpSukuraData.createInfo(entity.ctid, 6);
  4649. }
  4650. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4651. entity.UpdateTime = DateTime.Now;
  4652. entity.MemoOpt = 0;
  4653. entity.Update();
  4654. returnSuccessMsg("操作成功!");
  4655. return;
  4656. }
  4657. returnErrorMsg("找不到记录");
  4658. }
  4659. }
  4660. public void get_erp_deliveryunusual()
  4661. {
  4662. DataStruct dStruct = GetPostStruct();
  4663. List<string> lw = new List<string>();
  4664. string tid = GetPostString("ctid");
  4665. if (tid.Length > 0)
  4666. {
  4667. string select_tid = getTidByCtid(tid);
  4668. lw.Add(string.Format("tid='{0}'", select_tid));
  4669. }
  4670. string shopname = GetPostString("shopname");
  4671. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4672. string buyernick = GetPostString("buyer_nick");
  4673. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4674. string customer = GetPostString("customer");
  4675. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4676. string design = GetPostString("design");
  4677. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4678. string sellermemo = GetPostString("seller_memo");
  4679. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4680. string supplier = GetPostString("supplier");
  4681. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4682. string date1 = GetPostString("date1");
  4683. string date2 = GetPostString("date2");
  4684. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4685. if (dw.Length > 0) lw.Add(dw);
  4686. string placedate1 = GetPostString("placedate1");
  4687. string placedate2 = GetPostString("placedate2");
  4688. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4689. if (dw_place.Length > 0) lw.Add(dw_place);
  4690. string price1 = GetPostString("price1");
  4691. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4692. string price2 = GetPostString("price2");
  4693. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4694. string unusualCon = GetPostString("unusualcon");
  4695. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4696. string posTag = CurrentUser.UserPost.Post.Code;
  4697. if (posTag == "Supplier")
  4698. {
  4699. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4700. }
  4701. lw.Add(string.Format("OrderState = 6"));
  4702. lw.Add(string.Format("UnusualTag = 5"));
  4703. lw.Add(string.Format("IsRefund<={0}", 1));
  4704. dStruct.Order = "FinishPlaceTime desc";
  4705. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4706. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4707. writeGridDataTableJson(dStruct.TotalCount, dt);
  4708. }
  4709. public void get_erp_deliveryedlist()
  4710. {
  4711. DataStruct dStruct = GetPostStruct();
  4712. List<string> lw = new List<string>();
  4713. string tid = GetPostString("ctid");
  4714. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4715. string shopname = GetPostString("shopname");
  4716. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4717. string buyernick = GetPostString("buyer_nick");
  4718. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4719. string customer = GetPostString("customer");
  4720. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4721. string design = GetPostString("design");
  4722. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4723. string sellermemo = GetPostString("seller_memo");
  4724. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4725. string logistics = GetPostString("logistics");
  4726. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4727. string date1 = GetPostString("date1");
  4728. string date2 = GetPostString("date2");
  4729. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4730. //if (dw.Length > 0) lw.Add(dw);
  4731. string placedate1 = GetPostString("placedate1");
  4732. string placedate2 = GetPostString("placedate2");
  4733. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4734. if (fdw.Length > 0) lw.Add(fdw);
  4735. string devdate1 = GetPostString("deliverydate1");
  4736. string devdate2 = GetPostString("deliverydate2");
  4737. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4738. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4739. string price1 = GetPostString("price1");
  4740. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4741. string price2 = GetPostString("price2");
  4742. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4743. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4744. {
  4745. if (tid.Length > 0)
  4746. {
  4747. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4748. if (tid.Length > 5)
  4749. {
  4750. List<string> tids = getTidByCtidLike(tid);
  4751. if (tids.Count > 0 && tids.Count < 10)
  4752. {
  4753. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4754. }
  4755. }
  4756. lw.Add(tid_sql);
  4757. }
  4758. if (buyernick.Length > 0)
  4759. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4760. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4761. if (dw.Length > 0) lw.Add(dw);
  4762. }
  4763. else
  4764. {
  4765. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4766. }
  4767. string posTag = CurrentUser.UserPost.Post.Code;
  4768. if (posTag == "Supplier")
  4769. {
  4770. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4771. }
  4772. else
  4773. {
  4774. string supplier = GetPostString("supplier");
  4775. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4776. }
  4777. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4778. lw.Add(string.Format("type != 'PDD' "));
  4779. lw.Add(string.Format("IsRefund!={0}", 2));
  4780. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4781. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4782. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4783. /*if (tid.Length > 0)
  4784. {
  4785. List<string> tids = new List<string>();
  4786. if (dt != null && dt.Rows.Count > 0)
  4787. {
  4788. foreach (DataRow item in dt.Rows)
  4789. {
  4790. tids.Add("'" + item["tid"] + "'");
  4791. }
  4792. }
  4793. if (tids.Count > 0)
  4794. {
  4795. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4796. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4797. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4798. dt = WebCache.GetData("view_erptradecell", dStruct);
  4799. }
  4800. }*/
  4801. if (dt != null)
  4802. {
  4803. foreach (DataRow dr in dt.Rows)
  4804. {
  4805. 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();
  4806. }
  4807. }
  4808. writeGridDataTableJson(dStruct.TotalCount, dt);
  4809. }
  4810. public void get_erp_pdddeliveryed()
  4811. {
  4812. DataStruct dStruct = GetPostStruct();
  4813. List<string> lw = new List<string>();
  4814. string tid = GetPostString("ctid");
  4815. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4816. string shopname = GetPostString("shopname");
  4817. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4818. string buyernick = GetPostString("buyer_nick");
  4819. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4820. string customer = GetPostString("customer");
  4821. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4822. string design = GetPostString("design");
  4823. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4824. string sellermemo = GetPostString("seller_memo");
  4825. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4826. string logistics = GetPostString("logistics");
  4827. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4828. string date1 = GetPostString("date1");
  4829. string date2 = GetPostString("date2");
  4830. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4831. //if (dw.Length > 0) lw.Add(dw);
  4832. string placedate1 = GetPostString("placedate1");
  4833. string placedate2 = GetPostString("placedate2");
  4834. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4835. if (fdw.Length > 0) lw.Add(fdw);
  4836. string devdate1 = GetPostString("deliverydate1");
  4837. string devdate2 = GetPostString("deliverydate2");
  4838. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4839. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4840. string price1 = GetPostString("price1");
  4841. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4842. string price2 = GetPostString("price2");
  4843. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4844. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4845. {
  4846. if (tid.Length > 0)
  4847. {
  4848. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4849. if (tid.Length > 5)
  4850. {
  4851. List<string> tids = getTidByCtidLike(tid);
  4852. if (tids.Count > 0 && tids.Count < 10)
  4853. {
  4854. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4855. }
  4856. }
  4857. lw.Add(tid_sql);
  4858. }
  4859. if (buyernick.Length > 0)
  4860. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4861. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4862. if (dw.Length > 0) lw.Add(dw);
  4863. }
  4864. else
  4865. {
  4866. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4867. }
  4868. string posTag = CurrentUser.UserPost.Post.Code;
  4869. if (posTag == "Supplier")
  4870. {
  4871. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4872. }
  4873. else
  4874. {
  4875. string supplier = GetPostString("supplier");
  4876. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4877. }
  4878. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4879. lw.Add(string.Format("type = 'PDD' "));
  4880. lw.Add(string.Format("IsRefund!={0}", 2));
  4881. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4882. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4883. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4884. /* if (tid.Length > 0)
  4885. {
  4886. List<string> tids = new List<string>();
  4887. if (dt != null && dt.Rows.Count > 0)
  4888. {
  4889. foreach (DataRow item in dt.Rows)
  4890. {
  4891. tids.Add("'" + item["tid"] + "'");
  4892. }
  4893. }
  4894. if (tids.Count > 0)
  4895. {
  4896. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4897. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4898. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4899. dt = WebCache.GetData("view_erptradecell", dStruct);
  4900. }
  4901. }*/
  4902. foreach (DataRow dr in dt.Rows)
  4903. {
  4904. 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();
  4905. }
  4906. writeGridDataTableJson(dStruct.TotalCount, dt);
  4907. }
  4908. public void get_erp_jddeliveryed()
  4909. {
  4910. DataStruct dStruct = GetPostStruct();
  4911. List<string> lw = new List<string>();
  4912. string tid = GetPostString("ctid");
  4913. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4914. string shopname = GetPostString("shopname");
  4915. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4916. string buyernick = GetPostString("buyer_nick");
  4917. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4918. string customer = GetPostString("customer");
  4919. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4920. string design = GetPostString("design");
  4921. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4922. string sellermemo = GetPostString("seller_memo");
  4923. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4924. string date1 = GetPostString("date1");
  4925. string date2 = GetPostString("date2");
  4926. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4927. //if (dw.Length > 0) lw.Add(dw);
  4928. string placedate1 = GetPostString("placedate1");
  4929. string placedate2 = GetPostString("placedate2");
  4930. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4931. if (fdw.Length > 0) lw.Add(fdw);
  4932. string devdate1 = GetPostString("deliverydate1");
  4933. string devdate2 = GetPostString("deliverydate2");
  4934. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4935. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4936. string price1 = GetPostString("price1");
  4937. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4938. string price2 = GetPostString("price2");
  4939. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4940. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4941. {
  4942. if (tid.Length > 0)
  4943. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4944. if (buyernick.Length > 0)
  4945. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4946. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4947. if (dw.Length > 0) lw.Add(dw);
  4948. }
  4949. else
  4950. {
  4951. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4952. }
  4953. string posTag = CurrentUser.UserPost.Post.Code;
  4954. if (posTag == "Supplier")
  4955. {
  4956. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4957. }
  4958. else
  4959. {
  4960. string supplier = GetPostString("supplier");
  4961. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4962. }
  4963. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4964. lw.Add(string.Format("type = 'JD' "));
  4965. lw.Add(string.Format("IsRefund!={0}", 2));
  4966. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4967. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4968. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4969. foreach (DataRow dr in dt.Rows)
  4970. {
  4971. 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();
  4972. }
  4973. writeGridDataTableJson(dStruct.TotalCount, dt);
  4974. }
  4975. public void get_erp_allplacelist()
  4976. {
  4977. DataStruct dStruct = GetPostStruct();
  4978. List<string> lw = new List<string>();
  4979. string tid = GetPostString("ctid");
  4980. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4981. string shopname = GetPostString("shopname");
  4982. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4983. string buyernick = GetPostString("buyer_nick");
  4984. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4985. string customer = GetPostString("customer");
  4986. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4987. string design = GetPostString("design");
  4988. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4989. string sellermemo = GetPostString("seller_memo");
  4990. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4991. string supplier = GetPostString("supplier");
  4992. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4993. string date1 = GetPostString("date1");
  4994. string date2 = GetPostString("date2");
  4995. string pldate1 = GetPostString("placedate1");
  4996. string pldate2 = GetPostString("placedate2");
  4997. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4998. //if (dw.Length > 0) lw.Add(dw);
  4999. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5000. {
  5001. if (tid.Length > 0)
  5002. {
  5003. string select_tid = getTidByCtid(tid);
  5004. lw.Add(string.Format("tid='{0}'", select_tid));
  5005. }
  5006. if (buyernick.Length > 0)
  5007. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5008. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5009. if (dw.Length > 0) lw.Add(dw);
  5010. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5011. if (dw_place.Length > 0) lw.Add(dw_place);
  5012. }
  5013. else
  5014. {
  5015. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5016. {
  5017. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5018. }
  5019. }
  5020. string price1 = GetPostString("price1");
  5021. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5022. string price2 = GetPostString("price2");
  5023. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5024. string posTag = CurrentUser.UserPost.Post.Code;
  5025. if (posTag == "Supplier")
  5026. {
  5027. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5028. }
  5029. lw.Add(string.Format("OrderState >= 6"));
  5030. lw.Add(string.Format("IsSample != 2 "));
  5031. //lw.Add(string.Format("isDianziOrder = 0 "));
  5032. lw.Add(string.Format("SupplierId > 0 "));
  5033. //lw.Add(string.Format("IsRefund<={0}", 1));
  5034. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5035. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5036. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5037. foreach (DataRow dr in dt.Rows)
  5038. {
  5039. 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();
  5040. }
  5041. writeGridDataTableJson(dStruct.TotalCount, dt);
  5042. }
  5043. public void get_erp_financeallplacelist()
  5044. {
  5045. DataStruct dStruct = GetPostStruct();
  5046. List<string> lw = new List<string>();
  5047. string tid = GetPostString("ctid");
  5048. string shopname = GetPostString("shopname");
  5049. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5050. string buyernick = GetPostString("buyer_nick");
  5051. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5052. string customer = GetPostString("customer");
  5053. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5054. string design = GetPostString("design");
  5055. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5056. string sellermemo = GetPostString("seller_memo");
  5057. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5058. string supplier = GetPostString("supplier");
  5059. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5060. string date1 = GetPostString("date1");
  5061. string date2 = GetPostString("date2");
  5062. string pldate1 = GetPostString("placedate1");
  5063. string pldate2 = GetPostString("placedate2");
  5064. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5065. {
  5066. if (tid.Length > 0)
  5067. {
  5068. string select_tid = getTidByCtid(tid);
  5069. lw.Add(string.Format("tid='{0}'", select_tid));
  5070. }
  5071. if (buyernick.Length > 0)
  5072. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5073. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5074. if (dw.Length > 0) lw.Add(dw);
  5075. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5076. if (dw_place.Length > 0) lw.Add(dw_place);
  5077. }
  5078. else
  5079. {
  5080. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5081. {
  5082. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5083. }
  5084. }
  5085. string price1 = GetPostString("price1");
  5086. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5087. string price2 = GetPostString("price2");
  5088. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5089. string posTag = CurrentUser.UserPost.Post.Code;
  5090. if (posTag == "Supplier")
  5091. {
  5092. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5093. }
  5094. //lw.Add(string.Format("OrderState >= 6"));
  5095. lw.Add(string.Format("IsSample != 2 "));
  5096. lw.Add(string.Format("isDianziOrder = 0 "));
  5097. //lw.Add(string.Format("IsRefund<={0}", 1));
  5098. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5099. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5100. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5101. foreach (DataRow dr in dt.Rows)
  5102. {
  5103. 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();
  5104. }
  5105. writeGridDataTableJson(dStruct.TotalCount, dt);
  5106. }
  5107. public void get_erp_expresslist()
  5108. {
  5109. int listtype = GetInt("ltype");
  5110. DataStruct dStruct = GetPostStruct();
  5111. List<string> lw = new List<string>();
  5112. string tid = GetPostString("tid");
  5113. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5114. string outsid = GetPostString("out_sid");
  5115. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5116. string importer = GetPostString("ImportUserName");
  5117. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5118. string file = GetPostString("import_file");
  5119. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5120. string printman = GetPostString("printman");
  5121. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5122. string date1 = GetPostString("date1");
  5123. string date2 = GetPostString("date2");
  5124. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5125. if (dw.Length > 0) lw.Add(dw);
  5126. string fdate1 = GetPostString("finishdate1");
  5127. string fdate2 = GetPostString("finishdate2");
  5128. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5129. if (fdw.Length > 0) lw.Add(fdw);
  5130. string supplierId = GetPostString("supplierId");
  5131. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5132. if (listtype == 1)
  5133. {
  5134. lw.Add(string.Format("importUserId !=0"));
  5135. }
  5136. string posTag = CurrentUser.UserPost.Post.Code;
  5137. if (posTag == "Supplier")
  5138. {
  5139. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5140. }
  5141. if (dStruct.PageSize != 100000)
  5142. {
  5143. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5144. }
  5145. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5146. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5147. writeGridDataTableJson(dStruct.TotalCount, dt);
  5148. }
  5149. public void set_erp_buchaorderdelivery()
  5150. {
  5151. if (UrlPostParmsCheck("ctid"))
  5152. {
  5153. string eid = GetPostString("ctid");
  5154. CeErpTradeCell entity = null;
  5155. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5156. if (entity != null)
  5157. {
  5158. if (entity.IsSample != 2)
  5159. {
  5160. returnErrorMsg("补差价单才能标记为已发货");
  5161. return;
  5162. }
  5163. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5164. entity.OrderState = 7;
  5165. entity.Update();
  5166. returnSuccessMsg("操作成功!");
  5167. return;
  5168. }
  5169. returnErrorMsg("找不到记录");
  5170. }
  5171. }
  5172. public void get_stdtemplates()
  5173. {
  5174. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5175. //string res = taobaoHelper.test();
  5176. string res = apiHelper.API_PrintTemplate();
  5177. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5178. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5179. {
  5180. int sidx = res.IndexOf("error_code");
  5181. int eidx = res.IndexOf("success");
  5182. string msg = res.Substring(sidx, eidx - sidx);
  5183. returnErrorMsg(msg);
  5184. return;
  5185. }
  5186. if (res.Length <= 0)
  5187. {
  5188. returnErrorMsg("模板数据为空!");
  5189. return;
  5190. }
  5191. ReturnSuccess(res);
  5192. }
  5193. public void cancel_print_order()
  5194. {
  5195. if (UrlPostParmsCheck("ctid"))
  5196. {
  5197. string ctid = GetPostString("ctid");
  5198. CeErpTradeCell entity = null;
  5199. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5200. if (entity != null)
  5201. {
  5202. string res = "";
  5203. string code = entity.LastBillWaybillCode;
  5204. if (code == "")
  5205. {
  5206. code = entity.OutSid;
  5207. }
  5208. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5209. XLog.SaveLog(0, "取消面单" + res);
  5210. }
  5211. }
  5212. }
  5213. public void set_erp_printwaybill()
  5214. {
  5215. if (UrlPostParmsCheck("ctid"))
  5216. {
  5217. string ctid = GetPostString("ctid");
  5218. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5219. string cpName = GetPostString("cpname");
  5220. string isTogether = GetPostString("together");
  5221. //var res_obj = new
  5222. //{
  5223. // restype = 1,
  5224. // 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\"}"
  5225. //};
  5226. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5227. //ReturnSuccess(ro_json);
  5228. //return;
  5229. bool isUseLastWayBillCode = false;
  5230. CeErpTradeCell entity = null;
  5231. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5232. if (entity != null)
  5233. {
  5234. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5235. {
  5236. isUseLastWayBillCode = true;
  5237. }
  5238. if (entity.OrderState == 7 && "2".Equals(isTogether))
  5239. {
  5240. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5241. return;
  5242. }
  5243. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5244. {
  5245. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5246. return;
  5247. }
  5248. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5249. {
  5250. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5251. return;
  5252. }
  5253. }
  5254. string res = "";
  5255. Api_waybill_code_response_Obj fullObj = null;
  5256. string pData_str = "";
  5257. string curUseWayBillCode = "";
  5258. if (isUseLastWayBillCode == false)
  5259. {
  5260. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5261. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5262. if (res.IndexOf("failure") != -1)
  5263. {
  5264. //int idx = res.IndexOf("sub_message");
  5265. //int idx2 = res.IndexOf("flag");
  5266. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5267. string errMsgNeed = commonHelper.KeepChinese(res);
  5268. var res_objd = new
  5269. {
  5270. restype = 0,
  5271. data = "获取面单失败" + errMsgNeed
  5272. };
  5273. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5274. returnSuccess(ro_jsond);
  5275. if (res.IndexOf("停发") != -1)
  5276. {
  5277. entity.UnusualCon = "物流停发";
  5278. entity.Update();
  5279. }
  5280. //returnErrorMsg("获取面单失败,"+emsg);
  5281. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5282. return;
  5283. }
  5284. else if (res.IndexOf("errorMsg") != -1)
  5285. {
  5286. //int idx = res.IndexOf("errorMsg");
  5287. //int idx2 = res.IndexOf("}]}");
  5288. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5289. string errMsgNeed = commonHelper.KeepChinese(res);
  5290. var res_objf = new
  5291. {
  5292. restype = 0,
  5293. data = "获取面单失败2" + errMsgNeed
  5294. };
  5295. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5296. if (res.IndexOf("停发") != -1)
  5297. {
  5298. entity.UnusualCon = "物流停发";
  5299. entity.Update();
  5300. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5301. if (trade != null)
  5302. {
  5303. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5304. }
  5305. }
  5306. returnSuccess(ro_jsonf);
  5307. //returnErrorMsg("获取面单失败," + emsg);
  5308. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5309. return;
  5310. }
  5311. try
  5312. {
  5313. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5314. //res = res.Replace(" ", "");
  5315. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5316. }
  5317. catch (Exception ex)
  5318. {
  5319. XLog.SaveLog(0, "生成fullObj" + res);
  5320. var res_objf = new
  5321. {
  5322. restype = 0,
  5323. data = "生成fullObj发生错误" + ex.Message
  5324. };
  5325. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5326. returnSuccess(ro_jsonf);
  5327. return;
  5328. }
  5329. if (fullObj.response.data.content.Count > 0)
  5330. {
  5331. ContentItem codeObj = fullObj.response.data.content[0];
  5332. if (cpCode.IndexOf("SFFQ-") != -1)
  5333. {
  5334. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5335. }
  5336. else
  5337. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5338. curUseWayBillCode = codeObj.waybillCode;
  5339. }
  5340. else
  5341. {
  5342. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5343. var res_objf = new
  5344. {
  5345. restype = 0,
  5346. data = "生成fullObj找不到快递单号waybillCode"
  5347. };
  5348. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5349. returnSuccess(ro_jsonf);
  5350. return;
  5351. }
  5352. }
  5353. else
  5354. {
  5355. //使用上次打印的快递单号
  5356. if (cpCode == "SFFQ-LY")
  5357. {
  5358. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5359. }
  5360. else
  5361. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5362. curUseWayBillCode = entity.LastBillWaybillCode;
  5363. }
  5364. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5365. {
  5366. var res_obje = new
  5367. {
  5368. restype = 0,
  5369. data = "获取加密打印数据失败"
  5370. };
  5371. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5372. returnSuccess(ro_jsone);
  5373. entity.LastBillCpCode = cpCode;
  5374. entity.LastBillWaybillCode = curUseWayBillCode;
  5375. entity.Update();
  5376. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5377. //returnErrorMsg("获取加密打印数据失败");
  5378. return;
  5379. }
  5380. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5381. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5382. string btnType = "";
  5383. string errorMsg = "";
  5384. if (entity != null)
  5385. {
  5386. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5387. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5388. //cpcode是 YTO-CAINIAO
  5389. //string comCode = cpCode.Split('-')[0].ToString();
  5390. string apires = "";
  5391. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5392. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5393. {
  5394. if (ctid.IndexOf("N") != -1)
  5395. {
  5396. apires = "发货成功";
  5397. }
  5398. else
  5399. {
  5400. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5401. }
  5402. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5403. //打单后发货
  5404. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5405. {
  5406. try
  5407. {
  5408. btnType = "待发货";
  5409. entity.OutSid = curUseWayBillCode;
  5410. entity.OrderState = 7;
  5411. entity.IsUrgency = false;
  5412. entity.LastBillCpCode = "";
  5413. entity.LastBillWaybillCode = "";
  5414. entity.FinishDeliveryTime = DateTime.Now;
  5415. entity.IsReturn = 0;
  5416. entity.MemoOpt = 0;
  5417. entity.UpdateTime = DateTime.Now;
  5418. entity.Update();
  5419. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5420. //还要插入快递信息到 快递信息表
  5421. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5422. exinfo.tid = entity.ctid;
  5423. exinfo.out_sid = curUseWayBillCode;
  5424. exinfo.company_code = cpCode;
  5425. exinfo.company_name = cpName;
  5426. exinfo.supplierUserName = supplierName;
  5427. exinfo.deliveryType = "发货成功";
  5428. exinfo.print_time = DateTime.Now;
  5429. exinfo.printUser = CurrentUser.UserName;
  5430. exinfo.postData = pData_str;
  5431. exinfo.Create();
  5432. commonHelper.UpdateRelationOrder(entity.ctid);
  5433. CeErpSukuraData.createInfo(ctid, 4);
  5434. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5435. if (entity.SupplierId == 64)
  5436. {
  5437. commonHelper.sendCytExpress(exinfo);
  5438. }
  5439. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5440. if (!string.IsNullOrEmpty(isTogether))
  5441. {
  5442. if (Convert.ToInt32(isTogether) > 0)
  5443. {
  5444. StringBuilder sqlsb = new StringBuilder();
  5445. 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);
  5446. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5447. }
  5448. }
  5449. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5450. }
  5451. catch (Exception ex)
  5452. {
  5453. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5454. }
  5455. }
  5456. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5457. {
  5458. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5459. if (entity.OrderState == 6)
  5460. {
  5461. entity.OrderState = 7;
  5462. }
  5463. entity.UpdateTime = DateTime.Now;
  5464. entity.FinishDeliveryTime = DateTime.Now;
  5465. btnType = "已发货";
  5466. entity.Update();
  5467. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5468. exinfo.tid = entity.ctid;
  5469. exinfo.out_sid = curUseWayBillCode;
  5470. exinfo.company_code = cpCode;
  5471. exinfo.company_name = cpName;
  5472. exinfo.supplierUserName = supplierName;
  5473. exinfo.deliveryType = "发货成功";
  5474. exinfo.print_time = DateTime.Now;
  5475. exinfo.printUser = CurrentUser.UserName;
  5476. exinfo.postData = pData_str;
  5477. exinfo.Create();
  5478. commonHelper.UpdateRelationOrder(entity.ctid);
  5479. CeErpSukuraData.createInfo(entity.ctid, 4);
  5480. if (entity.SupplierId == 64)
  5481. {
  5482. commonHelper.sendCytExpress(exinfo);
  5483. }
  5484. if (!string.IsNullOrEmpty(isTogether))
  5485. {
  5486. if (Convert.ToInt32(isTogether) > 0)
  5487. {
  5488. StringBuilder sqlsb = new StringBuilder();
  5489. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}',FinishDeliveryTime=GETDATE(),UpdateTime=GETDATE() where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5490. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5491. }
  5492. }
  5493. //不处理
  5494. }
  5495. else
  5496. {
  5497. entity.UpdateTime = DateTime.Now;
  5498. entity.LastBillCpCode = cpCode;
  5499. entity.LastBillWaybillCode = curUseWayBillCode;
  5500. entity.Update();
  5501. string errmsg = commonHelper.KeepChinese(apires);
  5502. var res_objz = new
  5503. {
  5504. restype = 0,
  5505. data = "打单后发货失败"
  5506. };
  5507. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5508. returnSuccess(ro_jsonz);
  5509. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5510. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5511. return;
  5512. }
  5513. }
  5514. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5515. {
  5516. StringBuilder allSql = new StringBuilder();
  5517. allSql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,tid from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  5518. if (string.IsNullOrEmpty(mainEn.receiverId))
  5519. {
  5520. allSql.AppendFormat(" and (tid='{0}');", entity.tid);
  5521. }
  5522. else
  5523. {
  5524. //查询同车间同状态下的收货地址相同的单子
  5525. allSql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}') );", entity.tid, mainEn.receiverId, entity.IsSF);
  5526. }
  5527. DataTable dt = DbHelper.DbConn.ExecuteDataset(allSql.ToString()).Tables[0];
  5528. List<string> list = new List<string>();
  5529. List<string> send_list = new List<string>();
  5530. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5531. CeErpTrade ceErpTrade = new CeErpTrade();
  5532. foreach (DataRow row in dt.Rows)
  5533. {
  5534. list.Add("'" + row["ctid"] + "'");
  5535. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5536. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5537. if (ctid.IndexOf("N") != -1)
  5538. {
  5539. apires = "发货成功";
  5540. }
  5541. else
  5542. {
  5543. if (!send_list.Contains(ceErpTrade.tid))
  5544. {
  5545. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5546. }
  5547. else
  5548. {
  5549. apires = "发货成功";
  5550. }
  5551. }
  5552. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5553. {
  5554. send_list.Add(ceErpTrade.tid);
  5555. try
  5556. {
  5557. btnType = "待发货";
  5558. ceErpTradeCell.OutSid = curUseWayBillCode;
  5559. ceErpTradeCell.OrderState = 7;
  5560. ceErpTradeCell.IsUrgency = false;
  5561. ceErpTradeCell.LastBillCpCode = "";
  5562. ceErpTradeCell.LastBillWaybillCode = "";
  5563. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5564. ceErpTradeCell.IsReturn = 0;
  5565. ceErpTradeCell.MemoOpt = 0;
  5566. ceErpTradeCell.UpdateTime = DateTime.Now;
  5567. ceErpTradeCell.Update();
  5568. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5569. //还要插入快递信息到 快递信息表
  5570. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5571. exinfo.tid = ceErpTradeCell.ctid;
  5572. exinfo.out_sid = curUseWayBillCode;
  5573. exinfo.company_code = cpCode;
  5574. exinfo.company_name = cpName;
  5575. exinfo.supplierUserName = supplierName;
  5576. exinfo.deliveryType = "发货成功";
  5577. exinfo.print_time = DateTime.Now;
  5578. exinfo.printUser = CurrentUser.UserName;
  5579. exinfo.postData = pData_str;
  5580. exinfo.Create();
  5581. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5582. CeErpSukuraData.createInfo(ctid, 4);
  5583. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5584. if (ceErpTradeCell.SupplierId == 64)
  5585. {
  5586. commonHelper.sendCytExpress(exinfo);
  5587. }
  5588. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5589. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5590. }
  5591. catch (Exception ex)
  5592. {
  5593. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5594. }
  5595. }
  5596. else
  5597. {
  5598. ceErpTradeCell.UpdateTime = DateTime.Now;
  5599. ceErpTradeCell.LastBillCpCode = cpCode;
  5600. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5601. ceErpTradeCell.Update();
  5602. string errmsg = commonHelper.KeepChinese(apires);
  5603. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5604. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5605. }
  5606. }
  5607. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5608. }
  5609. }
  5610. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5611. var res_obj = new
  5612. {
  5613. restype = 1,
  5614. data = pData_str,
  5615. errorMsg
  5616. };
  5617. string ro_json = JsonConvert.SerializeObject(res_obj);
  5618. ReturnSuccess(ro_json);
  5619. return;
  5620. }
  5621. }
  5622. private string GetUTF8String(byte[] vs)
  5623. {
  5624. throw new NotImplementedException();
  5625. }
  5626. public void set_erp_printwaybill_cn()
  5627. {
  5628. if (UrlPostParmsCheck("ctid"))
  5629. {
  5630. string ctid = GetPostString("ctid");
  5631. string cpCode = GetPostString("cpcode");
  5632. string cpName = GetPostString("cpname");
  5633. string tempUrl = GetPostString("tempurl");
  5634. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5635. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5636. //string res = taobaoHelper.test();
  5637. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5638. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5639. {
  5640. int sidx = res.IndexOf("errorMsg");
  5641. int eidx = res.IndexOf("}");
  5642. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5643. var res_objzxx = new
  5644. {
  5645. restype = 0,
  5646. data = msg
  5647. };
  5648. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5649. returnSuccess(ro_jsonzxx);
  5650. //returnErrorMsg(msg);
  5651. return;
  5652. }
  5653. int idx = res.IndexOf("waybillCode");
  5654. int idx2 = res.IndexOf("printData");
  5655. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5656. string eid = GetPostString("ctid");
  5657. CeErpTradeCell entity = null;
  5658. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5659. if (entity != null)
  5660. {
  5661. string osid = entity.OutSid;
  5662. entity.OutSid = osid + "," + outsid;
  5663. entity.FinishDeliveryTime = DateTime.Now;
  5664. entity.OrderState = 7;
  5665. entity.UpdateTime = DateTime.Now;
  5666. entity.IsReturn = 0;
  5667. entity.Update();
  5668. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5669. exinfo.tid = entity.ctid;
  5670. exinfo.out_sid = outsid;
  5671. exinfo.company_code = cpCode;
  5672. exinfo.company_name = cpName;
  5673. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5674. exinfo.deliveryType = "发货成功";
  5675. exinfo.print_time = DateTime.Now;
  5676. exinfo.printUser = CurrentUser.UserName;
  5677. exinfo.Create();
  5678. if (entity.SupplierId == 64)
  5679. {
  5680. commonHelper.sendCytExpress(exinfo);
  5681. }
  5682. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5683. }
  5684. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5685. var res_objz = new
  5686. {
  5687. restype = 1,
  5688. data = res
  5689. };
  5690. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5691. returnSuccess(ro_jsonz);
  5692. //ReturnSuccess(res);
  5693. }
  5694. }
  5695. ////打单,打印面单 获取面单号
  5696. //public void set_erp_printwaybill()
  5697. //{
  5698. // if (UrlPostParmsCheck("ctid"))
  5699. // {
  5700. // string ctid = GetPostString("ctid");
  5701. // string cpCode = GetPostString("cpcode");
  5702. // string tempUrl = GetPostString("tempurl");
  5703. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5704. // //string res = taobaoHelper.test();
  5705. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5706. // if (res.IndexOf("error_response") != -1)
  5707. // {
  5708. // int sidx = res.IndexOf("sub_msg");
  5709. // int eidx = res.IndexOf("request_id");
  5710. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5711. // returnErrorMsg(msg);
  5712. // return;
  5713. // }
  5714. // int idx = res.IndexOf("waybill_code");
  5715. // int idx2 = res.IndexOf("}]}");
  5716. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5717. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5718. // ReturnSuccess(res);
  5719. // }
  5720. //}
  5721. public void cancel_erp_aftersale()
  5722. {
  5723. if (UrlPostParmsCheck("ctid"))
  5724. {
  5725. string eid = GetPostString("ctid");
  5726. CeErpTradeCell entity = null;
  5727. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5728. if (entity != null)
  5729. {
  5730. //有过处理的售后,取消也不能删除 售 字,保留
  5731. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5732. {
  5733. entity.AfterSaleState = 4;
  5734. }
  5735. else
  5736. entity.AfterSaleState = 0;
  5737. entity.UpdateTime = DateTime.Now;
  5738. entity.Update();
  5739. returnSuccessMsg("操作成功!");
  5740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5741. return;
  5742. }
  5743. returnErrorMsg("找不到订单记录");
  5744. }
  5745. }
  5746. public void get_erp_aftersalelist()
  5747. {
  5748. DataStruct dStruct = GetPostStruct();
  5749. List<string> lw = new List<string>();
  5750. int st = GetInt("st");
  5751. string tid = GetPostString("ctid");
  5752. if (st == 3)
  5753. {
  5754. if (tid.Length > 0)
  5755. {
  5756. string select_tid = getTidByCtid(tid);
  5757. lw.Add(string.Format("tid='{0}'", select_tid));
  5758. }
  5759. }
  5760. else
  5761. {
  5762. if (tid.Length > 0)
  5763. {
  5764. string select_tid = getTidByCtid(tid);
  5765. lw.Add(string.Format("tid='{0}'", select_tid));
  5766. }
  5767. }
  5768. string shopname = GetPostString("shopname");
  5769. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5770. string buyernick = GetPostString("buyer_nick");
  5771. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5772. string sellermemo = GetPostString("seller_memo");
  5773. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5774. string orderState = GetPostString("orderState");
  5775. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5776. string afterState = GetPostString("afterstate");
  5777. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5778. string date1 = GetPostString("date1");
  5779. string date2 = GetPostString("date2");
  5780. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5781. if (dw.Length > 0) lw.Add(dw);
  5782. string price1 = GetPostString("price1");
  5783. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5784. string price2 = GetPostString("price2");
  5785. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5786. //lw.Add(string.Format("IsRefund!={0}", 1));
  5787. string reason = GetPostString("reason");
  5788. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5789. string method = GetPostString("method");
  5790. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5791. string handler = GetPostString("handler");
  5792. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5793. string handledate1 = GetPostString("handledate1");
  5794. string handledate2 = GetPostString("handledate2");
  5795. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5796. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5797. string finish1 = GetPostString("finishdate1");
  5798. string finish2 = GetPostString("finishdate2");
  5799. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5800. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5801. string afterdate1 = GetPostString("afterdate1");
  5802. string afterdate2 = GetPostString("afterdate2");
  5803. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5804. if (afterDate.Length > 0) lw.Add(afterDate);
  5805. string supplier = GetPostString("supplier");
  5806. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5807. string responsible = GetPostString("responsibleman");
  5808. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5809. string customer = GetPostString("customer");
  5810. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5811. string design = GetPostString("design");
  5812. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5813. string afterMemoType = GetPostString("aftermemotype");
  5814. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5815. string posCode = CurrentUser.UserPost.Post.Code;
  5816. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5817. //{
  5818. // string vstate = GetPostString("vstate");
  5819. // if (vstate.Length > 0)
  5820. // {
  5821. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5822. // }
  5823. // if (posCode == "Supplier")
  5824. // {
  5825. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5826. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5827. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5828. // }
  5829. // else
  5830. // {
  5831. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5832. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5833. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5834. // {
  5835. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5836. // }
  5837. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5838. // {
  5839. // int orgid = CurrentUser.UserPost.OrgID;
  5840. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5841. // }
  5842. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5843. // {
  5844. // string shopid = CurrentUser.User.pemShop;
  5845. // lw.Add(string.Format("shopId in ({0})", shopid));
  5846. // }
  5847. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5848. // //{
  5849. // // int org_id = CurrentUser.UserPost.OrgID;
  5850. // // lw.Add(string.Format("OrgID={0}", org_id));
  5851. // //}
  5852. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5853. // }
  5854. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5855. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5856. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5857. //}
  5858. if (st == 5)
  5859. {
  5860. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5861. {
  5862. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5863. {
  5864. string shopid = CurrentUser.User.pemShop;
  5865. lw.Add(string.Format("shopId in ({0})", shopid));
  5866. }
  5867. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5868. {
  5869. int mrOrgid = CurrentUser.UserPost.OrgID;
  5870. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5871. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5872. }
  5873. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5874. //{
  5875. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5876. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5877. //}
  5878. else
  5879. {
  5880. string userIdStr = "";
  5881. if (posCode == "CustomerService")
  5882. {
  5883. userIdStr = CurrentUser.UserID + "_k";
  5884. }
  5885. else if (posCode == "Designer" || posCode == "wxDesigner")
  5886. {
  5887. userIdStr = CurrentUser.UserID + "_s";
  5888. }
  5889. else if (posCode == "Place")
  5890. {
  5891. userIdStr = CurrentUser.UserID + "_x";
  5892. }
  5893. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5894. }
  5895. }
  5896. string placedate1 = GetPostString("placedate1");
  5897. string placedate2 = GetPostString("placedate2");
  5898. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5899. if (dwplace.Length > 0) lw.Add(dwplace);
  5900. string supState = GetPostString("supState");
  5901. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5902. string searchType = GetPostString("searchType");
  5903. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5904. {
  5905. lw.Add(string.Format("BackNum>1"));
  5906. }
  5907. lw.Add(string.Format("AfterSaleState>0"));
  5908. if (ex_psize > 0)
  5909. {
  5910. if (CurrentUser.UserPost.Post.Code == "Finance")
  5911. dStruct.Order = "pay_time desc";
  5912. else
  5913. dStruct.Order = "HandleTime desc";
  5914. }
  5915. else
  5916. dStruct.Order = "HandleTime desc";
  5917. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5918. DataTable dt = WebCache.GetData("view_test", dStruct);
  5919. writeGridDataTableJson(dStruct.TotalCount, dt);
  5920. }
  5921. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5922. //{
  5923. // lw.Add(string.Format("AfterSaleState=4"));
  5924. // string code = CurrentUser.UserPost.Post.Code;
  5925. // if (code == "CustomerService")
  5926. // {
  5927. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5928. // }
  5929. // else if (code == "Designer" || code == "DesignerMr")
  5930. // {
  5931. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5932. // }
  5933. // else if (code == "Place" || code == "PlaceMr")
  5934. // {
  5935. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5936. // }
  5937. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5938. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5939. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5940. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5941. //}
  5942. //else //处理中的售后,待处理和处理中合并
  5943. //{
  5944. // if (afterState.Length <= 0)
  5945. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5946. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5947. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5948. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5949. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5950. //}
  5951. }
  5952. public void get_erp_disagreeftersalelist()
  5953. {
  5954. DataStruct dStruct = GetPostStruct();
  5955. List<string> lw = new List<string>();
  5956. int st = 2;
  5957. string tid = GetPostString("ctid");
  5958. if (tid.Length > 0)
  5959. {
  5960. string select_tid = getTidByCtid(tid);
  5961. lw.Add(string.Format("tid='{0}'", select_tid));
  5962. }
  5963. string shopname = GetPostString("shopname");
  5964. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5965. string buyernick = GetPostString("buyer_nick");
  5966. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5967. string sellermemo = GetPostString("seller_memo");
  5968. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5969. string orderState = GetPostString("orderState");
  5970. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5971. string afterState = GetPostString("afterstate");
  5972. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5973. string date1 = GetPostString("date1");
  5974. string date2 = GetPostString("date2");
  5975. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5976. if (dw.Length > 0) lw.Add(dw);
  5977. string price1 = GetPostString("price1");
  5978. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5979. string price2 = GetPostString("price2");
  5980. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5981. //lw.Add(string.Format("IsRefund!={0}", 1));
  5982. string reason = GetPostString("reason");
  5983. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5984. string method = GetPostString("method");
  5985. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5986. string handler = GetPostString("handler");
  5987. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5988. string handledate1 = GetPostString("handledate1");
  5989. string handledate2 = GetPostString("handledate2");
  5990. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5991. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5992. string afterdate1 = GetPostString("afterdate1");
  5993. string afterdate2 = GetPostString("afterdate2");
  5994. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5995. if (afterDate.Length > 0) lw.Add(afterDate);
  5996. string backdate1 = GetPostString("backdate1");
  5997. string backdate2 = GetPostString("backdate2");
  5998. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5999. if (backDate.Length > 0) lw.Add(backDate);
  6000. string supplier = GetPostString("supplier");
  6001. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6002. string responsible = GetPostString("responsibleman");
  6003. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6004. string customer = GetPostString("customer");
  6005. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6006. string design = GetPostString("design");
  6007. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6008. string afterSaleMemo = GetPostString("afterSaleMemo");
  6009. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6010. string afterMemoType = GetPostString("aftermemotype");
  6011. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6012. string aftersakereason = GetPostString("aftersakereason");
  6013. if (aftersakereason.Length > 0)
  6014. {
  6015. if (aftersakereason == "1")
  6016. {
  6017. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6018. }
  6019. if (aftersakereason == "2")
  6020. {
  6021. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6022. }
  6023. }
  6024. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6025. string poscode = CurrentUser.UserPost.Post.Code;
  6026. if (poscode != "SysAdmin")
  6027. {
  6028. string shopid = CurrentUser.User.pemShop;
  6029. lw.Add(string.Format("shopId in ({0})", shopid));
  6030. }
  6031. string searchType = GetPostString("searchType");
  6032. if (searchType == "wait")
  6033. {
  6034. lw.Add(string.Format("HandleTime is null"));
  6035. }
  6036. if (searchType == "handling")
  6037. {
  6038. lw.Add(string.Format("HandleTime is not null "));
  6039. }
  6040. if (searchType == "back" || searchType == "puBack")
  6041. {
  6042. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6043. }
  6044. if (searchType == "reBack")
  6045. {
  6046. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6047. }
  6048. if (searchType == "moreBack")
  6049. {
  6050. lw.Add(string.Format("backNum > 1"));
  6051. }
  6052. lw.Add(string.Format("(AfterSaleState=5)"));
  6053. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6054. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6055. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6056. writeGridDataTableJson(dStruct.TotalCount, dt);
  6057. }
  6058. public void get_erp_handlingaftersalelist()
  6059. {
  6060. DataStruct dStruct = GetPostStruct();
  6061. List<string> lw = new List<string>();
  6062. int st = 2;
  6063. string tid = GetPostString("ctid");
  6064. if (tid.Length > 0)
  6065. {
  6066. string select_tid = getTidByCtid(tid);
  6067. lw.Add(string.Format("tid='{0}'", select_tid));
  6068. }
  6069. string shopname = GetPostString("shopname");
  6070. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6071. string buyernick = GetPostString("buyer_nick");
  6072. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6073. string sellermemo = GetPostString("seller_memo");
  6074. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6075. string orderState = GetPostString("orderState");
  6076. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6077. string afterState = GetPostString("afterstate");
  6078. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6079. string date1 = GetPostString("date1");
  6080. string date2 = GetPostString("date2");
  6081. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6082. if (dw.Length > 0) lw.Add(dw);
  6083. string price1 = GetPostString("price1");
  6084. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6085. string price2 = GetPostString("price2");
  6086. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6087. //lw.Add(string.Format("IsRefund!={0}", 1));
  6088. string reason = GetPostString("reason");
  6089. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6090. string method = GetPostString("method");
  6091. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6092. string handler = GetPostString("handler");
  6093. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6094. string handledate1 = GetPostString("handledate1");
  6095. string handledate2 = GetPostString("handledate2");
  6096. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6097. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6098. string afterdate1 = GetPostString("afterdate1");
  6099. string afterdate2 = GetPostString("afterdate2");
  6100. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6101. if (afterDate.Length > 0) lw.Add(afterDate);
  6102. string supplier = GetPostString("supplier");
  6103. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6104. string responsible = GetPostString("responsibleman");
  6105. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6106. string customer = GetPostString("customer");
  6107. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6108. string design = GetPostString("design");
  6109. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6110. string afterSaleMemo = GetPostString("afterSaleMemo");
  6111. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6112. string afterMemoType = GetPostString("aftermemotype");
  6113. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6114. string afterresult = GetPostString("afterresult");
  6115. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6116. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6117. string poscode = CurrentUser.UserPost.Post.Code;
  6118. if (poscode != "SysAdmin")
  6119. {
  6120. string shopid = CurrentUser.User.pemShop;
  6121. lw.Add(string.Format("shopId in ({0})", shopid));
  6122. }
  6123. string searchType = GetPostString("searchType");
  6124. if (searchType == "wait")
  6125. {
  6126. lw.Add(string.Format("HandleTime is null"));
  6127. }
  6128. if (searchType == "documentary")
  6129. {
  6130. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6131. }
  6132. if (searchType == "handling")
  6133. {
  6134. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6135. }
  6136. if (searchType == "back" || searchType == "puBack")
  6137. {
  6138. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6139. }
  6140. if (searchType == "reBack")
  6141. {
  6142. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6143. }
  6144. if (afterState.Length <= 0)
  6145. {
  6146. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6147. }
  6148. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6149. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6150. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6151. writeGridDataTableJson(dStruct.TotalCount, dt);
  6152. }
  6153. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6154. //public void get_erp_back_handlingaftersalelist()
  6155. //{
  6156. // DataStruct dStruct = GetPostStruct();
  6157. // List<string> lw = new List<string>();
  6158. // string tid = GetPostString("ctid");
  6159. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6160. // string shopname = GetPostString("shopname");
  6161. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6162. // string buyernick = GetPostString("buyer_nick");
  6163. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6164. // string sellermemo = GetPostString("seller_memo");
  6165. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6166. // string orderState = GetPostString("orderState");
  6167. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6168. // string afterState = GetPostString("afterstate");
  6169. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6170. // string date1 = GetPostString("date1");
  6171. // string date2 = GetPostString("date2");
  6172. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6173. // if (dw.Length > 0) lw.Add(dw);
  6174. // string price1 = GetPostString("price1");
  6175. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6176. // string price2 = GetPostString("price2");
  6177. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6178. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6179. // string reason = GetPostString("reason");
  6180. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6181. // string method = GetPostString("method");
  6182. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6183. // string handler = GetPostString("handler");
  6184. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6185. // string handledate1 = GetPostString("handledate1");
  6186. // string handledate2 = GetPostString("handledate2");
  6187. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6188. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6189. // string afterdate1 = GetPostString("afterdate1");
  6190. // string afterdate2 = GetPostString("afterdate2");
  6191. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6192. // if (afterDate.Length > 0) lw.Add(afterDate);
  6193. // string supplier = GetPostString("supplier");
  6194. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6195. // string responsible = GetPostString("responsibleman");
  6196. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6197. // string customer = GetPostString("customer");
  6198. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6199. // string design = GetPostString("design");
  6200. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6201. // string afterMemoType = GetPostString("aftermemotype");
  6202. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6203. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6204. // if (afterState.Length <= 0)
  6205. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6206. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6207. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6208. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6209. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6210. //}
  6211. public void get_erp_aftersaleverifylist()
  6212. {
  6213. DataStruct dStruct = GetPostStruct();
  6214. List<string> lw = new List<string>();
  6215. string tid = GetPostString("ctid");
  6216. if (tid.Length > 0)
  6217. {
  6218. string select_tid = getTidByCtid(tid);
  6219. lw.Add(string.Format("tid='{0}'", select_tid));
  6220. }
  6221. string shopname = GetPostString("shopname");
  6222. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6223. string buyernick = GetPostString("buyer_nick");
  6224. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6225. string sellermemo = GetPostString("seller_memo");
  6226. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6227. string orderState = GetPostString("orderState");
  6228. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6229. //lw.Add(string.Format("IsRefund!={0}", 1));
  6230. string reason = GetPostString("reason");
  6231. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6232. string method = GetPostString("method");
  6233. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6234. string handler = GetPostString("handler");
  6235. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6236. string handledate1 = GetPostString("handledate1");
  6237. string handledate2 = GetPostString("handledate2");
  6238. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6239. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6240. string finish1 = GetPostString("finishdate1");
  6241. string finish2 = GetPostString("finishdate2");
  6242. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6243. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6244. string supplier = GetPostString("supplier");
  6245. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6246. string responsible = GetPostString("responsibleman");
  6247. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6248. string posCode = CurrentUser.UserPost.Post.Code;
  6249. string vstate = GetPostString("vstate");
  6250. if (vstate.Length > 0)
  6251. {
  6252. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6253. }
  6254. if (posCode == "Supplier")
  6255. {
  6256. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6257. lw.Add(string.Format("VerifyState = 0"));
  6258. lw.Add("type = 1");
  6259. lw.Add(string.Format("AfterSaleState={0}", 3));
  6260. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6261. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6262. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6263. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6264. writeGridDataTableJson(dStruct.TotalCount, dt);
  6265. }
  6266. else if (posCode == "logistics")
  6267. {
  6268. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6269. lw.Add(string.Format("VerifyState = 0"));
  6270. lw.Add("type = 2");
  6271. lw.Add(string.Format("AfterSaleState={0}", 3));
  6272. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6273. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6274. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6275. writeGridDataTableJson(dStruct.TotalCount, dt);
  6276. }
  6277. else
  6278. {
  6279. lw.Add(string.Format("(AfterSaleState = 3)"));
  6280. string reasonState = GetPostString("reasonState");
  6281. lw.Add("type = 0");
  6282. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6283. || posCode == "Summarize" || posCode == "Finance")
  6284. {
  6285. if (reasonState == "2")
  6286. {
  6287. lw.Add("VerifyState = 3");
  6288. }
  6289. else if (reasonState == "1")
  6290. {
  6291. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6292. }
  6293. else
  6294. {
  6295. lw.Add("VerifyState in (0,3)");
  6296. }
  6297. //不加条件,可以看全部
  6298. }
  6299. 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")
  6300. {
  6301. int orgid = CurrentUser.UserPost.OrgID;
  6302. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6303. if (string.IsNullOrEmpty(manageOrgId))
  6304. {
  6305. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6306. }
  6307. else
  6308. {
  6309. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6310. }
  6311. if (reasonState == "1")
  6312. {
  6313. lw.Add("VerifyState = 3");
  6314. }
  6315. else if (reasonState == "2")
  6316. {
  6317. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6318. }
  6319. else
  6320. {
  6321. }
  6322. }
  6323. else
  6324. {
  6325. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6326. }
  6327. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6328. //{
  6329. // int org_id = CurrentUser.UserPost.OrgID;
  6330. // lw.Add(string.Format("OrgID={0}", org_id));
  6331. //}
  6332. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6333. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6334. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6335. writeGridDataTableJson(dStruct.TotalCount, dt);
  6336. }
  6337. }
  6338. public void get_erp_finishaftersalelist()
  6339. {
  6340. DataStruct dStruct = GetPostStruct();
  6341. List<string> lw = new List<string>();
  6342. int st = 4;
  6343. string tid = GetPostString("ctid");
  6344. if (tid.Length > 0)
  6345. {
  6346. string select_tid = getTidByCtid(tid);
  6347. lw.Add(string.Format("tid='{0}'", select_tid));
  6348. }
  6349. string shopname = GetPostString("shopname");
  6350. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6351. //lw.Add(string.Format("IsRefund!={0}", 1));
  6352. string reason = GetPostString("reason");
  6353. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6354. string method = GetPostString("method");
  6355. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6356. string buyernick = GetPostString("buyer_nick");
  6357. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6358. string handler = GetPostString("handler");
  6359. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6360. string handledate1 = GetPostString("handledate1");
  6361. string handledate2 = GetPostString("handledate2");
  6362. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6363. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6364. string finish1 = GetPostString("finishdate1");
  6365. string finish2 = GetPostString("finishdate2");
  6366. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6367. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6368. string supplier = GetPostString("supplier");
  6369. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6370. string responsible = GetPostString("responsibleman");
  6371. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6372. string vstate = GetPostString("vstate");
  6373. if (vstate.Length > 0)
  6374. {
  6375. if ("3".Equals(vstate))
  6376. {
  6377. lw.Add(string.Format("IsTem=1"));
  6378. }
  6379. else
  6380. {
  6381. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6382. }
  6383. }
  6384. lw.Add(string.Format("AfterSaleState=4"));
  6385. string code = CurrentUser.UserPost.Post.Code;
  6386. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6387. {
  6388. //不加条件,可以看全部
  6389. }
  6390. else if (code == "Supplier")
  6391. {
  6392. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6393. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6394. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6395. }
  6396. else if (code == "logistics")
  6397. {
  6398. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6399. lw.Add("type = 2");
  6400. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6401. }
  6402. 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")
  6403. {
  6404. int orgid = CurrentUser.UserPost.OrgID;
  6405. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6406. if (string.IsNullOrEmpty(manageOrgIds))
  6407. {
  6408. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6409. }
  6410. else
  6411. {
  6412. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6413. }
  6414. }
  6415. else
  6416. {
  6417. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6418. }
  6419. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6420. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6421. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6422. writeGridDataTableJson(dStruct.TotalCount, dt);
  6423. }
  6424. public void handle_erp_aftersale()
  6425. {
  6426. if (UrlPostParmsCheck("ctid"))
  6427. {
  6428. string eid = GetPostString("ctid");
  6429. string responStr = GetPostString("AfterSaleResponsible");
  6430. if (responStr.Length <= 0)
  6431. {
  6432. returnErrorMsg("售后责任人不能为空");
  6433. return;
  6434. }
  6435. bool isDesign = false;
  6436. double designFree = 0.00;
  6437. int responsibleId = 0;
  6438. CeErpTradeCell entity = null;
  6439. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6440. if (entity != null)
  6441. {
  6442. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6443. string afterMethod = GetPostString("AfterSaleMethod");
  6444. if (isNeedNewOrder == 1)
  6445. {
  6446. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6447. bool ishav = true;
  6448. if (newentity == null)
  6449. {
  6450. newentity = entity.Clone() as CeErpTradeCell;
  6451. ishav = false;
  6452. newentity.ctid = "S_" + entity.ctid;
  6453. newentity.OrderState = 0;
  6454. //唯一标识
  6455. newentity.OrderSn = newentity.ctid;
  6456. string orderSn = dataHelper.getSaleOrderSn();
  6457. if (orderSn != "")
  6458. {
  6459. newentity.OrderSn = orderSn;
  6460. }
  6461. }
  6462. newentity.UpdateTime = DateTime.Now;
  6463. newentity.AfterSaleState = 0;
  6464. newentity.AfterSaleMethod = afterMethod;
  6465. if (!ishav)
  6466. {
  6467. string memo_str = newentity.seller_memo;
  6468. memo_str = memo_str.Replace("(", "(");
  6469. memo_str = memo_str.Replace(")", ")");
  6470. int sIndex = memo_str.IndexOf("(");
  6471. int eIndex = memo_str.IndexOf(")");
  6472. if (sIndex == -1 || eIndex == -1)
  6473. {
  6474. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6475. return;
  6476. }
  6477. string first = memo_str.Substring(0, sIndex + 1);
  6478. string memoCtid = newentity.OrderSn;
  6479. //if (memoCtid.IndexOf("C") != -1)
  6480. //{
  6481. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6482. //if (CIdx.IndexOf("+") != -1)
  6483. //{
  6484. //CIdx = "C" + CIdx.Split('+')[1];
  6485. //}
  6486. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6487. //}
  6488. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6489. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6490. string newMemo = first + memoCtid + last;
  6491. newentity.seller_memo = newMemo;
  6492. newentity.FinishPlaceTime = null;
  6493. newentity.UnusualTag = 0;
  6494. newentity.UnusualCon = "";
  6495. newentity.UnusualTime = null;
  6496. newentity.AfterSaleMemo = "";
  6497. newentity.AfterSaleMethod = afterMethod;
  6498. newentity.AfterSalePreTime = null;
  6499. newentity.AfterSaleReason = "";
  6500. newentity.AfterSaleResponsible = "";
  6501. newentity.AfterSaleState = 0;
  6502. newentity.AfterSaleTime = null;
  6503. newentity.AfterSaleUserId = 0;
  6504. newentity.AfterSaleSupplierState = 0;
  6505. newentity.LastBillWaybillCode = "";
  6506. newentity.LastBillCpCode = "";
  6507. newentity.FinishAfterSaleTime = null;
  6508. newentity.HandleTime = null;
  6509. newentity.IsSF = 0;
  6510. newentity.IsOldCustomer = 0;
  6511. newentity.UrgencyTime = null;
  6512. newentity.ResponsibleUserId = "";
  6513. newentity.IsVerifyToSupplier = false;
  6514. newentity.payment = 0;
  6515. newentity.CheckMemo = "";
  6516. newentity.OutSid = "";
  6517. newentity.CheckOrderTime = null;
  6518. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6519. }
  6520. newentity.isAfterSaleOrder = 1;
  6521. newentity.IsRefund = 0;
  6522. string receiveMobile = GetPostString("receiver_mobile");
  6523. if (receiveMobile.Length > 0)
  6524. {
  6525. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6526. if (trade != null)
  6527. {
  6528. trade.receiver_name = GetPostString("receiver_name");
  6529. trade.receiver_mobile = receiveMobile;
  6530. trade.receiver_state = GetPostString("receiver_state");
  6531. trade.receiver_city = GetPostString("receiver_city");
  6532. trade.receiver_district = GetPostString("receiver_district");
  6533. trade.receiver_address = GetPostString("receiver_address");
  6534. newentity.IsOffLineOrder = 1;
  6535. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6536. }
  6537. }
  6538. string st = GetPostString("ToState");
  6539. if (st.Length > 0)
  6540. {
  6541. if (newentity.OrderState <= 3)
  6542. {
  6543. newentity.WaitDesignTime = DateTime.Now;
  6544. newentity.StartDesignTime = null;
  6545. newentity.FinishDesignTime = null;
  6546. newentity.OrderState = 3;
  6547. if (st == "下单员")
  6548. {
  6549. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6550. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6551. {
  6552. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6553. }
  6554. }
  6555. else
  6556. {
  6557. newentity.WaitDesignTime = DateTime.Now;
  6558. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6559. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6560. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6561. {
  6562. DataRow user = dt1.Rows[0];
  6563. //找主管
  6564. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6565. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6566. if (dt != null && dt.Rows.Count > 0)
  6567. {
  6568. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6569. newentity.DesignUserId = designMr;
  6570. string key = "aftersale_order_" + designMr;
  6571. if (RedisHelper.HasKey(key))
  6572. {
  6573. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6574. list.Add(newentity.ctid);
  6575. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6576. }
  6577. }
  6578. //账号正常
  6579. if (user["State"].ToString() == "0")
  6580. {
  6581. newentity.DesignUserId = entity.DesignUserId;
  6582. string key = "aftersale_order_" + entity.DesignUserId;
  6583. if (RedisHelper.HasKey(key))
  6584. {
  6585. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6586. list.Add(newentity.ctid);
  6587. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6588. }
  6589. }
  6590. }
  6591. }
  6592. }
  6593. if (entity.IsXianHuo == 1)
  6594. {
  6595. newentity.OrderState = 6;
  6596. entity.FinishPlaceTime = DateTime.Now;
  6597. }
  6598. }
  6599. if (ishav)
  6600. {
  6601. newentity.Update();
  6602. }
  6603. else
  6604. {
  6605. newentity.Create();
  6606. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6607. newCellExtend.ctid = newentity.ctid;
  6608. newCellExtend.orderFrom = 20;
  6609. newCellExtend.orderType = 30;
  6610. if (st == "下单员")
  6611. {
  6612. }
  6613. else
  6614. {
  6615. newCellExtend.ReprintTime = DateTime.Now;
  6616. }
  6617. newCellExtend.Create();
  6618. }
  6619. if (st != "下单员")
  6620. {
  6621. designHelper.API_GetPrintData_CreateOrder(newentity);
  6622. }
  6623. }
  6624. //处理售后扩展
  6625. string resIdStr = GetPostString("ResponsibleUserId");
  6626. string refundFees = GetPostString("refundFrees");
  6627. int IsComplain = GetPostInt("isComplain");
  6628. int IsBad = GetPostInt("isBad");
  6629. string IsOriginal = GetPostString("isOriginal");
  6630. double diffResultPrice = GetPostDouble("diffResultPrice");
  6631. string textResult = GetPostString("textResult");
  6632. string supplierResponsible = GetPostString("supplierResponsible");
  6633. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6634. if (ceErpTradeAfterSaleExtend == null)
  6635. {
  6636. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6637. ceErpTradeAfterSaleExtend.tid = eid;
  6638. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6639. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6640. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6641. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6642. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6643. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6644. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6645. ceErpTradeAfterSaleExtend.Create();
  6646. }
  6647. else
  6648. {
  6649. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6650. {
  6651. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6652. }
  6653. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6654. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6655. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6656. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6657. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6658. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6659. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6660. ceErpTradeAfterSaleExtend.Update();
  6661. }
  6662. int gysid = GetPostInt("ResponsibleSupId");
  6663. if (entity.AfterSaleUserId == 0)
  6664. {
  6665. entity.AfterSaleUserId = CurrentUser.UserID;
  6666. }
  6667. entity.ResponsibleUserId = resIdStr;
  6668. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6669. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6670. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6671. {
  6672. CeErpTradeResponsible.DelByTid(eid, -1);
  6673. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6674. int backNum = 0;
  6675. if (number != null)
  6676. {
  6677. backNum = number.BackNum;
  6678. }
  6679. char[] separator = { ',' };
  6680. string[] sArray = resIdStr.Split(separator);
  6681. string[] refundFreeList = { };
  6682. if (refundFees.Length > 0)
  6683. {
  6684. refundFreeList = refundFees.Split(separator);
  6685. }
  6686. int index = -1;
  6687. foreach (string i in sArray)
  6688. {
  6689. index++;
  6690. if (i.Length <= 0) continue;
  6691. char[] separator2 = { '_' };
  6692. string idstr = i.Split(separator2)[0];
  6693. string idtype = i.Split(separator2)[1];
  6694. double refudFree = 0;
  6695. if (refundFreeList.Length > 0)
  6696. {
  6697. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6698. }
  6699. if (idtype == "s")
  6700. {
  6701. isDesign = true;
  6702. designFree = refudFree;
  6703. }
  6704. int userId = Convert.ToInt32(idstr);
  6705. int type = 0;
  6706. if (idtype == "g")
  6707. {
  6708. type = 1;
  6709. }
  6710. if (idtype == "w")
  6711. {
  6712. type = 2;
  6713. }
  6714. if (idtype == "t")
  6715. {
  6716. type = 3;
  6717. }
  6718. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6719. if (ceErpTradeResponsible == null)
  6720. {
  6721. ceErpTradeResponsible = new CeErpTradeResponsible();
  6722. ceErpTradeResponsible.tid = eid;
  6723. ceErpTradeResponsible.UserId = userId;
  6724. ceErpTradeResponsible.createdTime = DateTime.Now;
  6725. ceErpTradeResponsible.type = type;
  6726. if (type == 1)
  6727. {
  6728. ceErpTradeResponsible.IsSup = 1;
  6729. }
  6730. if (type == 2)
  6731. {
  6732. ceErpTradeResponsible.IsFlow = 1;
  6733. }
  6734. }
  6735. ceErpTradeResponsible.RefundFee = refudFree;
  6736. ceErpTradeResponsible.VerifyState = 0;
  6737. if (userId == 2125 || idtype == "w")
  6738. {
  6739. ceErpTradeResponsible.VerifyState = 1;
  6740. }
  6741. if (idtype == "w" && userId == 101)
  6742. {
  6743. ceErpTradeResponsible.VerifyState = 0;
  6744. }
  6745. if (ceErpTradeResponsible.ID > 0)
  6746. {
  6747. ceErpTradeResponsible.Update();
  6748. }
  6749. else
  6750. {
  6751. ceErpTradeResponsible.Create();
  6752. }
  6753. if (isDesign)
  6754. {
  6755. responsibleId = ceErpTradeResponsible.ID;
  6756. }
  6757. }
  6758. CeErpTradeResponsible.NumByTid(backNum, eid);
  6759. }
  6760. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6761. if (ceErpTradeCellExtend != null)
  6762. {
  6763. ceErpTradeCellExtend.returnVisit = 0;
  6764. ceErpTradeCellExtend.Update();
  6765. }
  6766. if (entity.HandleTime != null)
  6767. {
  6768. if (entity.AfterSaleState == 1)
  6769. {
  6770. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6771. }
  6772. else
  6773. {
  6774. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6775. }
  6776. }
  6777. else
  6778. {
  6779. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6780. entity.HandleTime = DateTime.Now;
  6781. }
  6782. bool isCompale = false;
  6783. if (entity.AfterSaleState == 5)
  6784. {
  6785. isCompale = true;
  6786. entity.AfterSaleState = 3;
  6787. }
  6788. entity.AfterSaleSupplierState = 0;
  6789. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6790. {
  6791. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6792. }
  6793. string sImgs = GetPostString("img");
  6794. entity.AfterSaleSupplierImg = sImgs;
  6795. entity.supRefundType = GetPostString("supRefundType");
  6796. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6797. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6798. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6799. entity.AfterSaleMemoType = GetPostString("MemoType");
  6800. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6801. {
  6802. //entity.AfterSaleSupplierState = 2;
  6803. }
  6804. string df = GetPostString("DeductFee");
  6805. if (df == "")
  6806. {
  6807. df = "0";
  6808. }
  6809. string rf = GetPostString("RefundFee");
  6810. if (rf == "")
  6811. {
  6812. rf = "0";
  6813. }
  6814. string pm = GetPostString("AfterSalePayment");
  6815. if (pm == "")
  6816. {
  6817. pm = "0";
  6818. }
  6819. entity.AfterSalePayment = Convert.ToDouble(pm);
  6820. entity.DeductFee = Convert.ToDouble(df);
  6821. entity.RefundFee = Convert.ToDouble(rf);
  6822. entity.UpdateTime = DateTime.Now;
  6823. entity.Update();
  6824. string toState = GetPostString("ToState");
  6825. string original = GetPostString("isOriginal");
  6826. ApiVo apiVo = new ApiVo();
  6827. apiVo.orderNumber = entity.ctid;
  6828. apiVo.actionName = "afterDesign";
  6829. apiVo.orderRemarks = entity.AfterSaleMethod;
  6830. apiVo.reasonRemarks = entity.AfterSaleReason;
  6831. apiVo.isDesign = isDesign;
  6832. apiVo.designFree = designFree;
  6833. apiVo.responsibleId = responsibleId;
  6834. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6835. if (toState == "设计师")
  6836. {
  6837. apiVo.isOriginal = Convert.ToBoolean(original);
  6838. }
  6839. designHelper.API_WorkCore(apiVo);//afterDesign
  6840. CeErpMethod methodSql = new CeErpMethod();
  6841. methodSql.con = entity.AfterSaleMethod;
  6842. methodSql.addTime = DateTime.Now;
  6843. methodSql.Create();
  6844. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6845. CeErpMethod.ExecuteNonQuery(delsql);
  6846. if (isCompale)
  6847. {
  6848. aftersale_data_change(entity.ctid);
  6849. }
  6850. returnSuccessMsg("操作成功!");
  6851. return;
  6852. }
  6853. returnErrorMsg("找不到订单记录");
  6854. }
  6855. }
  6856. public void ins_erp_toresponsible()
  6857. {
  6858. if (UrlPostParmsCheck("ctid"))
  6859. {
  6860. string eid = GetPostString("ctid");
  6861. CeErpTradeCell entity = null;
  6862. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6863. if (entity != null)
  6864. {
  6865. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6866. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6867. {
  6868. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6869. return;
  6870. }
  6871. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6872. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6873. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6874. if (entity.AfterSalePreTime == null)
  6875. {
  6876. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6877. {
  6878. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6879. }
  6880. }
  6881. entity.AfterSalePreTime = DateTime.Now;
  6882. //预完成给售后主管审核客户问题直接完成
  6883. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6884. {
  6885. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6886. {
  6887. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6888. }
  6889. }
  6890. ceErpTradeAfterSaleExtend.Update();
  6891. entity.AfterSaleState = 2;
  6892. entity.UpdateTime = DateTime.Now;
  6893. entity.Update();
  6894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6895. aftersale_data_change(entity.ctid);
  6896. returnSuccessMsg("操作成功!");
  6897. return;
  6898. }
  6899. returnErrorMsg("找不到订单记录");
  6900. }
  6901. }
  6902. public void cancel_erp_aftersaleanddelnew()
  6903. {
  6904. if (UrlPostParmsCheck("ctid"))
  6905. {
  6906. string eid = GetPostString("ctid");
  6907. CeErpTradeCell entity = null;
  6908. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6909. if (entity != null)
  6910. {
  6911. entity.AfterSaleState = 0;
  6912. entity.AfterSaleReason = "";
  6913. entity.AfterSaleMethod = "";
  6914. entity.AfterSaleMemo = "";
  6915. entity.AfterSaleResponsible = "";
  6916. entity.ResponsibleUserId = "";
  6917. entity.DeductFee = 0;
  6918. entity.RefundFee = 0;
  6919. entity.IsArbitrate = 0;
  6920. CeErpTradeResponsible.DelByTid(eid, -1);
  6921. entity.Update();
  6922. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6923. if (after != null)
  6924. {
  6925. if (after.OrderState < 5)
  6926. CeErpTradeCell.DelByCtid("S_" + eid);
  6927. }
  6928. returnSuccessMsg("操作成功!");
  6929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6930. return;
  6931. }
  6932. returnErrorMsg("找不到订单记录");
  6933. }
  6934. }
  6935. public void get_erp_aftersale_pregather()
  6936. {
  6937. List<string> lw = new List<string>();
  6938. int st = GetInt("st");
  6939. string tid = GetPostString("ctid");
  6940. if (tid.Length > 0)
  6941. {
  6942. string select_tid = getTidByCtid(tid);
  6943. lw.Add(string.Format("tid='{0}'", select_tid));
  6944. }
  6945. string shopname = GetPostString("shopname");
  6946. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6947. string buyernick = GetPostString("buyer_nick");
  6948. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6949. string sellermemo = GetPostString("seller_memo");
  6950. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6951. string orderState = GetPostString("orderState");
  6952. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6953. string reason = GetPostString("reason");
  6954. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6955. string method = GetPostString("method");
  6956. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6957. string handler = GetPostString("handler");
  6958. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6959. string handledate1 = GetPostString("handledate1");
  6960. string handledate2 = GetPostString("handledate2");
  6961. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6962. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6963. string supplier = GetPostString("supplier");
  6964. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6965. string responsible = GetPostString("responsibleman");
  6966. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6967. string customer = GetPostString("customer");
  6968. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6969. string design = GetPostString("design");
  6970. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6971. string afterMemoType = GetPostString("aftermemotype");
  6972. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6973. string afterSaleMemo = GetPostString("afterSaleMemo");
  6974. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6975. string afterresult = GetPostString("afterresult");
  6976. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6977. string poscode = CurrentUser.UserPost.Post.Code;
  6978. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6979. {
  6980. string shopid = CurrentUser.User.pemShop;
  6981. lw.Add(string.Format("shopId in ({0})", shopid));
  6982. }
  6983. var mainwhere = string.Join(" and ", lw.ToArray());
  6984. string ro_json = "";
  6985. string type = GetPostString("gather_type");
  6986. int number = 0;
  6987. if (poscode == "AfterSale")
  6988. {
  6989. //处理中
  6990. if (type == "Handling")
  6991. {
  6992. 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) : ""));
  6993. DataTable dt = null;
  6994. try
  6995. {
  6996. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6997. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6998. }
  6999. catch (Exception e)
  7000. {
  7001. dt = new DataTable();
  7002. }
  7003. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7004. return;
  7005. }
  7006. if (type == "Wait")
  7007. {
  7008. //待处理
  7009. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7010. DataTable dt1 = null;
  7011. try
  7012. {
  7013. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7014. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7015. }
  7016. catch (Exception e)
  7017. {
  7018. dt1 = new DataTable();
  7019. }
  7020. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7021. return;
  7022. }
  7023. if (type == "back")
  7024. {
  7025. //打回
  7026. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7027. DataTable dt2 = null;
  7028. try
  7029. {
  7030. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7031. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7032. }
  7033. catch (Exception e)
  7034. {
  7035. dt2 = new DataTable();
  7036. }
  7037. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7038. return;
  7039. }
  7040. if (type == "preCompletion")
  7041. {
  7042. //预完成
  7043. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7044. DataTable dt3 = null;
  7045. try
  7046. {
  7047. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7048. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7049. }
  7050. catch (Exception e)
  7051. {
  7052. dt3 = new DataTable();
  7053. }
  7054. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7055. return;
  7056. }
  7057. if (type == "documentary")
  7058. {
  7059. //跟单中
  7060. 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) : ""));
  7061. DataTable dt4 = null;
  7062. try
  7063. {
  7064. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7065. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7066. }
  7067. catch (Exception e)
  7068. {
  7069. dt4 = new DataTable();
  7070. }
  7071. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7072. return;
  7073. }
  7074. if (type == "reBack")
  7075. {
  7076. //被打回
  7077. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7078. DataTable dt1 = null;
  7079. try
  7080. {
  7081. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7082. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7083. }
  7084. catch (Exception e)
  7085. {
  7086. dt1 = new DataTable();
  7087. }
  7088. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7089. return;
  7090. }
  7091. }
  7092. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7093. {
  7094. if (type == "puBack")
  7095. {
  7096. //退回
  7097. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7098. DataTable dt = null;
  7099. try
  7100. {
  7101. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7102. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7103. }
  7104. catch (Exception e)
  7105. {
  7106. dt = new DataTable();
  7107. }
  7108. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7109. return;
  7110. }
  7111. if (type == "reBack")
  7112. {
  7113. //打回
  7114. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7115. DataTable dt1 = null;
  7116. try
  7117. {
  7118. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7119. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7120. }
  7121. catch (Exception e)
  7122. {
  7123. dt1 = new DataTable();
  7124. }
  7125. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7126. return;
  7127. }
  7128. if (type == "examEd")
  7129. {
  7130. //已审核
  7131. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7132. DataTable dt2 = null;
  7133. try
  7134. {
  7135. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7136. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7137. }
  7138. catch (Exception e)
  7139. {
  7140. dt2 = new DataTable();
  7141. }
  7142. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7143. return;
  7144. }
  7145. if (type == "waitExam")
  7146. {
  7147. //待审核
  7148. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7149. DataTable dt3 = null;
  7150. try
  7151. {
  7152. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7153. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7154. }
  7155. catch (Exception e)
  7156. {
  7157. dt3 = new DataTable();
  7158. }
  7159. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7160. return;
  7161. }
  7162. if (type == "Handling")
  7163. {
  7164. //处理中
  7165. 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) : ""));
  7166. DataTable dt4 = null;
  7167. try
  7168. {
  7169. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7170. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7171. }
  7172. catch (Exception e)
  7173. {
  7174. dt4 = new DataTable();
  7175. }
  7176. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7177. return;
  7178. }
  7179. if (type == "Wait")
  7180. {
  7181. //待处理
  7182. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7183. DataTable dt5 = null;
  7184. try
  7185. {
  7186. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7187. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7188. }
  7189. catch (Exception e)
  7190. {
  7191. dt5 = new DataTable();
  7192. }
  7193. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7194. return;
  7195. }
  7196. if (type == "documentary")
  7197. {
  7198. //跟单中
  7199. 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) : ""));
  7200. DataTable dt6 = null;
  7201. try
  7202. {
  7203. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7204. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7205. }
  7206. catch (Exception e)
  7207. {
  7208. dt6 = new DataTable();
  7209. }
  7210. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7211. return;
  7212. }
  7213. }
  7214. returnSuccess(ro_json);
  7215. }
  7216. public void end_erp_aftersale()
  7217. {
  7218. if (UrlPostParmsCheck("ctid"))
  7219. {
  7220. string eid = GetPostString("ctid");
  7221. CeErpTradeCell entity = null;
  7222. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7223. if (entity != null)
  7224. {
  7225. string stype = GetPostString("stype");
  7226. string typeStr = stype;
  7227. entity.AfterSaleState = 4;
  7228. entity.FinishAfterSaleTime = DateTime.Now;
  7229. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7230. entity.Update();
  7231. ApiVo apiVo = new ApiVo();
  7232. apiVo.orderNumber = entity.ctid;
  7233. apiVo.actionName = "afterOver";
  7234. designHelper.API_WorkCore(apiVo); //afterOver
  7235. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7236. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7237. CeErpSukuraData.createInfo(entity.ctid, 8);
  7238. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7239. returnSuccessMsg("操作成功!");
  7240. return;
  7241. }
  7242. returnErrorMsg("找不到订单记录");
  7243. }
  7244. }
  7245. public void ins_erp_finishaftersale()
  7246. {
  7247. if (UrlPostParmsCheck("id"))
  7248. {
  7249. string eid = GetPostString("id");
  7250. CeErpTradeResponsible entity = null;
  7251. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7252. if (entity != null)
  7253. {
  7254. entity.VerifyState = 1;
  7255. entity.VerifyTime = DateTime.Now;
  7256. entity.Update();
  7257. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7258. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7259. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7260. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7261. if (dt.Rows.Count <= 0)
  7262. {
  7263. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7264. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7265. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7266. CeErpSukuraData.createInfo(entity.tid, 8);
  7267. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7268. {
  7269. CeErpDesignerBill.Del(entity.tid);
  7270. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7271. }
  7272. }
  7273. returnSuccessMsg("操作成功!");
  7274. return;
  7275. }
  7276. returnErrorMsg("找不到订单记录");
  7277. }
  7278. }
  7279. public void upd_erp_arbitrateaftersale()
  7280. {
  7281. if (UrlPostParmsCheck("id"))
  7282. {
  7283. string eid = GetPostString("id");
  7284. CeErpTradeResponsible entity = null;
  7285. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7286. if (entity != null)
  7287. {
  7288. entity.IsArbitrate = 1;
  7289. entity.ArbitradeMemo = GetPostString("reason");
  7290. entity.VerifyState = 2;
  7291. entity.Update();
  7292. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7293. if (tradecell != null)
  7294. {
  7295. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7296. tradecell.IsArbitrate = 1;
  7297. tradecell.Update();
  7298. }
  7299. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7300. returnSuccessMsg("操作成功!");
  7301. return;
  7302. }
  7303. returnErrorMsg("找不到订单记录");
  7304. }
  7305. }
  7306. public void upd_erp_backaftersale()
  7307. {
  7308. if (UrlPostParmsCheck("tid"))
  7309. {
  7310. string eid = GetPostString("tid");
  7311. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7312. int backNum = 0;
  7313. if (number != null)
  7314. {
  7315. backNum = number.BackNum;
  7316. }
  7317. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7318. CeErpTradeCell entity = null;
  7319. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7320. if (entity != null)
  7321. {
  7322. entity.AfterSaleBackReason = GetPostString("backreason");
  7323. entity.AfterSaleState = 1;
  7324. entity.AfterSaleSupplierState = 0;
  7325. entity.UpdateTime = DateTime.Now;
  7326. entity.Update();
  7327. returnSuccessMsg("操作成功!");
  7328. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7329. return;
  7330. }
  7331. returnErrorMsg("找不到订单记录");
  7332. }
  7333. }
  7334. public void get_erp_supplieraftersalelist()
  7335. {
  7336. DataStruct dStruct = GetPostStruct();
  7337. List<string> lw = new List<string>();
  7338. string tid = GetPostString("ctid");
  7339. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7340. string shopname = GetPostString("shopname");
  7341. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7342. string buyernick = GetPostString("buyer_nick");
  7343. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7344. string sellermemo = GetPostString("seller_memo");
  7345. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7346. string orderState = GetPostString("orderState");
  7347. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7348. string afterState = GetPostString("afterstate");
  7349. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7350. string date1 = GetPostString("date1");
  7351. string date2 = GetPostString("date2");
  7352. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7353. if (dw.Length > 0) lw.Add(dw);
  7354. string price1 = GetPostString("price1");
  7355. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7356. string price2 = GetPostString("price2");
  7357. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7358. string reason = GetPostString("reason");
  7359. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7360. string method = GetPostString("method");
  7361. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7362. string handledate1 = GetPostString("handledate1");
  7363. string handledate2 = GetPostString("handledate2");
  7364. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7365. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7366. string handler = GetPostString("handler");
  7367. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7368. string afterdate1 = GetPostString("afterdate1");
  7369. string afterdate2 = GetPostString("afterdate2");
  7370. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7371. if (afterDate.Length > 0) lw.Add(afterDate);
  7372. string customer = GetPostString("customer");
  7373. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7374. string design = GetPostString("design");
  7375. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7376. string afterMemoType = GetPostString("aftermemotype");
  7377. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7378. string vstate = GetPostString("vstate");
  7379. if (vstate.Length > 0)
  7380. {
  7381. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7382. }
  7383. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7384. string supplier = GetPostString("supplier");
  7385. int supid = commonHelper.getSupplierIDByName(supplier);
  7386. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7387. string posCode = CurrentUser.UserPost.Post.Code;
  7388. if (posCode == "Supplier")
  7389. {
  7390. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7391. }
  7392. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7393. {
  7394. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7395. }
  7396. else
  7397. {
  7398. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7399. }
  7400. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7401. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7402. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7403. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7404. writeGridDataTableJson(dStruct.TotalCount, dt);
  7405. }
  7406. public void upd_erp_supverifyaftersale()
  7407. {
  7408. if (UrlPostParmsCheck("id"))
  7409. {
  7410. string id = GetPostString("id");
  7411. int st = GetPostInt("afterstate");
  7412. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7413. CeErpTradeCell entity = null;
  7414. if (ceErpTradeResponsible != null)
  7415. {
  7416. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7417. }
  7418. string afmemo = GetPostString("supmemo");
  7419. string image = GetPostString("image");
  7420. if (entity != null)
  7421. {
  7422. entity.AfterSaleSupplierState = st;
  7423. entity.AfterSaleSupplierMemo = afmemo;
  7424. if (st == 1)
  7425. {
  7426. ceErpTradeResponsible.VerifyState = 1;
  7427. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7428. ceErpTradeResponsible.Update();
  7429. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7430. if (isAll)
  7431. {
  7432. entity.AfterSaleState = 4;
  7433. entity.FinishAfterSaleTime = DateTime.Now;
  7434. }
  7435. }
  7436. else
  7437. {
  7438. CeErpTradeResponsible.dateByTid(entity.ctid);
  7439. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7440. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7441. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7442. if (num <= 1)
  7443. {
  7444. entity.AfterSaleState = 1;
  7445. }
  7446. else
  7447. {
  7448. entity.AfterSaleState = 5;
  7449. }
  7450. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7451. if (ceErpTradeAfterSaleExtend != null)
  7452. {
  7453. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7454. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7455. ceErpTradeAfterSaleExtend.Update();
  7456. }
  7457. else
  7458. {
  7459. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7460. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7461. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7462. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7463. ceErpTradeAfterSaleExtend.Create();
  7464. }
  7465. }
  7466. if (entity.AfterSaleState == 4)
  7467. {
  7468. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7469. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7470. {
  7471. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7472. }
  7473. ApiVo apiVo = new ApiVo();
  7474. apiVo.orderNumber = entity.ctid;
  7475. apiVo.actionName = "afterOver";
  7476. designHelper.API_WorkCore(apiVo); //afterOver
  7477. }
  7478. entity.UpdateTime = DateTime.Now;
  7479. entity.Update();
  7480. returnSuccessMsg("操作成功!");
  7481. CeErpSukuraData.createInfo(entity.ctid, 8);
  7482. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7483. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7484. return;
  7485. }
  7486. returnErrorMsg("找不到订单记录");
  7487. }
  7488. }
  7489. public void upd_erp_masteraftersale()
  7490. {
  7491. if (UrlPostParmsCheck("id"))
  7492. {
  7493. string id = GetPostString("id");
  7494. int st = GetPostInt("afterstate");
  7495. string afmemo = GetPostString("supmemo");
  7496. string image = GetPostString("image");
  7497. string textResult = GetPostString("textResult");
  7498. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7499. if (ceErpTradeResponsible != null)
  7500. {
  7501. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7502. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7503. ceErpTradeResponsible.Update();
  7504. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7505. if (entity != null)
  7506. {
  7507. entity.AfterSaleSupplierState = st;
  7508. entity.AfterSaleSupplierMemo = afmemo;
  7509. if (st == 1)
  7510. {
  7511. }
  7512. else
  7513. {
  7514. CeErpTradeResponsible.dateByTid(entity.ctid);
  7515. //退回到售后
  7516. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7517. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7518. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7519. if (num <= 1)
  7520. {
  7521. entity.AfterSaleState = 1;
  7522. }
  7523. else
  7524. {
  7525. entity.AfterSaleState = 5;
  7526. }
  7527. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7528. if (ceErpTradeAfterSaleExtend != null)
  7529. {
  7530. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7531. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7532. ceErpTradeAfterSaleExtend.Update();
  7533. }
  7534. else
  7535. {
  7536. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7537. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7538. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7539. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7540. ceErpTradeAfterSaleExtend.Create();
  7541. }
  7542. }
  7543. entity.UpdateTime = DateTime.Now;
  7544. entity.Update();
  7545. returnSuccessMsg("操作成功!");
  7546. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7547. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7548. return;
  7549. }
  7550. }
  7551. returnErrorMsg("找不到订单记录");
  7552. }
  7553. }
  7554. public void upd_erp_personaftersale()
  7555. {
  7556. if (UrlPostParmsCheck("id"))
  7557. {
  7558. string id = GetPostString("id");
  7559. int st = GetPostInt("afterstate");
  7560. string afmemo = GetPostString("supmemo");
  7561. string image = GetPostString("image");
  7562. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7563. if (ceErpTradeResponsible != null)
  7564. {
  7565. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7566. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7567. ceErpTradeResponsible.Update();
  7568. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7569. if (entity != null)
  7570. {
  7571. entity.AfterSaleSupplierMemo = afmemo;
  7572. entity.AfterSaleSupplierState = st;
  7573. if (st == 1)
  7574. {
  7575. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7576. if (isAll)
  7577. {
  7578. entity.AfterSaleState = 4;
  7579. entity.FinishAfterSaleTime = DateTime.Now;
  7580. }
  7581. }
  7582. else
  7583. {
  7584. CeErpTradeResponsible.dateByTid(entity.ctid);
  7585. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7586. if (ceErpTradeAfterSaleExtend != null)
  7587. {
  7588. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7589. ceErpTradeAfterSaleExtend.Update();
  7590. }
  7591. else
  7592. {
  7593. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7594. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7595. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7596. ceErpTradeAfterSaleExtend.Create();
  7597. }
  7598. //退回到主管
  7599. //entity.AfterSaleState = 2;
  7600. }
  7601. if (entity.AfterSaleState == 4)
  7602. {
  7603. ApiVo apiVo = new ApiVo();
  7604. apiVo.orderNumber = entity.ctid;
  7605. apiVo.actionName = "afterOver";
  7606. designHelper.API_WorkCore(apiVo); //afterOver
  7607. }
  7608. entity.UpdateTime = DateTime.Now;
  7609. entity.Update();
  7610. returnSuccessMsg("操作成功!");
  7611. CeErpSukuraData.createInfo(entity.ctid, 8);
  7612. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7613. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7614. return;
  7615. }
  7616. }
  7617. returnErrorMsg("找不到订单记录");
  7618. }
  7619. }
  7620. public void set_erp_supplierrefundtag()
  7621. {
  7622. if (UrlPostParmsCheck("ctid"))
  7623. {
  7624. string eid = GetPostString("ctid");
  7625. CeErpTradeCell entity = null;
  7626. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7627. if (entity != null)
  7628. {
  7629. entity.IsSupplierRefund = GetPostInt("tag");
  7630. entity.Update();
  7631. returnSuccessMsg("操作成功!");
  7632. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7633. return;
  7634. }
  7635. returnErrorMsg("找不到订单记录");
  7636. }
  7637. }
  7638. public void get_erp_refundlist()
  7639. {
  7640. DataStruct dStruct = GetPostStruct();
  7641. List<string> lw = new List<string>();
  7642. string tid = GetPostString("tid");
  7643. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7644. //string rid = GetPostString("refund_id");
  7645. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7646. string shopname = GetPostString("shopname");
  7647. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7648. string buyernick = GetPostString("buyer_nick");
  7649. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7650. string customer = GetPostString("customer");
  7651. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7652. string design = GetPostString("design");
  7653. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7654. string sellermemo = GetPostString("seller_memo");
  7655. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7656. //string date1 = GetPostString("date1");
  7657. //string date2 = GetPostString("date2");
  7658. //string dateType = GetPostString("dateType");
  7659. //if (dateType.Length > 0)
  7660. //{
  7661. // if (dateType == "1001") dateType = "0";
  7662. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7663. // if (searchDT.Count == 2)
  7664. // {
  7665. // date1 = searchDT[0].ToString();
  7666. // date2 = searchDT[1].ToString();
  7667. // }
  7668. //}
  7669. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7670. //if (dw.Length > 0) lw.Add(dw);
  7671. string redate1 = GetPostString("refunddate1");
  7672. string redate2 = GetPostString("refunddate2");
  7673. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7674. if (dwdate.Length > 0) lw.Add(dwdate);
  7675. string price1 = GetPostString("price1");
  7676. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7677. string price2 = GetPostString("price2");
  7678. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7679. string ispartrefund = GetPostString("ispartrefund");
  7680. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7681. string refundState = GetPostString("refundvstate");
  7682. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7683. int st = GetInt("st");
  7684. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7685. {
  7686. string responsible = GetPostString("responsibleman");
  7687. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7688. lw.Add(string.Format("RefundState>={0}", st));
  7689. string code = CurrentUser.UserPost.Post.Code;
  7690. if (code == "CustomerService")
  7691. {
  7692. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7693. }
  7694. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7695. {
  7696. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7697. }
  7698. else if (code == "Place" || code == "PlaceMr")
  7699. {
  7700. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7701. }
  7702. dStruct.Order = "RefundState asc,created desc";
  7703. }
  7704. else if (st == 10)
  7705. {
  7706. string responsible = GetPostString("responsibleman");
  7707. if (responsible == "空白")
  7708. {
  7709. lw.Add(string.Format("ResponsibleUserName = ''"));
  7710. }
  7711. else if (responsible.Length > 0)
  7712. {
  7713. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7714. }
  7715. lw.Add(string.Format("RefundState>=0"));
  7716. dStruct.Order = "created desc";
  7717. }
  7718. else
  7719. {
  7720. string responsible = GetPostString("responsibleman");
  7721. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7722. lw.Add(string.Format("RefundState={0}", st));
  7723. dStruct.Order = "created desc";
  7724. }
  7725. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7726. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7727. dt.Columns.Add("refund_fees");
  7728. foreach (DataRow dr in dt.Rows)
  7729. {
  7730. String status = dr["status"].ToString();
  7731. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7732. {
  7733. dr["refund_fees"] = dr["refund_fee"];
  7734. }
  7735. else
  7736. {
  7737. dr["refund_fees"] = "0.0";
  7738. }
  7739. }
  7740. writeGridDataTableJson(dStruct.TotalCount, dt);
  7741. }
  7742. public void get_erp_refunddesignlist()
  7743. {
  7744. DataStruct dStruct = GetPostStruct();
  7745. List<string> lw = new List<string>();
  7746. string tid = GetPostString("tid");
  7747. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7748. string shopname = GetPostString("shopname");
  7749. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7750. string buyernick = GetPostString("buyer_nick");
  7751. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7752. string customer = GetPostString("customer");
  7753. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7754. string design = GetPostString("design");
  7755. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7756. string sellermemo = GetPostString("seller_memo");
  7757. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7758. string redate1 = GetPostString("refunddate1");
  7759. string redate2 = GetPostString("refunddate2");
  7760. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7761. if (dwdate.Length > 0) lw.Add(dwdate);
  7762. string price1 = GetPostString("price1");
  7763. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7764. string price2 = GetPostString("price2");
  7765. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7766. string ispartrefund = GetPostString("ispartrefund");
  7767. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7768. string designerorg = GetPostString("designerorg");
  7769. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7770. string refundState = GetPostString("refundState");
  7771. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7772. int myOrgid = CurrentUser.UserPost.OrgID;
  7773. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7774. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7775. {
  7776. if (CurrentUser.User.TeamIds.Length > 0)
  7777. {
  7778. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7779. }
  7780. else
  7781. {
  7782. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7783. }
  7784. }
  7785. else if ("SysAdmin".Equals(myOrgCode))
  7786. {
  7787. }
  7788. else
  7789. {
  7790. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7791. {
  7792. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7793. }
  7794. else
  7795. {
  7796. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7797. }
  7798. }
  7799. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7800. dStruct.Order = "created desc";
  7801. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7802. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7803. dt.Columns.Add("refund_fees");
  7804. foreach (DataRow dr in dt.Rows)
  7805. {
  7806. String status = dr["status"].ToString();
  7807. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7808. {
  7809. dr["refund_fees"] = dr["refund_fee"];
  7810. }
  7811. else
  7812. {
  7813. dr["refund_fees"] = "0.0";
  7814. }
  7815. }
  7816. writeGridDataTableJson(dStruct.TotalCount, dt);
  7817. }
  7818. public void handle_erp_refundtag()
  7819. {
  7820. if (UrlPostParmsCheck("refund_id"))
  7821. {
  7822. string eid = GetPostString("refund_id");
  7823. string respMan = GetPostString("ResponsibleName");
  7824. if (respMan.Length <= 0)
  7825. {
  7826. returnErrorMsg("责任人不能为空");
  7827. return;
  7828. }
  7829. CeErpTradeRefund entity = null;
  7830. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7831. if (entity != null)
  7832. {
  7833. entity.ResponsibleUserName = respMan;
  7834. string userid = GetPostString("ResponsibleUserId");
  7835. if (userid.Length > 0)
  7836. {
  7837. entity.ResponsibleUserId = userid;
  7838. }
  7839. entity.Memo = GetPostString("Memo");
  7840. if (respMan.IndexOf("客服") != -1 ||
  7841. respMan.IndexOf("设计师") != -1 ||
  7842. respMan.IndexOf("下单员") != -1)
  7843. {
  7844. entity.RefundState = 2;
  7845. }
  7846. else
  7847. {
  7848. entity.RefundState = 3;
  7849. }
  7850. entity.modified = DateTime.Now;
  7851. entity.Update();
  7852. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7853. returnSuccessMsg("操作成功!");
  7854. return;
  7855. }
  7856. returnErrorMsg("找不到订单记录");
  7857. }
  7858. }
  7859. public void handle_erp_designrefundtag()
  7860. {
  7861. if (UrlPostParmsCheck("refund_id"))
  7862. {
  7863. string eid = GetPostString("refund_id");
  7864. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7865. if (ceErpTradeCellExtend == null)
  7866. {
  7867. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7868. ceErpTradeCellExtend.ctid = eid;
  7869. }
  7870. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7871. if (ceErpTradeCellExtend.ID > 0)
  7872. {
  7873. ceErpTradeCellExtend.Update();
  7874. }
  7875. else
  7876. {
  7877. ceErpTradeCellExtend.Create();
  7878. }
  7879. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7880. returnSuccessMsg("操作成功!");
  7881. return;
  7882. }
  7883. returnErrorMsg("找不到订单记录");
  7884. }
  7885. public void upd_erp_refundverify()
  7886. {
  7887. if (UrlPostParmsCheck("refund_id"))
  7888. {
  7889. string eid = GetPostString("refund_id");
  7890. CeErpTradeRefund entity = null;
  7891. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7892. if (entity != null)
  7893. {
  7894. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7895. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7896. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7897. {
  7898. entity.RefundState = 2;
  7899. }
  7900. else
  7901. {
  7902. entity.RefundState = 3;
  7903. }
  7904. entity.Update();
  7905. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7906. returnSuccessMsg("操作成功!");
  7907. return;
  7908. }
  7909. returnErrorMsg("找不到订单记录");
  7910. }
  7911. }
  7912. public void upd_erp_refundapprove()
  7913. {
  7914. if (UrlPostParmsCheck("refund_id"))
  7915. {
  7916. string eid = GetPostString("refund_id");
  7917. CeErpTradeRefund entity = null;
  7918. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7919. if (entity != null)
  7920. {
  7921. int apr = GetPostInt("approve");
  7922. if (apr == 0)
  7923. {
  7924. entity.RefundState = 1;
  7925. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7926. }
  7927. else if (apr == 1)
  7928. {
  7929. entity.RefundState = 3;
  7930. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7931. }
  7932. entity.modified = DateTime.Now;
  7933. entity.Update();
  7934. returnSuccessMsg("操作成功!");
  7935. return;
  7936. }
  7937. returnErrorMsg("找不到订单记录");
  7938. }
  7939. }
  7940. public void get_erp_billlist()
  7941. {
  7942. DataStruct dStruct = GetPostStruct();
  7943. List<string> lw = new List<string>();
  7944. string title = GetPostString("title");
  7945. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7946. string tid = GetPostString("tid");
  7947. string tids = GetPostString("tids");
  7948. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7949. if (tids.Length > 0)
  7950. {
  7951. tids = "'" + tids + "'";
  7952. tids = tids.Replace(",", "','");
  7953. lw.Add(string.Format("tid in ({0})", tids));
  7954. }
  7955. string shopname = GetPostString("shopname");
  7956. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7957. string buyernick = GetPostString("buyer_nick");
  7958. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7959. string customer = GetPostString("customer");
  7960. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7961. string date1 = GetPostString("date1");
  7962. string date2 = GetPostString("date2");
  7963. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7964. if (dw.Length > 0) lw.Add(dw);
  7965. string price1 = GetPostString("price1");
  7966. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7967. string price2 = GetPostString("price2");
  7968. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7969. string returndate1 = GetPostString("returndate1");
  7970. string returndate2 = GetPostString("returndate2");
  7971. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7972. if (dw1.Length > 0) lw.Add(dw1);
  7973. string billtype = GetPostString("billtype");
  7974. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7975. string billstate = GetPostString("billstate");
  7976. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7977. string usershop = CurrentUser.User.pemShop;
  7978. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7979. dStruct.Order = "createTime desc";
  7980. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7981. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7982. //foreach (DataRow dr in dt.Rows)
  7983. //{
  7984. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7985. //}
  7986. writeGridDataTableJson(dStruct.TotalCount, dt);
  7987. }
  7988. public void modify_erp_billinfo()
  7989. {
  7990. if (UrlPostParmsCheck("ID"))
  7991. {
  7992. string eid = GetPostString("ID");
  7993. CeErpBill bill_entity = null;
  7994. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7995. if (bill_entity != null)
  7996. {
  7997. bill_entity.tid = GetPostString("tid");
  7998. bill_entity.title = GetPostString("title");
  7999. bill_entity.tax = GetPostString("tax");
  8000. bill_entity.bank = GetPostString("bank");
  8001. bill_entity.bankac = GetPostString("bankac");
  8002. bill_entity.address = GetPostString("address");
  8003. bill_entity.phone = GetPostString("phone");
  8004. bill_entity.price = GetPostString("price");
  8005. bill_entity.productId = GetPostInt("ProductName");
  8006. bill_entity.num = GetPostInt("num");
  8007. bill_entity.unit = GetPostString("unit");
  8008. bill_entity.type = GetPostString("type");
  8009. bill_entity.sendType = GetPostString("SendType");
  8010. bill_entity.email = GetPostString("email");
  8011. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8012. bill_entity.shopName = GetPostString("ShopName");
  8013. bill_entity.applymemo = GetPostString("applymemo");
  8014. bill_entity.modifyTime = DateTime.Now;
  8015. bill_entity.createTime = DateTime.Now;
  8016. bill_entity.state = 0;
  8017. bill_entity.Update();
  8018. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8019. returnSuccessMsg("发票修改成功!");
  8020. return;
  8021. }
  8022. returnErrorMsg("找不到对应记录");
  8023. }
  8024. }
  8025. public void set_erp_invoicing()
  8026. {
  8027. if (UrlPostParmsCheck("id"))
  8028. {
  8029. try
  8030. {
  8031. string eid = GetPostString("id");
  8032. CeErpBill bill_entity = null;
  8033. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8034. if (bill_entity != null)
  8035. {
  8036. int ComId = GetPostInt("ComId");
  8037. //string memo = GetPostString("Memo");
  8038. int allInfo = GetPostInt("allinfo");
  8039. string clert = CurrentUser.User.Name;
  8040. //string detailValue = GetPostString("detailvalue");
  8041. string billId = bill_entity.billOrderId;
  8042. string[] billIdList = billId.Split(',');
  8043. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8044. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8045. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8046. {
  8047. billCount += 1;
  8048. }
  8049. if (billId.Length <= 0 || billIdList.Length != billCount)
  8050. {
  8051. bill_entity.billOrderId = "";
  8052. string prebill = "ltb";
  8053. for (int idx = 1; idx <= billCount; idx++)
  8054. {
  8055. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8056. string billoid = prebill + idx + dtstr;
  8057. bill_entity.billOrderId += billoid;
  8058. if (idx < billCount)
  8059. {
  8060. bill_entity.billOrderId += ",";
  8061. }
  8062. }
  8063. }
  8064. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8065. if (bill_entity.state == 5)
  8066. {
  8067. string errMsg = bill_entity.failerror;
  8068. string[] errlist = errMsg.Split('|');
  8069. string[] errTags = new string[errlist.Length];
  8070. for (int itag = 0; itag < errlist.Length; itag++)
  8071. {
  8072. if (errlist[itag].Length <= 0) continue;
  8073. errTags[itag] = errlist[itag].Split('&')[0];
  8074. }
  8075. for (int iii = 0; iii < errTags.Length; iii++)
  8076. {
  8077. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8078. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8079. if (billOrderList.Length >= erroBillOrderTag)
  8080. {
  8081. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8082. if (needModifyBillId.Length <= 19)
  8083. {
  8084. needModifyBillId = needModifyBillId + "1";
  8085. }
  8086. else
  8087. {
  8088. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8089. last = last + 1;
  8090. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8091. }
  8092. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8093. }
  8094. }
  8095. }
  8096. bool isHaveBillSucces = false;
  8097. string totalRes = "";
  8098. bill_entity.failerror = "";
  8099. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8100. {
  8101. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8102. totalRes += res;
  8103. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8104. {
  8105. isHaveBillSucces = true;
  8106. bill_entity.comId = ComId;
  8107. bill_entity.state = 1;
  8108. bill_entity.executeTime = DateTime.Now;
  8109. bill_entity.executeUser = clert;
  8110. }
  8111. else
  8112. {
  8113. bill_entity.state = 5;
  8114. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8115. }
  8116. }
  8117. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8118. bill_entity.Update();
  8119. if (isHaveBillSucces)
  8120. {
  8121. StringBuilder sql = new StringBuilder();
  8122. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8123. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8124. }
  8125. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8126. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8127. {
  8128. returnErrorMsg("开票失败");
  8129. }
  8130. else
  8131. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8132. return;
  8133. }
  8134. returnErrorMsg("找不到对应记录");
  8135. }
  8136. catch (Exception ex)
  8137. {
  8138. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8139. returnErrorMsg("操作失败");
  8140. }
  8141. }
  8142. }
  8143. public void get_erp_invoicing_back()
  8144. {
  8145. if (UrlPostParmsCheck("id"))
  8146. {
  8147. try
  8148. {
  8149. string id = GetPostString("id");
  8150. CeErpBill entiy = CeErpBill.Get(id);
  8151. if (entiy != null)
  8152. {
  8153. if (entiy.state == 0)
  8154. {
  8155. returnErrorMsg("发票还未开具");
  8156. return;
  8157. }
  8158. string[] billOrderList = entiy.billOrderId.Split(',');
  8159. int iTag = 0;
  8160. entiy.fplsh = "";
  8161. entiy.fpdm = "";
  8162. entiy.fphm = "";
  8163. foreach (string billOrderId in billOrderList)
  8164. {
  8165. iTag++;
  8166. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8167. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8168. {
  8169. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8170. try
  8171. {
  8172. Invoicing_get_response_Obj iObj = null;
  8173. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8174. if (iObj != null)
  8175. {
  8176. entiy.state = 2;
  8177. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8178. entiy.fpdm += iObj.list[0].c_fpdm;
  8179. entiy.fphm += iObj.list[0].c_fphm;
  8180. if (iTag < billOrderList.Length)
  8181. {
  8182. entiy.fplsh += ",";
  8183. entiy.fpdm += ",";
  8184. entiy.fphm += ",";
  8185. }
  8186. entiy.Update();
  8187. }
  8188. StringBuilder sql = new StringBuilder();
  8189. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8190. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8191. returnSuccessMsg("开票成功");
  8192. }
  8193. catch (Exception ex)
  8194. {
  8195. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8196. }
  8197. return;
  8198. }
  8199. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8200. {
  8201. var res_obj = new
  8202. {
  8203. data = "开票中"
  8204. };
  8205. string ro_json = JsonConvert.SerializeObject(res_obj);
  8206. returnSuccess(ro_json);
  8207. return;
  8208. }
  8209. else
  8210. {
  8211. int eidx = res.IndexOf("c_resultmsg");
  8212. int lidx = res.IndexOf("c_status");
  8213. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8214. entiy.state = 5;
  8215. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8216. entiy.Update();
  8217. returnErrorMsg("开票失败");
  8218. return;
  8219. }
  8220. }
  8221. }
  8222. }
  8223. catch (Exception ex)
  8224. {
  8225. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8226. }
  8227. return;
  8228. }
  8229. }
  8230. public void get_erp_invoicing()
  8231. {
  8232. if (UrlPostParmsCheck("id"))
  8233. {
  8234. try
  8235. {
  8236. string id = GetPostString("id");
  8237. CeErpBill entiy = CeErpBill.Get(id);
  8238. if (entiy != null)
  8239. {
  8240. if (entiy.state == 0)
  8241. {
  8242. returnErrorMsg("发票还未开具");
  8243. return;
  8244. }
  8245. if (entiy.sendType == "纸质发票")
  8246. {
  8247. if (entiy.img.Length <= 0)
  8248. {
  8249. returnErrorMsg("查无纸质发票");
  8250. return;
  8251. }
  8252. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8253. returnSuccess(returnres);
  8254. return;
  8255. }
  8256. string[] billOrderList = entiy.billOrderId.Split(',');
  8257. int iTag = 0;
  8258. string fpUrl = "";
  8259. entiy.fplsh = "";
  8260. entiy.fpdm = "";
  8261. entiy.fphm = "";
  8262. foreach (string billOrderId in billOrderList)
  8263. {
  8264. iTag++;
  8265. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8266. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8267. {
  8268. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8269. Invoicing_get_response_Obj iObj = null;
  8270. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8271. if (iObj != null)
  8272. {
  8273. //entiy.state = 2;
  8274. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8275. entiy.fpdm += iObj.list[0].c_fpdm;
  8276. entiy.fphm += iObj.list[0].c_fphm;
  8277. if (iTag < billOrderList.Length)
  8278. {
  8279. entiy.fplsh += ",";
  8280. entiy.fpdm += ",";
  8281. entiy.fphm += ",";
  8282. }
  8283. entiy.Update();
  8284. fpUrl += iObj.list[0].c_url + ",";
  8285. }
  8286. //returnSuccess(res);
  8287. StringBuilder sql = new StringBuilder();
  8288. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8289. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8290. }
  8291. else
  8292. {
  8293. int eidx = res.IndexOf("c_resultmsg");
  8294. //int lidx = res.IndexOf("c_status");
  8295. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8296. //开票失败
  8297. entiy.state = 5;
  8298. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8299. entiy.Update();
  8300. returnErrorMsg("开票失败");
  8301. return;
  8302. }
  8303. }
  8304. var returnObj = new
  8305. {
  8306. data = fpUrl
  8307. };
  8308. string ro_json = JsonConvert.SerializeObject(returnObj);
  8309. returnSuccess(ro_json);
  8310. }
  8311. }
  8312. catch (Exception ex)
  8313. {
  8314. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8315. }
  8316. return;
  8317. }
  8318. }
  8319. public void save_erp_billimg()
  8320. {
  8321. if (UrlPostParmsCheck("id"))
  8322. {
  8323. string eid = GetPostString("id");
  8324. CeErpBill bill_entity = null;
  8325. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8326. if (bill_entity != null)
  8327. {
  8328. bill_entity.img = GetPostString("img");
  8329. bill_entity.executeTime = DateTime.Now;
  8330. bill_entity.state = 2;
  8331. bill_entity.Update();
  8332. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8333. returnSuccessMsg("保存成功");
  8334. }
  8335. return;
  8336. }
  8337. }
  8338. public void upd_erp_billreturnback()
  8339. {
  8340. if (UrlPostParmsCheck("id"))
  8341. {
  8342. int eid = GetPostInt("id");
  8343. CeErpBill bill_entity = null;
  8344. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8345. if (bill_entity != null)
  8346. {
  8347. bill_entity.state = 3;
  8348. bill_entity.returnReason = GetPostString("reason");
  8349. bill_entity.Update();
  8350. returnSuccessMsg("驳回成功!");
  8351. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8352. }
  8353. return;
  8354. }
  8355. }
  8356. public void cancel_erp_bill()
  8357. {
  8358. if (UrlPostParmsCheck("id"))
  8359. {
  8360. int eid = GetPostInt("id");
  8361. int detailValue = GetPostInt("detailvalue");
  8362. CeErpBill bill_entity = null;
  8363. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8364. string cres = "";
  8365. string gres = "";
  8366. if (bill_entity != null)
  8367. {
  8368. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8369. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8370. {
  8371. int iTag = 0;
  8372. bill_entity.fplsh = "";
  8373. bill_entity.fpdm = "";
  8374. bill_entity.fphm = "";
  8375. foreach (string billOrderId in billOrderList)
  8376. {
  8377. iTag++;
  8378. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8379. if (gres.IndexOf("success") != -1)
  8380. {
  8381. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8382. Invoicing_get_response_Obj iObj = null;
  8383. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8384. if (iObj != null)
  8385. {
  8386. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8387. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8388. bill_entity.fphm += iObj.list[0].c_fphm;
  8389. if (iTag < billOrderList.Length)
  8390. {
  8391. bill_entity.fplsh += ",";
  8392. bill_entity.fpdm += ",";
  8393. bill_entity.fphm += ",";
  8394. }
  8395. bill_entity.Update();
  8396. }
  8397. }
  8398. else
  8399. {
  8400. returnErrorMsg(gres);
  8401. return;
  8402. }
  8403. }
  8404. }
  8405. if (bill_entity.sendType == "纸质发票")
  8406. {
  8407. //作废
  8408. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8409. //if (DateTime.Now.Month == extime.Month)
  8410. //{
  8411. //cres = taobaoHelper.cancel_invoicing(eid);
  8412. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8413. //{
  8414. bill_entity.state = 4;//已作废
  8415. bill_entity.Update();
  8416. returnSuccessMsg("发票已作废");
  8417. return;
  8418. //}
  8419. //else
  8420. //{
  8421. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8422. // bill_entity.Update();
  8423. // returnErrorMsg(cres);
  8424. // return;
  8425. //}
  8426. //}
  8427. //else
  8428. //{
  8429. // returnErrorMsg("纸质发票只能作废本月的发票");
  8430. // return;
  8431. //}
  8432. }
  8433. //红冲
  8434. int redTag = 0;
  8435. string[] fpdmList = bill_entity.fpdm.Split(',');
  8436. string[] fphmList = bill_entity.fphm.Split(',');
  8437. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8438. {
  8439. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8440. return;
  8441. }
  8442. foreach (string billOrderId in billOrderList)
  8443. {
  8444. redTag++;
  8445. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8446. cres += onecres;
  8447. cres += ",";
  8448. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8449. {
  8450. bill_entity.state = 4;//已作废
  8451. //bill_entity.Update();
  8452. //returnSuccessMsg("发票已红冲");
  8453. }
  8454. else if (onecres.IndexOf("重复冲红") != -1)
  8455. {
  8456. bill_entity.state = 4;//已作废
  8457. //bill_entity.Update();
  8458. //returnSuccessMsg("发票已红冲");
  8459. }
  8460. else
  8461. {
  8462. string errmsg = commonHelper.KeepChinese(onecres);
  8463. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8464. }
  8465. }
  8466. bill_entity.Update();
  8467. if (cres.IndexOf("失败") != -1)
  8468. returnErrorMsg("红冲失败");
  8469. else
  8470. returnSuccessMsg("发票已红冲");
  8471. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8472. return;
  8473. }
  8474. return;
  8475. }
  8476. }
  8477. public void del_erp_billorder()
  8478. {
  8479. if (UrlPostParmsCheck("id"))
  8480. {
  8481. string eid = GetPostString("id");
  8482. CeErpBill.Del(eid);
  8483. CeErpBill bill = CeErpBill.Get(eid);
  8484. if (bill != null)
  8485. {
  8486. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8487. }
  8488. returnSuccessMsg("删除成功");
  8489. }
  8490. }
  8491. public void finish_erp_bill()
  8492. {
  8493. if (UrlPostParmsCheck("ids"))
  8494. {
  8495. string eids = GetPostString("ids");
  8496. string[] list = eids.Split(',');
  8497. foreach (string eid in list)
  8498. {
  8499. CeErpBill bill = CeErpBill.Get(eid);
  8500. if (bill != null)
  8501. {
  8502. bill.state = 2;
  8503. bill.Update();
  8504. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8505. }
  8506. }
  8507. returnSuccessMsg("操作成功");
  8508. }
  8509. }
  8510. public void get_erp_returncash()
  8511. {
  8512. DataStruct dStruct = GetPostStruct();
  8513. List<string> lw = new List<string>();
  8514. string tid = GetPostString("tid");
  8515. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8516. string shopname = GetPostString("shopname");
  8517. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8518. string buyernick = GetPostString("buyer_nick");
  8519. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8520. string customer = GetPostString("customer");
  8521. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8522. string returndate1 = GetPostString("returndate1");
  8523. string returndate2 = GetPostString("returndate2");
  8524. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8525. if (dw.Length > 0) lw.Add(dw);
  8526. string finishDate1 = GetPostString("finishdate1");
  8527. string finishDate2 = GetPostString("finishdate2");
  8528. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8529. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8530. string returntype = GetPostString("returntype");
  8531. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8532. string returnvstate = GetPostString("returnvstate");
  8533. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8534. dStruct.Order = "created desc";
  8535. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8536. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8537. writeGridDataTableJson(dStruct.TotalCount, dt);
  8538. }
  8539. public void get_erp_staygoods()
  8540. {
  8541. DataStruct dStruct = GetPostStruct();
  8542. List<string> lw = new List<string>();
  8543. string tid = GetPostString("tid");
  8544. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8545. string shopname = GetPostString("shopname");
  8546. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8547. string wangwang = GetPostString("wangwang");
  8548. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8549. string customer = GetPostString("customer");
  8550. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8551. string returndate1 = GetPostString("returndate1");
  8552. string returndate2 = GetPostString("returndate2");
  8553. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8554. if (dw.Length > 0) lw.Add(dw);
  8555. string finishDate1 = GetPostString("finishdate1");
  8556. string finishDate2 = GetPostString("finishdate2");
  8557. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8558. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8559. string returnvstate = GetPostString("returnvstate");
  8560. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8561. string persuadetype = GetPostString("persuadetype");
  8562. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8563. string customerOrg = GetPostString("customerOrg");
  8564. if (customerOrg.Length > 0)
  8565. {
  8566. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8567. }
  8568. dStruct.Order = "creata_time desc";
  8569. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8570. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8571. writeGridDataTableJson(dStruct.TotalCount, dt);
  8572. }
  8573. public void upd_erp_staygoods()
  8574. {
  8575. if (UrlPostParmsCheck("id"))
  8576. {
  8577. int eid = GetPostInt("id");
  8578. CeErpStayGoods entity = null;
  8579. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8580. if (entity != null)
  8581. {
  8582. entity.audit_type = 1;
  8583. entity.audit_time = DateTime.Now;
  8584. entity.audit_u_id = CurrentUser.UserID;
  8585. entity.audit_u_name = CurrentUser.UserName;
  8586. entity.Update();
  8587. returnSuccessMsg("审核成功!");
  8588. return;
  8589. }
  8590. returnErrorMsg("找不到订单记录");
  8591. }
  8592. }
  8593. public void upd_erp_stayGoodsback()
  8594. {
  8595. if (UrlPostParmsCheck("id"))
  8596. {
  8597. int eid = GetPostInt("id");
  8598. CeErpStayGoods entity = null;
  8599. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8600. if (entity != null)
  8601. {
  8602. entity.audit_text = GetPostString("reason");
  8603. entity.audit_type = 2;
  8604. entity.audit_time = DateTime.Now;
  8605. entity.audit_u_id = CurrentUser.UserID;
  8606. entity.audit_u_name = CurrentUser.UserName;
  8607. entity.Update();
  8608. returnSuccessMsg("退回成功!");
  8609. return;
  8610. }
  8611. returnErrorMsg("找不到订单记录");
  8612. }
  8613. }
  8614. public void upd_erp_returncashverify()
  8615. {
  8616. if (UrlPostParmsCheck("ID"))
  8617. {
  8618. int eid = GetPostInt("ID");
  8619. CeErpReturnCash entity = null;
  8620. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8621. if (entity != null)
  8622. {
  8623. entity.cashstate = 1;
  8624. entity.verifytime = DateTime.Now;
  8625. entity.verifyuserid = CurrentUser.UserID;
  8626. entity.Update();
  8627. returnSuccessMsg("审核成功!");
  8628. return;
  8629. }
  8630. returnErrorMsg("找不到订单记录");
  8631. }
  8632. }
  8633. public void upd_all_erp_returncashverify()
  8634. {
  8635. if (UrlPostParmsCheck("ID"))
  8636. {
  8637. String[] list = GetPostString("ID").Split(',');
  8638. CeErpReturnCash entity = null;
  8639. for (int i = 0; i < list.Length; i++)
  8640. {
  8641. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8642. if (entity != null)
  8643. {
  8644. if (entity.cashstate == 1)
  8645. {
  8646. returnErrorMsg("已审核过的订单不需要在审核!");
  8647. return;
  8648. }
  8649. entity.cashstate = 1;
  8650. entity.verifytime = DateTime.Now;
  8651. entity.verifyuserid = CurrentUser.UserID;
  8652. entity.Update();
  8653. }
  8654. }
  8655. returnSuccessMsg("审核成功!");
  8656. return;
  8657. }
  8658. }
  8659. public void upd_erp_returncashback()
  8660. {
  8661. if (UrlPostParmsCheck("ID"))
  8662. {
  8663. int eid = GetPostInt("ID");
  8664. CeErpReturnCash entity = null;
  8665. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8666. if (entity != null)
  8667. {
  8668. entity.backreason = GetPostString("reason");
  8669. entity.cashstate = 2;
  8670. entity.verifytime = DateTime.Now;
  8671. entity.verifyuserid = CurrentUser.UserID;
  8672. entity.Update();
  8673. returnSuccessMsg("退回成功!");
  8674. return;
  8675. }
  8676. returnErrorMsg("找不到订单记录");
  8677. }
  8678. }
  8679. public void upd_erp_returnprice()
  8680. {
  8681. if (UrlPostParmsCheck("ID"))
  8682. {
  8683. int eid = GetPostInt("ID");
  8684. CeErpReturnCash entity = null;
  8685. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8686. if (entity != null)
  8687. {
  8688. if (entity.cashstate == 1)
  8689. {
  8690. returnErrorMsg("审核通过了不能改");
  8691. return;
  8692. }
  8693. entity.returnprice = GetPostDouble("returnprice");
  8694. entity.Update();
  8695. returnSuccessMsg("修改成功!");
  8696. return;
  8697. }
  8698. returnErrorMsg("找不到订单记录");
  8699. }
  8700. }
  8701. public void del_erp_returncash()
  8702. {
  8703. if (UrlPostParmsCheck("ID"))
  8704. {
  8705. int eid = GetPostInt("ID");
  8706. CeErpReturnCash.Del(eid);
  8707. returnSuccessMsg("操作成功");
  8708. return;
  8709. }
  8710. }
  8711. public void test_for_do_sql()
  8712. {
  8713. string sql = GetPostString("sqlstr");
  8714. if (sql.Length > 0)
  8715. {
  8716. try
  8717. {
  8718. DbHelper.DbConn.ExecuteNonQuery(sql);
  8719. var res_obj = new
  8720. {
  8721. data = "成功",
  8722. };
  8723. string ro_json = JsonConvert.SerializeObject(res_obj);
  8724. returnSuccess(ro_json);
  8725. }
  8726. catch (Exception ex)
  8727. {
  8728. var res_obj = new
  8729. {
  8730. data = ex.Message,
  8731. };
  8732. string ro_json = JsonConvert.SerializeObject(res_obj);
  8733. returnSuccess(ro_json);
  8734. }
  8735. }
  8736. }
  8737. public void get_user_info()
  8738. {
  8739. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8740. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8741. }
  8742. public void get_total_data()
  8743. {
  8744. int userId = CurrentUser.UserID;
  8745. string sql = "";
  8746. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8747. {
  8748. 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);
  8749. }
  8750. else
  8751. {
  8752. 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 " +
  8753. "(select ID from CE_ErpUser where ID = {0}) d " +
  8754. "left join " +
  8755. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8756. ") a on d.ID = a.id left join " +
  8757. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8758. ") b on a.id = b.id1 left join" +
  8759. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8760. ") c on a.id = c.id2;", userId);
  8761. }
  8762. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8763. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8764. }
  8765. public void get_date_area_total_data2()
  8766. {
  8767. int userId = CurrentUser.UserID;
  8768. string date_type = GetPostString("timetype");
  8769. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8770. string sql = "";
  8771. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8772. {
  8773. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8774. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8775. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8776. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8777. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8778. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8779. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8780. ") a on e.ID = a.id left join " +
  8781. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8782. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8783. ") b on a.id = b.id1 " +
  8784. "left join " +
  8785. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8786. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8787. ") c on a.id = c.id2 " +
  8788. "left join " +
  8789. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8790. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8791. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8792. }
  8793. else
  8794. {
  8795. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8796. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8797. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8798. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8799. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8800. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8801. ") a on e.ID = a.id left join " +
  8802. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8803. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8804. ") c on a.id = c.id2 " +
  8805. "left join " +
  8806. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8807. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8808. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8809. }
  8810. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8811. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8812. }
  8813. public void get_date_area_total_data()
  8814. {
  8815. int userId = CurrentUser.UserID;
  8816. string date_type = GetPostString("timetype");
  8817. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8818. string date1 = searchDT[0].ToString();
  8819. string date2 = searchDT[1].ToString();
  8820. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8821. {
  8822. SqlParameter[] sqlParameter ={
  8823. new SqlParameter("@userId", SqlDbType.Int,4),
  8824. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8825. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8826. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8827. };
  8828. sqlParameter[0].Value = userId;
  8829. sqlParameter[1].Value = date1;
  8830. sqlParameter[2].Value = date2;
  8831. sqlParameter[3].Direction = ParameterDirection.Output;
  8832. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8833. string res = sqlParameter[3].Value.ToString();
  8834. var res_obj = new
  8835. {
  8836. data = res
  8837. };
  8838. string ro_json = JsonConvert.SerializeObject(res_obj);
  8839. returnSuccess(ro_json);
  8840. }
  8841. else
  8842. {
  8843. SqlParameter[] sqlParameter ={
  8844. new SqlParameter("@userId", SqlDbType.Int,4),
  8845. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8846. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8847. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8848. };
  8849. sqlParameter[0].Value = userId;
  8850. sqlParameter[1].Value = date1;
  8851. sqlParameter[2].Value = date2;
  8852. sqlParameter[3].Direction = ParameterDirection.Output;
  8853. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8854. string res = sqlParameter[3].Value.ToString();
  8855. var res_obj = new
  8856. {
  8857. data = res
  8858. };
  8859. string ro_json = JsonConvert.SerializeObject(res_obj);
  8860. returnSuccess(ro_json);
  8861. }
  8862. //writeGridDataViewJson(dt.Rows.Count, dv);
  8863. }
  8864. public void get_order_list()
  8865. {
  8866. string strFields = GetPostString("paraFields");
  8867. string strOrder = GetPostString("paraOrder");
  8868. string strWhere = GetPostString("paraWhere");
  8869. string strPageSize = GetPostString("paraPageSize");
  8870. DataStruct dStruct = GetPostStruct();
  8871. dStruct.PageSize = int.Parse(strPageSize);
  8872. dStruct.Fileds = strFields;
  8873. dStruct.Order = strOrder;
  8874. dStruct.MainWhere = strWhere;
  8875. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8876. writeGridDataTableJson(dStruct.TotalCount, dt);
  8877. }
  8878. ////获取待开始订单列表
  8879. //public void get_wait_design_order_list()
  8880. //{
  8881. // string date_type = GetPostString("date_type");
  8882. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8883. // DataStruct dStruct = GetPostStruct();
  8884. // dStruct.PageSize = 1000;
  8885. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8886. // List<string> lw = new List<string>();
  8887. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8888. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8889. // dStruct.Order = "WaitDesignTime asc";
  8890. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8891. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8892. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8893. //}
  8894. //获取完成单量排名
  8895. public void get_finish_order_count_ranking()
  8896. {
  8897. /* string date_type = GetPostString("date_type");
  8898. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8899. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8900. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8901. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8902. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8903. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8904. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8905. writeGridDataTableJson(0, new DataTable());
  8906. }
  8907. public void get_finish_order_amount_ranking()
  8908. {
  8909. /*string date_type = GetPostString("date_type");
  8910. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8911. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8912. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8913. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8914. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8915. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8916. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8917. writeGridDataTableJson(0, new DataTable());
  8918. }
  8919. public void get_finish_refund_count_ranking()
  8920. {
  8921. string date_type = GetPostString("date_type");
  8922. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8923. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8924. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8925. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8926. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8927. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8928. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8929. writeGridDataTableJson(dt.Rows.Count, dt);
  8930. }
  8931. public void get_finish_refund_amount_ranking()
  8932. {
  8933. string date_type = GetPostString("date_type");
  8934. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8935. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8936. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8937. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8938. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8939. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8940. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8941. writeGridDataTableJson(dt.Rows.Count, dt);
  8942. }
  8943. public void set_erp_finishorder_director()
  8944. {
  8945. if (UrlPostParmsCheck("ctid"))
  8946. {
  8947. string eid = GetPostString("ctid");
  8948. CeErpTradeCell entity = null;
  8949. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8950. if (entity != null)
  8951. {
  8952. entity.OrderState = 8;
  8953. entity.Update();
  8954. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8955. returnSuccessMsg("操作成功!");
  8956. return;
  8957. }
  8958. returnErrorMsg("找不到记录");
  8959. }
  8960. }
  8961. public void get_erp_placeregistlist()
  8962. {
  8963. DataStruct dStruct = GetPostStruct();
  8964. List<string> lw = new List<string>();
  8965. string outsid = GetPostString("outsid");
  8966. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8967. string memo = GetPostString("memo");
  8968. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8969. string filename = GetPostString("filename");
  8970. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8971. string islate = GetPostString("islate");
  8972. if (islate.Length > 0)
  8973. {
  8974. if (islate == "1")
  8975. lw.Add(string.Format("OutLate>0"));
  8976. else
  8977. lw.Add(string.Format("OutLate=0"));
  8978. }
  8979. string placedate1 = GetPostString("placedate1");
  8980. string placedate2 = GetPostString("placedate2");
  8981. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8982. if (dw.Length > 0) lw.Add(dw);
  8983. string deliveryDate1 = GetPostString("deliverydate1");
  8984. string deliveryDate2 = GetPostString("deliverydate2");
  8985. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8986. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8987. dStruct.Order = "ID desc";
  8988. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8989. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8990. writeGridDataTableJson(dStruct.TotalCount, dt);
  8991. }
  8992. public void ins_erp_placeregist()
  8993. {
  8994. if (UrlPostParmsCheck("id"))
  8995. {
  8996. string eid = GetPostString("id");
  8997. CeErpPlaceRegister entity = null;
  8998. if (eid == "0")//新增
  8999. {
  9000. entity = new CeErpPlaceRegister();
  9001. string xdTime = GetPostString("placeTime");
  9002. if (xdTime.Length > 0)
  9003. {
  9004. entity.PlactTime = Convert.ToDateTime(xdTime);
  9005. }
  9006. string fhTime = GetPostString("deliveryTime");
  9007. if (fhTime.Length > 0)
  9008. {
  9009. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9010. }
  9011. string preTime = GetPostString("preOutTime");
  9012. if (preTime.Length > 0)
  9013. {
  9014. entity.PreOutTime = Convert.ToDateTime(preTime);
  9015. }
  9016. entity.DeliveryCount = GetPostInt("deliveryCount");
  9017. entity.ReceiveCount = GetPostInt("receiveCount");
  9018. entity.OutSid = GetPostString("outSid");
  9019. entity.FileName = GetPostString("fileName");
  9020. entity.Memo = GetPostString("memo");
  9021. entity.AddUserId = CurrentUser.UserID;
  9022. entity.CreateTime = DateTime.Now;
  9023. entity.Img = GetPostString("img");
  9024. entity.Supplier = GetPostInt("supplier");
  9025. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9026. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9027. {
  9028. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9029. DateTime dt2 = (DateTime)entity.PreOutTime;
  9030. TimeSpan span = dt1.Subtract(dt2);
  9031. if (span.Days > 0)
  9032. {
  9033. entity.OutLate = span.Days;
  9034. }
  9035. }
  9036. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9037. entity.Create();
  9038. returnSuccessMsg("添加成功!");
  9039. return;
  9040. }
  9041. else //修改
  9042. {
  9043. entity = CeErpPlaceRegister.Get(eid);
  9044. if (entity != null)
  9045. {
  9046. string xdTime = GetPostString("placeTime");
  9047. if (xdTime.Length > 0)
  9048. {
  9049. entity.PlactTime = Convert.ToDateTime(xdTime);
  9050. }
  9051. string fhTime = GetPostString("deliveryTime");
  9052. if (fhTime.Length > 0)
  9053. {
  9054. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9055. }
  9056. string preTime = GetPostString("preOutTime");
  9057. if (preTime.Length > 0)
  9058. {
  9059. entity.PreOutTime = Convert.ToDateTime(preTime);
  9060. }
  9061. entity.DeliveryCount = GetPostInt("deliveryCount");
  9062. entity.ReceiveCount = GetPostInt("receiveCount");
  9063. if (entity.DeliveryCount == entity.ReceiveCount)
  9064. {
  9065. entity.CurState = "已完成";
  9066. }
  9067. else
  9068. {
  9069. entity.CurState = "未完成";
  9070. }
  9071. entity.OutSid = GetPostString("outSid");
  9072. entity.FileName = GetPostString("fileName");
  9073. entity.Memo = GetPostString("memo");
  9074. entity.Img = GetPostString("img");
  9075. entity.Supplier = GetPostInt("supplier");
  9076. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9077. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9078. {
  9079. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9080. DateTime dt2 = (DateTime)entity.PreOutTime;
  9081. TimeSpan span = dt1.Subtract(dt2);
  9082. if (span.Days > 0)
  9083. {
  9084. entity.OutLate = span.Days;
  9085. }
  9086. }
  9087. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9088. entity.Update();
  9089. returnSuccessMsg("修改成功");
  9090. return;
  9091. }
  9092. returnErrorMsg("找不到对应的记录");
  9093. return;
  9094. }
  9095. }
  9096. returnErrorMsg("缺少必要参数");
  9097. }
  9098. public void del_erp_placeregist()
  9099. {
  9100. string eid = GetPostString("id");
  9101. CeErpPlaceRegister.Del(eid);
  9102. returnSuccessMsg("删除成功!");
  9103. return;
  9104. }
  9105. public void ins_erp_placeregistbyorder()
  9106. {
  9107. string ctid = GetPostString("ctid");
  9108. if (ctid.Length > 0)
  9109. {
  9110. StringBuilder sql = new StringBuilder();
  9111. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9112. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9113. if (dt.Rows.Count > 0)
  9114. {
  9115. foreach (DataRow dr in dt.Rows)
  9116. {
  9117. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9118. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9119. entity.AddUserId = CurrentUser.UserID;
  9120. entity.tid = dr["tid"].ToString();
  9121. entity.Did = Convert.ToString(dr["ctid"]);
  9122. entity.splitTag = dr["SplitTag"].ToString();
  9123. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9124. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9125. if (pre_ctid.Length > 0)
  9126. {
  9127. sellmemo = sellmemo.Replace(pre_ctid, "");
  9128. }
  9129. sellmemo = sellmemo.Replace("[", "");
  9130. sellmemo = sellmemo.Replace("]", "");
  9131. entity.FileName = sellmemo;
  9132. string count = dr["ProductCount"].ToString();
  9133. int usecount = commonHelper.getIntCountFromString(count);
  9134. entity.DeliveryCount = usecount;
  9135. entity.CurState = "未完成";
  9136. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9137. {
  9138. entity.Supplier = 24;//dl手提袋定制
  9139. }
  9140. else
  9141. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9142. entity.CreateTime = DateTime.Now;
  9143. entity.Create();
  9144. }
  9145. returnSuccessMsg("操作成功");
  9146. return;
  9147. }
  9148. returnErrorMsg("没有找到对应订单");
  9149. return;
  9150. }
  9151. returnErrorMsg("缺少订单编号");
  9152. return;
  9153. }
  9154. public void get_erp_persuadelist()
  9155. {
  9156. DataStruct dStruct = GetPostStruct();
  9157. List<string> lw = new List<string>();
  9158. string ctid = GetPostString("ctid");
  9159. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9160. string shopname = GetPostString("shopname");
  9161. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9162. string buyernick = GetPostString("buyer_nick");
  9163. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9164. string customer = GetPostString("customer");
  9165. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9166. string returndate1 = GetPostString("returndate1");
  9167. string returndate2 = GetPostString("returndate2");
  9168. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9169. if (dw.Length > 0) lw.Add(dw);
  9170. string finishDate1 = GetPostString("finishdate1");
  9171. string finishDate2 = GetPostString("finishdate2");
  9172. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9173. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9174. string persuadetype = GetPostString("persuadetype");
  9175. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9176. string returnvstate = GetPostString("returnvstate");
  9177. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9178. dStruct.Order = "created desc";
  9179. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9180. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9181. writeGridDataTableJson(dStruct.TotalCount, dt);
  9182. }
  9183. public void upd_erp_returnpersuadeback()
  9184. {
  9185. if (UrlPostParmsCheck("ID"))
  9186. {
  9187. int eid = GetPostInt("ID");
  9188. CeErpPersuade entity = null;
  9189. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9190. if (entity != null)
  9191. {
  9192. entity.backreason = GetPostString("reason");
  9193. entity.pstate = 2;
  9194. entity.verifytime = DateTime.Now;
  9195. entity.verifyuserid = CurrentUser.UserID;
  9196. entity.Update();
  9197. returnSuccessMsg("退回成功!");
  9198. return;
  9199. }
  9200. returnErrorMsg("找不到订单记录");
  9201. }
  9202. }
  9203. public void upd_erp_returnpersuadeverify()
  9204. {
  9205. if (UrlPostParmsCheck("ID"))
  9206. {
  9207. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9208. {
  9209. returnErrorMsg("暂无权限审核");
  9210. return;
  9211. }
  9212. int eid = GetPostInt("ID");
  9213. CeErpPersuade entity = null;
  9214. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9215. if (entity != null)
  9216. {
  9217. entity.pstate = 1;
  9218. entity.verifytime = DateTime.Now;
  9219. entity.verifyuserid = CurrentUser.UserID;
  9220. entity.Update();
  9221. returnSuccessMsg("审核成功!");
  9222. return;
  9223. }
  9224. returnErrorMsg("找不到订单记录");
  9225. }
  9226. }
  9227. public void del_erp_persuade()
  9228. {
  9229. if (UrlPostParmsCheck("ID"))
  9230. {
  9231. int eid = GetPostInt("ID");
  9232. CeErpPersuade.Del(eid);
  9233. returnSuccessMsg("操作成功");
  9234. return;
  9235. }
  9236. }
  9237. public void get_erp_oldcustoupload()
  9238. {
  9239. DataStruct dStruct = GetPostStruct();
  9240. List<string> lw = new List<string>();
  9241. string buyernick = GetPostString("buyer_nick");
  9242. if (buyernick.Length > 0)
  9243. {
  9244. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9245. }
  9246. else
  9247. return;
  9248. dStruct.Order = "pay_time desc";
  9249. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9250. DataTable dt = null;
  9251. dt = WebCache.GetData("view_erptradecell", dStruct);
  9252. writeGridDataTableJson(dStruct.TotalCount, dt);
  9253. }
  9254. public void get_erp_checkorderlist()
  9255. {
  9256. DataStruct dStruct = GetPostStruct();
  9257. List<string> lw = new List<string>();
  9258. string tid = GetPostString("ctid");
  9259. if (tid.Length > 0)
  9260. {
  9261. string select_tid = getTidByCtid(tid);
  9262. lw.Add(string.Format("tid='{0}'", select_tid));
  9263. }
  9264. string shopname = GetPostString("shopname");
  9265. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9266. string buyernick = GetPostString("buyer_nick");
  9267. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9268. string customer = GetPostString("customer");
  9269. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9270. string design = GetPostString("design");
  9271. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9272. string orderState = GetPostString("orderState");
  9273. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9274. string address = GetPostString("address");
  9275. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9276. string sellermemo = GetPostString("seller_memo");
  9277. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9278. string supplier = GetPostString("supplier");
  9279. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9280. {
  9281. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9282. }
  9283. else
  9284. {
  9285. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9286. }
  9287. string date1 = GetPostString("date1");
  9288. string date2 = GetPostString("date2");
  9289. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9290. if (dw.Length > 0) lw.Add(dw);
  9291. string placedate1 = GetPostString("placedate1");
  9292. string placedate2 = GetPostString("placedate2");
  9293. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9294. if (fdw.Length > 0) lw.Add(fdw);
  9295. string price1 = GetPostString("price1");
  9296. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9297. string price2 = GetPostString("price2");
  9298. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9299. string checkst = GetPostString("checkstate");
  9300. if (checkst.Length > 0 && "10".Equals(checkst))
  9301. {
  9302. lw.Add(string.Format("CheckOut>0"));
  9303. }
  9304. else
  9305. {
  9306. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9307. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9308. }
  9309. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9310. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9311. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9312. writeGridDataTableJson(dStruct.TotalCount, dt);
  9313. }
  9314. public void ins_erp_startCheck()
  9315. {
  9316. if (UrlPostParmsCheck("ctid"))
  9317. {
  9318. string eid = GetPostString("ctid");
  9319. CeErpTradeCell entity = null;
  9320. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9321. if (entity != null)
  9322. {
  9323. entity.MemoOpt = 4;
  9324. entity.UpdateTime = DateTime.Now;
  9325. entity.Update();
  9326. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9327. CeErpSukuraData.createInfo(entity.ctid, 6);
  9328. returnSuccessMsg("操作成功!");
  9329. return;
  9330. }
  9331. returnErrorMsg("找不到记录");
  9332. }
  9333. }
  9334. public void upd_erp_sendXlw()
  9335. {
  9336. if (UrlPostParmsCheck("ctid"))
  9337. {
  9338. string eid = GetPostString("ctid");
  9339. CeErpTradeCell entity = null;
  9340. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9341. if (entity != null)
  9342. {
  9343. if (entity.IsSendGift == 1)
  9344. {
  9345. returnErrorMsg("请勿重复标记");
  9346. return;
  9347. }
  9348. entity.IsSendGift = 1;
  9349. entity.Update();
  9350. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9351. returnSuccessMsg("操作成功!");
  9352. return;
  9353. }
  9354. returnErrorMsg("找不到记录");
  9355. }
  9356. }
  9357. public void cancel_sendXlw()
  9358. {
  9359. if (UrlPostParmsCheck("ctid"))
  9360. {
  9361. string eid = GetPostString("ctid");
  9362. CeErpTradeCell entity = null;
  9363. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9364. if (entity != null)
  9365. {
  9366. if (entity.IsSendGift == 0)
  9367. {
  9368. returnErrorMsg("未标记小礼物");
  9369. return;
  9370. }
  9371. entity.IsSendGift = 0;
  9372. entity.Update();
  9373. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9374. returnSuccessMsg("操作成功!");
  9375. return;
  9376. }
  9377. returnErrorMsg("找不到记录");
  9378. }
  9379. }
  9380. public void get_erp_designbill()
  9381. {
  9382. DataStruct dStruct = GetPostStruct();
  9383. List<string> lw = new List<string>();
  9384. int isMy = GetInt("my");
  9385. if (isMy == 1)
  9386. {
  9387. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9388. }
  9389. string tid = GetPostString("tid");
  9390. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9391. string userName = GetPostString("design");
  9392. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9393. string price1 = GetPostString("price1");
  9394. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9395. string price2 = GetPostString("price2");
  9396. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9397. string rePrice1 = GetPostString("rePrice1");
  9398. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9399. string rePrice2 = GetPostString("rePrice2");
  9400. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9401. string designerType = GetPostString("designerType");
  9402. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9403. string orderState = GetPostString("orderState");
  9404. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9405. string endTime1 = GetPostString("endTime1");
  9406. string endTime2 = GetPostString("endTime2");
  9407. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9408. if (dw.Length > 0) lw.Add(dw);
  9409. string isDk = GetPostString("isDk");
  9410. if (isDk == "1")
  9411. {
  9412. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9413. }
  9414. else if (isDk == "0")
  9415. {
  9416. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9417. }
  9418. dStruct.Order = "oid, create_time desc";
  9419. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9420. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9421. writeGridDataTableJson(dStruct.TotalCount, dt);
  9422. }
  9423. public void upd_erp_designerbill()
  9424. {
  9425. if (UrlPostParmsCheck("ID"))
  9426. {
  9427. string eid = GetPostString("ID");
  9428. CeErpDesignerBill entity = null;
  9429. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9430. if (entity != null)
  9431. {
  9432. if (GetPostDouble("designerpirce") > 0)
  9433. {
  9434. entity.realPrice = GetPostDouble("designerpirce");
  9435. entity.update_time = DateTime.Now;
  9436. entity.update_u_id = CurrentUser.UserID;
  9437. entity.update_u_name = CurrentUser.UserName;
  9438. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9439. entity.Update();
  9440. returnSuccessMsg("操作成功!");
  9441. return;
  9442. }
  9443. else
  9444. {
  9445. entity.price = GetPostDouble("price");
  9446. entity.update_time = DateTime.Now;
  9447. entity.update_u_id = CurrentUser.UserID;
  9448. entity.update_u_name = CurrentUser.UserName;
  9449. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9450. entity.Update();
  9451. returnSuccessMsg("操作成功!");
  9452. return;
  9453. }
  9454. }
  9455. returnErrorMsg("找不到记录");
  9456. }
  9457. }
  9458. public void audit_erp_designerbill()
  9459. {
  9460. if (UrlPostParmsCheck("ID"))
  9461. {
  9462. string eid = GetPostString("ID");
  9463. CeErpDesignerBill entity = null;
  9464. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9465. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9466. if (entity != null)
  9467. {
  9468. entity.realPrice = GetPostDouble("designerpirce");
  9469. entity.update_time = DateTime.Now;
  9470. entity.update_u_id = CurrentUser.UserID;
  9471. entity.update_u_name = CurrentUser.UserName;
  9472. entity.isAudit = 1;
  9473. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9474. entity.Update();
  9475. if (orderEntity != null)
  9476. {
  9477. orderEntity.IsReadTag = 3;
  9478. orderEntity.Update();
  9479. }
  9480. returnSuccessMsg("操作成功!");
  9481. return;
  9482. }
  9483. returnErrorMsg("找不到记录");
  9484. }
  9485. }
  9486. public void all_audit_erp_designerbill()
  9487. {
  9488. if (UrlPostParmsCheck("idList"))
  9489. {
  9490. string[] list = GetPostString("idList").Split(',');
  9491. CeErpDesignerBill entity = null;
  9492. for (int i = 0; i < list.Length; i++)
  9493. {
  9494. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9495. if (entity == null) return;
  9496. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9497. if (orderEntity == null) return;
  9498. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9499. entity.update_time = DateTime.Now;
  9500. entity.update_u_id = CurrentUser.UserID;
  9501. entity.update_u_name = CurrentUser.UserName;
  9502. entity.isAudit = 1;
  9503. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9504. entity.Update();
  9505. orderEntity.IsReadTag = 3;
  9506. orderEntity.Update();
  9507. }
  9508. returnSuccessMsg("操作成功!");
  9509. return;
  9510. }
  9511. }
  9512. public void get_erp_sameorders()
  9513. {
  9514. if (UrlPostParmsCheck("ctid"))
  9515. {
  9516. string eid = GetPostString("ctid");
  9517. CeErpTradeCell entity = null;
  9518. entity = CeErpTradeCell.GetByCtid(eid);
  9519. if (entity != null)
  9520. {
  9521. StringBuilder sql = new StringBuilder();
  9522. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9523. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9524. var res = new
  9525. {
  9526. data = dt.Rows.Count
  9527. };
  9528. string ro_jsond = JsonConvert.SerializeObject(res);
  9529. returnSuccess(ro_jsond);
  9530. return;
  9531. }
  9532. returnErrorMsg("未找到订单");
  9533. return;
  9534. }
  9535. returnErrorMsg("缺少必要的参数");
  9536. }
  9537. public void get_erp_islasthavesameorder()
  9538. {
  9539. if (UrlPostParmsCheck("ctid"))
  9540. {
  9541. string eid = GetPostString("ctid");
  9542. string[] ctidList = eid.Split(',');
  9543. StringBuilder sql = new StringBuilder();
  9544. string tisCtid = "";
  9545. foreach (string ctid in ctidList)
  9546. {
  9547. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9548. if (entity != null)
  9549. {
  9550. sql = new StringBuilder();
  9551. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9552. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9553. if (dth.Rows.Count > 0)
  9554. {
  9555. tisCtid += entity.ctid;
  9556. tisCtid += ",";
  9557. }
  9558. }
  9559. }
  9560. if (tisCtid.Length > 0)
  9561. {
  9562. var res = new
  9563. {
  9564. data = tisCtid
  9565. };
  9566. string ro_jsond = JsonConvert.SerializeObject(res);
  9567. returnSuccess(ro_jsond);
  9568. }
  9569. else
  9570. {
  9571. var res = new
  9572. {
  9573. data = ""
  9574. };
  9575. string ro_jsond = JsonConvert.SerializeObject(res);
  9576. returnSuccess(ro_jsond);
  9577. }
  9578. return;
  9579. }
  9580. returnErrorMsg("缺少必要的参数");
  9581. }
  9582. public void file_client_down_url()
  9583. {
  9584. if (!UrlPostParmsCheck("userId"))
  9585. {
  9586. returnErrorMsg("缺少必要的参数");
  9587. }
  9588. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9589. }
  9590. public void checkout_form_data()
  9591. {
  9592. if (!UrlPostParmsCheck("tid"))
  9593. {
  9594. returnErrorMsg("缺少必要的参数");
  9595. }
  9596. string tid = GetPostString("tid");
  9597. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9598. if (ceErpOrderFormData != null)
  9599. {
  9600. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9601. returnSuccess(ro_jsond);
  9602. return;
  9603. }
  9604. returnErrorMsg("尚未有文件!");
  9605. }
  9606. public void back_supplier_audit()
  9607. {
  9608. int userId = CurrentUser.UserID;
  9609. StringBuilder sql = new StringBuilder();
  9610. 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);
  9611. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9612. if (dt.Rows.Count > 0)
  9613. {
  9614. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9615. }
  9616. else
  9617. {
  9618. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9619. }
  9620. }
  9621. public void back_supplier_query()
  9622. {
  9623. string eid = GetPostString("ctid");
  9624. if (eid != "")
  9625. {
  9626. StringBuilder sql = new StringBuilder();
  9627. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9628. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9629. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9630. }
  9631. else
  9632. {
  9633. returnErrorMsg("找不到订单记录");
  9634. return;
  9635. }
  9636. }
  9637. public void verified_to_order()
  9638. {
  9639. int userId = CurrentUser.UserID;
  9640. StringBuilder sql = new StringBuilder();
  9641. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9642. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9643. if (dt.Rows.Count > 0)
  9644. {
  9645. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9646. }
  9647. else
  9648. {
  9649. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9650. }
  9651. }
  9652. public void upd_supplier_audit()
  9653. {
  9654. if (UrlPostParmsCheck("ctid"))
  9655. {
  9656. string eid = GetPostString("ctid");
  9657. string reason = GetPostString("returnreason");
  9658. CeErpTradeCell entity = null;
  9659. CeWithdraw withdraw = null;
  9660. withdraw = CeWithdraw.GetByTid(eid);
  9661. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9662. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9663. {
  9664. if (withdraw != null)
  9665. {
  9666. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9667. {
  9668. returnSuccessMsg("您没有权限操作!");
  9669. return;
  9670. }
  9671. else
  9672. {
  9673. if (reason.Equals("1"))
  9674. {
  9675. if (entity.OrderState == -1)
  9676. {
  9677. if (entity.FinishPlaceTime == null)
  9678. {
  9679. entity.OrderState = 2;
  9680. }
  9681. else
  9682. {
  9683. entity.OrderState = 6;
  9684. }
  9685. }
  9686. entity.Update();
  9687. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9688. if (withdraw != null)
  9689. {
  9690. withdraw.status = int.Parse(reason);
  9691. withdraw.Update();
  9692. }
  9693. returnSuccessMsg("操作成功!");
  9694. return;
  9695. }
  9696. else
  9697. {
  9698. withdraw.status = int.Parse(reason);
  9699. withdraw.acknowledgingtime = DateTime.Now;
  9700. withdraw.Update();
  9701. returnSuccessMsg("查看详细请点击线下订单查询");
  9702. return;
  9703. }
  9704. }
  9705. }
  9706. // 第一个字符是 'N'
  9707. }
  9708. if (eid[0] != 'N')
  9709. {
  9710. }
  9711. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9712. {
  9713. entity.IsVerifyToSupplier = false;
  9714. entity.IsReturn = 1;
  9715. entity.ReturnTime = DateTime.Now;
  9716. entity.ReturnReason = reason;
  9717. if (entity.OrderState == 6)
  9718. {
  9719. entity.OrderState = 5;
  9720. }
  9721. entity.Update();
  9722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9723. if (withdraw != null)
  9724. {
  9725. withdraw.status = int.Parse(reason);
  9726. withdraw.Update();
  9727. }
  9728. returnSuccessMsg("操作成功!");
  9729. return;
  9730. }
  9731. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9732. {
  9733. ;
  9734. if (withdraw != null)
  9735. {
  9736. withdraw.status = int.Parse(reason);
  9737. withdraw.acknowledgingtime = DateTime.Now;
  9738. withdraw.Update();
  9739. returnSuccessMsg("供应商取消撤回!");
  9740. return;
  9741. }
  9742. }
  9743. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9744. {
  9745. if (entity.OrderState == -1)
  9746. {
  9747. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9748. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id))
  9749. {
  9750. returnErrorMsg("订单spu没有确认无法通过审核!");
  9751. return;
  9752. }
  9753. if (entity.FinishPlaceTime == null)
  9754. {
  9755. entity.OrderState = 2;
  9756. }
  9757. else
  9758. {
  9759. entity.OrderState = 3;
  9760. }
  9761. commonHelper.getCytPrice(entity);
  9762. }
  9763. entity.Update();
  9764. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9765. if (withdraw != null)
  9766. {
  9767. withdraw.status = int.Parse(reason);
  9768. withdraw.Update();
  9769. }
  9770. returnSuccessMsg("操作成功!");
  9771. return;
  9772. }
  9773. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9774. {
  9775. if (withdraw == null)
  9776. {
  9777. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9778. return;
  9779. }
  9780. }
  9781. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9782. {
  9783. if (withdraw != null)
  9784. {
  9785. withdraw.status = int.Parse(reason);
  9786. withdraw.acknowledgingtime = DateTime.Now;
  9787. withdraw.Update();
  9788. returnSuccessMsg("查看详细请点击线下订单查询");
  9789. return;
  9790. }
  9791. }
  9792. return;
  9793. }
  9794. }
  9795. //校验报价
  9796. public void refund_order_tip()
  9797. {
  9798. int userid = CurrentUser.UserID;
  9799. int sectionId = CurrentUser.UserPost.OrgID;
  9800. StringBuilder sql = new StringBuilder();
  9801. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9802. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9803. List<string> ids = new List<string>();
  9804. if (dth.Rows.Count > 0)
  9805. {
  9806. foreach (DataRow dr in dth.Rows)
  9807. {
  9808. ids.Add(dr["ID"].ToString());
  9809. }
  9810. try
  9811. {
  9812. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9813. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9814. }
  9815. catch (Exception ex)
  9816. {
  9817. }
  9818. }
  9819. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9820. }
  9821. public void refund_order_Design()
  9822. {
  9823. int userid = CurrentUser.UserID;
  9824. int sectionId = CurrentUser.UserPost.OrgID;
  9825. StringBuilder sql = new StringBuilder();
  9826. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9827. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9828. List<string> ids = new List<string>();
  9829. if (dth.Rows.Count > 0)
  9830. {
  9831. foreach (DataRow dr in dth.Rows)
  9832. {
  9833. ids.Add(dr["ID"].ToString());
  9834. }
  9835. try
  9836. {
  9837. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9838. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9839. }
  9840. catch (Exception ex)
  9841. {
  9842. }
  9843. }
  9844. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9845. }
  9846. public void change_order_info()
  9847. {
  9848. int userid = CurrentUser.UserID;
  9849. StringBuilder sql = new StringBuilder();
  9850. 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);
  9851. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9852. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9853. }
  9854. public void change_win_mome()
  9855. {
  9856. if (UrlPostParmsCheck("id,ctid"))
  9857. {
  9858. string id = GetPostString("id");
  9859. string ctid = GetPostString("ctid");
  9860. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9861. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9862. if (ce == null || ceErpMessageTip == null)
  9863. {
  9864. returnSuccessMsg("未找到对应的订单!");
  9865. return;
  9866. }
  9867. if (ce.OrderState >= 5)
  9868. {
  9869. returnSuccessMsg("已上传文件无法修改!");
  9870. return;
  9871. }
  9872. int type = GetPostInt("type");
  9873. string content = GetPostString("content");
  9874. if (type == 0)
  9875. {
  9876. content = content.Replace("(", "(");
  9877. content = content.Replace(")", ")");
  9878. string check = MidStrEx(content, "(", ")").Trim();
  9879. if (string.IsNullOrEmpty(check))
  9880. {
  9881. returnSuccessMsg("文件名格式不正确");
  9882. return;
  9883. }
  9884. }
  9885. ce.seller_memo = content;
  9886. ce.Update();
  9887. ceErpMessageTip.isVisit = true;
  9888. ceErpMessageTip.Update();
  9889. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9890. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9891. ApiVo apiVo = new ApiVo();
  9892. apiVo.orderNumber = ce.ctid;
  9893. apiVo.actionName = "demandDesign";
  9894. apiVo.orderRemarks = content;
  9895. apiVo.demandExamine = type + 1;
  9896. designHelper.API_WorkCore(apiVo);//demandDesign
  9897. returnSuccessMsg("修改成功!");
  9898. }
  9899. }
  9900. public static string MidStrEx(string sourse, string startstr, string endstr)
  9901. {
  9902. string result = string.Empty;
  9903. int startindex, endindex;
  9904. try
  9905. {
  9906. startindex = sourse.IndexOf(startstr);
  9907. if (startindex == -1)
  9908. return result;
  9909. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9910. endindex = tmpstr.IndexOf(endstr);
  9911. if (endindex == -1)
  9912. return result;
  9913. result = tmpstr.Remove(endindex);
  9914. }
  9915. catch (Exception ex)
  9916. {
  9917. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9918. }
  9919. return result;
  9920. }
  9921. public void refund_order_list()
  9922. {
  9923. int userid = CurrentUser.UserID;
  9924. int sectionId = CurrentUser.UserPost.OrgID;
  9925. StringBuilder sql = new StringBuilder();
  9926. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9927. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9928. DataStruct dStruct = GetPostStruct();
  9929. DataTable dt = null;
  9930. List<string> ids = new List<string>();
  9931. List<string> tids = new List<string>();
  9932. if (dth.Rows.Count > 0)
  9933. {
  9934. foreach (DataRow dr in dth.Rows)
  9935. {
  9936. tids.Add("'" + dr["tid"].ToString() + "'");
  9937. ids.Add(dr["id"].ToString());
  9938. }
  9939. try
  9940. {
  9941. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9942. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9943. List<string> lw = new List<string>();
  9944. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9945. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9946. dt = WebCache.GetData("view_orderlist", dStruct);
  9947. }
  9948. catch (Exception ex)
  9949. {
  9950. }
  9951. }
  9952. writeGridDataTableJson(dStruct.TotalCount, dt);
  9953. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9954. }
  9955. //新增
  9956. public void order_batch_downloads()
  9957. {
  9958. string ceid = GetPostString("tid");
  9959. String[] tid = ceid.Split(',');
  9960. order_batch_caiyingtong(tid);
  9961. /* (string success, string errors) = UploadFiles(tid);
  9962. returnSuccessMsg(success + errors);*/
  9963. return;
  9964. }
  9965. //报价接口
  9966. public void Get_To_Quote()
  9967. {
  9968. string ceid = GetPostString("ctid");
  9969. if (ceid != null)
  9970. {
  9971. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9972. if (entity != null)
  9973. {
  9974. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9975. {
  9976. return;
  9977. }
  9978. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9979. double price = 0;
  9980. if (cp == null)
  9981. {
  9982. JObject jsonObject12 = new JObject
  9983. {
  9984. { "UserId", "77886" },
  9985. { "Pwd", "lt666888" },
  9986. { "Filename", entity.seller_memo }
  9987. };
  9988. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9989. JObject jsonObjects1 = JObject.Parse(response1);
  9990. string ms1g = (string)jsonObjects1["msg"];
  9991. if (ms1g == "报价成功")
  9992. {
  9993. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9994. string data = (string)jsonObject1["price"];
  9995. 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 + "');";
  9996. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9997. returnSuccessMsg("获取报价成功:" + data);
  9998. price = Convert.ToDouble(data);
  9999. }
  10000. else
  10001. {
  10002. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10003. return;
  10004. }
  10005. }
  10006. String[] beizhu = entity.seller_memo.Split('-');
  10007. String chanp = "";
  10008. if (beizhu.Length > 0)
  10009. {
  10010. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10011. }
  10012. else
  10013. {
  10014. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10015. }
  10016. JObject jsonObject = new JObject
  10017. {
  10018. { "UserId", "77886" },
  10019. { "Pwd", "lt666888" },
  10020. { "Filename", chanp }
  10021. };
  10022. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10023. JObject jsonObjects = JObject.Parse(response);
  10024. string msg = (string)jsonObjects["msg"];
  10025. if (msg == "报价成功")
  10026. {
  10027. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10028. string data = (string)jsonObject1["price"];
  10029. 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 + "');";
  10030. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10031. returnSuccessMsg("获取报价成功:" + data);
  10032. price = Convert.ToDouble(data);
  10033. }
  10034. else
  10035. {
  10036. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10037. return;
  10038. }
  10039. if (price > 0)
  10040. {
  10041. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10042. if (ceErpTradeCellExtend == null)
  10043. {
  10044. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10045. ceErpTradeCellExtend.ctid = entity.ctid;
  10046. ceErpTradeCellExtend.payment_cyt = price;
  10047. ceErpTradeCellExtend.Create();
  10048. }
  10049. else
  10050. {
  10051. ceErpTradeCellExtend.payment_cyt = price;
  10052. ceErpTradeCellExtend.Update();
  10053. }
  10054. }
  10055. return;
  10056. }
  10057. }
  10058. else
  10059. {
  10060. returnErrorMsg("请至少选择一条数据");
  10061. return;
  10062. }
  10063. }
  10064. //新增
  10065. public void order_To_Supplier()
  10066. {
  10067. string ceid = GetPostString("tid");
  10068. String[] tid = ceid.Split(',');
  10069. if (tid.Length > 0)
  10070. {
  10071. try
  10072. {
  10073. for (int i = 0; i < tid.Length; i++)
  10074. {
  10075. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10076. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10077. entity.SupplierId = suid;
  10078. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10079. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10080. entity.Update();
  10081. }
  10082. }
  10083. catch (Exception ex)
  10084. {
  10085. returnErrorMsg("自动匹配供应商失败");
  10086. return;
  10087. }
  10088. }
  10089. else
  10090. {
  10091. returnErrorMsg("请至少选择一条数据");
  10092. return;
  10093. }
  10094. returnSuccessMsg("自动匹配供应商成功");
  10095. return;
  10096. }
  10097. public (string, string) UploadFiles(string[] urls)
  10098. {
  10099. string success = "";
  10100. string errors = "";
  10101. int userid = CurrentUser.UserID;
  10102. foreach (string url in urls)
  10103. {
  10104. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10105. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10106. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10107. {
  10108. JObject jsonObject = new JObject
  10109. {
  10110. { "Userid", "77886" },
  10111. { "pwd", "cyt86435015" },
  10112. { "content", base64FileContent },
  10113. { "ext", Path.GetExtension(fileName) }
  10114. };
  10115. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10116. JObject jsonObjects = JObject.Parse(response);
  10117. string msg = (string)jsonObjects["msg"];
  10118. if (msg.Equals("上传成功"))
  10119. {
  10120. success += url + " 上传成功";
  10121. }
  10122. else
  10123. {
  10124. errors += url + " 上传失败";
  10125. }
  10126. }
  10127. else
  10128. {
  10129. errors += url + " 格式出现问题";
  10130. }
  10131. }
  10132. if (urls.Length == 0)
  10133. {
  10134. return (success, errors);
  10135. }
  10136. return (success, errors);
  10137. }
  10138. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10139. {
  10140. return true; //总是接受
  10141. }
  10142. public static string HttpPost(string url, string param = null)
  10143. {
  10144. HttpWebRequest request;
  10145. //如果是发送HTTPS请求
  10146. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10147. {
  10148. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10149. request = WebRequest.Create(url) as HttpWebRequest;
  10150. request.ProtocolVersion = HttpVersion.Version10;
  10151. }
  10152. else
  10153. {
  10154. request = WebRequest.Create(url) as HttpWebRequest;
  10155. }
  10156. request.Method = "POST";
  10157. request.ContentType = "application/json";
  10158. request.Accept = "*/*";
  10159. request.Timeout = 120000;
  10160. request.AllowAutoRedirect = false;
  10161. StreamWriter requestStream = null;
  10162. WebResponse response = null;
  10163. string responseStr = null;
  10164. try
  10165. {
  10166. requestStream = new StreamWriter(request.GetRequestStream());
  10167. requestStream.Write(param);
  10168. requestStream.Close();
  10169. response = request.GetResponse();
  10170. if (response != null)
  10171. {
  10172. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10173. responseStr = reader.ReadToEnd();
  10174. reader.Close();
  10175. }
  10176. }
  10177. catch (Exception ex)
  10178. {
  10179. return ex.Message;
  10180. }
  10181. finally
  10182. {
  10183. request = null;
  10184. requestStream = null;
  10185. response = null;
  10186. }
  10187. return responseStr;
  10188. }
  10189. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10190. {
  10191. string base64FileContent;
  10192. string fileName;
  10193. using (WebClient webClient = new WebClient())
  10194. {
  10195. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10196. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10197. {
  10198. using (Stream stream = response.GetResponseStream())
  10199. {
  10200. using (MemoryStream memoryStream = new MemoryStream())
  10201. {
  10202. stream.CopyTo(memoryStream);
  10203. byte[] fileBytes = memoryStream.ToArray();
  10204. base64FileContent = Convert.ToBase64String(fileBytes);
  10205. fileName = response.Headers["Content-Disposition"];
  10206. if (!string.IsNullOrEmpty(fileName))
  10207. {
  10208. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10209. if (index >= 0)
  10210. {
  10211. fileName = fileName.Substring(index + 9).Trim('\"');
  10212. }
  10213. }
  10214. else
  10215. {
  10216. fileName = Path.GetFileName(downloadUrl);
  10217. }
  10218. }
  10219. }
  10220. }
  10221. }
  10222. return (fileName, base64FileContent);
  10223. }
  10224. //新增
  10225. public void order_batch_caiyingtong(string[] downloadUrls)
  10226. {
  10227. try
  10228. {
  10229. //遍历文件
  10230. DataStruct dStruct = GetPostStruct();
  10231. DataTable dt = null;
  10232. int userid = CurrentUser.UserID;
  10233. List<string> ids = new List<string>();//失败组
  10234. List<string> tids = new List<string>();
  10235. using (WebClient webClient = new WebClient())
  10236. {
  10237. foreach (var url in downloadUrls)
  10238. {
  10239. try
  10240. {
  10241. tids.Add("'" + url + "'");
  10242. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10243. if (entity != null)
  10244. {
  10245. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10246. if (cp == null)
  10247. {
  10248. JObject jsonObject = new JObject
  10249. {
  10250. { "Userid", "77886" },
  10251. { "pwd", "lt666888" },
  10252. { "Filename",entity.seller_memo }
  10253. };
  10254. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10255. JObject jsonObjects = JObject.Parse(response);
  10256. string msg = (string)jsonObjects["msg"];
  10257. if (msg == "报价成功")
  10258. {
  10259. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10260. DownloadAndConvertToBase64(url1);
  10261. }
  10262. else
  10263. {
  10264. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10265. }
  10266. }
  10267. else
  10268. {
  10269. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10270. JObject jsonObject = new JObject
  10271. {
  10272. { "Userid", "77886" },
  10273. { "pwd", "lt666888" },
  10274. { "Filename",chanp }
  10275. };
  10276. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10277. JObject jsonObjects = JObject.Parse(response);
  10278. string msg = (string)jsonObjects["msg"];
  10279. if (msg == "报价成功")
  10280. {
  10281. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10282. DownloadAndConvertToBase64(url1);
  10283. }
  10284. else
  10285. {
  10286. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10287. }
  10288. }
  10289. }
  10290. // 上传文件到FTP
  10291. }
  10292. catch (Exception ex)
  10293. {
  10294. Console.WriteLine($"An error occurred: {ex.Message}");
  10295. }
  10296. }
  10297. List<string> lw = new List<string>();
  10298. lw.Add(string.Format("( OrderState < 6 )"));
  10299. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10301. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10302. if (dt.Rows.Count > 0)
  10303. {
  10304. foreach (DataRow dr in dt.Rows)
  10305. {
  10306. ids.Add(dr["ctid"].ToString());
  10307. }
  10308. }
  10309. String ErrorMsgs = "";
  10310. foreach (String id in ids)
  10311. {
  10312. ErrorMsgs += id + ",";
  10313. }
  10314. if (ErrorMsgs.Length > 1)
  10315. {
  10316. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10317. }
  10318. if (ErrorMsgs.Length < 1)
  10319. {
  10320. ErrorMsgs = "上传成功";
  10321. returnSuccessMsg(ErrorMsgs);
  10322. }
  10323. else
  10324. {
  10325. returnErrorMsg("以下订单" + ErrorMsgs);
  10326. }
  10327. }
  10328. // 删除文件夹及其内容
  10329. /* Directory.Delete(localDirectory, true);*/
  10330. }
  10331. catch { }
  10332. }
  10333. public void get_center_data()
  10334. {
  10335. int userId = CurrentUser.UserID;
  10336. string postCode = CurrentUser.UserPost.Post.Code;
  10337. List<string> lw = new List<string>();
  10338. List<string> ww = new List<string>();
  10339. DateTime currentTime = DateTime.Now;
  10340. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10341. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10342. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10343. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10344. string sql = " SELECT ";
  10345. string startTime = "2023-10-01 11:22:31";
  10346. //设计
  10347. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10348. {
  10349. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10350. 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));
  10351. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10352. 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));
  10353. }
  10354. //客服
  10355. else if (postCode == "CustomerService" || postCode == "Director")
  10356. {
  10357. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10358. 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));
  10359. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10360. 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));
  10361. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10362. 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));
  10363. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10364. 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));
  10365. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10366. 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));
  10367. }
  10368. //售后
  10369. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10370. {
  10371. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10372. 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));
  10373. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10374. 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));
  10375. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10376. 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));
  10377. }
  10378. //下单部
  10379. else if (postCode == "Place" || postCode == "PlaceMr")
  10380. {
  10381. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10382. 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));
  10383. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10384. 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));
  10385. }
  10386. //车间
  10387. else if (postCode == "Supplier")
  10388. {
  10389. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10390. 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));
  10391. }
  10392. DataTable dt = new DataTable();
  10393. if (lw.Count > 0)
  10394. {
  10395. sql += string.Join(" , ", lw);
  10396. sql += " FROM ";
  10397. sql += string.Join(" , ", ww);
  10398. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10399. }
  10400. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10401. }
  10402. public void get_center_data_list()
  10403. {
  10404. int userId = CurrentUser.UserID;
  10405. string postCode = CurrentUser.UserPost.Post.Code;
  10406. string shopIds = CurrentUser.User.pemShop;
  10407. DataStruct dStruct = GetPostStruct();
  10408. List<string> lw = new List<string>();
  10409. DateTime currentTime = DateTime.Now;
  10410. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10411. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10412. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10413. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10414. string startTime = "2023-10-01 11:22:31";
  10415. int order_type = GetPostInt("order_type");
  10416. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10417. {
  10418. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10419. if (order_type == 0)
  10420. {
  10421. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10422. }
  10423. else if (order_type == 3)
  10424. {
  10425. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10426. }
  10427. else
  10428. {
  10429. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10430. }
  10431. }
  10432. //客服
  10433. if (postCode == "CustomerService" || postCode == "Director")
  10434. {
  10435. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10436. if (order_type == 0)
  10437. {
  10438. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10439. }
  10440. else if (order_type == 1)
  10441. {
  10442. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10443. }
  10444. else if (order_type == 2)
  10445. {
  10446. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10447. }
  10448. else if (order_type == 3)
  10449. {
  10450. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10451. }
  10452. else if (order_type == 4)
  10453. {
  10454. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10455. }
  10456. else
  10457. {
  10458. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10459. }
  10460. }
  10461. //售后
  10462. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10463. {
  10464. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10465. if (shopIds != "")
  10466. {
  10467. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10468. }
  10469. if (order_type == 2)
  10470. {
  10471. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10472. }
  10473. else if (order_type == 4)
  10474. {
  10475. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10476. }
  10477. else if (order_type == 5)
  10478. {
  10479. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10480. }
  10481. else
  10482. {
  10483. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10484. }
  10485. }
  10486. //下单部
  10487. if (postCode == "Place" || postCode == "PlaceMr")
  10488. {
  10489. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10490. if (shopIds != "")
  10491. {
  10492. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10493. }
  10494. else if (order_type == 1)
  10495. {
  10496. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10497. }
  10498. else if (order_type == 2)
  10499. {
  10500. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10501. }
  10502. else
  10503. {
  10504. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10505. }
  10506. }
  10507. //车间
  10508. if (postCode == "Supplier")
  10509. {
  10510. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10511. if (order_type == 5)
  10512. {
  10513. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10514. }
  10515. else
  10516. {
  10517. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10518. }
  10519. }
  10520. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10521. dStruct.Fileds = "tid,ctid";
  10522. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10523. writeGridDataTableJson(dStruct.TotalCount, dt);
  10524. }
  10525. public void aftersale_audit_master()
  10526. {
  10527. if (UrlPostParmsCheck("ctid"))
  10528. {
  10529. string ctid = GetPostString("ctid");
  10530. if (ctid.Length > 0)
  10531. {
  10532. bool result = aftersale_data_change(ctid);
  10533. if (result)
  10534. {
  10535. returnSuccessMsg("修改成功!");
  10536. return;
  10537. }
  10538. }
  10539. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10540. }
  10541. }
  10542. public void aftersale_batch_audit_master()
  10543. {
  10544. if (UrlPostParmsCheck("ctids"))
  10545. {
  10546. string ctids = GetPostString("ctids");
  10547. if (ctids.Length > 0)
  10548. {
  10549. List<string> list = new List<string>();
  10550. string[] ctid_list = ctids.Split(',');
  10551. foreach (var item in ctid_list)
  10552. {
  10553. bool result = aftersale_data_change(item);
  10554. if (!result)
  10555. {
  10556. list.Add(item);
  10557. }
  10558. }
  10559. if (list.Count > 0)
  10560. {
  10561. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10562. return;
  10563. }
  10564. returnSuccessMsg("修改成功!");
  10565. return;
  10566. }
  10567. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10568. }
  10569. }
  10570. public bool aftersale_data_change(string ctid)
  10571. {
  10572. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10573. if (ceErpTradeCell != null)
  10574. {
  10575. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10576. ceErpTradeCell.AfterSaleSupplierState = 0;
  10577. StringBuilder sql = new StringBuilder();
  10578. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10579. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10580. CeErpTradeResponsible.DelByTid(ctid, 0);
  10581. 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 == "不理赔")
  10582. {
  10583. CeErpTradeResponsible.DelByTid(ctid, 1);
  10584. ceErpTradeCell.AfterSaleSupplierState = 1;
  10585. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10586. ceErpTradeCell.AfterSaleState = 4;
  10587. }
  10588. else
  10589. {
  10590. ceErpTradeCell.AfterSaleState = 3;
  10591. }
  10592. bool needCyt = false;
  10593. if (dt != null)
  10594. {
  10595. if (dt.Rows.Count == 1)
  10596. {
  10597. bool isEnd = false;
  10598. foreach (DataRow dr in dt.Rows)
  10599. {
  10600. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10601. {
  10602. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10603. isEnd = true;
  10604. }
  10605. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10606. {
  10607. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10608. isEnd = true;
  10609. }
  10610. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10611. {
  10612. needCyt = true;
  10613. }
  10614. }
  10615. if (isEnd)
  10616. {
  10617. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10618. ceErpTradeCell.AfterSaleState = 4;
  10619. ceErpTradeCell.AfterSaleSupplierState = 1;
  10620. }
  10621. }
  10622. else
  10623. {
  10624. bool isAll = true;
  10625. foreach (DataRow dr in dt.Rows)
  10626. {
  10627. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10628. {
  10629. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10630. continue;
  10631. }
  10632. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10633. {
  10634. string path = "";
  10635. int OrgID = 0;
  10636. if (!Convert.IsDBNull(dr["OrgPath"]))
  10637. {
  10638. path = dr["OrgPath"].ToString();
  10639. }
  10640. if (!Convert.IsDBNull(dr["OrgID"]))
  10641. {
  10642. OrgID = Convert.ToInt32(dr["OrgID"]);
  10643. }
  10644. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10645. {
  10646. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10647. continue;
  10648. }
  10649. }
  10650. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10651. {
  10652. needCyt = true;
  10653. }
  10654. isAll = false;
  10655. }
  10656. if (isAll)
  10657. {
  10658. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10659. ceErpTradeCell.AfterSaleState = 4;
  10660. ceErpTradeCell.AfterSaleSupplierState = 1;
  10661. }
  10662. }
  10663. }
  10664. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10665. {
  10666. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10667. }
  10668. if (ceErpTradeCell.AfterSaleState == 4)
  10669. {
  10670. ApiVo apiVo = new ApiVo();
  10671. apiVo.orderNumber = ceErpTradeCell.ctid;
  10672. apiVo.actionName = "afterOver";
  10673. designHelper.API_WorkCore(apiVo); //afterOver
  10674. }
  10675. ceErpTradeCell.Update();
  10676. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10677. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10678. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10679. return true;
  10680. }
  10681. return false;
  10682. }
  10683. public void get_erp_wechatorder()
  10684. {
  10685. DataStruct dStruct = GetPostStruct();
  10686. List<string> lw = new List<string>();
  10687. string tid = GetPostString("tid");
  10688. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10689. string shopname = GetPostString("shopname");
  10690. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10691. string buyernick = GetPostString("buyer_nick");
  10692. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10693. string customer = GetPostString("customer");
  10694. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10695. string returndate1 = GetPostString("returndate1");
  10696. string returndate2 = GetPostString("returndate2");
  10697. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10698. if (dw.Length > 0) lw.Add(dw);
  10699. string finishDate1 = GetPostString("finishdate1");
  10700. string finishDate2 = GetPostString("finishdate2");
  10701. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10702. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10703. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10704. dStruct.Order = "created desc";
  10705. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10706. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10707. writeGridDataTableJson(dStruct.TotalCount, dt);
  10708. }
  10709. public void get_erp_wechatlist_sumprice()
  10710. {
  10711. DataStruct dStruct = GetPostStruct();
  10712. List<string> lw = new List<string>();
  10713. string tid = GetPostString("tid");
  10714. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10715. string shopname = GetPostString("shopname");
  10716. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10717. string buyernick = GetPostString("buyer_nick");
  10718. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10719. string customer = GetPostString("customer");
  10720. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10721. string returndate1 = GetPostString("returndate1");
  10722. string returndate2 = GetPostString("returndate2");
  10723. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10724. if (dw.Length > 0) lw.Add(dw);
  10725. string finishDate1 = GetPostString("finishdate1");
  10726. string finishDate2 = GetPostString("finishdate2");
  10727. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10728. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10729. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10730. string mainWhere = string.Join(" and ", lw.ToArray());
  10731. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10732. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10733. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10734. decimal total = 0;
  10735. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10736. {
  10737. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10738. }
  10739. var res = new
  10740. {
  10741. data = total
  10742. };
  10743. string ro_jsond = JsonConvert.SerializeObject(res);
  10744. returnSuccess(ro_jsond);
  10745. return;
  10746. }
  10747. public void get_erp_qr_waitdeliverylist()
  10748. {
  10749. DataStruct dStruct = GetPostStruct();
  10750. List<string> lw = new List<string>();
  10751. string tid = GetPostString("ctid");
  10752. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10753. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10754. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10755. var res_objz = new
  10756. {
  10757. restype = 1,
  10758. data = dt
  10759. };
  10760. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10761. returnSuccess(ro_jsonz);
  10762. }
  10763. public void get_erp_yield_list()
  10764. {
  10765. DataStruct dStruct = GetPostStruct();
  10766. List<string> lw = new List<string>();
  10767. string tid = GetPostString("ctid");
  10768. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10769. string shopname = GetPostString("shopname");
  10770. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10771. string buyernick = GetPostString("buyer_nick");
  10772. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10773. //if (tid.Length == 0 && buyernick.Length == 0)
  10774. //{
  10775. // lw.Add(string.Format("IsRefund<={0}", 1));
  10776. //}
  10777. string customer = GetPostString("customer");
  10778. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10779. string design = GetPostString("design");
  10780. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10781. string orderState = GetPostString("orderState");
  10782. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10783. string address = GetPostString("address");
  10784. 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));
  10785. string sellermemo = GetPostString("seller_memo");
  10786. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10787. string supplier = GetPostString("supplier");
  10788. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10789. string OrderArea = GetPostString("order_area");
  10790. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10791. string placedate1 = GetPostString("placedate1");
  10792. string placedate2 = GetPostString("placedate2");
  10793. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10794. if (fdw.Length > 0) lw.Add(fdw);
  10795. string price1 = GetPostString("price1");
  10796. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10797. string price2 = GetPostString("price2");
  10798. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10799. string unusualCon = GetPostString("unusualcon");
  10800. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10801. string posTag = CurrentUser.UserPost.Post.Code;
  10802. if (posTag == "Supplier")
  10803. {
  10804. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10805. }
  10806. lw.Add(string.Format("OrderState = 6 "));
  10807. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10808. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10809. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10810. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10811. writeGridDataTableJson(dStruct.TotalCount, dt);
  10812. }
  10813. public void change_erp_sup_state()
  10814. {
  10815. if (UrlPostParmsCheck("ctid"))
  10816. {
  10817. string ctid = GetPostString("ctid");
  10818. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10819. if (ceErpTradeCell != null)
  10820. {
  10821. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10822. if (ceErpTradeCellExtend == null)
  10823. {
  10824. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10825. ceErpTradeCellExtend.ctid = ctid;
  10826. ceErpTradeCellExtend.SupState = 1;
  10827. ceErpTradeCellExtend.Create();
  10828. }
  10829. else
  10830. {
  10831. ceErpTradeCellExtend.SupState = 1;
  10832. ceErpTradeCellExtend.Update();
  10833. }
  10834. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10835. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10836. return;
  10837. }
  10838. returnErrorMsg("找不到订单");
  10839. }
  10840. }
  10841. public void supplier_all_downs()
  10842. {
  10843. if (UrlPostParmsCheck("tids"))
  10844. {
  10845. string tids = GetPostString("tids");
  10846. if (tids != null && tids.Length > 0)
  10847. {
  10848. StringBuilder sql = new StringBuilder();
  10849. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10850. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10851. sql = new StringBuilder();
  10852. 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, "下载设计文件");
  10853. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10854. string[] list = tids.Split(',');
  10855. foreach (string ctid in list)
  10856. {
  10857. CeErpSukuraData.createInfo(ctid, 3);
  10858. }
  10859. designHelper.api_approveDesign(tids); //approveDesign
  10860. returnSuccessMsg("下载成功!");
  10861. return;
  10862. }
  10863. returnErrorMsg("下载订单更新失败");
  10864. }
  10865. }
  10866. public void uploaderFileSuccess()
  10867. {
  10868. if (UrlPostParmsCheck("fileName"))
  10869. {
  10870. string fileName = GetPostString("fileName");
  10871. ApiVo apiVo = new ApiVo();
  10872. apiVo.orderNumber = fileName;
  10873. apiVo.actionName = "finishDesign";
  10874. designHelper.API_WorkCore(apiVo);//finishDesign
  10875. returnSuccessMsg("");
  10876. }
  10877. }
  10878. public void get_sample2_order()
  10879. {
  10880. if (UrlPostParmsCheck("ctid"))
  10881. {
  10882. string ctid = GetPostString("ctid");
  10883. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10884. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10885. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10886. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10887. double total = 0.0;
  10888. double order_price = 0.0;
  10889. if (dt_bu.Rows.Count > 0)
  10890. {
  10891. foreach (DataRow dr in dt_bu.Rows)
  10892. {
  10893. total += Convert.ToDouble(dr["payment"]);
  10894. }
  10895. }
  10896. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10897. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10898. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10899. string tid = ctid.Replace("S_", "");
  10900. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10901. double paymant = 0.0;
  10902. if (entity != null)
  10903. {
  10904. paymant = entity.payment;
  10905. }
  10906. string return_reason = "";
  10907. if (dt_after != null && dt_after.Rows.Count > 0)
  10908. {
  10909. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10910. }
  10911. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10912. }
  10913. }
  10914. public void get_erp_design_status()
  10915. {
  10916. string designName = GetPostString("designName");
  10917. DataStruct dStruct = GetPostStruct();
  10918. if (designName.Length > 0)
  10919. {
  10920. 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";
  10921. sql_user += " and Name like '%" + designName + "%'";
  10922. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10923. List<string> ids_list = new List<string>();
  10924. if (user_table.Rows.Count > 0)
  10925. {
  10926. foreach (DataRow item in user_table.Rows)
  10927. {
  10928. ids_list.Add(item["id"].ToString());
  10929. string ids_s = item["TeamIds"].ToString();
  10930. if (ids_s.Length > 0)
  10931. {
  10932. ids_list.AddRange(ids_s.Split(','));
  10933. }
  10934. }
  10935. }
  10936. HashSet<string> set = new HashSet<string>(ids_list);
  10937. ids_list = set.ToList();
  10938. if (ids_list.Count > 0)
  10939. {
  10940. 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));
  10941. dStruct.MainWhere = sql;
  10942. DataTable dt = null;
  10943. dt = WebCache.GetData("view_ErpUser", dStruct);
  10944. writeGridDataTableJson(dStruct.TotalCount, dt);
  10945. }
  10946. }
  10947. }
  10948. public void change_erp_order_price()
  10949. {
  10950. string ctid = GetPostString("ctid");
  10951. double price = GetPostDouble("price");
  10952. if (ctid.Length > 0)
  10953. {
  10954. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10955. if (ceErpTradeCellExtend == null)
  10956. {
  10957. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10958. ceErpTradeCellExtend.ctid = ctid;
  10959. ceErpTradeCellExtend.payment_cyt = price;
  10960. ceErpTradeCellExtend.Create();
  10961. }
  10962. else
  10963. {
  10964. ceErpTradeCellExtend.payment_cyt = price;
  10965. ceErpTradeCellExtend.Update();
  10966. }
  10967. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10968. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10969. {
  10970. ceErpDataSendOrderInfo.isSync = false;
  10971. ceErpDataSendOrderInfo.Update();
  10972. }
  10973. if (ceErpDataSendOrderInfo == null)
  10974. {
  10975. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10976. ceErpDataSendOrderInfo.isSync = false;
  10977. ceErpDataSendOrderInfo.ctid = ctid;
  10978. ceErpDataSendOrderInfo.Create();
  10979. }
  10980. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10981. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10982. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10983. if (dth != null && dth.Rows.Count > 0)
  10984. {
  10985. dataSendOrderBean dataSendOrderBean = null;
  10986. foreach (DataRow item in dth.Rows)
  10987. {
  10988. try
  10989. {
  10990. dataSendOrderBean = new dataSendOrderBean();
  10991. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10992. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10993. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10994. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10995. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10996. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10997. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10998. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10999. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11000. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11001. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11002. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11003. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11004. if (result != null)
  11005. {
  11006. if ("0".Equals(result.errcode))
  11007. {
  11008. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11009. }
  11010. else
  11011. {
  11012. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11013. }
  11014. }
  11015. }
  11016. catch (Exception ex)
  11017. {
  11018. }
  11019. }
  11020. }
  11021. returnSuccessMsg("修改成功!");
  11022. return;
  11023. }
  11024. returnErrorMsg("找不到订单");
  11025. }
  11026. public void find_he_together()
  11027. {
  11028. string ctid = GetPostString("ctid");
  11029. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11030. List<string> list = new List<string>();
  11031. if (ceErpTradeCell != null)
  11032. {
  11033. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11034. {
  11035. 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);
  11036. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11037. if (table != null && table.Rows.Count > 0)
  11038. {
  11039. foreach (TableRow row in table.Rows)
  11040. {
  11041. }
  11042. }
  11043. }
  11044. }
  11045. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11046. }
  11047. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11048. {
  11049. //chy----19
  11050. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11051. //GD-CYT-----64
  11052. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11053. //ZHX----3
  11054. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11055. //JK----97
  11056. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11057. //ZT----70
  11058. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11059. //LHCY-----98
  11060. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11061. //XD-----90
  11062. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11063. //CYCY-----14
  11064. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11065. };
  11066. //其他改名
  11067. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11068. {
  11069. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11070. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11071. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11072. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11073. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11074. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11075. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11076. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11077. };
  11078. //不统计
  11079. List<int> no_suppliers = new List<int>()
  11080. {
  11081. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11082. };
  11083. //配件单
  11084. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11085. {
  11086. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11087. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11088. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11089. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11090. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11091. {"旗杆",new List<string>(){ "班旗" } },
  11092. {"牙签",new List<string>(){ "不干胶" } }
  11093. };
  11094. public void get_place_order_data()
  11095. {
  11096. string date1 = GetPostString("date1");
  11097. string date2 = GetPostString("date2");
  11098. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11099. DateTime start = DateTime.Parse(starttime);
  11100. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11101. DateTime end = DateTime.Parse(endtime);
  11102. if (date1 != null && date1.Length > 0)
  11103. {
  11104. DateTime dateTime = DateTime.Parse(date1);
  11105. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11106. start = DateTime.Parse(starttime);
  11107. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11108. end = DateTime.Parse(endtime);
  11109. }
  11110. if (date2 != null && date2.Length > 0)
  11111. {
  11112. DateTime dateTime = DateTime.Parse(date2);
  11113. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11114. end = DateTime.Parse(endtime);
  11115. }
  11116. 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);
  11117. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11118. //不干胶-----1,卡片-----29
  11119. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11120. foreach (DataRow row in data.Rows)
  11121. {
  11122. int productId = Convert.ToInt32(row["ProductId"]);
  11123. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11124. if (no_suppliers.Contains(supplierId))
  11125. {
  11126. continue;
  11127. }
  11128. string seller_memo = row["seller_memo"].ToString();
  11129. bool ispj = false;//是否配件单
  11130. bool isfirst = true;//第一个配
  11131. maps.Keys.ForEach(key =>
  11132. {
  11133. //备注包含配件
  11134. if (seller_memo.Contains(key) && isfirst)
  11135. {
  11136. List<string> list = maps[key];
  11137. ispj = true;
  11138. isfirst = false;
  11139. for (int i = 0; i < list.Count; i++)
  11140. {
  11141. if (seller_memo.Contains(list[i]))
  11142. {
  11143. ispj = false;
  11144. break;
  11145. }
  11146. }
  11147. }
  11148. });
  11149. if (ispj)
  11150. {
  11151. continue;
  11152. }
  11153. seller_memo = seller_memo.Replace("UV", "uv");
  11154. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11155. //吊牌归到卡片
  11156. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11157. seller_memo = seller_memo.Replace("卡套", "卡片");
  11158. seller_memo = seller_memo.Replace("封套", "卡片");
  11159. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11160. seller_memo = seller_memo.Replace("腰封", "卡片");
  11161. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11162. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11163. seller_memo = seller_memo.Replace("横幅", "条幅");
  11164. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11165. string map_key = "";
  11166. string type = "";
  11167. if (supplierMap.ContainsKey(supplierId))
  11168. {
  11169. foreach (var kvp in supplierMap[supplierId])
  11170. {
  11171. if (seller_memo.Contains(kvp.Key))
  11172. {
  11173. map_key = kvp.Value;
  11174. type = kvp.Value;
  11175. break;
  11176. }
  11177. }
  11178. }
  11179. if (map_key == "")
  11180. {
  11181. type = "其他";
  11182. map_key = "其他";
  11183. }
  11184. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11185. {
  11186. map_key = suppliers[supplierId];
  11187. }
  11188. if (supplierId == 70)
  11189. {
  11190. supplierId = 70;
  11191. }
  11192. map_key += "_" + row["SupplierName"].ToString();
  11193. Dictionary<string, int> map = null;
  11194. if (other_map.ContainsKey(map_key))
  11195. {
  11196. other_map.TryGetValue(map_key, out map);
  11197. }
  11198. else
  11199. {
  11200. map = new Dictionary<string, int>();
  11201. map.Add("dayDev", 0);//当天出货
  11202. map.Add("dayTotal", 0);//下单总数
  11203. map.Add("payTotal", 0);//500以上
  11204. map.Add("today", 0);//当天出货数量
  11205. map.Add("unusua", 0);//异常数
  11206. other_map.Add(map_key, map);
  11207. other_map.TryGetValue(map_key, out map);
  11208. }
  11209. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11210. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11211. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11212. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11213. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11214. {
  11215. map["dayTotal"]++;
  11216. if (supplierId == 97)
  11217. {
  11218. supplierId = 97;
  11219. }
  11220. }
  11221. if (Convert.ToDecimal(row["payment"]) >= 500)
  11222. {
  11223. map["payTotal"]++;
  11224. }
  11225. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11226. {
  11227. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11228. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11229. {
  11230. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11231. {
  11232. map["today"]++;
  11233. }
  11234. }
  11235. else
  11236. {
  11237. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11238. {
  11239. map["today"]++;
  11240. }
  11241. else
  11242. {
  11243. if (supplierId == 119)
  11244. {
  11245. Debug.WriteLine(row["seller_memo"].ToString());
  11246. }
  11247. }
  11248. }
  11249. }
  11250. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11251. {
  11252. map["unusua"]++;
  11253. }
  11254. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11255. //GD-CYT-----64
  11256. DateTime two = palceTimeStart.AddHours(14);
  11257. DateTime three = palceTimeStart.AddHours(15);
  11258. DateTime four = palceTimeStart.AddHours(16);
  11259. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11260. {
  11261. //下午四点前 500-1000
  11262. string count = row["ProductCount"].ToString();
  11263. if (count != null && count.Length > 0)
  11264. {
  11265. int productCount = commonHelper.getPlaceProductCount(count);
  11266. if (productCount >= 500 && productCount <= 1000)
  11267. {
  11268. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11269. {
  11270. map["dayDev"]++;
  11271. }
  11272. }
  11273. }
  11274. }
  11275. //UV
  11276. else if ("uv".Equals(type))
  11277. {
  11278. //ZT----70
  11279. //ZHX----3
  11280. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11281. {
  11282. map["dayDev"]++;
  11283. }
  11284. //JK----97
  11285. //HZX----105
  11286. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11287. {
  11288. map["dayDev"]++;
  11289. if (supplierId == 97)
  11290. {
  11291. supplierId = 97;
  11292. }
  11293. }
  11294. }
  11295. //帆布---52|条幅---27
  11296. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11297. {
  11298. //LHCY-----98
  11299. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11300. {
  11301. map["dayDev"]++;
  11302. }
  11303. }
  11304. //条幅
  11305. else if ("条幅".Equals(type))
  11306. {
  11307. //XD-----90
  11308. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11309. {
  11310. map["dayDev"]++;
  11311. }
  11312. }
  11313. //桌布
  11314. else if ("桌布".Equals(type))
  11315. {
  11316. //XD-----90
  11317. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11318. {
  11319. map["dayDev"]++;
  11320. }
  11321. }
  11322. //DL---10
  11323. //AYTW---119
  11324. //FS-CYT-DY ----80
  11325. //JK----97
  11326. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11327. {
  11328. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11329. {
  11330. map["dayDev"]++;
  11331. }
  11332. }
  11333. }
  11334. DataTable dt = new DataTable();
  11335. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11336. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11337. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11338. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11339. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11340. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11341. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11342. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11343. other_map.Keys.ForEach(key =>
  11344. {
  11345. DataRow dr = dt.NewRow();
  11346. Dictionary<string, int> map = other_map[key];
  11347. string[] key_list = key.Split('_');
  11348. dr[0] = key_list[0];
  11349. dr[1] = key_list[1];
  11350. if (key_list.Length > 2)
  11351. {
  11352. dr[1] += "(" + key_list[2] + ")";
  11353. }
  11354. dr[2] = map["dayTotal"];
  11355. dr[3] = map["payTotal"];
  11356. dr[4] = map["today"];
  11357. dr[5] = map["unusua"];
  11358. dr[6] = map["dayDev"];
  11359. double rate = 0.00;
  11360. if (map["dayDev"] > 0)
  11361. {
  11362. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11363. }
  11364. dr[7] = rate.ToString();
  11365. dt.Rows.Add(dr);
  11366. });
  11367. DataView dv = new DataView(dt);
  11368. dv.Sort = "SupplierName";
  11369. //dv.Sort = "AllOrder desc";
  11370. DataTable dtNew = dv.ToTable();
  11371. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11372. }
  11373. public void check_order_desing_info()
  11374. {
  11375. string ctid = GetPostString("ctid");
  11376. if (!string.IsNullOrEmpty(ctid))
  11377. {
  11378. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11379. if (ceErpTradeCell != null)
  11380. {
  11381. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11382. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11383. return;
  11384. }
  11385. returnErrorMsg("找不到订单");
  11386. return;
  11387. }
  11388. returnErrorMsg("找不到订单");
  11389. }
  11390. public void get_timeout_detail()
  11391. {
  11392. string poscode = CurrentUser.UserPost.Post.Code;
  11393. DataStruct dStruct = GetPostStruct();
  11394. List<string> lw = new List<string>();
  11395. string id = GetPostString("id");
  11396. string pay_date1 = GetPostString("pay_date1");
  11397. string pay_date2 = GetPostString("pay_date2");
  11398. int type = GetPostInt("type");
  11399. if (type == 0)
  11400. {
  11401. if (pay_date1.Length > 0)
  11402. {
  11403. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11404. }
  11405. if (pay_date2.Length > 0)
  11406. {
  11407. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11408. }
  11409. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11410. }
  11411. if (type == 1)
  11412. {
  11413. if (pay_date1.Length > 0)
  11414. {
  11415. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11416. }
  11417. if (pay_date2.Length > 0)
  11418. {
  11419. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11420. }
  11421. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11422. }
  11423. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11424. DataTable dt = null;
  11425. dt = WebCache.GetData("view_orderlist", dStruct);
  11426. writeGridDataTableJson(dStruct.TotalCount, dt);
  11427. }
  11428. public void saveUrgentChargePrice()
  11429. {
  11430. string ctid = GetPostString("ctid");
  11431. if (!string.IsNullOrEmpty(ctid))
  11432. {
  11433. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11434. if (ceErpTradeCell != null)
  11435. {
  11436. double price = GetPostDouble("price");
  11437. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11438. if (ceErpTradeCellExtend == null)
  11439. {
  11440. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11441. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11442. }
  11443. ceErpTradeCellExtend.urgentCharge = price;
  11444. if (ceErpTradeCellExtend.ID > 0)
  11445. {
  11446. ceErpTradeCellExtend.Update();
  11447. }
  11448. else
  11449. {
  11450. ceErpTradeCellExtend.Save();
  11451. }
  11452. returnSuccessMsg("修改成功!");
  11453. return;
  11454. }
  11455. returnErrorMsg("找不到订单");
  11456. return;
  11457. }
  11458. returnErrorMsg("找不到订单");
  11459. }
  11460. public void finish_erp_order()
  11461. {
  11462. string ctid = GetPostString("ctid");
  11463. if (!string.IsNullOrEmpty(ctid))
  11464. {
  11465. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11466. {
  11467. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11468. if (ceErpTradeCell != null)
  11469. {
  11470. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11471. ceErpTradeCell.Update();
  11472. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11473. returnSuccessMsg("修改成功!");
  11474. return;
  11475. }
  11476. }
  11477. }
  11478. returnErrorMsg("找不到订单");
  11479. }
  11480. public void get_trade_order_list()
  11481. {
  11482. string tid = GetPostString("tid");
  11483. if (!string.IsNullOrEmpty(tid))
  11484. {
  11485. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11486. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11487. writeGridDataTableJson(data.Rows.Count, data);
  11488. return;
  11489. }
  11490. returnErrorMsg("找不到订单");
  11491. }
  11492. public void save_cell_spu()
  11493. {
  11494. string ctid = GetPostString("ctid");
  11495. string spu_id = GetPostString("spu_id");
  11496. if (!string.IsNullOrEmpty(ctid))
  11497. {
  11498. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11499. if (ceErpTradeCellExtend == null)
  11500. {
  11501. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11502. ceErpTradeCellExtend.ctid = ctid;
  11503. }
  11504. ceErpTradeCellExtend.spu_id = spu_id;
  11505. if (ceErpTradeCellExtend.ID == 0)
  11506. {
  11507. ceErpTradeCellExtend.Create();
  11508. }
  11509. else
  11510. {
  11511. ceErpTradeCellExtend.Update();
  11512. }
  11513. returnSuccessMsg("修改成功!");
  11514. return;
  11515. }
  11516. returnErrorMsg("找不到订单");
  11517. }
  11518. public void change_express_info()
  11519. {
  11520. string ctid = GetPostString("ctid");
  11521. string transNo = GetPostString("transNo");
  11522. string transCom = GetPostString("transCom");
  11523. if (!string.IsNullOrEmpty(ctid))
  11524. {
  11525. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11526. if (ceErpTradeCellExtend == null)
  11527. {
  11528. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11529. ceErpTradeCellExtend.ctid = ctid;
  11530. }
  11531. ceErpTradeCellExtend.modExpressNo = transNo;
  11532. ceErpTradeCellExtend.modExpressCom = transCom;
  11533. ceErpTradeCellExtend.readMod = 2;
  11534. if (ceErpTradeCellExtend.ID == 0)
  11535. {
  11536. ceErpTradeCellExtend.Create();
  11537. }
  11538. else
  11539. {
  11540. ceErpTradeCellExtend.Update();
  11541. }
  11542. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11543. returnSuccessMsg("修改成功!");
  11544. return;
  11545. }
  11546. returnErrorMsg("找不到订单");
  11547. }
  11548. public void get_change_express_list()
  11549. {
  11550. DataStruct dStruct = GetPostStruct();
  11551. List<string> lw = new List<string>();
  11552. int st = 2;
  11553. string tid = GetPostString("ctid");
  11554. if (tid.Length > 0)
  11555. {
  11556. string select_tid = getTidByCtid(tid);
  11557. lw.Add(string.Format("tid='{0}'", select_tid));
  11558. }
  11559. string shopname = GetPostString("shopname");
  11560. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11561. string buyernick = GetPostString("buyer_nick");
  11562. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11563. string sellermemo = GetPostString("seller_memo");
  11564. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11565. string supplier = GetPostString("supplier");
  11566. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11567. string customer = GetPostString("customer");
  11568. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11569. string design = GetPostString("design");
  11570. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11571. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11572. string poscode = CurrentUser.UserPost.Post.Code;
  11573. if (poscode != "SysAdmin")
  11574. {
  11575. string shopid = CurrentUser.User.pemShop;
  11576. lw.Add(string.Format("shopId in ({0})", shopid));
  11577. }
  11578. lw.Add("readMod = 2");
  11579. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11580. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11581. writeGridDataTableJson(dStruct.TotalCount, dt);
  11582. }
  11583. public void deal_express_complete()
  11584. {
  11585. string ctid = GetPostString("ctid");
  11586. if (!string.IsNullOrEmpty(ctid))
  11587. {
  11588. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11589. if (ceErpTradeCellExtend == null)
  11590. {
  11591. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11592. ceErpTradeCellExtend.ctid = ctid;
  11593. }
  11594. ceErpTradeCellExtend.readMod = 1;
  11595. if (ceErpTradeCellExtend.ID == 0)
  11596. {
  11597. ceErpTradeCellExtend.Create();
  11598. }
  11599. else
  11600. {
  11601. ceErpTradeCellExtend.Update();
  11602. }
  11603. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11604. returnSuccessMsg("修改成功!");
  11605. return;
  11606. }
  11607. returnErrorMsg("找不到订单");
  11608. }
  11609. public void aftersale_return_visit()
  11610. {
  11611. string ctid = GetPostString("ctid");
  11612. if (!string.IsNullOrEmpty(ctid))
  11613. {
  11614. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11615. if (ceErpTradeCellExtend == null)
  11616. {
  11617. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11618. ceErpTradeCellExtend.ctid = ctid;
  11619. }
  11620. ceErpTradeCellExtend.returnVisit = 1;
  11621. if (ceErpTradeCellExtend.ID == 0)
  11622. {
  11623. ceErpTradeCellExtend.Create();
  11624. }
  11625. else
  11626. {
  11627. ceErpTradeCellExtend.Update();
  11628. }
  11629. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11630. if (ceErpTradeAfterSaleExtend != null)
  11631. {
  11632. ceErpTradeAfterSaleExtend.TextResult = "";
  11633. ceErpTradeAfterSaleExtend.Update();
  11634. }
  11635. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11636. returnSuccessMsg("修改成功!");
  11637. return;
  11638. }
  11639. returnErrorMsg("找不到订单");
  11640. }
  11641. public void orderPlaceInfo()
  11642. {
  11643. string ctids = GetPostString("ctids");
  11644. string[] list = ctids.Split(',');
  11645. foreach (string ctid in list)
  11646. {
  11647. CeErpSukuraData.createInfo(ctid, 3);
  11648. }
  11649. StringBuilder sql = new StringBuilder();
  11650. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11651. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11652. designHelper.api_approveDesign(ctids); //approveDesign
  11653. returnSuccessMsg("");
  11654. }
  11655. public void get_issue_list()
  11656. {
  11657. DataStruct dStruct = GetPostStruct();
  11658. List<string> lw = new List<string>();
  11659. int st = 2;
  11660. string tid = GetPostString("ctid");
  11661. if (tid.Length > 0)
  11662. {
  11663. string select_tid = getTidByCtid(tid);
  11664. lw.Add(string.Format("tid='{0}'", select_tid));
  11665. }
  11666. string shopname = GetPostString("shopname");
  11667. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11668. string buyernick = GetPostString("buyer_nick");
  11669. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11670. string sellermemo = GetPostString("seller_memo");
  11671. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11672. string supplier = GetPostString("supplier");
  11673. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11674. string customer = GetPostString("customer");
  11675. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11676. string design = GetPostString("design");
  11677. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11678. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11679. string poscode = CurrentUser.UserPost.Post.Code;
  11680. if (poscode != "SysAdmin")
  11681. {
  11682. string shopid = CurrentUser.User.pemShop;
  11683. lw.Add(string.Format("shopId in ({0})", shopid));
  11684. }
  11685. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11686. {
  11687. lw.Add("IssueState = 1");
  11688. }
  11689. lw.Add("IssueState > 0");
  11690. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11691. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11692. writeGridDataTableJson(dStruct.TotalCount, dt);
  11693. }
  11694. public void saveIssueContent()
  11695. {
  11696. string ctid = GetPostString("ctid");
  11697. if (!string.IsNullOrEmpty(ctid))
  11698. {
  11699. string content = GetPostString("content");
  11700. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11701. if (ceErpTradeAfterSaleExtend == null)
  11702. {
  11703. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11704. ceErpTradeAfterSaleExtend.tid = ctid;
  11705. }
  11706. ceErpTradeAfterSaleExtend.IssueContent = content;
  11707. ceErpTradeAfterSaleExtend.IssueState = 1;
  11708. if (ceErpTradeAfterSaleExtend.ID > 0)
  11709. {
  11710. ceErpTradeAfterSaleExtend.Update();
  11711. }
  11712. else
  11713. {
  11714. ceErpTradeAfterSaleExtend.Create();
  11715. }
  11716. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11717. returnSuccessMsg("添加成功!");
  11718. return;
  11719. }
  11720. returnErrorMsg("找不到订单");
  11721. }
  11722. public void dealIssueContent()
  11723. {
  11724. string ctid = GetPostString("ctid");
  11725. if (!string.IsNullOrEmpty(ctid))
  11726. {
  11727. string content = GetPostString("content");
  11728. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11729. if (ceErpTradeAfterSaleExtend != null)
  11730. {
  11731. ceErpTradeAfterSaleExtend.IssueState = 2;
  11732. ceErpTradeAfterSaleExtend.Update();
  11733. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11734. returnSuccessMsg("修改完成!");
  11735. return;
  11736. }
  11737. }
  11738. returnErrorMsg("找不到订单");
  11739. }
  11740. public void set_tid_attachments()
  11741. {
  11742. string tid = GetPostString("tid");
  11743. string atta = GetPostString("atta");
  11744. if (!string.IsNullOrEmpty(tid))
  11745. {
  11746. if (string.IsNullOrEmpty(atta))
  11747. {
  11748. returnErrorMsg("文件地址为空");
  11749. return;
  11750. }
  11751. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11752. if (ceErpTradeCell != null)
  11753. {
  11754. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11755. if (ceErpTrade == null)
  11756. {
  11757. returnErrorMsg("找不到订单");
  11758. return;
  11759. }
  11760. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11761. bool isSend = false;
  11762. if (dt != null && dt.Rows.Count > 0)
  11763. {
  11764. foreach (DataRow row in dt.Rows)
  11765. {
  11766. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11767. {
  11768. isSend = true;
  11769. }
  11770. }
  11771. if (isSend)
  11772. {
  11773. returnErrorMsg("已发货无法修改");
  11774. return;
  11775. }
  11776. ceErpTrade.Attachments = atta;
  11777. ceErpTrade.Update();
  11778. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11779. returnSuccessMsg("上传成功!");
  11780. return;
  11781. }
  11782. }
  11783. }
  11784. returnErrorMsg("找不到订单");
  11785. }
  11786. public void get_tid_attachments()
  11787. {
  11788. string tid = GetPostString("tid");
  11789. if (!string.IsNullOrEmpty(tid))
  11790. {
  11791. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11792. if (ceErpTradeCell != null)
  11793. {
  11794. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11795. if (ceErpTrade == null)
  11796. {
  11797. returnErrorMsg("找不到订单");
  11798. return;
  11799. }
  11800. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11801. return;
  11802. }
  11803. }
  11804. returnErrorMsg("找不到订单");
  11805. }
  11806. public void check_erp_sameorders()
  11807. {
  11808. if (UrlPostParmsCheck("ctid"))
  11809. {
  11810. string eid = GetPostString("ctid");
  11811. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11812. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11813. if (entity != null && ceErpTrade != null)
  11814. {
  11815. if (entity.OrderState > 6)
  11816. {
  11817. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11818. return;
  11819. }
  11820. StringBuilder sql = new StringBuilder();
  11821. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  11822. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  11823. {
  11824. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  11825. }
  11826. else
  11827. {
  11828. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  11829. }
  11830. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11831. List<string> ids = new List<string>();
  11832. if (dt != null && dt.Rows.Count > 1)
  11833. {
  11834. bool needhe = true;
  11835. foreach (DataRow dr in dt.Rows)
  11836. {
  11837. ids.Add("'" + dr["ctid"] + "'");
  11838. /* //备注有合包
  11839. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11840. {
  11841. needhe = true;
  11842. }
  11843. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11844. {
  11845. needhe = true;
  11846. }
  11847. //顺丰快递
  11848. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11849. {
  11850. needhe = true;
  11851. }*/
  11852. }
  11853. if (!needhe)
  11854. {
  11855. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11856. return;
  11857. }
  11858. sql = new StringBuilder();
  11859. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11860. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11861. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11862. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11863. foreach (DataRow dr in dt.Rows)
  11864. {
  11865. dr["dstate"] = 0;
  11866. dr["dnumber"] = 0;
  11867. foreach (DataRow row in dt1.Rows)
  11868. {
  11869. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11870. {
  11871. dr["dstate"] = 2;
  11872. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11873. }
  11874. }
  11875. if (eid.Equals(dr["ctid"].ToString()))
  11876. {
  11877. dr["dstate"] = 1;
  11878. }
  11879. }
  11880. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11881. return;
  11882. }
  11883. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11884. return;
  11885. }
  11886. returnErrorMsg("未找到订单");
  11887. return;
  11888. }
  11889. returnErrorMsg("缺少必要的参数");
  11890. }
  11891. public void get_mark_number()
  11892. {
  11893. string eid = GetPostString("ctid");
  11894. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11895. if (entity != null)
  11896. {
  11897. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11898. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  11899. int current = 1;
  11900. if (ceErpDeliverMark == null)
  11901. {
  11902. StringBuilder sql = new StringBuilder();
  11903. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  11904. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  11905. {
  11906. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  11907. }
  11908. else
  11909. {
  11910. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  11911. }
  11912. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11913. List<string> ids = new List<string>();
  11914. if (dt != null && dt.Rows.Count > 1)
  11915. {
  11916. foreach (DataRow dr in dt.Rows)
  11917. {
  11918. ids.Add("'" + dr["ctid"] + "'");
  11919. }
  11920. //查询已有的编号
  11921. sql = new StringBuilder();
  11922. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11923. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11924. if (dt1 == null || dt1.Rows.Count == 0)
  11925. {
  11926. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  11927. List<int> list_number = new List<int>();
  11928. foreach (DataRow row in numbers.Rows)
  11929. {
  11930. list_number.Add(Convert.ToInt32(row["markNumber"]));
  11931. }
  11932. //查询空余编号
  11933. for (int i = 0; i < list_number.Count + 2; i++)
  11934. {
  11935. if (!list_number.Contains(current))
  11936. {
  11937. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  11938. //防止查询过程中有新数据生成
  11939. if (ceErpDeliverMark1 == null)
  11940. {
  11941. break;
  11942. }
  11943. }
  11944. current++;
  11945. }
  11946. }
  11947. else
  11948. {
  11949. foreach (DataRow row in dt1.Rows)
  11950. {
  11951. current = Convert.ToInt32(row["markNumber"]);
  11952. }
  11953. }
  11954. ceErpDeliverMark = new CeErpDeliverMark();
  11955. ceErpDeliverMark.ctid = eid;
  11956. ceErpDeliverMark.createtime = DateTime.Now;
  11957. if (ceErpTrade != null)
  11958. {
  11959. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  11960. }
  11961. ceErpDeliverMark.markNumber = current;
  11962. ceErpDeliverMark.Create();
  11963. }
  11964. }
  11965. else
  11966. {
  11967. current = ceErpDeliverMark.markNumber;
  11968. }
  11969. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  11970. return;
  11971. }
  11972. }
  11973. }
  11974. }