sync.order.cs 603 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\1.xls");
  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("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1743037314000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1743210111000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":100.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2200806677467/O1CN01FNM4MW251wJNQ0RTV_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4279817918999398627\",\"refSkuId\":\"0\",\"refSpuId\":\"743796792540\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":50.0,\"singleFee\":50.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【活动价】镜子贴纸定制婚礼迎宾牌装饰静电贴镜面玻璃窗户字母转印贴画墙贴\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1743040267000,\"openBuyerId\":\"AAEXRHraABkUZRPgSx1Mbz6h\",\"openBuyerNick\":\"天**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1743037310000,\"payTime\":1743037311000,\"payment\":100.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"齐齐哈尔市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"建华区\",\"receiverId\":\"82f9bfecd2ef7df766b42edd73faa2f3$\",\"receiverState\":\"黑龙江省\",\"receiverTown\":\"文化街道\",\"refOid\":\"4279817918999398627\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"500x640mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50,580x585mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0,\"type\":\"SALE\"}}");
  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. List<string> lw = new List<string>();
  68. string tid = GetPostString("ctid");
  69. string date1 = GetPostString("date1");
  70. //12-1 修改
  71. string urgent = GetPostString("urgent");
  72. string back = GetPostString("back");
  73. string offlineSearch = GetPostString("offlineSearch");
  74. int paramsCount = 0;
  75. if (!string.IsNullOrWhiteSpace(urgent))
  76. {
  77. if (urgent.Equals("true"))
  78. {
  79. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  80. }
  81. }
  82. if (!string.IsNullOrWhiteSpace(back))
  83. {
  84. if (back.Equals("true"))
  85. {
  86. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  87. }
  88. }
  89. if (!string.IsNullOrWhiteSpace(offlineSearch))
  90. {
  91. if (offlineSearch.Equals("true"))
  92. {
  93. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  94. }
  95. }
  96. //end
  97. string date2 = GetPostString("date2");
  98. string buyernick = GetPostString("buyer_nick");
  99. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  100. {
  101. if (tid.Length <= 0 && buyernick.Length <= 0)
  102. {
  103. return;
  104. }
  105. }
  106. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  107. {
  108. if (tid.Length > 0)
  109. {
  110. string select_tid = getTidByCtid(tid);
  111. lw.Add(string.Format("tid='{0}'", select_tid));
  112. }
  113. if (buyernick.Length > 0)
  114. {
  115. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  116. }
  117. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  118. if (dw.Length > 0)
  119. {
  120. lw.Add(dw);
  121. }
  122. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  123. {
  124. string usershop = CurrentUser.User.pemShop;
  125. lw.Add(string.Format("ShopId in ({0})", usershop));
  126. }
  127. }
  128. else
  129. {
  130. if (ex_psize == 0)
  131. {
  132. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  133. }
  134. if (PKey != "admin")
  135. {
  136. string usershop = CurrentUser.User.pemShop;
  137. lw.Add(string.Format("ShopId in ({0})", usershop));
  138. paramsCount++;
  139. }
  140. }
  141. string uploaddate1 = GetPostString("uploaddate1");
  142. string uploaddate2 = GetPostString("uploaddate2");
  143. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  144. if (update.Length > 0) lw.Add(update);
  145. string deliverydate1 = GetPostString("deliverydate1");
  146. string deliverydate2 = GetPostString("deliverydate2");
  147. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  148. if (deliverydate.Length > 0)
  149. {
  150. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  151. };
  152. string shopname = GetPostString("shopname");
  153. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  154. string addwechat = GetPostString("addwechat");
  155. if (addwechat.Length > 0)
  156. {
  157. int addWt = Convert.ToInt32(addwechat);
  158. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  159. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  160. }
  161. string customer = GetPostString("customer");
  162. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  163. string design = GetPostString("design");
  164. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  165. string orderState = GetPostString("orderState");
  166. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  167. string address = GetPostString("address");
  168. 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));
  169. string sellermemo = GetPostString("seller_memo");
  170. if (sellermemo.Length > 0)
  171. {
  172. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  173. }
  174. string backReason = GetPostString("backReason");
  175. if (backReason.Length > 0)
  176. {
  177. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  178. }
  179. string apdate1 = GetPostString("apdate1");
  180. string apdate2 = GetPostString("apdate2");
  181. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  182. if (dwap.Length > 0) lw.Add(dwap);
  183. string price1 = GetPostString("price1");
  184. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  185. string price2 = GetPostString("price2");
  186. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  187. string isoldcustomer = GetPostString("isoldcus");
  188. string finishdate1 = GetPostString("finishdate1");
  189. string finishdate2 = GetPostString("finishdate2");
  190. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  191. bool isFinish = false;
  192. if (finishdate.Length > 0)
  193. {
  194. lw.Add(finishdate);
  195. isFinish = true;
  196. paramsCount++;
  197. }
  198. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  199. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  200. if (ex_psize > 0)
  201. {
  202. int UserID = CurrentUser.UserID;
  203. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  204. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  205. {
  206. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  207. }
  208. dStruct.Order = "pay_time desc";
  209. }
  210. string isNew = GetPostString("isNew");
  211. if (isNew == "true")
  212. {
  213. lw.Add(string.Format("IsNew = {0}", 1));
  214. }
  215. string overtime = GetPostString("overtime");
  216. if (overtime == "1")
  217. {
  218. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  219. }
  220. String usePost = CurrentUser.UserPost.Post.Code;
  221. if (usePost.Equals("Operation") == true)
  222. {
  223. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  224. }
  225. else
  226. {
  227. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  228. }
  229. //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";
  230. if (dStruct.PageSize == 100000)
  231. {
  232. dStruct.Order = "";
  233. }
  234. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  235. DataTable dt = null;
  236. string tablename = "view_orderlist";
  237. if (isFinish)
  238. {
  239. tablename = "view_orderlist_end";
  240. }
  241. dt = WebCache.GetData(tablename, dStruct);
  242. if (dt != null && dt.Rows.Count > 0)
  243. {
  244. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  245. foreach (DataRow dr in dt.Rows)
  246. {
  247. try
  248. {
  249. if (dr["refund_fees"] != null)
  250. {
  251. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  252. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  253. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  254. if (payment == refund_fees)
  255. {
  256. dr["refund_fees"] = Math.Round(refund_fees, 2);
  257. }
  258. else if (refund_fees == total_fee)
  259. {
  260. dr["refund_fees"] = payment;
  261. }
  262. else
  263. {
  264. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  265. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  266. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  267. }
  268. }
  269. // 对象操作
  270. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  271. ceErpTradeCell.ctid = dr["ctid"].ToString();
  272. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  273. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  274. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  275. if (dStruct.PageSize != 100000)
  276. {
  277. if (dr["DispatchSort"].ToString() == "2")
  278. {
  279. dr["gongchuang"] = 200;
  280. }
  281. else
  282. {
  283. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  284. dr["gongchuang"] = response.code;
  285. }
  286. }
  287. }
  288. catch (NullReferenceException ex)
  289. {
  290. // 处理空引用异常
  291. dr["refund_fees"] = "0.00";
  292. }
  293. }
  294. }
  295. writeGridDataTableJson(dStruct.TotalCount, dt);
  296. }
  297. public void get_erp_orderlist_sumprice()
  298. {
  299. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  300. return;
  301. List<string> lw = new List<string>();
  302. string tid = GetPostString("ctid");
  303. string date1 = GetPostString("date1");
  304. string date2 = GetPostString("date2");
  305. if (tid.Length > 0 || date1.Length > 0)
  306. {
  307. lw.Add(string.Format("ctid like '%{0}%'", tid));
  308. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  309. if (dw.Length > 0) lw.Add(dw);
  310. }
  311. else
  312. {
  313. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  314. }
  315. string shopname = GetPostString("shopname");
  316. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  317. string buyernick = GetPostString("buyer_nick");
  318. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  319. string customer = GetPostString("customer");
  320. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  321. string design = GetPostString("design");
  322. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  323. string orderState = GetPostString("orderState");
  324. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  325. string address = GetPostString("address");
  326. 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));
  327. string sellermemo = GetPostString("seller_memo");
  328. if (sellermemo.Length > 0)
  329. {
  330. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  331. }
  332. string apdate1 = GetPostString("apdate1");
  333. string apdate2 = GetPostString("apdate2");
  334. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  335. if (dwap.Length > 0) lw.Add(dwap);
  336. string price1 = GetPostString("price1");
  337. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  338. string price2 = GetPostString("price2");
  339. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  340. string isoldcustomer = GetPostString("isoldcus");
  341. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  342. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  343. if (PKey != "admin")
  344. {
  345. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  346. lw.Add(string.Format("shopId in ({0})", usershop));
  347. }
  348. //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";
  349. string mainWhere = string.Join(" and ", lw.ToArray());
  350. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  351. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  352. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  353. decimal total = 0;
  354. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  355. {
  356. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  357. }
  358. var res = new
  359. {
  360. data = total
  361. };
  362. string ro_jsond = JsonConvert.SerializeObject(res);
  363. returnSuccess(ro_jsond);
  364. return;
  365. }
  366. public void get_erp_CustomerServiceGather()
  367. {
  368. string userWhere = "", orderWhere = "";
  369. List<string> lw = new List<string>();
  370. string customer = GetPostString("customer");
  371. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  372. string shopname = GetPostString("shopname");
  373. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  374. string date1 = GetPostString("date1");
  375. string date2 = GetPostString("date2");
  376. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  377. if (dw.Length > 0) lw.Add(dw);
  378. orderWhere = string.Join(" and ", lw.ToArray());
  379. 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 " +
  380. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  381. "left join " +
  382. "( " +
  383. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  384. ") as b on a.ID = b.CustomerUserId " +
  385. "left join " +
  386. "( " +
  387. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  388. ") as d on a.ID = d.CustomerUserId " +
  389. "left join " +
  390. "( " +
  391. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  392. ") as e on a.ID = e.CustomerUserId " +
  393. "left join " +
  394. "( " +
  395. " select CustomerUserId, RefundCount, RefundSum from " +
  396. " ( " +
  397. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  398. " from CE_ErpTradeRefund a " +
  399. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  400. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  401. " group by CustomerUserId " +
  402. " ) as a " +
  403. ") as f on a.ID = f.CustomerUserId " +
  404. "where a.PostCode = 'CustomerService'",
  405. userWhere, orderWhere);
  406. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  407. writeGridDataTableJson(dt.Rows.Count, dt);
  408. //writeGridDataTableJson(dt.Rows.Count, dt);
  409. }
  410. //设计汇总
  411. public void get_erp_DesignerGather()
  412. {
  413. string userWhere = "", orderWhere = "";
  414. List<string> lw = new List<string>();
  415. string Designer = GetPostString("designer");
  416. int org = GetPostInt("org");
  417. if (Designer.Length > 0)
  418. {
  419. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  420. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  421. }
  422. else if (org > 0)
  423. {
  424. userWhere = string.Format(" where OrgID ={0}", org);
  425. }
  426. string shopname = GetPostString("shopname");
  427. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  428. string state = GetPostString("state");
  429. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  430. string OrderArea = GetPostString("order_area");
  431. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  432. string date1 = GetPostString("date1");
  433. string date2 = GetPostString("date2");
  434. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  435. if (dw.Length > 0) lw.Add(dw);
  436. string UpDate1 = GetPostString("UpDate1");
  437. string UpDate2 = GetPostString("UpDate2");
  438. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  439. if (dw.Length > 0) lw.Add(dw);
  440. orderWhere = string.Join(" and ", lw.ToArray());
  441. 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 (" +
  442. "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 " +
  443. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  444. "left join " +
  445. "( " +
  446. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  447. ") as b on a.ID = b.DesignUserId " +
  448. "left join " +
  449. "( " +
  450. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  451. ") as d on a.ID = d.DesignUserId " +
  452. "left join " +
  453. "( " +
  454. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  455. ") as e on a.ID = e.DesignUserId " +
  456. "left join " +
  457. "( " +
  458. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  459. ") as g on a.ID = g.DesignUserId " +
  460. "left join " +
  461. "( " +
  462. " select CustomerUserId, RefundCount, RefundSum from " +
  463. " ( " +
  464. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  465. " from CE_ErpTradeRefund a " +
  466. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  467. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  468. " group by CustomerUserId " +
  469. " ) as a " +
  470. ") as f on a.ID = f.CustomerUserId " +
  471. "where a.PostCode = 'Designer') as z",
  472. userWhere, orderWhere);
  473. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  474. writeGridDataTableJson(dt.Rows.Count, dt);
  475. }
  476. //删除tradecell的订单
  477. public void del_erp_cellorder()
  478. {
  479. if (UrlPostParmsCheck("ctid"))
  480. {
  481. string eid = GetPostString("ctid");
  482. CeErpTradeCell.DelByCtid(eid);
  483. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  484. returnSuccessMsg("删除成功");
  485. }
  486. }
  487. public void clear_erp_refundstate()
  488. {
  489. if (UrlPostParmsCheck("ids"))
  490. {
  491. string eids = GetPostString("ids");
  492. string[] ctidList = eids.Split(',');
  493. foreach (string ctid in ctidList)
  494. {
  495. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  496. if (entity != null)
  497. {
  498. entity.IsRefund = 0;
  499. entity.Update();
  500. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  501. }
  502. else
  503. continue;
  504. }
  505. returnSuccessMsg("操作成功");
  506. return;
  507. }
  508. returnErrorMsg("缺少必要参数");
  509. }
  510. public void set_erp_urgency()
  511. {
  512. if (UrlPostParmsCheck("ctid"))
  513. {
  514. string eid = GetPostString("ctid");
  515. CeErpTradeCell entity = null;
  516. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  517. if (entity != null)
  518. {
  519. string utime = GetPostString("urgencytime");
  520. if (utime.Length > 0)
  521. {
  522. entity.UrgencyTime = Convert.ToDateTime(utime);
  523. }
  524. else
  525. {
  526. returnErrorMsg("请选择加急时间");
  527. return;
  528. }
  529. if (entity.OrderState <= 4)
  530. {
  531. //entity.seller_memo = entity.seller_memo + "-加急";
  532. string smemo = entity.seller_memo;
  533. int kindex = smemo.IndexOf(")");
  534. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  535. if (lastoneStr != "-")
  536. {
  537. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  538. }
  539. string prememo = smemo.Substring(0, kindex + 2);
  540. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  541. int lastkindex = lastmemo.IndexOf("(");
  542. DateTime urgtime = Convert.ToDateTime(utime);
  543. string newlastmemo = "";
  544. if (lastkindex == 0)
  545. {
  546. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  547. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  548. }
  549. else
  550. {
  551. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  552. }
  553. entity.seller_memo = prememo + newlastmemo;
  554. }
  555. entity.IsUrgency = true;
  556. entity.UpdateTime = DateTime.Now;
  557. entity.Update();
  558. ApiVo apiVo = new ApiVo();
  559. apiVo.orderNumber = entity.ctid;
  560. apiVo.actionName = "changeDesign";
  561. apiVo.orderRemarks = entity.seller_memo;
  562. apiVo.remarkSign = 3;
  563. designHelper.API_WorkCore(apiVo); //changeDesign
  564. CeErpSukuraData.createInfo(entity.ctid, 7);
  565. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  566. returnSuccessMsg("设置成功!");
  567. return;
  568. }
  569. returnErrorMsg("找不到记录");
  570. }
  571. }
  572. public void set_erp_reset()
  573. {
  574. if (UrlPostParmsCheck("ctid"))
  575. {
  576. string eid = GetPostString("ctid");
  577. CeErpTradeCell entity = null;
  578. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  579. if (entity != null)
  580. {
  581. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  582. {
  583. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  584. {
  585. returnErrorMsg("财务要求已下单已发货无法重置");
  586. return;
  587. }
  588. }
  589. entity.IsUrgency = false;
  590. entity.seller_memo = "";
  591. entity.OtherMemo = "";
  592. entity.OrderState = 0;
  593. entity.IsReturn = 0;
  594. //entity.IsRefund = 0;
  595. entity.MemoOpt = 0;
  596. entity.AfterSaleState = 0;
  597. entity.AfterSaleResponsible = "";
  598. entity.AfterSaleUserId = 0;
  599. entity.IsNeedBill = 0;
  600. entity.CustomerUserId = 0;
  601. entity.DesignUserId = 0;
  602. entity.SupplierId = 0;
  603. entity.PlaceUserId = 0;
  604. entity.ptid = "";
  605. entity.IsSample = 0;
  606. entity.IsXianHuo = 0;
  607. entity.isDianziOrder = 0;
  608. entity.DispatchSort = 0;
  609. entity.FinishPlaceTime = null;
  610. entity.Update();
  611. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  612. if (trade != null)
  613. {
  614. trade.seller_memo = "";
  615. trade.Update();
  616. }
  617. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  618. returnSuccessMsg("重置成功!");
  619. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  620. if (desginBill != null)
  621. {
  622. desginBill.isDel = 1;
  623. desginBill.Update();
  624. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  625. }
  626. ApiVo apiVo = new ApiVo();
  627. apiVo.orderNumber = entity.ctid;
  628. apiVo.actionName = "resetDesign";
  629. designHelper.API_WorkCore(apiVo);//resetDesign
  630. return;
  631. }
  632. returnErrorMsg("找不到记录");
  633. }
  634. }
  635. public void save_erp_sellermemo()
  636. {
  637. if (UrlPostParmsCheck("ctid"))
  638. {
  639. string ctid = GetPostString("ctid");
  640. CeErpTradeCell entity = null;
  641. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  642. if (entity != null)
  643. {
  644. string memo = GetPostString("seller_memo");
  645. memo = memo.Replace(" ", "");
  646. if (memo.Contains("补差"))
  647. {
  648. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  649. return;
  650. }
  651. if (entity.seller_memo != memo)
  652. {
  653. if (entity.IsSample == 2)
  654. {
  655. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  656. return;
  657. }
  658. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  659. {
  660. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  661. {
  662. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  663. return;
  664. }
  665. }
  666. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  667. }
  668. commonHelper.getCytPrice(entity);
  669. int memoopt = GetPostInt("MemoOpt");
  670. Boolean ismemoopt = false;
  671. if (memoopt > 0)
  672. {
  673. string stropt = "";
  674. if (memoopt == 1)
  675. {
  676. stropt = "“改稿”";
  677. ismemoopt = true;
  678. }
  679. else if (memoopt == 2)
  680. {
  681. stropt = "“定稿”";
  682. }
  683. else if (memoopt == 3)
  684. {
  685. stropt = "“查货”";
  686. CeErpSukuraData.createInfo(entity.ctid, 6);
  687. }
  688. entity.MemoOpt = Convert.ToInt32(memoopt);
  689. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  690. }
  691. if (entity.OrderState < 5)
  692. {
  693. memo = memo.Replace("(", "(");
  694. memo = memo.Replace(")", ")");
  695. }
  696. entity.seller_memo = memo;
  697. entity.UpdateTime = DateTime.Now;
  698. entity.Update();
  699. ApiVo apiVo = new ApiVo();
  700. apiVo.orderNumber = entity.ctid;
  701. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  702. apiVo.orderRemarks = memo;
  703. apiVo.remarkSign = memoopt;
  704. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  705. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  706. returnSuccessMsg("保存成功!");
  707. return;
  708. }
  709. returnErrorMsg("找不到记录");
  710. }
  711. }
  712. public void ins_erp_checkorder()
  713. {
  714. if (UrlPostParmsCheck("ctid"))
  715. {
  716. string ctid = GetPostString("ctid");
  717. CeErpTradeCell entity = null;
  718. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  719. if (entity != null)
  720. {
  721. if (entity.OrderState < 6)
  722. {
  723. returnErrorMsg("下单完成后才可查货");
  724. return;
  725. }
  726. /*if (entity.OrderState > 6)
  727. {
  728. returnErrorMsg("订单已发货");
  729. return;
  730. }*/
  731. if (entity.FinishPlaceTime != null)
  732. {
  733. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  734. {
  735. returnErrorMsg("下单时间不足,无法查货");
  736. return;
  737. }
  738. }
  739. entity.MemoOpt = 3;
  740. entity.CheckOrderTime = DateTime.Now;
  741. entity.UpdateTime = DateTime.Now;
  742. entity.Update();
  743. CeErpSukuraData.createInfo(entity.ctid, 6);
  744. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  745. returnSuccessMsg("操作成功!");
  746. return;
  747. }
  748. returnErrorMsg("找不到记录");
  749. }
  750. }
  751. public void save_erp_othermemo()
  752. {
  753. if (UrlPostParmsCheck("ctid"))
  754. {
  755. string ctid = GetPostString("ctid");
  756. CeErpTradeCell entity = null;
  757. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  758. if (entity != null)
  759. {
  760. entity.OtherMemo = GetPostString("otherMemo");
  761. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  762. {
  763. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  764. StringBuilder sql = new StringBuilder();
  765. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  766. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  767. if (dt != null && dt.Rows.Count > 0)
  768. {
  769. foreach (DataRow dr in dt.Rows)
  770. {
  771. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  772. {
  773. //品类一直
  774. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  775. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  776. if (ceErpSampleCustomer == null)
  777. {
  778. ceErpSampleCustomer = new CeErpSampleCustomer();
  779. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  780. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  781. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  782. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  783. ceErpSampleCustomer.shopId = entity.ShopId;
  784. }
  785. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  786. ceErpSampleCustomer.lastTid = entity.tid;
  787. if (ceErpSampleCustomer.ID > 0)
  788. {
  789. ceErpSampleCustomer.Update();
  790. }
  791. else
  792. {
  793. ceErpSampleCustomer.Create();
  794. }
  795. }
  796. }
  797. }
  798. }
  799. //if (entity.IsOldCustomer == 1)
  800. //{
  801. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  802. //{
  803. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  804. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  805. //}
  806. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  807. //{
  808. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  809. // {
  810. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  811. // {
  812. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  813. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  814. // }
  815. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  816. // {
  817. // entity.OrderState = 2;
  818. // entity.DesignUserId = 0;
  819. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  820. // }
  821. // else
  822. // {
  823. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  824. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  825. // }
  826. // }
  827. //}
  828. //}
  829. entity.Update();
  830. returnSuccessMsg("保存成功!");
  831. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  832. return;
  833. }
  834. returnErrorMsg("找不到记录");
  835. }
  836. }
  837. public void save_erp_customermemo()
  838. {
  839. if (UrlPostParmsCheck("ctid"))
  840. {
  841. string ctid = GetPostString("ctid");
  842. CeErpTradeCell entity = null;
  843. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  844. if (entity != null)
  845. {
  846. entity.CustomerMemo = GetPostString("CustomerMemo");
  847. entity.Update();
  848. ApiVo apiVo = new ApiVo();
  849. apiVo.orderNumber = entity.ctid;
  850. apiVo.actionName = "followRemarks";
  851. apiVo.orderRemarks = entity.CustomerMemo;
  852. designHelper.API_WorkCore(apiVo);//followRemarks
  853. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  854. returnSuccessMsg("保存成功!");
  855. return;
  856. }
  857. returnErrorMsg("找不到记录");
  858. }
  859. }
  860. public void upd_erp_addmemotag()
  861. {
  862. if (UrlPostParmsCheck("ctid"))
  863. {
  864. ;
  865. string eid = GetPostString("ctid");
  866. string sfTagstr = GetPostString("memotag");
  867. CeErpTradeCell entity = null;
  868. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  869. if (entity != null)
  870. {
  871. if (entity.OrderState == 0)
  872. {
  873. returnErrorMsg("请先领单");
  874. return;
  875. }
  876. //撤销顺丰
  877. if (sfTagstr == "撤销顺丰")
  878. {
  879. entity.IsSF = 0;
  880. string reMsg = "";
  881. string oldmemo = entity.seller_memo;
  882. if (entity.OrderState < 5)
  883. {
  884. oldmemo = oldmemo.Replace("顺丰到付", "");
  885. oldmemo = oldmemo.Replace("顺丰寄付", "");
  886. entity.seller_memo = oldmemo;
  887. }
  888. else
  889. {
  890. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  891. {
  892. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  893. }
  894. }
  895. entity.Update();
  896. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  897. api.orderNumber = entity.ctid;
  898. api.actionName = "followRemarks";
  899. api.orderRemarks = entity.seller_memo;
  900. api.isSf = entity.IsSF.ToString();
  901. designHelper.API_WorkCore(api);//followRemarks
  902. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  903. returnSuccessMsg("撤销成功!" + reMsg);
  904. return;
  905. }
  906. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  907. {
  908. //string oldmemo = entity.seller_memo;
  909. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  910. string sfStr = GetPostString("memotag");
  911. string smemo = entity.seller_memo;
  912. int kindex = smemo.IndexOf(")");
  913. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  914. if (lastoneStr != "-")
  915. {
  916. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  917. }
  918. string prememo = smemo.Substring(0, kindex + 2);
  919. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  920. int lastkindex = lastmemo.IndexOf("(");
  921. string newlastmemo = "";
  922. if (lastkindex == 0)
  923. {
  924. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  925. newlastmemo = "(" + sfStr + "." + useLastmemo;
  926. }
  927. else
  928. {
  929. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  930. }
  931. entity.seller_memo = prememo + newlastmemo;
  932. }
  933. string sfTagMSg = "";
  934. if (sfTagstr == "顺丰寄付")
  935. {
  936. entity.IsSF = 1;
  937. sfTagMSg = "顺丰寄付";
  938. }
  939. else if (sfTagstr == "顺丰到付")
  940. {
  941. entity.IsSF = 2;
  942. sfTagMSg = "顺丰到付";
  943. }
  944. entity.Update();
  945. ApiVo apiVo = new ApiVo();
  946. apiVo.orderNumber = entity.ctid;
  947. apiVo.actionName = "orderRemarks";
  948. apiVo.orderRemarks = entity.seller_memo;
  949. apiVo.isSf = entity.IsSF.ToString();
  950. designHelper.API_WorkCore(apiVo);//orderRemarks
  951. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  952. returnSuccessMsg("标记成功!");
  953. return;
  954. }
  955. returnErrorMsg("找不到记录");
  956. }
  957. }
  958. public void upd_erp_ordertag()
  959. {
  960. if (UrlPostParmsCheck("ctid"))
  961. {
  962. string eid = GetPostString("ctid");
  963. CeErpTradeCell entity = null;
  964. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  965. if (entity != null)
  966. {
  967. int tag = GetPostInt("wechattag");
  968. //if(tag==4 && entity.IsSample == 2)
  969. //{
  970. // returnErrorMsg("补差价单不能标记微信单");
  971. // return;
  972. //}
  973. entity.wechatTag = tag;
  974. entity.Update();
  975. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  976. if (tag == 1)
  977. {
  978. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  979. if (cash == null)
  980. {
  981. CeErpTrade main = CeErpTrade.Get(entity.tid);
  982. cash = new CeErpReturnCash();
  983. cash.tid = entity.tid;
  984. cash.seller_nick = main.seller_nick;
  985. cash.payment = trade.payment;
  986. cash.buyer_nick = main.buyer_nick;
  987. cash.cashstate = 0;
  988. cash.rtype = "微信返现";
  989. cash.returnprice = 0;
  990. cash.created = DateTime.Now;
  991. cash.con = "订单标记微信单";
  992. cash.img = "";
  993. cash.applyuserid = CurrentUser.UserID;
  994. cash.Create();
  995. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  996. }
  997. else
  998. {
  999. cash.cashstate = 0;
  1000. cash.Update();
  1001. }
  1002. CeErpSukuraData.createInfo(entity.ctid, 9);
  1003. }
  1004. else if (tag == 2)
  1005. {
  1006. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1007. if (cash == null)
  1008. {
  1009. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1010. cash = new CeErpReturnCash();
  1011. cash.tid = entity.tid;
  1012. cash.seller_nick = main.seller_nick;
  1013. cash.payment = trade.payment;
  1014. cash.buyer_nick = main.buyer_nick;
  1015. cash.cashstate = 0;
  1016. cash.rtype = "推购返现";
  1017. cash.returnprice = 5;
  1018. cash.created = DateTime.Now;
  1019. cash.con = "订单标记推购单";
  1020. cash.img = "";
  1021. cash.applyuserid = CurrentUser.UserID;
  1022. cash.Create();
  1023. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1024. }
  1025. else
  1026. {
  1027. cash.cashstate = 0;
  1028. cash.Update();
  1029. }
  1030. CeErpSukuraData.createInfo(entity.ctid, 9);
  1031. }
  1032. else if (tag == 3)
  1033. {
  1034. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1035. if (pers == null)
  1036. {
  1037. pers = new CeErpPersuade();
  1038. pers.ctid = entity.ctid;
  1039. pers.pstate = 0;
  1040. pers.created = DateTime.Now;
  1041. pers.applyuserid = CurrentUser.UserID;
  1042. pers.Create();
  1043. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1044. }
  1045. else
  1046. {
  1047. pers.pstate = 0;
  1048. pers.Update();
  1049. }
  1050. }
  1051. else if (tag == 4 || tag == 5)
  1052. {
  1053. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1054. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1055. if (pers == null)
  1056. {
  1057. pers = new CeErpStayGoods();
  1058. pers.t_id = entity.tid;
  1059. pers.status = "待审核";
  1060. pers.audit_type = 0;
  1061. if (tag == 4)
  1062. {
  1063. pers.stay_type = "微信推购";
  1064. }
  1065. else
  1066. {
  1067. pers.stay_type = "旺旺推购";
  1068. }
  1069. if (entity.IsXianHuo == 0)
  1070. {
  1071. pers.product_id = entity.ProductId;
  1072. }
  1073. pers.wangwang = main.buyer_nick;
  1074. pers.shop_name = main.seller_nick;
  1075. pers.creata_time = DateTime.Now;
  1076. pers.create_u_id = CurrentUser.UserID;
  1077. pers.create_u_name = CurrentUser.UserName;
  1078. pers.Create();
  1079. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1080. }
  1081. else
  1082. {
  1083. pers.audit_type = 0;
  1084. pers.Update();
  1085. }
  1086. CeErpSukuraData.createInfo(entity.ctid, 10);
  1087. }
  1088. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1089. returnSuccessMsg("标记成功!");
  1090. return;
  1091. }
  1092. returnErrorMsg("找不到记录");
  1093. }
  1094. }
  1095. public void upd_erp_ordertag_cancel()
  1096. {
  1097. if (UrlPostParmsCheck("ctid"))
  1098. {
  1099. string eid = GetPostString("ctid");
  1100. CeErpTradeCell entity = null;
  1101. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1102. if (entity != null)
  1103. {
  1104. entity.wechatTag = 0;
  1105. entity.Update();
  1106. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1107. if (pers != null)
  1108. {
  1109. pers.status = "取消推购";
  1110. pers.audit_type = 3;
  1111. pers.Update();
  1112. }
  1113. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1114. returnSuccessMsg("标记成功!");
  1115. return;
  1116. }
  1117. returnErrorMsg("找不到记录");
  1118. }
  1119. }
  1120. public void upd_erp_addweichattag()
  1121. {
  1122. if (UrlPostParmsCheck("ctid"))
  1123. {
  1124. ;
  1125. string eid = GetPostString("ctid");
  1126. CeErpTradeCell entity = null;
  1127. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1128. if (entity != null)
  1129. {
  1130. if (entity.IsAddWechat > 0)
  1131. {
  1132. returnErrorMsg("此单已经标记过了");
  1133. return;
  1134. }
  1135. 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);
  1136. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1137. if (dt.Rows.Count > 0)
  1138. {
  1139. entity.IsAddWechat = 2;
  1140. }
  1141. else
  1142. {
  1143. entity.IsAddWechat = 1;
  1144. }
  1145. entity.Update();
  1146. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1147. returnSuccessMsg("标记成功!");
  1148. return;
  1149. }
  1150. returnErrorMsg("找不到记录");
  1151. }
  1152. }
  1153. public void upd_erp_getmyorder()
  1154. {
  1155. if (UrlPostParmsCheck("ctid"))
  1156. {
  1157. ;
  1158. string eid = GetPostString("ctid");
  1159. CeErpTradeCell entity = null;
  1160. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1161. if (entity != null)
  1162. {
  1163. if (entity.ctid.IndexOf("C") != -1)
  1164. {
  1165. StringBuilder sql = new StringBuilder();
  1166. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1167. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1168. if (dt.Rows.Count > 0)
  1169. {
  1170. decimal total = 0;
  1171. foreach (DataRow dr in dt.Rows)
  1172. {
  1173. total += Convert.ToDecimal(dr["payment"]);
  1174. }
  1175. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1176. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1177. {
  1178. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1179. return;
  1180. }
  1181. }
  1182. }
  1183. entity.CustomerUserId = CurrentUser.UserID;
  1184. if (entity.OrderState < 2)
  1185. {
  1186. entity.OrderState = 2;
  1187. if (entity.ShopId != 0)
  1188. {
  1189. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1190. }
  1191. }
  1192. entity.UpdateTime = DateTime.Now;
  1193. entity.Update();
  1194. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1195. returnSuccessMsg("领单成功!");
  1196. return;
  1197. }
  1198. returnErrorMsg("找不到记录");
  1199. }
  1200. }
  1201. public void getmyorder_from_init()
  1202. {
  1203. if (UrlPostParmsCheck("ctid"))
  1204. {
  1205. string eid = GetPostString("ctid");
  1206. CeErpTradeCell entity = null;
  1207. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1208. if (entity != null)
  1209. {
  1210. string sellerMemo = GetPostString("sellerMemo");
  1211. if (sellerMemo.Length > 0)
  1212. {
  1213. entity.seller_memo = sellerMemo;
  1214. }
  1215. string oterhMemo = GetPostString("otherMemo");
  1216. if (oterhMemo.Length > 0)
  1217. {
  1218. entity.OtherMemo = oterhMemo;
  1219. }
  1220. int urg = GetPostInt("urgency");
  1221. entity.IsUrgency = (urg == 1 ? true : false);
  1222. int wechat = GetPostInt("wechat");
  1223. int command = GetPostInt("command");
  1224. if (wechat == 1)
  1225. {
  1226. entity.wechatTag = 1;
  1227. }
  1228. if (command == 1)
  1229. {
  1230. entity.wechatTag = 2;
  1231. }
  1232. string pPro = GetPostString("pprofession");
  1233. if (pPro.Length > 0)
  1234. {
  1235. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1236. string spro = GetPostString("profession");
  1237. if (spro.Length > 0)
  1238. {
  1239. entity.ProfessionId = Convert.ToInt32(spro);
  1240. }
  1241. }
  1242. string proId = GetPostString("productId");
  1243. if (proId.Length > 0)
  1244. {
  1245. entity.ProductId = Convert.ToInt32(proId);
  1246. }
  1247. entity.Material = GetPostString("material");
  1248. entity.Craft = GetPostString("craft");
  1249. entity.CustomerUserId = CurrentUser.UserID;
  1250. if (entity.OrderState < 2)
  1251. {
  1252. entity.OrderState = 2;
  1253. if (entity.ShopId != 0)
  1254. {
  1255. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1256. }
  1257. }
  1258. entity.Update();
  1259. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1260. returnSuccessMsg("领单成功!");
  1261. return;
  1262. }
  1263. returnErrorMsg("找不到记录");
  1264. }
  1265. }
  1266. public void upd_erp_setrelationorder()
  1267. {
  1268. if (UrlPostParmsCheck("ctid"))
  1269. {
  1270. ;
  1271. string eid = GetPostString("ctid");
  1272. string ftid = GetPostString("ftid");
  1273. CeErpTradeCell entity = null;
  1274. CeErpTradeCell fentity = null;
  1275. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1276. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1277. if (fentity == null)
  1278. {
  1279. returnErrorMsg("找不到关联的主订单");
  1280. return;
  1281. }
  1282. if (entity != null)
  1283. {
  1284. if (entity.OrderState >= 5)
  1285. {
  1286. returnErrorMsg("本单已经设计完成无法关联");
  1287. return;
  1288. }
  1289. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1290. {
  1291. returnErrorMsg("线下单续审核后才能关联!");
  1292. return;
  1293. }
  1294. entity.ptid = ftid;
  1295. entity.OrderState = fentity.OrderState;
  1296. //entity.status = fentity.status;
  1297. entity.CustomerUserId = fentity.CustomerUserId;
  1298. entity.DesignUserId = fentity.DesignUserId;
  1299. entity.seller_memo = "补差价单:" + ftid;
  1300. entity.IsSample = 2;
  1301. entity.Update();
  1302. ApiVo apiVo = new ApiVo();
  1303. apiVo.orderNumber = ftid;
  1304. apiVo.payment = entity.payment;
  1305. apiVo.actionName = "repairDesign";
  1306. designHelper.API_WorkCore(apiVo);//repairDesign
  1307. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1308. returnSuccessMsg("关联成功!");
  1309. return;
  1310. }
  1311. else
  1312. returnErrorMsg("找不到记录");
  1313. }
  1314. }
  1315. public void download_erp_neworder()
  1316. {
  1317. string seller = GetPostString("seller_nick");
  1318. string tid = GetPostString("tid");
  1319. if (seller.Length <= 0 || tid.Length <= 0)
  1320. {
  1321. returnErrorMsg("数据错误");
  1322. }
  1323. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1324. //{
  1325. // returnErrorMsg("找不到店铺Sessionkey");
  1326. //}
  1327. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1328. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1329. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1330. if (res.IndexOf("refOid") == -1)
  1331. {
  1332. returnErrorMsg("下载订单数据失败");
  1333. return;
  1334. }
  1335. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1336. returnSuccessMsg("下载完成");
  1337. //tmcHelper.createNewOrder(res);
  1338. //CeErpTrade entr = null;
  1339. //entr = CeErpTrade.Get(tid);
  1340. //if (entr != null)
  1341. //{
  1342. // returnSuccess("下载成功");
  1343. // //下载成功之后,Cell表生成对应的订单;
  1344. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1345. //}
  1346. //else
  1347. //{
  1348. // returnErrorMsg("下载失败或者创建订单失败");
  1349. //}
  1350. }
  1351. public void set_erp_atersale()
  1352. {
  1353. if (UrlPostParmsCheck("ctid"))
  1354. {
  1355. string eid = GetPostString("ctid");
  1356. string reason = GetPostString("AfterSaleReason");
  1357. CeErpTradeCell entity = null;
  1358. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1359. if (entity != null)
  1360. {
  1361. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1362. {
  1363. returnErrorMsg("此订单已经在售后");
  1364. return;
  1365. }
  1366. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1367. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1368. entity.AfterSaleTime = DateTime.Now;
  1369. entity.Update();
  1370. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1371. returnSuccessMsg("转售后成功!");
  1372. return;
  1373. }
  1374. returnErrorMsg("找不到记录");
  1375. }
  1376. }
  1377. public void set_erp_withdraw()
  1378. {
  1379. if (UrlPostParmsCheck("ctid"))
  1380. {
  1381. try
  1382. {
  1383. string eid = GetPostString("ctid");//商品id
  1384. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1385. CeWithdraw ceWithdrawSelect = null;
  1386. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1387. if (ceWithdrawSelect != null)
  1388. {
  1389. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1390. {
  1391. ceWithdrawSelect.status = -1;
  1392. ceWithdrawSelect.Update();
  1393. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1394. returnSuccessMsg("重新发起审核成功");
  1395. return;
  1396. }
  1397. else
  1398. {
  1399. returnSuccessMsg("请勿重复申请!");
  1400. return;
  1401. }
  1402. }
  1403. else
  1404. {
  1405. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1406. if (string.IsNullOrEmpty(CustomerUserId))
  1407. {
  1408. CustomerUserId = "-1";
  1409. }
  1410. int Userid = CurrentUser.UserID;//用户id
  1411. CeWithdraw ceWithdraw = new CeWithdraw();
  1412. ceWithdraw.tid = eid;
  1413. ceWithdraw.userid = Userid;
  1414. ceWithdraw.providerid = CustomerUserId;
  1415. ceWithdraw.status = 3;
  1416. ceWithdraw.creationtime = DateTime.Now;
  1417. ceWithdraw.Create();
  1418. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1419. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1420. return;
  1421. }
  1422. }
  1423. catch
  1424. {
  1425. returnErrorMsg("申请撤回订单失败");
  1426. return;
  1427. }
  1428. }
  1429. }
  1430. public void ins_erp_billinfo()
  1431. {
  1432. if (UrlPostParmsCheck("ctid"))
  1433. {
  1434. string eid = GetPostString("ctid");
  1435. CeErpTradeCell entity = null;
  1436. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1437. if (entity != null)
  1438. {
  1439. CeErpBill bill = CeErpBill.GetByTid(eid);
  1440. bool isHave = false;
  1441. if (bill != null)
  1442. {
  1443. isHave = true;
  1444. if (bill.state != 4)
  1445. {
  1446. returnErrorMsg("此单已经申请过发票了");
  1447. return;
  1448. }
  1449. }
  1450. if (entity.IsNeedBill == 0)
  1451. {
  1452. entity.IsNeedBill = 1;
  1453. }
  1454. entity.Update();
  1455. string errjson = "";
  1456. try
  1457. {
  1458. CeErpBill bill_entity = new CeErpBill();
  1459. bill_entity.tid = entity.tid;
  1460. bill_entity.title = GetPostString("title");
  1461. string taxstr = GetPostString("tax");
  1462. taxstr = taxstr.Replace(" ", "");
  1463. bill_entity.tax = taxstr;
  1464. bill_entity.bank = GetPostString("bank");
  1465. string bankacstr = GetPostString("bankac");
  1466. bankacstr = bankacstr.Replace(" ", "");
  1467. bill_entity.bankac = bankacstr;
  1468. bill_entity.address = GetPostString("address");
  1469. bill_entity.phone = GetPostString("phone");
  1470. bill_entity.price = GetPostString("price");
  1471. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1472. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1473. {
  1474. billCount += 1;
  1475. }
  1476. string prebill = "ltb";
  1477. for (int idx = 1; idx <= billCount; idx++)
  1478. {
  1479. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1480. string billoid = prebill + idx + dtstr;
  1481. bill_entity.billOrderId += billoid;
  1482. if (idx < billCount)
  1483. {
  1484. bill_entity.billOrderId += ",";
  1485. }
  1486. }
  1487. bill_entity.productId = GetPostInt("ProductName");
  1488. bill_entity.num = GetPostInt("num");
  1489. bill_entity.unit = GetPostString("unit");
  1490. bill_entity.type = GetPostString("type");
  1491. bill_entity.sendType = GetPostString("SendType");
  1492. bill_entity.email = GetPostString("email");
  1493. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1494. bill_entity.shopName = GetPostString("ShopName");
  1495. bill_entity.applymemo = GetPostString("applyMemo");
  1496. bill_entity.createTime = DateTime.Now;
  1497. bill_entity.state = 0;
  1498. bill_entity.userId = CurrentUser.UserID;
  1499. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1500. bill_entity.Create();
  1501. }
  1502. catch (Exception ex)
  1503. {
  1504. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1505. returnErrorMsg("创建发票出错!");
  1506. return;
  1507. }
  1508. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1509. returnSuccessMsg("发票申请成功!");
  1510. return;
  1511. }
  1512. returnErrorMsg("找不到记录");
  1513. }
  1514. }
  1515. public void ins_erp_neworder()
  1516. {
  1517. if (UrlPostParmsCheck("receiver_name"))
  1518. {
  1519. CeErpTrade entity = new CeErpTrade();
  1520. string plat_form = GetPostString("platform");
  1521. string preStr = "N_";
  1522. if (plat_form == "拼多多")
  1523. {
  1524. preStr = "P_";
  1525. }
  1526. else if (plat_form == "阿里巴巴")
  1527. {
  1528. preStr = "A_";
  1529. }
  1530. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1531. entity.seller_nick = GetPostString("seller_nick");
  1532. entity.buyer_nick = GetPostString("buyer_nick");
  1533. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1534. entity.total_fee = entity.payment;
  1535. entity.pay_time = DateTime.Now;
  1536. entity.status = "NOT_SHIPPED";
  1537. entity.receiver_name = GetPostString("receiver_name");
  1538. entity.receiver_mobile = GetPostString("receiver_mobile");
  1539. entity.receiver_state = GetPostString("receiver_state");
  1540. entity.receiver_city = GetPostString("receiver_city");
  1541. entity.receiver_district = GetPostString("receiver_district");
  1542. entity.receiver_address = GetPostString("receiver_address");
  1543. if (entity.receiver_state == "" || entity.receiver_city == "")
  1544. {
  1545. returnErrorMsg("收件地址不能为空");
  1546. return;
  1547. }
  1548. int shopId = 0;
  1549. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1550. if (nShop != null)
  1551. {
  1552. shopId = nShop.ID;
  1553. }
  1554. if (shopId != 34 && entity.payment == 0)
  1555. {
  1556. returnErrorMsg("公司自用的单金额才能为0");
  1557. return;
  1558. }
  1559. entity.Create();
  1560. CeErpTradeCell entitycell = new CeErpTradeCell();
  1561. entitycell.ctid = entity.tid;
  1562. entitycell.tid = entity.tid;
  1563. entitycell.ShopId = shopId;
  1564. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1565. entitycell.OrderState = 0;
  1566. entitycell.pay_time = entity.pay_time;
  1567. entitycell.IsOffLineOrder = 1;
  1568. entitycell.Create();
  1569. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1570. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1571. return;
  1572. }
  1573. }
  1574. public void ins_erp_neworder2()
  1575. {
  1576. if (UrlPostParmsCheck("receiver_name"))
  1577. {
  1578. //string plat_form = GetPostString("platform");
  1579. string preStr = "X_";
  1580. string memo = GetPostString("memo");
  1581. string productId = GetPostString("productId");
  1582. string primg = GetPostString("proofimg");
  1583. string sellerNick = GetPostString("seller_nick");
  1584. string addFrom = GetPostString("addfrom");
  1585. if (addFrom == "1")
  1586. {
  1587. preStr = "N_";
  1588. }
  1589. int shopId = 0;
  1590. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1591. if (nShop != null)
  1592. {
  1593. shopId = nShop.ID;
  1594. }
  1595. else
  1596. {
  1597. returnErrorMsg("找不到对应店铺");
  1598. return;
  1599. }
  1600. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1601. {
  1602. returnErrorMsg("必须上传付款凭证");
  1603. return;
  1604. }
  1605. CeErpTrade entity = new CeErpTrade();
  1606. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1607. entity.seller_nick = sellerNick;
  1608. entity.buyer_nick = GetPostString("buyer_nick");
  1609. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1610. entity.total_fee = entity.payment;
  1611. entity.pay_time = DateTime.Now;
  1612. entity.status = "NOT_SHIPPED";
  1613. entity.receiver_name = GetPostString("receiver_name");
  1614. entity.receiver_mobile = GetPostString("receiver_mobile");
  1615. entity.receiver_state = GetPostString("receiver_state");
  1616. entity.receiver_city = GetPostString("receiver_city");
  1617. entity.receiver_district = GetPostString("receiver_district");
  1618. entity.receiver_address = GetPostString("receiver_address");
  1619. entity.seller_memo = memo;
  1620. entity.orderFrom = 20;
  1621. entity.orderType = 15;
  1622. if (entity.receiver_state == "" || entity.receiver_city == "")
  1623. {
  1624. returnErrorMsg("收件地址不能为空");
  1625. return;
  1626. }
  1627. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1628. {
  1629. returnErrorMsg("公司自用的单金额才能为0");
  1630. return;
  1631. }
  1632. entity.Create();
  1633. string toWhere = GetPostString("towhere");
  1634. CeErpTradeCell entitycell = new CeErpTradeCell();
  1635. entitycell.ctid = entity.tid;
  1636. //唯一标识
  1637. entitycell.OrderSn = entity.tid;
  1638. string orderSn = dataHelper.getSaleOrderSn();
  1639. if (orderSn != "")
  1640. {
  1641. entitycell.OrderSn = orderSn;
  1642. }
  1643. entitycell.tid = entity.tid;
  1644. //if (preStr == "X_")
  1645. //{
  1646. entitycell.IsOffLineOrder = 1;
  1647. //}
  1648. entitycell.CustomerUserId = CurrentUser.UserID;
  1649. entitycell.PayProofImg = primg;
  1650. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1651. entitycell.ProductId = Convert.ToInt32(productId);
  1652. entitycell.ShopId = shopId;
  1653. entitycell.UpdateTime = DateTime.Now;
  1654. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1655. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1656. {
  1657. entitycell.IsXianHuo = 1;
  1658. }
  1659. entitycell.pay_time = entity.pay_time;
  1660. if (toWhere == "1")
  1661. {
  1662. entitycell.OrderState = 2;
  1663. }
  1664. else
  1665. {
  1666. entitycell.OrderState = 6;
  1667. entitycell.FinishPlaceTime = entitycell.pay_time;
  1668. }
  1669. if (shopId == 94)
  1670. {
  1671. entitycell.OrderState = 4;
  1672. entitycell.WaitDesignTime = entitycell.pay_time;
  1673. entitycell.StartDesignTime = entitycell.pay_time;
  1674. entitycell.DesignUserId = 218;
  1675. }
  1676. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1677. {
  1678. entitycell.OrderState = -1;//修改12-5
  1679. CeWithdraw ceWithdraw = new CeWithdraw();
  1680. ceWithdraw.tid = entity.tid;
  1681. ceWithdraw.providerid = "-1";
  1682. ceWithdraw.status = -1;
  1683. ceWithdraw.creationtime = DateTime.Now;
  1684. ceWithdraw.userid = 1337;
  1685. ceWithdraw.Create();
  1686. }
  1687. entitycell.Create();
  1688. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1689. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1690. {
  1691. addPlaceRegist(entitycell, CurrentUser.UserID);
  1692. }
  1693. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1694. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1695. return;
  1696. }
  1697. }
  1698. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1699. {
  1700. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1701. entity.PlactTime = tradecell.pay_time;
  1702. entity.AddUserId = userid;
  1703. entity.FileName = tradecell.seller_memo;
  1704. entity.Supplier = 24;
  1705. entity.CreateTime = DateTime.Now;
  1706. entity.Did = tradecell.ctid;
  1707. entity.tid = tradecell.tid;
  1708. entity.splitTag = tradecell.SplitTag;
  1709. entity.CurState = "未完成";
  1710. entity.Create();
  1711. }
  1712. public void get_erp_offlinelist()
  1713. {
  1714. DataStruct dStruct = GetPostStruct();
  1715. List<string> lw = new List<string>();
  1716. string tid = GetPostString("ctid");
  1717. string date1 = GetPostString("date1");
  1718. string date2 = GetPostString("date2");
  1719. if (tid.Length > 0 || date1.Length > 0)
  1720. {
  1721. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1722. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1723. if (dw.Length > 0) lw.Add(dw);
  1724. }
  1725. else
  1726. {
  1727. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1728. }
  1729. string shopname = GetPostString("shopname");
  1730. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1731. string buyernick = GetPostString("buyer_nick");
  1732. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1733. string customer = GetPostString("customer");
  1734. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1735. string design = GetPostString("design");
  1736. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1737. string orderState = GetPostString("orderState");
  1738. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1739. string address = GetPostString("address");
  1740. 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));
  1741. string sellermemo = GetPostString("seller_memo");
  1742. if (sellermemo.Length > 0)
  1743. {
  1744. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1745. }
  1746. string price1 = GetPostString("price1");
  1747. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1748. string price2 = GetPostString("price2");
  1749. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1750. //if (PKey != "admin")
  1751. //{
  1752. // string usershop = CurrentUser.User.pemShop;
  1753. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1754. //}
  1755. //if (ex_psize > 0)
  1756. //{
  1757. dStruct.Order = "pay_time desc";
  1758. //}
  1759. //else
  1760. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1761. lw.Add(string.Format("IsOffLineOrder=1"));
  1762. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1763. DataTable dt = null;
  1764. dt = WebCache.GetData("view_erptradecell", dStruct);
  1765. writeGridDataTableJson(dStruct.TotalCount, dt);
  1766. }
  1767. public void get_erp_returncashrecord()
  1768. {
  1769. DataStruct dStruct = GetPostStruct();
  1770. List<string> lw = new List<string>();
  1771. string tid = GetPostString("ctid");
  1772. if (tid.Length > 0)
  1773. {
  1774. lw.Add(string.Format("tid like '%{0}%'", tid));
  1775. dStruct.Order = "id desc";
  1776. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1777. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1778. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1779. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1780. return;
  1781. }
  1782. returnErrorMsg("id数据错误!");
  1783. }
  1784. public void ins_erp_returncashrecord()
  1785. {
  1786. if (UrlPostParmsCheck("tid"))
  1787. {
  1788. string tid = GetPostString("tid");
  1789. string retype = GetPostString("type");
  1790. StringBuilder sql = new StringBuilder();
  1791. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1792. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1793. if (dt.Rows.Count > 0)
  1794. {
  1795. returnErrorMsg("相同返现类型记录已存在");
  1796. return;
  1797. }
  1798. CeErpReturnCash entity = new CeErpReturnCash();
  1799. entity.tid = tid;
  1800. entity.seller_nick = GetPostString("seller_nick");
  1801. string pment = GetPostString("payment");
  1802. if (pment.Length > 0)
  1803. {
  1804. entity.payment = Convert.ToDouble(pment);
  1805. }
  1806. entity.buyer_nick = GetPostString("buyer_nick");
  1807. entity.cashstate = 0;
  1808. entity.rtype = retype;
  1809. string rPrice = GetPostString("returnprice");
  1810. if (rPrice.Length > 0)
  1811. {
  1812. entity.returnprice = Convert.ToDouble(rPrice);
  1813. }
  1814. entity.created = DateTime.Now;
  1815. entity.con = GetPostString("con");
  1816. entity.img = GetPostString("img");
  1817. entity.applyuserid = CurrentUser.UserID;
  1818. entity.Create();
  1819. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1820. returnSuccessMsg("操作成功!");
  1821. return;
  1822. }
  1823. }
  1824. public void set_erp_predelivery()
  1825. {
  1826. if (UrlPostParmsCheck("ctid"))
  1827. {
  1828. string eid = GetPostString("ctid");
  1829. CeErpTradeCell entity = null;
  1830. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1831. if (entity != null)
  1832. {
  1833. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1834. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1835. //{
  1836. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1837. // return;
  1838. //}
  1839. entity.IsPreDelivery = 1;
  1840. entity.Update();
  1841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1842. returnSuccessMsg("预发货成功!");
  1843. return;
  1844. //string shop = GetPostString("seller_nick");
  1845. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1846. //string comName = GetPostString("comName");
  1847. //string comCode = GetPostString("comCode");
  1848. //string outSid = GetPostString("outSid");//运单号
  1849. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1850. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1851. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1852. //string apires = "";
  1853. //if (deliveryType == "虚拟发货")
  1854. //{
  1855. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1856. //}
  1857. //else
  1858. //{
  1859. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1860. //}
  1861. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1862. ////{
  1863. //if (apires.IndexOf("发货成功") != -1)
  1864. //{
  1865. // if (deliveryType != "虚拟发货")
  1866. // {
  1867. // //还要插入快递信息到 快递信息表
  1868. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1869. // exinfo.tid = eid;
  1870. // exinfo.out_sid = outSid;
  1871. // exinfo.company_code = comCode;
  1872. // exinfo.company_name = comName;
  1873. // exinfo.delivery_memo = deliveryMemo;
  1874. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1875. // exinfo.deliveryType = deliveryType;
  1876. // exinfo.Create();
  1877. // }
  1878. // returnSuccessMsg("发货成功!");
  1879. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1880. //}
  1881. //else
  1882. //{
  1883. // returnErrorMsg("淘宝发货失败!!");
  1884. //}
  1885. //return;
  1886. }
  1887. returnErrorMsg("找不到订单记录");
  1888. }
  1889. }
  1890. public void get_erp_unusuallist()
  1891. {
  1892. DataStruct dStruct = GetPostStruct();
  1893. List<string> lw = new List<string>();
  1894. string tid = GetPostString("ctid");
  1895. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1896. string shopname = GetPostString("shopname");
  1897. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1898. string buyernick = GetPostString("buyer_nick");
  1899. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1900. string ResponsibleMan = GetPostString("responsible");
  1901. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1902. string date1 = GetPostString("date1");
  1903. string date2 = GetPostString("date2");
  1904. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1905. if (dw.Length > 0) lw.Add(dw);
  1906. string price1 = GetPostString("price1");
  1907. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1908. string price2 = GetPostString("price2");
  1909. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1910. string orderState = GetPostString("orderState");
  1911. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1912. string sellermemo = GetPostString("seller_memo");
  1913. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1914. lw.Add(string.Format("UnusualTag > 0"));
  1915. lw.Add(string.Format("IsRefund<={0}", 1));
  1916. dStruct.Order = "pay_time desc";
  1917. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1918. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1919. writeGridDataTableJson(dStruct.TotalCount, dt);
  1920. }
  1921. public void set_erp_unusualtonomal()
  1922. {
  1923. if (UrlPostParmsCheck("ctid"))
  1924. {
  1925. string eid = GetPostString("ctid");
  1926. CeErpTradeCell entity = null;
  1927. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1928. if (entity != null)
  1929. {
  1930. entity.UnusualTag = -1;
  1931. entity.Update();
  1932. returnSuccessMsg("忽略成功!");
  1933. return;
  1934. }
  1935. returnErrorMsg("找不到记录");
  1936. }
  1937. }
  1938. public void ins_erp_unusualreason()
  1939. {
  1940. if (UrlPostParmsCheck("ctid"))
  1941. {
  1942. string eid = GetPostString("ctid");
  1943. CeErpTradeCell entity = null;
  1944. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1945. if (entity != null)
  1946. {
  1947. entity.MemoOpt = 4;
  1948. entity.UnusualCon = GetPostString("con");
  1949. entity.Update();
  1950. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1951. if (trade != null)
  1952. {
  1953. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1954. }
  1955. //查货是否超时
  1956. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1957. if (ceErpTradeCellExtend == null)
  1958. {
  1959. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1960. ceErpTradeCellExtend.ctid = entity.ctid;
  1961. }
  1962. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1963. {
  1964. ceErpTradeCellExtend.CheckOut += 1;
  1965. }
  1966. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1967. if (ceErpTradeCellExtend.ID > 0)
  1968. {
  1969. ceErpTradeCellExtend.Update();
  1970. }
  1971. else
  1972. {
  1973. ceErpTradeCellExtend.Create();
  1974. }
  1975. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1976. returnSuccessMsg("操作成功!");
  1977. return;
  1978. }
  1979. returnErrorMsg("找不到记录");
  1980. }
  1981. }
  1982. public void upd_erp_sampleorder()
  1983. {
  1984. if (UrlPostParmsCheck("ctid"))
  1985. {
  1986. string eid = GetPostString("ctid");
  1987. string[] eArr = eid.Split(',');
  1988. if (eArr.Length > 1)
  1989. {
  1990. List<string> eLst = new List<string>();
  1991. for (int i = 0; i < eArr.Length; i++)
  1992. {
  1993. eLst.Add("'" + eArr[i] + "'");
  1994. }
  1995. eid = string.Join(",", eLst.ToArray());
  1996. }
  1997. else
  1998. {
  1999. eid = "'" + eid + "'";
  2000. }
  2001. StringBuilder sql = new StringBuilder();
  2002. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2003. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2004. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2005. if (dt.Rows.Count > 0)
  2006. {
  2007. string errmsg = "";
  2008. foreach (DataRow dr in dt.Rows)
  2009. {
  2010. StringBuilder sqlsb = new StringBuilder();
  2011. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2012. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2013. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2014. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2015. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2016. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2017. {
  2018. continue;
  2019. }
  2020. else
  2021. {
  2022. string emsg = commonHelper.KeepChinese(apires);
  2023. errmsg += emsg;
  2024. }
  2025. }
  2026. if (errmsg.Length > 0)
  2027. {
  2028. returnErrorMsg(errmsg);
  2029. return;
  2030. }
  2031. returnSuccessMsg("操作成功");
  2032. return;
  2033. }
  2034. returnErrorMsg("找不到记录");
  2035. }
  2036. }
  2037. public void upd_erp_transcustomer()
  2038. {
  2039. if (UrlPostParmsCheck("ctid"))
  2040. {
  2041. string eid = GetPostString("ctid");
  2042. int userid = GetPostInt("CustomerUserId");
  2043. CeErpTradeCell entity = null;
  2044. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2045. if (entity != null)
  2046. {
  2047. //string[] mlist = entity.seller_memo.Split('-');
  2048. //string sql = "select * from view_erpuser where id=" + userid;
  2049. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2050. //if (dt != null && dt.Rows.Count > 0)
  2051. //{
  2052. // string nmemo = "";
  2053. // for(int i = 0; i < mlist.Length - 1; i++)
  2054. // {
  2055. // nmemo += mlist[i];
  2056. // nmemo += "-";
  2057. // }
  2058. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2059. // entity.seller_memo = nmemo;
  2060. //}
  2061. entity.CustomerUserId = userid;
  2062. entity.Update();
  2063. returnSuccessMsg("操作成功!");
  2064. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2065. return;
  2066. }
  2067. returnErrorMsg("找不到记录");
  2068. }
  2069. }
  2070. public void upd_erp_transdesigner()
  2071. {
  2072. if (UrlPostParmsCheck("ctid"))
  2073. {
  2074. string eids = GetPostString("ctid");
  2075. string[] ctidList = eids.Split(',');
  2076. int userid = GetPostInt("DesignUserId");
  2077. foreach (string ctid in ctidList)
  2078. {
  2079. CeErpTradeCell entity = null;
  2080. CeErpDesignerBill entitys = null;
  2081. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2082. entitys = CeErpDesignerBill.GetByTid(ctid);
  2083. if (entity != null)
  2084. {
  2085. if (entity.OrderState > 4)
  2086. {
  2087. continue;
  2088. }
  2089. //存在退款不能流转
  2090. if (entity.IsRefund > 0)
  2091. {
  2092. continue;
  2093. }
  2094. entity.DesignUserId = userid;
  2095. entity.WaitDesignTime = DateTime.Now;
  2096. entity.Update();
  2097. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2098. }
  2099. }
  2100. returnSuccessMsg("操作成功!");
  2101. }
  2102. }
  2103. public void upd_erp_distributedesigner()
  2104. {
  2105. if (UrlPostParmsCheck("ctid"))
  2106. {
  2107. string eid = GetPostString("ctid");
  2108. int userid = GetPostInt("DesignUserId");
  2109. string[] idlist = eid.Split(',');
  2110. if (idlist.Length <= 0)
  2111. {
  2112. returnErrorMsg("订单不能为空");
  2113. return;
  2114. }
  2115. foreach (string ctid in idlist)
  2116. {
  2117. CeErpTradeCell entity = null;
  2118. CeErpDesignerBill entitys = null;
  2119. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2120. else continue;
  2121. if (entity != null)
  2122. {
  2123. if (userid == 2125 || userid == 3542)
  2124. { }
  2125. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2126. {
  2127. returnErrorMsg("金额错误的订单无法指派");
  2128. return;
  2129. }
  2130. if (entity.OrderState >= 5)
  2131. {
  2132. returnErrorMsg("已经设计完成无法指派");
  2133. return;
  2134. }
  2135. if (entity.OrderState == -1)
  2136. {
  2137. returnErrorMsg("审核中的订单无法指派");
  2138. return;
  2139. }
  2140. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2141. {
  2142. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2143. return;
  2144. }
  2145. //157赖橙帆 159林晨
  2146. 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)
  2147. {
  2148. returnErrorMsg("指派设计共创无法再次指派!");
  2149. return;
  2150. }
  2151. entity.OrderState = 3;
  2152. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2153. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2154. {
  2155. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2156. entity.SupplierId = suid;
  2157. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2158. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2159. }
  2160. if (userid == 2125 && entity.seller_memo != "")
  2161. {
  2162. apiDesign.API_GetPrintData_CreateOrder(entity);
  2163. }
  2164. if (userid == 3542 && entity.seller_memo != "")
  2165. {
  2166. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2167. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2168. if (response.msg != "设计共创:成功")
  2169. {
  2170. returnErrorMsg(response.msg);
  2171. return;
  2172. }
  2173. entity.DispatchSort = 2;
  2174. }
  2175. else
  2176. {
  2177. if (entity.DispatchSort == 2)
  2178. {
  2179. ApiVo apiVo = new ApiVo();
  2180. apiVo.actionName = "closeDesign";
  2181. apiVo.orderNumber = entity.ctid;
  2182. designHelper.API_WorkCore(apiVo);//closeDesign
  2183. }
  2184. entity.DispatchSort = 0;
  2185. }
  2186. entity.DesignUserId = userid;
  2187. entity.WaitDesignTime = DateTime.Now;
  2188. entity.UpdateTime = DateTime.Now;
  2189. entity.Update();
  2190. string name = commonHelper.getUserNameById(userid);
  2191. commonHelper.UpdateRelationOrder(entity.ctid);
  2192. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2193. }
  2194. }
  2195. returnSuccessMsg("操作成功!");
  2196. return;
  2197. }
  2198. }
  2199. public string getTidByCtid(string ctid)
  2200. {
  2201. string tid = "";
  2202. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2203. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2204. if (dataTable != null && dataTable.Rows.Count > 0)
  2205. {
  2206. tid = dataTable.Rows[0]["tid"].ToString();
  2207. }
  2208. return tid;
  2209. }
  2210. public List<string> getTidByCtidLike(string ctid)
  2211. {
  2212. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2213. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2214. List<string> list = new List<string>();
  2215. if (dataTable != null && dataTable.Rows.Count > 0)
  2216. {
  2217. foreach (DataRow item in dataTable.Rows)
  2218. {
  2219. list.Add("'" + item["tid"].ToString() + "'");
  2220. }
  2221. }
  2222. return list;
  2223. }
  2224. public void get_erp_myorderlist()
  2225. {
  2226. DataStruct dStruct = GetPostStruct();
  2227. List<string> lw = new List<string>();
  2228. string tid = GetPostString("ctid");
  2229. if (tid.Length > 0)
  2230. {
  2231. string select_tid = getTidByCtid(tid);
  2232. lw.Add(string.Format("tid='{0}'", select_tid));
  2233. }
  2234. else
  2235. {
  2236. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2237. }
  2238. //12-1 修改
  2239. string urgent = GetPostString("urgent");
  2240. string back = GetPostString("back");
  2241. string offlineSearch = GetPostString("offlineSearch");
  2242. if (!string.IsNullOrWhiteSpace(urgent))
  2243. {
  2244. if (urgent.Equals("true"))
  2245. {
  2246. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2247. }
  2248. }
  2249. if (!string.IsNullOrWhiteSpace(back))
  2250. {
  2251. if (back.Equals("true"))
  2252. {
  2253. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2254. }
  2255. }
  2256. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2257. {
  2258. if (offlineSearch.Equals("true"))
  2259. {
  2260. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2261. }
  2262. }
  2263. //end
  2264. string shopname = GetPostString("shopname");
  2265. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2266. string buyernick = GetPostString("buyer_nick");
  2267. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2268. string design = GetPostString("design");
  2269. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2270. string orderState = GetPostString("orderState");
  2271. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2272. string sellermemo = GetPostString("seller_memo");
  2273. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2274. string date1 = GetPostString("date1");
  2275. string date2 = GetPostString("date2");
  2276. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2277. if (dw.Length > 0) lw.Add(dw);
  2278. string price1 = GetPostString("price1");
  2279. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2280. string price2 = GetPostString("price2");
  2281. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2282. string urgency = GetPostString("urgency");
  2283. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2284. string after = GetPostString("after");
  2285. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2286. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2287. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2288. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2289. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2290. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2291. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2292. if (dt != null && dt.Rows.Count > 0)
  2293. {
  2294. foreach (DataRow dr in dt.Rows)
  2295. {
  2296. try
  2297. {
  2298. // 对象操作
  2299. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2300. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2301. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2302. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2303. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2304. if (dStruct.PageSize != 100000)
  2305. {
  2306. if (dr["DispatchSort"].ToString() == "2")
  2307. {
  2308. dr["gongchuang"] = 200;
  2309. }
  2310. else
  2311. {
  2312. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2313. dr["gongchuang"] = response.code;
  2314. }
  2315. }
  2316. }
  2317. catch (NullReferenceException ex)
  2318. {
  2319. }
  2320. }
  2321. }
  2322. writeGridDataTableJson(dStruct.TotalCount, dt);
  2323. }
  2324. public void get_erp_myreturnorderlist()
  2325. {
  2326. DataStruct dStruct = GetPostStruct();
  2327. List<string> lw = new List<string>();
  2328. string tid = GetPostString("ctid");
  2329. if (tid.Length > 0)
  2330. {
  2331. string select_tid = getTidByCtid(tid);
  2332. lw.Add(string.Format("tid='{0}'", select_tid));
  2333. }
  2334. else
  2335. {
  2336. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2337. }
  2338. string shopname = GetPostString("shopname");
  2339. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2340. string buyernick = GetPostString("buyer_nick");
  2341. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2342. string design = GetPostString("design");
  2343. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2344. string orderState = GetPostString("orderState");
  2345. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2346. string sellermemo = GetPostString("seller_memo");
  2347. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2348. string date1 = GetPostString("date1");
  2349. string date2 = GetPostString("date2");
  2350. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2351. if (dw.Length > 0) lw.Add(dw);
  2352. string price1 = GetPostString("price1");
  2353. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2354. string price2 = GetPostString("price2");
  2355. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2356. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2357. {
  2358. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2359. }
  2360. else
  2361. {
  2362. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2363. }
  2364. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2365. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2366. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2367. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2368. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2369. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2370. if (dt != null && dt.Rows.Count > 0)
  2371. {
  2372. foreach (DataRow dr in dt.Rows)
  2373. {
  2374. try
  2375. {
  2376. // 对象操作
  2377. if (dStruct.PageSize != 100000)
  2378. {
  2379. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2380. dr["gongchuang"] = response.code;
  2381. }
  2382. }
  2383. catch (NullReferenceException ex)
  2384. {
  2385. // 处理空引用异常
  2386. }
  2387. }
  2388. }
  2389. writeGridDataTableJson(dStruct.TotalCount, dt);
  2390. }
  2391. public void get_erp_myorderlist_pregather()
  2392. {
  2393. string date1 = GetPostString("date1");
  2394. string date2 = GetPostString("date2");
  2395. int userId = CurrentUser.UserID; //客服id
  2396. string orderWhere = "";
  2397. List<string> lw = new List<string>();
  2398. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2399. if (dw.Length > 0) lw.Add(dw);
  2400. lw.Add(string.Format("CustomerUserId={0}", userId));
  2401. lw.Add(string.Format("OrderState<9"));
  2402. orderWhere = string.Join(" and ", lw.ToArray());
  2403. string orderWhere2 = "";
  2404. List<string> lw2 = new List<string>();
  2405. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2406. if (dw2.Length > 0) lw2.Add(dw2);
  2407. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2408. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2409. string sql = string.Format("select *" +
  2410. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2411. "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 " +
  2412. "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 " +
  2413. "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");
  2414. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2415. //writeGridDataTableJson(dt.Rows.Count, dt);
  2416. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2417. }
  2418. public void upd_erp_publishorder()
  2419. {
  2420. if (UrlPostParmsCheck("ctid"))
  2421. {
  2422. string eid = GetPostString("ctid");
  2423. CeErpTradeCell entity = null;
  2424. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2425. if (entity != null)
  2426. {
  2427. entity.OrderState = 0; //发布后,变为待抢单
  2428. entity.Update();
  2429. commonHelper.UpdateRelationOrder(entity.ctid);
  2430. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2431. returnSuccessMsg("发布成功!");
  2432. return;
  2433. }
  2434. returnErrorMsg("找不到记录");
  2435. }
  2436. }
  2437. public void get_erp_my_tiporder()
  2438. {
  2439. StringBuilder sql = new StringBuilder();
  2440. int userId = 0;
  2441. if (CurrentUser != null) userId = CurrentUser.UserID;
  2442. string posCode = CurrentUser.UserPost.Post.Code;
  2443. string isTipedAfterSaleVerify = GetPostString("af");
  2444. DataTable dt = new DataTable();
  2445. if (posCode != "Supplier")
  2446. {
  2447. if (posCode == "CustomerService" || posCode == "Director")
  2448. {
  2449. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2450. }
  2451. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2452. {
  2453. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2454. }
  2455. else
  2456. {
  2457. string teamIds = CurrentUser.User.TeamIds;
  2458. if (teamIds == "")
  2459. {
  2460. teamIds = "0";
  2461. }
  2462. 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);
  2463. }
  2464. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2465. }
  2466. if (dt.Rows.Count <= 0)
  2467. {
  2468. string key = "aftersale_order_" + userId;
  2469. if (RedisHelper.HasKey(key))
  2470. {
  2471. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2472. dt.Columns.Add("ctid", typeof(string));
  2473. dt.Columns.Add("IsReadTag", typeof(int));
  2474. foreach (var i in list)
  2475. {
  2476. DataRow data = dt.NewRow();
  2477. data["ctid"] = i;
  2478. data["IsReadTag"] = 4;
  2479. dt.Rows.Add(data);
  2480. }
  2481. RedisHelper.StringDelete(key);
  2482. }
  2483. }
  2484. if (dt.Rows.Count <= 0)
  2485. {
  2486. sql = new StringBuilder();
  2487. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2488. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2489. }
  2490. if (posCode == "Supplier")
  2491. {
  2492. string ids = CurrentUser.User.pemVend;
  2493. if (ids != null && ids.Length > 0)
  2494. {
  2495. string[] ids_list = ids.Split(',');
  2496. foreach (var item in ids_list)
  2497. {
  2498. string key = "return_order_" + item;
  2499. if (RedisHelper.HasKey(key))
  2500. {
  2501. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2502. dt.Columns.Add("ctid", typeof(string));
  2503. dt.Columns.Add("IsReadTag", typeof(int));
  2504. foreach (var i in list)
  2505. {
  2506. DataRow data = dt.NewRow();
  2507. data["ctid"] = i;
  2508. data["IsReadTag"] = 1;
  2509. dt.Rows.Add(data);
  2510. }
  2511. RedisHelper.StringDelete(key);
  2512. }
  2513. }
  2514. }
  2515. if (dt.Rows.Count <= 0)
  2516. {
  2517. sql = new StringBuilder();
  2518. 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);
  2519. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2520. }
  2521. }
  2522. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2523. }
  2524. public void reset_erp_tiporder()
  2525. {
  2526. string ids = GetPostString("ids");
  2527. string[] ctidList = ids.Split(',');
  2528. foreach (string ctid in ctidList)
  2529. {
  2530. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2531. if (enty != null)
  2532. {
  2533. enty.IsReadTag = 0;
  2534. enty.Update();
  2535. }
  2536. }
  2537. returnSuccessMsg("成功!");
  2538. return;
  2539. }
  2540. public void get_erp_designlist()
  2541. {
  2542. DataStruct dStruct = GetPostStruct();
  2543. List<string> lw = new List<string>();
  2544. string tid = GetPostString("ctid");
  2545. if (tid.Length > 0)
  2546. {
  2547. string select_tid = getTidByCtid(tid);
  2548. lw.Add(string.Format("tid='{0}'", select_tid));
  2549. }
  2550. string shopname = GetPostString("shopname");
  2551. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2552. string buyernick = GetPostString("buyer_nick");
  2553. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2554. string customer = GetPostString("customer");
  2555. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2556. string design = GetPostString("design");
  2557. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2558. string orderState = GetPostString("orderState");
  2559. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2560. lw.Add(string.Format("OrderState<6"));
  2561. string address = GetPostString("address");
  2562. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2563. string sellermemo = GetPostString("seller_memo");
  2564. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2565. string date1 = GetPostString("date1");
  2566. string date2 = GetPostString("date2");
  2567. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2568. if (dw.Length > 0) lw.Add(dw);
  2569. string apdate1 = GetPostString("apdate1");
  2570. string apdate2 = GetPostString("apdate2");
  2571. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2572. if (dwap.Length > 0) lw.Add(dwap);
  2573. string price1 = GetPostString("price1");
  2574. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2575. string price2 = GetPostString("price2");
  2576. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2577. string designTime = GetPostString("designtime");
  2578. if (designTime.Length > 0)
  2579. {
  2580. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2581. }
  2582. string usershop = CurrentUser.User.pemShop;
  2583. if (usershop.Length > 0)
  2584. {
  2585. lw.Add(string.Format("shopId in ({0})", usershop));
  2586. }
  2587. int myOrgid = CurrentUser.UserPost.OrgID;
  2588. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2589. if (myOrgCode.IndexOf("Designer") != -1)
  2590. {
  2591. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2592. {
  2593. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2594. }
  2595. else
  2596. {
  2597. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2598. }
  2599. }
  2600. else
  2601. {
  2602. string orgId = GetPostString("designerhd");
  2603. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2604. }
  2605. if (tid.Length > 0 || buyernick.Length > 0)
  2606. {
  2607. lw.Add(string.Format("OrderState >= 3"));
  2608. }
  2609. else
  2610. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2611. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2612. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2613. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2614. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2615. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2616. if (dt != null && dt.Rows.Count > 0)
  2617. {
  2618. foreach (DataRow dr in dt.Rows)
  2619. {
  2620. try
  2621. {
  2622. // 对象操作
  2623. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2624. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2625. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2626. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2627. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2628. if (dStruct.PageSize != 100000)
  2629. {
  2630. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2631. dr["gongchuang"] = response.code;
  2632. }
  2633. }
  2634. catch (NullReferenceException ex)
  2635. {
  2636. }
  2637. }
  2638. }
  2639. writeGridDataTableJson(dStruct.TotalCount, dt);
  2640. }
  2641. public void get_erp_mydesignlist()
  2642. {
  2643. DataStruct dStruct = GetPostStruct();
  2644. List<string> lw = new List<string>();
  2645. string tid = GetPostString("ctid");
  2646. if (tid.Length > 0)
  2647. {
  2648. string select_tid = getTidByCtid(tid);
  2649. lw.Add(string.Format("tid='{0}'", select_tid));
  2650. }
  2651. string shopname = GetPostString("shopname");
  2652. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2653. string buyernick = GetPostString("buyer_nick");
  2654. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2655. string customer = GetPostString("customer");
  2656. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2657. string orderState = GetPostString("orderState");
  2658. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2659. //lw.Add(string.Format("OrderState<6"));
  2660. string date1 = GetPostString("date1");
  2661. string date2 = GetPostString("date2");
  2662. string dw = GetDateWhere("pay_time", date1, date2);
  2663. if (dw.Length > 0) lw.Add(dw);
  2664. string apdate1 = GetPostString("apdate1");
  2665. string apdate2 = GetPostString("apdate2");
  2666. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2667. if (dwap.Length > 0) lw.Add(dwap);
  2668. string price1 = GetPostString("price1");
  2669. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2670. string price2 = GetPostString("price2");
  2671. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2672. string olddownload = GetPostString("olddown");
  2673. if (olddownload == "1")
  2674. {
  2675. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2676. }
  2677. else if (olddownload == "2")
  2678. {
  2679. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2680. }
  2681. string sellermemo = GetPostString("seller_memo");
  2682. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2683. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2684. if (CurrentUser.User.TeamIds.Length > 0)
  2685. {
  2686. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2687. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2688. else
  2689. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2690. }
  2691. else
  2692. {
  2693. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2694. }
  2695. if (tid.Length <= 0)
  2696. {
  2697. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2698. }
  2699. lw.Add(string.Format("IsReturn!=3"));
  2700. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2701. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2702. string teamids = CurrentUser.User.TeamIds.ToString();
  2703. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2704. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2705. if (dt != null && dt.Rows.Count > 0)
  2706. {
  2707. foreach (DataRow dr in dt.Rows)
  2708. {
  2709. try
  2710. {
  2711. // 对象操作
  2712. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2713. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2714. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2715. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2716. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2717. if (dStruct.PageSize != 100000)
  2718. {
  2719. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2720. dr["gongchuang"] = response.code;
  2721. }
  2722. }
  2723. catch (NullReferenceException ex)
  2724. {
  2725. }
  2726. }
  2727. }
  2728. writeGridDataTableJson(dStruct.TotalCount, dt);
  2729. }
  2730. public void set_erp_startdesign()
  2731. {
  2732. if (UrlPostParmsCheck("ctid"))
  2733. {
  2734. string eid = GetPostString("ctid");
  2735. CeErpTradeCell entity = null;
  2736. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2737. if (entity != null)
  2738. {
  2739. if (entity.OrderState != 3)
  2740. {
  2741. returnErrorMsg("请刷新,订单已经设计了");
  2742. return;
  2743. }
  2744. entity.StartDesignTime = DateTime.Now;
  2745. entity.OrderState = 4;
  2746. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2747. {
  2748. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2749. entity.SupplierId = suid;
  2750. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2751. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2752. }
  2753. entity.UpdateTime = DateTime.Now;
  2754. //entity.MakeSupplier = suname;
  2755. entity.Update();
  2756. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2757. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2758. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2759. commonHelper.getCytPrice(entity);
  2760. returnSuccessMsg("操作成功!");
  2761. return;
  2762. }
  2763. returnErrorMsg("找不到记录");
  2764. }
  2765. }
  2766. public void ins_erp_designselfmemo()
  2767. {
  2768. if (UrlPostParmsCheck("ctid"))
  2769. {
  2770. string eid = GetPostString("ctid");
  2771. string con = GetPostString("con");
  2772. CeErpTradeCell entity = null;
  2773. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2774. if (entity != null)
  2775. {
  2776. entity.DesignSelfMemo = con;
  2777. entity.Update();
  2778. returnSuccessMsg("操作成功!");
  2779. return;
  2780. }
  2781. returnErrorMsg("找不到记录");
  2782. }
  2783. }
  2784. public void ins_erp_designprice()
  2785. {
  2786. if (UrlPostParmsCheck("ctid"))
  2787. {
  2788. string eid = GetPostString("ctid");
  2789. int uid = CurrentUser.UserID;
  2790. string userName = CurrentUser.UserName;
  2791. CeErpTradeCell entity = null;
  2792. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2793. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2794. if (entitys == null)
  2795. {
  2796. entitys = new CeErpDesignerBill();
  2797. }
  2798. if (entity != null)
  2799. {
  2800. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2801. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2802. entity.StartDesignTime = DateTime.Now;
  2803. entity.OrderState = 4;
  2804. string suname = "";
  2805. if (entity.SupplierId == 0)
  2806. {
  2807. int sid = commonHelper.autoDistributeToSupplier(entity);
  2808. entity.SupplierId = sid;
  2809. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2810. }
  2811. entity.Update();
  2812. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2813. if (ceErpUserPost != null)
  2814. {
  2815. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2816. if (ceErpPost != null)
  2817. {
  2818. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2819. {
  2820. entitys.tid = entity.ctid;
  2821. entitys.oid = entity.tid;
  2822. entitys.uid = uid;
  2823. entitys.userName = userName;
  2824. entitys.designerType = 1;
  2825. entitys.designerTypeText = "内部设计师";
  2826. entitys.price = Convert.ToDouble(GetPostString("price"));
  2827. entitys.designNum = GetPostInt("designNum");
  2828. entitys.modifyNum = GetPostInt("modifyNum");
  2829. entitys.designSize = GetPostString("designSize");
  2830. entitys.modifySize = GetPostString("modifySize");
  2831. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2832. {
  2833. entitys.create_time = DateTime.Now;
  2834. entitys.create_u_id = uid;
  2835. entitys.create_u_name = userName;
  2836. entitys.Save();
  2837. }
  2838. else
  2839. {
  2840. entitys.update_time = DateTime.Now;
  2841. entitys.update_u_id = uid;
  2842. entitys.update_u_name = userName;
  2843. entitys.Update();
  2844. }
  2845. }
  2846. }
  2847. }
  2848. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2849. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2850. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2851. if (suname != "")
  2852. {
  2853. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2854. }
  2855. commonHelper.getCytPrice(entity);
  2856. returnSuccessMsg("操作成功!");
  2857. return;
  2858. }
  2859. returnErrorMsg("找不到记录");
  2860. }
  2861. }
  2862. public void upload_erp_filecomplete()
  2863. {
  2864. if (UrlPostParmsCheck("ctid"))
  2865. {
  2866. string eid = GetPostString("ctid");
  2867. CeErpTradeCell entity = null;
  2868. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2869. if (entity != null)
  2870. {
  2871. entity.OrderState = 5; //设计完成
  2872. entity.Update();
  2873. returnSuccessMsg(eid + "上传成功,设计完成!");
  2874. return;
  2875. }
  2876. returnErrorMsg("找不到订单记录");
  2877. }
  2878. }
  2879. public void get_erp_designovertimelist()
  2880. {
  2881. DataStruct dStruct = GetPostStruct();
  2882. List<string> lw = new List<string>();
  2883. string tid = GetPostString("ctid");
  2884. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2885. string shopname = GetPostString("shopname");
  2886. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2887. string buyernick = GetPostString("buyer_nick");
  2888. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2889. string ResponsibleMan = GetPostString("responsible");
  2890. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2891. string date1 = GetPostString("date1");
  2892. string date2 = GetPostString("date2");
  2893. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2894. if (dw.Length > 0) lw.Add(dw);
  2895. string price1 = GetPostString("price1");
  2896. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2897. string price2 = GetPostString("price2");
  2898. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2899. string orderState = GetPostString("orderState");
  2900. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2901. string sellermemo = GetPostString("seller_memo");
  2902. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2903. lw.Add(string.Format("UnusualTag=3"));
  2904. lw.Add(string.Format("IsRefund<={0}", 1));
  2905. dStruct.Order = "WaitDesignTime desc";
  2906. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2907. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2908. writeGridDataTableJson(dStruct.TotalCount, dt);
  2909. }
  2910. //设计管理 获取抢单大厅列表
  2911. public void get_erp_grabinglist()
  2912. {
  2913. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2914. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2915. bool oldOrder = false;
  2916. if (org != null)
  2917. {
  2918. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2919. }
  2920. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2921. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2922. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2923. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2924. //先处理订单数据
  2925. if (dt.Rows.Count > 0)
  2926. {
  2927. Dictionary<string, int> design = null;
  2928. int count = 0;
  2929. foreach (DataRow row in dt.Rows)
  2930. {
  2931. if (map.ContainsKey(row["ShopId"].ToString()))
  2932. {
  2933. map.TryGetValue(row["ShopId"].ToString(), out design);
  2934. }
  2935. else
  2936. {
  2937. design = new Dictionary<string, int>();
  2938. }
  2939. if (design.ContainsKey(row["ProductId"].ToString()))
  2940. {
  2941. design.TryGetValue(row["ProductId"].ToString(), out count);
  2942. }
  2943. count++;
  2944. design[row["ProductId"].ToString()] = count;
  2945. map[row["ShopId"].ToString()] = design;
  2946. }
  2947. }
  2948. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2949. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2950. //把店铺排序和技能排序分类
  2951. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2952. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2953. if (design_dt.Rows.Count > 0)
  2954. {
  2955. Dictionary<string, string> design = null;
  2956. List<string> shopIds = null;
  2957. foreach (DataRow row in design_dt.Rows)
  2958. {
  2959. if ("0".Equals(row["designId"].ToString()))
  2960. {
  2961. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2962. {
  2963. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2964. }
  2965. else
  2966. {
  2967. shopIds = new List<string>();
  2968. }
  2969. shopIds.Add(row["shopId"].ToString());
  2970. shop_orders[row["orders"].ToString()] = shopIds;
  2971. }
  2972. else
  2973. {
  2974. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2975. {
  2976. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2977. }
  2978. else
  2979. {
  2980. design = new Dictionary<string, string>();
  2981. }
  2982. design[row["orders"].ToString()] = row["designId"].ToString();
  2983. design_orders[row["shopId"].ToString()] = design;
  2984. }
  2985. }
  2986. //处理成key value后根据key排序
  2987. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2988. foreach (List<string> val in shop_orders.Values)
  2989. {
  2990. if (val != null)
  2991. {
  2992. foreach (string key in val)
  2993. {
  2994. if (design_orders.ContainsKey(key.ToString()))
  2995. {
  2996. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2997. }
  2998. }
  2999. }
  3000. }
  3001. }
  3002. //校验哪个优先级有订单
  3003. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3004. foreach (string key in shop_orders.Keys)
  3005. {
  3006. List<string> ids = null;
  3007. shop_orders.TryGetValue(key, out ids);
  3008. //id为shopid
  3009. foreach (string id in ids)
  3010. {
  3011. Dictionary<string, int> list = null;
  3012. Dictionary<string, string> desing = null;
  3013. map.TryGetValue(id, out list);
  3014. design_orders.TryGetValue(id, out desing);
  3015. if (list != null && desing != null)
  3016. {
  3017. foreach (var item in desing)
  3018. {
  3019. int count = 0;
  3020. if (list.ContainsKey(item.Value))
  3021. {
  3022. list.TryGetValue(item.Value, out count);
  3023. if (count > 0)
  3024. {
  3025. designIds[id] = item.Value;
  3026. break;
  3027. }
  3028. }
  3029. }
  3030. }
  3031. }
  3032. if (designIds.Count > 0)
  3033. {
  3034. break;
  3035. }
  3036. }
  3037. DataTable table = new DataTable();
  3038. table.Columns.Add("tid", typeof(string));
  3039. table.Columns.Add("ctid", typeof(string));
  3040. table.Columns.Add("seller_nick", typeof(string));
  3041. table.Columns.Add("productName", typeof(string));
  3042. table.Columns.Add("pay_time", typeof(string));
  3043. table.Columns.Add("seller_memo", typeof(string));
  3044. if (designIds.Count > 0)
  3045. {
  3046. string shopId = "";
  3047. string productId = "";
  3048. foreach (var designInfo in designIds)
  3049. {
  3050. shopId = designInfo.Key;
  3051. productId = designInfo.Value;
  3052. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3053. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3054. if (dt.Rows.Count > 0)
  3055. {
  3056. foreach (DataRow row in dt.Rows)
  3057. {
  3058. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3059. {
  3060. DataRow data = table.NewRow();
  3061. data["ctid"] = row["ctid"].ToString();
  3062. data["tid"] = row["tid"].ToString();
  3063. data["seller_nick"] = ceErpShop.ShopName;
  3064. data["pay_time"] = row["pay_time"].ToString();
  3065. data["seller_memo"] = row["seller_memo"].ToString();
  3066. data["productName"] = ceErpProduct.PType;
  3067. table.Rows.Add(data);
  3068. }
  3069. }
  3070. }
  3071. }
  3072. }
  3073. writeGridDataTableJson(table.Rows.Count, table);
  3074. }
  3075. private object rushLockObject = new object();
  3076. public void set_erp_grabingorder()
  3077. {
  3078. if (UrlPostParmsCheck("ctid"))
  3079. {
  3080. int total = CurrentUser.User.Person.Total;
  3081. int userId = CurrentUser.User.ID;
  3082. int noFinish = CurrentUser.User.Person.NoFinish;
  3083. int finalization = CurrentUser.User.Person.Finalization;
  3084. string eids = GetPostString("ctid");
  3085. string key = "RushKey_" + userId;
  3086. int count = 0;
  3087. if (erpRedis.RedisHelper.KeyExists(key))
  3088. {
  3089. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3090. if (redisCount != null)
  3091. {
  3092. count = Convert.ToInt32(redisCount);
  3093. }
  3094. }
  3095. if (count >= total)
  3096. {
  3097. returnErrorMsg("半小时内已经抢" + total + "单");
  3098. return;
  3099. }
  3100. string[] ctidlist = eids.Split(',');
  3101. if (count + ctidlist.Length > total)
  3102. {
  3103. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3104. return;
  3105. }
  3106. int itag = 0;
  3107. lock (rushLockObject)
  3108. {
  3109. if (ctidlist.Length > 0)
  3110. {
  3111. string[] dtList = new string[ctidlist.Length];
  3112. for (int i = 0; i < ctidlist.Length; i++)
  3113. {
  3114. dtList[i] = "'" + ctidlist[i] + "'";
  3115. }
  3116. 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"));
  3117. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3118. if (dt_user.Rows.Count > 0)
  3119. {
  3120. int doing = 0;//未定稿
  3121. int finish = 0;//已完成
  3122. foreach (DataRow dr in dt_user.Rows)
  3123. {
  3124. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3125. {
  3126. doing++;
  3127. }
  3128. else
  3129. {
  3130. finish++;
  3131. }
  3132. }
  3133. if (doing >= noFinish)
  3134. {
  3135. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3136. return;
  3137. }
  3138. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3139. {
  3140. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3141. return;
  3142. }
  3143. }
  3144. //校验选择单子状态
  3145. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3146. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3147. if (dt.Rows.Count > 0)
  3148. {
  3149. List<string> list = new List<string>();
  3150. foreach (DataRow dr in dt.Rows)
  3151. {
  3152. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3153. {
  3154. list.Add(dr["ctid"].ToString());
  3155. }
  3156. }
  3157. if (list.Count > 0)
  3158. {
  3159. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3160. return;
  3161. }
  3162. }
  3163. foreach (string ctid in ctidlist)
  3164. {
  3165. CeErpTradeCell entity = null;
  3166. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3167. if (entity != null)
  3168. {
  3169. entity.OrderState = 3;
  3170. entity.DesignUserId = CurrentUser.UserID;
  3171. entity.WaitDesignTime = DateTime.Now;
  3172. entity.StartDesignTime = DateTime.Now;
  3173. entity.Update();
  3174. commonHelper.UpdateRelationOrder(entity.ctid);
  3175. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3176. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3177. itag++;
  3178. }
  3179. }
  3180. }
  3181. }
  3182. count += ctidlist.Length;
  3183. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3184. if (itag == 0)
  3185. returnErrorMsg("没有找到相关订单");
  3186. else
  3187. returnSuccessMsg("抢单成功!");
  3188. return;
  3189. }
  3190. }
  3191. public void get_erp_waitorderlist()
  3192. {
  3193. DataStruct dStruct = GetPostStruct();
  3194. List<string> lw = new List<string>();
  3195. string tid = GetPostString("ctid");
  3196. if (tid.Length > 0)
  3197. {
  3198. string select_tid = getTidByCtid(tid);
  3199. lw.Add(string.Format("tid='{0}'", select_tid));
  3200. }
  3201. string shopname = GetPostString("shopname");
  3202. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3203. string buyernick = GetPostString("buyer_nick");
  3204. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3205. string customer = GetPostString("customer");
  3206. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3207. string design = GetPostString("design");
  3208. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3209. string orderState = GetPostString("orderState");
  3210. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3211. string supplier = GetPostString("supplier");
  3212. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3213. string sellermemo = GetPostString("seller_memo");
  3214. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3215. string otherMemo = GetPostString("otherMemo");
  3216. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3217. string address = GetPostString("address");
  3218. 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));
  3219. string date1 = GetPostString("date1");
  3220. string date2 = GetPostString("date2");
  3221. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3222. if (dw.Length > 0) lw.Add(dw);
  3223. string price1 = GetPostString("price1");
  3224. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3225. string price2 = GetPostString("price2");
  3226. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3227. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3228. lw.Add(string.Format("IsSample != 2 "));
  3229. lw.Add(string.Format("OrderState = 5 "));
  3230. lw.Add(string.Format("IsRefund<={0}", 1));
  3231. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3232. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3233. string pagesize = GetPostString("pagesize");
  3234. if (pagesize != null)
  3235. {
  3236. dStruct.PageSize = 200;
  3237. }
  3238. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3239. if (dt != null)
  3240. {
  3241. foreach (DataRow dr in dt.Rows)
  3242. {
  3243. 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();
  3244. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3245. {
  3246. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3247. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3248. entity.SupplierId = suid;
  3249. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3250. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3251. entity.Update();
  3252. }
  3253. }
  3254. }
  3255. writeGridDataTableJson(dStruct.TotalCount, dt);
  3256. }
  3257. public void get_erp_supplierwaitorderlist()
  3258. {
  3259. DataStruct dStruct = GetPostStruct();
  3260. List<string> lw = new List<string>();
  3261. string tid = GetPostString("ctid");
  3262. if (tid.Length > 0)
  3263. {
  3264. string select_tid = getTidByCtid(tid);
  3265. lw.Add(string.Format("tid='{0}'", select_tid));
  3266. }
  3267. string shopname = GetPostString("shopname");
  3268. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3269. string sellermemo = GetPostString("seller_memo");
  3270. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3271. string date1 = GetPostString("date1");
  3272. string date2 = GetPostString("date2");
  3273. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3274. if (dw.Length > 0) lw.Add(dw);
  3275. lw.Add(string.Format("OrderState = 5 "));
  3276. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3277. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3278. {
  3279. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3280. }
  3281. string supplier = GetPostString("supplier");
  3282. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3283. {
  3284. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3285. }
  3286. lw.Add(string.Format("IsRefund<={0}", 1));
  3287. dStruct.Order = "FinishDesignTime desc";
  3288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3289. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3290. if (dt != null)
  3291. {
  3292. foreach (DataRow dr in dt.Rows)
  3293. {
  3294. 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();
  3295. }
  3296. }
  3297. writeGridDataTableJson(dStruct.TotalCount, dt);
  3298. }
  3299. public void upd_erp_verifytosupplier()
  3300. {
  3301. if (UrlPostParmsCheck("ctid"))
  3302. {
  3303. string eids = GetPostString("ctid");
  3304. CeErpTradeCell entity = null;
  3305. string[] eidsList = eids.Split(',');
  3306. if (eidsList.Length <= 0)
  3307. {
  3308. returnErrorMsg("订单号不能空");
  3309. return;
  3310. }
  3311. List<string> tLst = new List<string>();
  3312. foreach (string ctidstr in eidsList)
  3313. {
  3314. tLst.Add("'" + ctidstr + "'");
  3315. CeErpDataSendOrderInfo.createObject(ctidstr);
  3316. }
  3317. string needtids = string.Join(",", tLst.ToArray());
  3318. StringBuilder sql = new StringBuilder();
  3319. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3320. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3321. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3322. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3323. returnSuccessMsg("操作成功!");
  3324. return;
  3325. /**foreach (string ctidstr in eidsList)
  3326. {
  3327. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3328. if (entity != null)
  3329. {
  3330. if (entity.SupplierId == 0)
  3331. {
  3332. continue;
  3333. }
  3334. entity.IsVerifyToSupplier = true;
  3335. if (entity.IsReturn == 1) //1是供应商打回
  3336. {
  3337. entity.IsReturn = 0;
  3338. }
  3339. entity.FinishPlaceTime = DateTime.Now;
  3340. entity.PlaceUserId = CurrentUser.UserID;
  3341. entity.Update();
  3342. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3343. }
  3344. }
  3345. returnSuccessMsg("操作成功!");
  3346. return;**/
  3347. }
  3348. }
  3349. public void upd_erp_supplierback()
  3350. {
  3351. if (UrlPostParmsCheck("ctid"))
  3352. {
  3353. string eid = GetPostString("ctid");
  3354. string reason = GetPostString("returnreason");
  3355. CeErpTradeCell entity = null;
  3356. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3357. if (entity != null)
  3358. {
  3359. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3360. {
  3361. string key = "return_order_" + entity.SupplierId;
  3362. List<string> list = new List<string>();
  3363. if (RedisHelper.HasKey(key))
  3364. {
  3365. object data = RedisHelper.StringGet(key);
  3366. list = Convert.ToString(data).Split(',').ToList();
  3367. }
  3368. list.Add(eid);
  3369. RedisHelper.StringSet(key, string.Join(",", list));
  3370. }
  3371. entity.IsVerifyToSupplier = false;
  3372. entity.IsReturn = 1;
  3373. entity.ReturnTime = DateTime.Now;
  3374. entity.ReturnReason = reason;
  3375. if (entity.OrderState == 6)
  3376. {
  3377. entity.OrderState = 5;
  3378. }
  3379. entity.Update();
  3380. CeErpSukuraData.createInfo(entity.ctid, 5);
  3381. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3382. returnSuccessMsg("操作成功!");
  3383. return;
  3384. }
  3385. returnErrorMsg("找不到订单记录");
  3386. }
  3387. }
  3388. public void upd_erp_toaftersaleorder()
  3389. {
  3390. if (UrlPostParmsCheck("ctid"))
  3391. {
  3392. string eid = GetPostString("ctid");
  3393. string reason = GetPostString("returnreason");
  3394. CeErpTradeCell entity = null;
  3395. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3396. if (entity != null)
  3397. {
  3398. if (entity.isAfterSaleOrder != 1)
  3399. {
  3400. returnErrorMsg("带S的售后单才能打回给售后");
  3401. return;
  3402. }
  3403. if (entity.OrderState >= 5)
  3404. {
  3405. returnErrorMsg("已经设计完成了不能打回给售后");
  3406. return;
  3407. }
  3408. entity.OrderState = 0;
  3409. entity.IsReturn = 3;
  3410. entity.ReturnTime = DateTime.Now;
  3411. entity.UpdateTime = DateTime.Now;
  3412. entity.ReturnReason = reason;
  3413. entity.Update();
  3414. CeErpSukuraData.createInfo(entity.ctid, 5);
  3415. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3416. returnSuccessMsg("操作成功!");
  3417. return;
  3418. }
  3419. returnErrorMsg("找不到订单记录");
  3420. }
  3421. }
  3422. public void upd_erp_aftersaletodesign()
  3423. {
  3424. if (UrlPostParmsCheck("ctid"))
  3425. {
  3426. string eid = GetPostString("ctid");
  3427. CeErpTradeCell entity = null;
  3428. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3429. if (entity != null)
  3430. {
  3431. entity.OrderState = 3;
  3432. entity.IsReturn = 0;
  3433. entity.UpdateTime = DateTime.Now;
  3434. entity.Update();
  3435. CeErpSukuraData.createInfo(entity.ctid, 5);
  3436. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3437. returnSuccessMsg("操作成功!");
  3438. return;
  3439. }
  3440. returnErrorMsg("找不到订单记录");
  3441. }
  3442. }
  3443. public void assign_erp_supplier()
  3444. {
  3445. if (UrlPostParmsCheck("ctid"))
  3446. {
  3447. string eids = GetPostString("ctid");
  3448. int sid = GetPostInt("SupplierName");
  3449. string fromTag = GetPostString("tag");
  3450. string[] eidList = eids.Split(',');
  3451. if (eidList.Length <= 0)
  3452. {
  3453. returnErrorMsg("指派不能为空");
  3454. return;
  3455. }
  3456. string errMsg = "";
  3457. string suname = commonHelper.getSupplierNameById(sid);
  3458. foreach (string ctid in eidList)
  3459. {
  3460. CeErpTradeCell entity = null;
  3461. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3462. if (entity != null)
  3463. {
  3464. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3465. {
  3466. errMsg += (ctid + "指派失败!!!");
  3467. continue;
  3468. }
  3469. entity.SupplierId = sid;
  3470. entity.Update();
  3471. commonHelper.UpdateRelationOrder(entity.ctid);
  3472. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3473. if (entity.OrderState >= 6)
  3474. {
  3475. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3476. //{
  3477. // string msl = entity.MakeSupplier;
  3478. // string[] mslist = msl.Split(',');
  3479. // 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);
  3480. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3481. //}
  3482. //else
  3483. //{
  3484. StringBuilder sql = new StringBuilder();
  3485. 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);
  3486. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3487. //}
  3488. }
  3489. }
  3490. else
  3491. {
  3492. continue;
  3493. }
  3494. }
  3495. if (errMsg.Length > 0)
  3496. {
  3497. returnErrorMsg(errMsg);
  3498. return;
  3499. }
  3500. returnSuccessMsg("操作成功!");
  3501. return;
  3502. }
  3503. }
  3504. public void assign_erp_makesupplier()
  3505. {
  3506. if (UrlPostParmsCheck("ctid"))
  3507. {
  3508. string eids = GetPostString("ctid");
  3509. string sname = GetPostString("SupplierName");
  3510. string[] eidList = eids.Split(',');
  3511. if (eidList.Length <= 0)
  3512. {
  3513. returnErrorMsg("指派不能为空");
  3514. return;
  3515. }
  3516. List<string> tLst = new List<string>();
  3517. foreach (string ctid in eidList)
  3518. {
  3519. CeErpTradeCell entity = null;
  3520. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3521. if (entity != null)
  3522. {
  3523. entity.MakeSupplier = sname;
  3524. entity.Update();
  3525. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3526. tLst.Add("'" + ctid + "'");
  3527. }
  3528. else
  3529. {
  3530. continue;
  3531. }
  3532. }
  3533. string ctids = string.Join(",", tLst.ToArray());
  3534. StringBuilder sql2 = new StringBuilder();
  3535. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3536. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3537. returnSuccessMsg("操作成功!");
  3538. return;
  3539. }
  3540. }
  3541. public void ins_erp_returnreason()
  3542. {
  3543. if (UrlPostParmsCheck("ctid"))
  3544. {
  3545. string eid = GetPostString("ctid");
  3546. CeErpTradeCell entity = null;
  3547. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3548. string userpost = CurrentUser.UserPost.Post.Code;
  3549. if (entity != null)
  3550. {
  3551. bool isPlace = false;
  3552. if (entity.OrderState > 6)
  3553. {
  3554. returnErrorMsg("已发货无法打回!");
  3555. return;
  3556. }
  3557. if (entity.OrderState == 6)
  3558. {
  3559. isPlace = true;
  3560. }
  3561. bool isNeedUpdateCell2 = false;
  3562. if (entity.OrderState >= 6)
  3563. {
  3564. isNeedUpdateCell2 = true;
  3565. }
  3566. int returnTag = 2;
  3567. if (userpost == "Supplier")
  3568. {
  3569. returnTag = 1;
  3570. }
  3571. int toType = GetPostInt("totype");
  3572. string fromType = "3";
  3573. if (entity.OrderState < 5)
  3574. {
  3575. fromType = "3";
  3576. }
  3577. else
  3578. {
  3579. fromType = "4";
  3580. }
  3581. if (entity.IsXianHuo == 0)
  3582. {
  3583. if (returnTag == 2)
  3584. {
  3585. if (toType == 1)
  3586. {
  3587. entity.OrderState = 0;
  3588. entity.ReturnUserType = 1;
  3589. string clearman = GetPostString("clearman");
  3590. if (!string.IsNullOrEmpty(clearman))
  3591. {
  3592. entity.DesignUserId = 0;
  3593. }
  3594. }
  3595. else
  3596. {
  3597. entity.OrderState = 3;
  3598. entity.ReturnUserType = 2;
  3599. }
  3600. entity.IsReadTag = 1;
  3601. }
  3602. else if (returnTag == 1)
  3603. {
  3604. entity.OrderState = 5;
  3605. }
  3606. entity.IsVerifyToSupplier = false;
  3607. }
  3608. if (entity.IsXianHuo == 1)
  3609. {
  3610. entity.OrderState = 5;
  3611. }
  3612. entity.UnusualTag = 0;
  3613. entity.UnusualTime = null;
  3614. entity.UnusualCon = "";
  3615. entity.IsReturn = returnTag;
  3616. entity.ReturnTime = DateTime.Now;
  3617. entity.UpdateTime = DateTime.Now;
  3618. entity.ReturnReason = GetPostString("returnreason");
  3619. entity.Update();
  3620. if (entity.OrderState == 3)
  3621. {
  3622. ApiVo apiVo = new ApiVo();
  3623. apiVo.orderNumber = entity.ctid;
  3624. apiVo.actionName = "rebutDesign";
  3625. apiVo.orderRemarks = entity.ReturnReason;
  3626. designHelper.API_WorkCore(apiVo);//rebutDesign
  3627. }
  3628. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3629. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3630. {
  3631. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3632. }
  3633. CeErpSukuraData.createInfo(entity.ctid, 5);
  3634. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3635. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3636. if (isPlace)
  3637. {
  3638. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3639. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3640. if (dth != null && dth.Rows.Count > 0)
  3641. {
  3642. dataSendOrderBean dataSendOrderBean = null;
  3643. foreach (DataRow item in dth.Rows)
  3644. {
  3645. try
  3646. {
  3647. dataSendOrderBean = new dataSendOrderBean();
  3648. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3649. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3650. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3651. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3652. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3653. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3654. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3655. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3656. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3657. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3658. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3659. dataSendOrderBean.Radio1723534706288 = "打回";
  3660. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3661. if (result != null)
  3662. {
  3663. if ("0".Equals(result.errcode))
  3664. {
  3665. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3666. }
  3667. else
  3668. {
  3669. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3670. }
  3671. }
  3672. }
  3673. catch (Exception ex)
  3674. {
  3675. }
  3676. }
  3677. }
  3678. }
  3679. if (isNeedUpdateCell2)
  3680. {
  3681. if (entity.MakeSupplier.IndexOf(",") != -1)
  3682. {
  3683. StringBuilder sql2 = new StringBuilder();
  3684. 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);
  3685. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3686. }
  3687. else
  3688. {
  3689. StringBuilder sql2 = new StringBuilder();
  3690. 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);
  3691. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3692. }
  3693. }
  3694. returnSuccessMsg("操作成功!");
  3695. return;
  3696. }
  3697. returnErrorMsg("找不到订单记录");
  3698. }
  3699. }
  3700. public void cyt_erp_returnreason()
  3701. {
  3702. if (UrlPostParmsCheck("ctid"))
  3703. {
  3704. string eid = GetPostString("ctid");
  3705. CeErpTradeCell entity = null;
  3706. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3707. string userpost = CurrentUser.UserPost.Post.Code;
  3708. if (entity != null)
  3709. {
  3710. if (entity.OrderState > 6)
  3711. {
  3712. returnErrorMsg("已发货无法打回!");
  3713. return;
  3714. }
  3715. JObject jsonObject = new JObject
  3716. {
  3717. { "Userid", "77886" },
  3718. { "Pwd", "lt666888" },
  3719. { "LTOrderId",eid }
  3720. };
  3721. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3722. JObject jsonObjects = JObject.Parse(response);
  3723. string msg = (string)jsonObjects["msg"];
  3724. if (msg != "取消成功")
  3725. {
  3726. returnErrorMsg(msg);
  3727. return;
  3728. }
  3729. bool isNeedUpdateCell2 = false;
  3730. if (entity.OrderState >= 6)
  3731. {
  3732. isNeedUpdateCell2 = true;
  3733. }
  3734. int returnTag = 2;
  3735. if (userpost == "Supplier")
  3736. {
  3737. returnTag = 1;
  3738. }
  3739. if (entity.IsXianHuo == 0)
  3740. {
  3741. if (returnTag == 2)
  3742. {
  3743. int toType = GetPostInt("totype");
  3744. if (toType == 1)
  3745. {
  3746. entity.OrderState = 0;
  3747. entity.ReturnUserType = 1;
  3748. }
  3749. else
  3750. {
  3751. entity.OrderState = 4;
  3752. entity.ReturnUserType = 2;
  3753. }
  3754. entity.IsReadTag = 1;
  3755. }
  3756. else if (returnTag == 1)
  3757. {
  3758. entity.OrderState = 5;
  3759. }
  3760. entity.IsVerifyToSupplier = false;
  3761. }
  3762. entity.UnusualTag = 0;
  3763. entity.UnusualTime = null;
  3764. entity.UnusualCon = "";
  3765. entity.IsReturn = returnTag;
  3766. entity.ReturnTime = DateTime.Now;
  3767. entity.ReturnReason = GetPostString("returnreason");
  3768. entity.Update();
  3769. if (entity.OrderState == 4)
  3770. {
  3771. ApiVo apiVo = new ApiVo();
  3772. apiVo.orderNumber = entity.ctid;
  3773. apiVo.actionName = "rebutDesign";
  3774. apiVo.orderRemarks = entity.ReturnReason;
  3775. designHelper.API_WorkCore(apiVo);//rebutDesign
  3776. }
  3777. CeErpSukuraData.createInfo(entity.ctid, 5);
  3778. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3779. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3780. if (isNeedUpdateCell2)
  3781. {
  3782. if (entity.MakeSupplier.IndexOf(",") != -1)
  3783. {
  3784. StringBuilder sql2 = new StringBuilder();
  3785. 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);
  3786. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3787. }
  3788. else
  3789. {
  3790. StringBuilder sql2 = new StringBuilder();
  3791. 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);
  3792. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3793. }
  3794. }
  3795. returnSuccessMsg("操作成功!");
  3796. return;
  3797. }
  3798. returnErrorMsg("找不到订单记录");
  3799. }
  3800. }
  3801. public void upd_erp_xianhuoreturntag()
  3802. {
  3803. if (UrlPostParmsCheck("ctid"))
  3804. {
  3805. string eids = GetPostString("ctid");
  3806. string[] ctids = eids.Split(',');
  3807. foreach (string ctid in ctids)
  3808. {
  3809. CeErpTradeCell entity = null;
  3810. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3811. if (entity != null)
  3812. {
  3813. entity.IsReturn = 0;
  3814. entity.Update();
  3815. CeErpSukuraData.createInfo(entity.ctid, 5);
  3816. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3817. }
  3818. }
  3819. returnSuccessMsg("操作成功!");
  3820. return;
  3821. }
  3822. }
  3823. public void get_erp_waitdeliverylist()
  3824. {
  3825. DataStruct dStruct = GetPostStruct();
  3826. List<string> lw = new List<string>();
  3827. string tid = GetPostString("ctid");
  3828. if (tid.Length > 0)
  3829. {
  3830. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3831. if (tid.Length > 5)
  3832. {
  3833. List<string> tids = getTidByCtidLike(tid);
  3834. if (tids.Count > 0 && tids.Count < 10)
  3835. {
  3836. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3837. }
  3838. }
  3839. lw.Add(tid_sql);
  3840. }
  3841. string shopname = GetPostString("shopname");
  3842. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3843. string buyernick = GetPostString("buyer_nick");
  3844. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3845. //if (tid.Length == 0 && buyernick.Length == 0)
  3846. //{
  3847. // lw.Add(string.Format("IsRefund<={0}", 1));
  3848. //}
  3849. string customer = GetPostString("customer");
  3850. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3851. string design = GetPostString("design");
  3852. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3853. string orderState = GetPostString("orderState");
  3854. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3855. string address = GetPostString("address");
  3856. 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));
  3857. string sellermemo = GetPostString("seller_memo");
  3858. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3859. string supplier = GetPostString("supplier");
  3860. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3861. string OrderArea = GetPostString("order_area");
  3862. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3863. string placedate1 = GetPostString("placedate1");
  3864. string placedate2 = GetPostString("placedate2");
  3865. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3866. if (fdw.Length > 0) lw.Add(fdw);
  3867. string price1 = GetPostString("price1");
  3868. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3869. string price2 = GetPostString("price2");
  3870. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3871. string unusualCon = GetPostString("unusualcon");
  3872. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3873. string otherMemo = GetPostString("otherMemo");
  3874. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3875. string posTag = CurrentUser.UserPost.Post.Code;
  3876. if (posTag == "Supplier")
  3877. {
  3878. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3879. }
  3880. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3881. lw.Add(string.Format("type != 'PDD' "));
  3882. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3883. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3884. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3885. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3886. writeGridDataTableJson(dStruct.TotalCount, dt);
  3887. }
  3888. public void get_erp_changedeliverylist()
  3889. {
  3890. DataStruct dStruct = GetPostStruct();
  3891. List<string> lw = new List<string>();
  3892. string tid = GetPostString("ctid");
  3893. if (tid.Length > 0)
  3894. {
  3895. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3896. if (tid.Length > 5)
  3897. {
  3898. List<string> tids = getTidByCtidLike(tid);
  3899. if (tids.Count > 0 && tids.Count < 10)
  3900. {
  3901. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3902. }
  3903. }
  3904. lw.Add(tid_sql);
  3905. }
  3906. string shopname = GetPostString("shopname");
  3907. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3908. string buyernick = GetPostString("buyer_nick");
  3909. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3910. //if (tid.Length == 0 && buyernick.Length == 0)
  3911. //{
  3912. // lw.Add(string.Format("IsRefund<={0}", 1));
  3913. //}
  3914. string customer = GetPostString("customer");
  3915. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3916. string design = GetPostString("design");
  3917. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3918. string orderState = GetPostString("orderState");
  3919. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3920. string address = GetPostString("address");
  3921. 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));
  3922. string sellermemo = GetPostString("seller_memo");
  3923. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3924. string supplier = GetPostString("supplier");
  3925. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3926. string OrderArea = GetPostString("order_area");
  3927. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3928. string placedate1 = GetPostString("placedate1");
  3929. string placedate2 = GetPostString("placedate2");
  3930. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3931. if (fdw.Length > 0) lw.Add(fdw);
  3932. string price1 = GetPostString("price1");
  3933. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3934. string price2 = GetPostString("price2");
  3935. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3936. string unusualCon = GetPostString("unusualcon");
  3937. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3938. string otherMemo = GetPostString("otherMemo");
  3939. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3940. string posTag = CurrentUser.UserPost.Post.Code;
  3941. if (posTag == "Supplier")
  3942. {
  3943. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3944. }
  3945. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3946. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3947. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3948. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3949. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3950. /*if (tid.Length > 0)
  3951. {
  3952. List<string> tids = new List<string>();
  3953. if (dt != null && dt.Rows.Count > 0)
  3954. {
  3955. foreach (DataRow item in dt.Rows)
  3956. {
  3957. tids.Add("'" + item["tid"] + "'");
  3958. }
  3959. }
  3960. if (tids.Count > 0)
  3961. {
  3962. lw.RemoveAt(0);
  3963. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3964. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3965. dt = WebCache.GetData("view_erptradecell", dStruct);
  3966. }
  3967. }*/
  3968. writeGridDataTableJson(dStruct.TotalCount, dt);
  3969. }
  3970. public void get_erp_pddderiving()
  3971. {
  3972. DataStruct dStruct = GetPostStruct();
  3973. List<string> lw = new List<string>();
  3974. string tid = GetPostString("ctid");
  3975. if (tid.Length > 0)
  3976. {
  3977. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3978. if (tid.Length > 5)
  3979. {
  3980. List<string> tids = getTidByCtidLike(tid);
  3981. if (tids.Count > 0 && tids.Count < 10)
  3982. {
  3983. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3984. }
  3985. }
  3986. lw.Add(tid_sql);
  3987. }
  3988. string shopname = GetPostString("shopname");
  3989. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3990. string buyernick = GetPostString("buyer_nick");
  3991. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3992. //if (tid.Length == 0 && buyernick.Length == 0)
  3993. //{
  3994. // lw.Add(string.Format("IsRefund<={0}", 1));
  3995. //}
  3996. string customer = GetPostString("customer");
  3997. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3998. string design = GetPostString("design");
  3999. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4000. string orderState = GetPostString("orderState");
  4001. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4002. string address = GetPostString("address");
  4003. 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));
  4004. string sellermemo = GetPostString("seller_memo");
  4005. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4006. string supplier = GetPostString("supplier");
  4007. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4008. string OrderArea = GetPostString("order_area");
  4009. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4010. string placedate1 = GetPostString("placedate1");
  4011. string placedate2 = GetPostString("placedate2");
  4012. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4013. if (fdw.Length > 0) lw.Add(fdw);
  4014. string price1 = GetPostString("price1");
  4015. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4016. string price2 = GetPostString("price2");
  4017. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4018. string unusualCon = GetPostString("unusualcon");
  4019. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4020. string posTag = CurrentUser.UserPost.Post.Code;
  4021. if (posTag == "Supplier")
  4022. {
  4023. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4024. }
  4025. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4026. lw.Add(string.Format("type = 'PDD' "));
  4027. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4028. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4029. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4030. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4031. /*if (tid.Length > 0)
  4032. {
  4033. List<string> tids = new List<string>();
  4034. if (dt != null && dt.Rows.Count > 0)
  4035. {
  4036. foreach (DataRow item in dt.Rows)
  4037. {
  4038. tids.Add("'" + item["tid"] + "'");
  4039. }
  4040. }
  4041. if (tids.Count > 0)
  4042. {
  4043. lw.RemoveAt(0);
  4044. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4046. dt = WebCache.GetData("view_erptradecell", dStruct);
  4047. }
  4048. }*/
  4049. writeGridDataTableJson(dStruct.TotalCount, dt);
  4050. }
  4051. public void get_erp_jdderiving()
  4052. {
  4053. DataStruct dStruct = GetPostStruct();
  4054. List<string> lw = new List<string>();
  4055. string tid = GetPostString("ctid");
  4056. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4057. string shopname = GetPostString("shopname");
  4058. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4059. string buyernick = GetPostString("buyer_nick");
  4060. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4061. //if (tid.Length == 0 && buyernick.Length == 0)
  4062. //{
  4063. // lw.Add(string.Format("IsRefund<={0}", 1));
  4064. //}
  4065. string customer = GetPostString("customer");
  4066. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4067. string design = GetPostString("design");
  4068. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4069. string orderState = GetPostString("orderState");
  4070. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4071. string address = GetPostString("address");
  4072. 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));
  4073. string sellermemo = GetPostString("seller_memo");
  4074. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4075. string supplier = GetPostString("supplier");
  4076. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4077. string OrderArea = GetPostString("order_area");
  4078. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4079. string placedate1 = GetPostString("placedate1");
  4080. string placedate2 = GetPostString("placedate2");
  4081. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4082. if (fdw.Length > 0) lw.Add(fdw);
  4083. string price1 = GetPostString("price1");
  4084. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4085. string price2 = GetPostString("price2");
  4086. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4087. string unusualCon = GetPostString("unusualcon");
  4088. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4089. string posTag = CurrentUser.UserPost.Post.Code;
  4090. if (posTag == "Supplier")
  4091. {
  4092. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4093. }
  4094. lw.Add(string.Format("OrderState = 6 "));
  4095. lw.Add(string.Format("type = 'JD' "));
  4096. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4097. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4098. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4099. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4100. writeGridDataTableJson(dStruct.TotalCount, dt);
  4101. }
  4102. public void get_erp_demoorderlist()
  4103. {
  4104. DataStruct dStruct = GetPostStruct();
  4105. List<string> lw = new List<string>();
  4106. string tid = GetPostString("ctid");
  4107. if (tid.Length > 0)
  4108. {
  4109. string select_tid = getTidByCtid(tid);
  4110. lw.Add(string.Format("tid='{0}'", select_tid));
  4111. }
  4112. string shopname = GetPostString("shopname");
  4113. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4114. string buyernick = GetPostString("buyer_nick");
  4115. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4116. string customer = GetPostString("customer");
  4117. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4118. string design = GetPostString("design");
  4119. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4120. string orderState = GetPostString("orderState");
  4121. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4122. string address = GetPostString("address");
  4123. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4124. string sellermemo = GetPostString("seller_memo");
  4125. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4126. string supplier = GetPostString("supplier");
  4127. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4128. string OrderArea = GetPostString("order_area");
  4129. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4130. string date1 = GetPostString("date1");
  4131. string date2 = GetPostString("date2");
  4132. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4133. if (dw.Length > 0) lw.Add(dw);
  4134. string price1 = GetPostString("price1");
  4135. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4136. string price2 = GetPostString("price2");
  4137. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4138. string posTag = CurrentUser.UserPost.Post.Code;
  4139. if (posTag == "Supplier")
  4140. {
  4141. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4142. }
  4143. //lw.Add(string.Format("OrderState = 6 "));
  4144. lw.Add(string.Format("IsSample={0}", 3));
  4145. lw.Add(string.Format("IsRefund<={0}", 1));
  4146. dStruct.Order = "pay_time desc";
  4147. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4148. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4149. writeGridDataTableJson(dStruct.TotalCount, dt);
  4150. }
  4151. public void save_erp_checkmemo()
  4152. {
  4153. if (UrlPostParmsCheck("ctid"))
  4154. {
  4155. string ctid = GetPostString("ctid");
  4156. CeErpTradeCell entity = null;
  4157. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4158. if (entity != null)
  4159. {
  4160. entity.CheckMemo = GetPostString("CheckMemo");
  4161. entity.Update();
  4162. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4163. if (trade != null)
  4164. {
  4165. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4166. }
  4167. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4168. returnSuccessMsg("保存成功!");
  4169. return;
  4170. }
  4171. returnErrorMsg("找不到记录");
  4172. }
  4173. }
  4174. public void get_erp_returnlist()
  4175. {
  4176. DataStruct dStruct = GetPostStruct();
  4177. List<string> lw = new List<string>();
  4178. string tid = GetPostString("ctid");
  4179. if (tid.Length > 0)
  4180. {
  4181. string select_tid = getTidByCtid(tid);
  4182. lw.Add(string.Format("tid='{0}'", select_tid));
  4183. }
  4184. string shopname = GetPostString("shopname");
  4185. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4186. string buyernick = GetPostString("buyer_nick");
  4187. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4188. string customer = GetPostString("customer");
  4189. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4190. string design = GetPostString("design");
  4191. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4192. string orderState = GetPostString("orderState");
  4193. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4194. string address = GetPostString("address");
  4195. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4196. string sellermemo = GetPostString("seller_memo");
  4197. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4198. string supplier = GetPostString("supplier");
  4199. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4200. string date1 = GetPostString("date1");
  4201. string date2 = GetPostString("date2");
  4202. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4203. if (dw.Length > 0) lw.Add(dw);
  4204. string bdate1 = GetPostString("backdate1");
  4205. string bdate2 = GetPostString("backdate2");
  4206. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4207. if (dw_back.Length > 0) lw.Add(dw_back);
  4208. string price1 = GetPostString("price1");
  4209. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4210. string price2 = GetPostString("price2");
  4211. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4212. lw.Add(string.Format("IsReturn>0"));
  4213. lw.Add(string.Format("IsXianHuo=0"));
  4214. lw.Add(string.Format("IsReturn!=3"));
  4215. string backtype = GetPostString("backtype");
  4216. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4217. dStruct.Order = "FinishDesignTime desc";
  4218. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4219. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4220. writeGridDataTableJson(dStruct.TotalCount, dt);
  4221. }
  4222. public void get_erp_today_sumreturn()
  4223. {
  4224. DataStruct dStruct = GetPostStruct();
  4225. List<string> lw = new List<string>();
  4226. string bdate1 = GetPostString("returnTimeS");
  4227. string bdate2 = GetPostString("returnTimeE");
  4228. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4229. if (dw_back.Length > 0) lw.Add(dw_back);
  4230. lw.Add(string.Format("IsReturn=0"));
  4231. lw.Add(string.Format("IsXianHuo=0"));
  4232. string mainWhere = string.Join(" and ", lw.ToArray());
  4233. string sql = "";
  4234. if (dw_back.Length > 0)
  4235. {
  4236. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4237. }
  4238. else
  4239. {
  4240. 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 + "'";
  4241. }
  4242. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4243. decimal total = 0, today_finish = 0;
  4244. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4245. {
  4246. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4247. }
  4248. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4249. {
  4250. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4251. }
  4252. var res = new
  4253. {
  4254. data = total,
  4255. data1 = today_finish,
  4256. };
  4257. string ro_jsond = JsonConvert.SerializeObject(res);
  4258. returnSuccess(ro_jsond);
  4259. return;
  4260. }
  4261. public void get_erp_allreturnlist()
  4262. {
  4263. DataStruct dStruct = GetPostStruct();
  4264. List<string> lw = new List<string>();
  4265. string tid = GetPostString("ctid");
  4266. if (tid.Length > 0)
  4267. {
  4268. string select_tid = getTidByCtid(tid);
  4269. lw.Add(string.Format("tid='{0}'", select_tid));
  4270. }
  4271. string shopname = GetPostString("shopname");
  4272. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4273. string buyernick = GetPostString("buyer_nick");
  4274. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4275. string customer = GetPostString("customer");
  4276. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4277. string design = GetPostString("design");
  4278. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4279. string orderState = GetPostString("orderState");
  4280. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4281. string address = GetPostString("address");
  4282. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4283. string sellermemo = GetPostString("seller_memo");
  4284. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4285. string supplier = GetPostString("supplier");
  4286. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4287. string date1 = GetPostString("date1");
  4288. string date2 = GetPostString("date2");
  4289. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4290. if (dw.Length > 0) lw.Add(dw);
  4291. string bdate1 = GetPostString("backdate1");
  4292. string bdate2 = GetPostString("backdate2");
  4293. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4294. if (dw_back.Length > 0) lw.Add(dw_back);
  4295. string price1 = GetPostString("price1");
  4296. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4297. string price2 = GetPostString("price2");
  4298. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4299. string backreason = GetPostString("backreason");
  4300. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4301. lw.Add(string.Format("IsXianHuo=0"));
  4302. lw.Add(string.Format("ReturnTime != ''"));
  4303. string backtype = GetPostString("backtype");
  4304. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4305. dStruct.Order = "FinishDesignTime desc";
  4306. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4307. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4308. writeGridDataTableJson(dStruct.TotalCount, dt);
  4309. }
  4310. public void get_erp_aftersalereturnlist()
  4311. {
  4312. DataStruct dStruct = GetPostStruct();
  4313. List<string> lw = new List<string>();
  4314. string tid = GetPostString("ctid");
  4315. if (tid.Length > 0)
  4316. {
  4317. string select_tid = getTidByCtid(tid);
  4318. lw.Add(string.Format("tid='{0}'", select_tid));
  4319. }
  4320. string shopname = GetPostString("shopname");
  4321. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4322. string buyernick = GetPostString("buyer_nick");
  4323. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4324. string customer = GetPostString("customer");
  4325. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4326. string design = GetPostString("design");
  4327. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4328. string orderState = GetPostString("orderState");
  4329. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4330. string address = GetPostString("address");
  4331. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4332. string sellermemo = GetPostString("seller_memo");
  4333. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4334. string supplier = GetPostString("supplier");
  4335. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4336. string date1 = GetPostString("date1");
  4337. string date2 = GetPostString("date2");
  4338. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4339. if (dw.Length > 0) lw.Add(dw);
  4340. string bdate1 = GetPostString("backdate1");
  4341. string bdate2 = GetPostString("backdate2");
  4342. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4343. if (dw_back.Length > 0) lw.Add(dw_back);
  4344. string price1 = GetPostString("price1");
  4345. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4346. string price2 = GetPostString("price2");
  4347. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4348. lw.Add(string.Format("IsReturn=3"));
  4349. string backtype = GetPostString("backtype");
  4350. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4351. string backreason = GetPostString("backreason");
  4352. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4353. dStruct.Order = "ReturnTime desc";
  4354. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4355. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4356. writeGridDataTableJson(dStruct.TotalCount, dt);
  4357. }
  4358. public void get_erp_xianhuoreturnlist()
  4359. {
  4360. DataStruct dStruct = GetPostStruct();
  4361. List<string> lw = new List<string>();
  4362. string tid = GetPostString("ctid");
  4363. if (tid.Length > 0)
  4364. {
  4365. string select_tid = getTidByCtid(tid);
  4366. lw.Add(string.Format("tid='{0}'", select_tid));
  4367. }
  4368. string shopname = GetPostString("shopname");
  4369. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4370. string buyernick = GetPostString("buyer_nick");
  4371. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4372. string customer = GetPostString("customer");
  4373. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4374. string design = GetPostString("design");
  4375. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4376. string orderState = GetPostString("orderState");
  4377. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4378. string address = GetPostString("address");
  4379. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4380. string sellermemo = GetPostString("seller_memo");
  4381. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4382. string supplier = GetPostString("supplier");
  4383. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4384. string OrderArea = GetPostString("order_area");
  4385. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4386. string date1 = GetPostString("date1");
  4387. string date2 = GetPostString("date2");
  4388. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4389. if (dw.Length > 0) lw.Add(dw);
  4390. string price1 = GetPostString("price1");
  4391. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4392. string price2 = GetPostString("price2");
  4393. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4394. string posTag = CurrentUser.UserPost.Post.Code;
  4395. if (posTag == "Supplier")
  4396. {
  4397. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4398. }
  4399. lw.Add(string.Format("OrderState=6 "));
  4400. lw.Add(string.Format("IsXianHuo=1 "));
  4401. lw.Add(string.Format("IsReturn>0 "));
  4402. lw.Add(string.Format("IsReturn!=3"));
  4403. lw.Add(string.Format("IsRefund<={0}", 1));
  4404. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4405. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4406. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4407. writeGridDataTableJson(dStruct.TotalCount, dt);
  4408. }
  4409. public void set_erp_orderdelivery()
  4410. {
  4411. if (UrlPostParmsCheck("ctid"))
  4412. {
  4413. string eid = GetPostString("ctid");
  4414. CeErpTradeCell entity = null;
  4415. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4416. if (entity != null)
  4417. {
  4418. if (entity.OrderState >= 7)
  4419. {
  4420. returnErrorMsg("此单已发货,无需重复发货");
  4421. return;
  4422. }
  4423. if (entity.OrderState != 6)
  4424. {
  4425. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4426. return;
  4427. }
  4428. string shop = GetPostString("seller_nick");
  4429. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4430. string comName = GetPostString("comName");
  4431. string comCode = GetPostString("comCode");
  4432. string outSid = GetPostString("outSid");
  4433. string deliveryType = GetPostString("deliveryType");
  4434. string deliveryMemo = GetPostString("deliveryMemo");
  4435. outSid = outSid.Trim();
  4436. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4437. if (mainEn == null)
  4438. {
  4439. returnErrorMsg("找不到原始订单记录");
  4440. return;
  4441. }
  4442. bool isInitOrderDeliv = false;
  4443. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4444. {
  4445. isInitOrderDeliv = true;
  4446. }
  4447. string apires = "";
  4448. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4449. 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)
  4450. {
  4451. apires = "发货成功true";
  4452. }
  4453. else
  4454. {
  4455. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4456. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4457. }
  4458. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4459. {
  4460. entity.OrderState = 7;//发货后订单已发货
  4461. entity.OutSid = outSid;
  4462. entity.MemoOpt = 0;
  4463. entity.UpdateTime = DateTime.Now;
  4464. entity.FinishDeliveryTime = DateTime.Now;
  4465. entity.Update();
  4466. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4467. commonHelper.UpdateRelationOrder(entity.ctid);
  4468. //还要插入快递信息到 快递信息表
  4469. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4470. exinfo.tid = eid;
  4471. exinfo.out_sid = outSid;
  4472. exinfo.company_code = comCode;
  4473. exinfo.company_name = comName;
  4474. exinfo.delivery_memo = deliveryMemo;
  4475. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4476. exinfo.deliveryType = deliveryType;
  4477. exinfo.Create();
  4478. returnSuccessMsg("发货操作成功!");
  4479. commonHelper.UpdateRelationOrder(entity.ctid);
  4480. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4481. CeErpSukuraData.createInfo(entity.ctid, 4);
  4482. if (entity.SupplierId == 64)
  4483. {
  4484. commonHelper.sendCytExpress(exinfo);
  4485. }
  4486. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4487. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4488. }
  4489. else
  4490. {
  4491. string errmsg = commonHelper.KeepChinese(apires);
  4492. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4493. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4494. }
  4495. return;
  4496. }
  4497. returnErrorMsg("找不到订单记录");
  4498. }
  4499. }
  4500. public void set_erp_multidelivery()
  4501. {
  4502. string eids = GetPostString("tids");
  4503. string[] eidList = eids.Split(',');
  4504. if (eidList.Length <= 0)
  4505. {
  4506. returnErrorMsg("发货不能为空");
  4507. return;
  4508. }
  4509. foreach (string ctid in eidList)
  4510. {
  4511. if (ctid.Length <= 0) continue;
  4512. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4513. if (expInfo != null)
  4514. {
  4515. StringBuilder sql = new StringBuilder();
  4516. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4517. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4518. if (dt.Rows.Count > 0)
  4519. {
  4520. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4521. {
  4522. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4523. expInfo.state = "异常";
  4524. expInfo.isMultiDelivery = 1;
  4525. expInfo.Update();
  4526. continue;
  4527. }
  4528. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4529. {
  4530. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4531. expInfo.state = "异常";
  4532. expInfo.Update();
  4533. continue;
  4534. }
  4535. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4536. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4537. bool isInitOrderDeliv = false;
  4538. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4539. {
  4540. isInitOrderDeliv = true;
  4541. expInfo.isMultiDelivery = 1;
  4542. }
  4543. if (ctid.IndexOf("N") != -1)
  4544. {
  4545. StringBuilder sqlbucha = new StringBuilder();
  4546. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4547. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4548. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4549. commonHelper.UpdateRelationOrder(ctid);
  4550. expInfo.delivery_memo = "发货成功";
  4551. expInfo.state = "发货成功";
  4552. expInfo.isMultiDelivery = 1;
  4553. expInfo.Update();
  4554. }
  4555. else
  4556. {
  4557. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4558. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4559. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4560. {
  4561. expInfo.delivery_memo = "发货成功";
  4562. expInfo.state = "发货成功";
  4563. expInfo.isMultiDelivery = 1;
  4564. expInfo.Update();
  4565. commonHelper.UpdateRelationOrder(ctid);
  4566. CeErpSukuraData.createInfo(ctid, 4);
  4567. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4568. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4569. }
  4570. else
  4571. {
  4572. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4573. expInfo.state = "异常";
  4574. expInfo.Update();
  4575. }
  4576. }
  4577. }
  4578. }
  4579. }
  4580. returnSuccessMsg("操作完成");
  4581. }
  4582. public void reset_erp_memoopt()
  4583. {
  4584. if (UrlPostParmsCheck("ctid"))
  4585. {
  4586. string eid = GetPostString("ctid");
  4587. CeErpTradeCell entity = null;
  4588. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4589. if (entity != null)
  4590. {
  4591. string stropt = "";
  4592. if (entity.MemoOpt == 1)
  4593. {
  4594. stropt = "“改稿”";
  4595. }
  4596. else if (entity.MemoOpt == 2)
  4597. {
  4598. stropt = "“定稿”";
  4599. }
  4600. else if (entity.MemoOpt == 3)
  4601. {
  4602. stropt = "“完成查货”";
  4603. CeErpSukuraData.createInfo(entity.ctid, 6);
  4604. }
  4605. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4606. entity.UpdateTime = DateTime.Now;
  4607. entity.MemoOpt = 0;
  4608. entity.Update();
  4609. returnSuccessMsg("操作成功!");
  4610. return;
  4611. }
  4612. returnErrorMsg("找不到记录");
  4613. }
  4614. }
  4615. public void get_erp_deliveryunusual()
  4616. {
  4617. DataStruct dStruct = GetPostStruct();
  4618. List<string> lw = new List<string>();
  4619. string tid = GetPostString("ctid");
  4620. if (tid.Length > 0)
  4621. {
  4622. string select_tid = getTidByCtid(tid);
  4623. lw.Add(string.Format("tid='{0}'", select_tid));
  4624. }
  4625. string shopname = GetPostString("shopname");
  4626. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4627. string buyernick = GetPostString("buyer_nick");
  4628. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4629. string customer = GetPostString("customer");
  4630. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4631. string design = GetPostString("design");
  4632. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4633. string sellermemo = GetPostString("seller_memo");
  4634. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4635. string supplier = GetPostString("supplier");
  4636. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4637. string date1 = GetPostString("date1");
  4638. string date2 = GetPostString("date2");
  4639. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4640. if (dw.Length > 0) lw.Add(dw);
  4641. string placedate1 = GetPostString("placedate1");
  4642. string placedate2 = GetPostString("placedate2");
  4643. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4644. if (dw_place.Length > 0) lw.Add(dw_place);
  4645. string price1 = GetPostString("price1");
  4646. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4647. string price2 = GetPostString("price2");
  4648. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4649. string unusualCon = GetPostString("unusualcon");
  4650. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4651. string posTag = CurrentUser.UserPost.Post.Code;
  4652. if (posTag == "Supplier")
  4653. {
  4654. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4655. }
  4656. lw.Add(string.Format("OrderState = 6"));
  4657. lw.Add(string.Format("UnusualTag = 5"));
  4658. lw.Add(string.Format("IsRefund<={0}", 1));
  4659. dStruct.Order = "FinishPlaceTime desc";
  4660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4661. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4662. writeGridDataTableJson(dStruct.TotalCount, dt);
  4663. }
  4664. public void get_erp_deliveryedlist()
  4665. {
  4666. DataStruct dStruct = GetPostStruct();
  4667. List<string> lw = new List<string>();
  4668. string tid = GetPostString("ctid");
  4669. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  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='{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 logistics = GetPostString("logistics");
  4681. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  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 fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4689. if (fdw.Length > 0) lw.Add(fdw);
  4690. string devdate1 = GetPostString("deliverydate1");
  4691. string devdate2 = GetPostString("deliverydate2");
  4692. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4693. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4694. string price1 = GetPostString("price1");
  4695. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4696. string price2 = GetPostString("price2");
  4697. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4698. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4699. {
  4700. if (tid.Length > 0)
  4701. {
  4702. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4703. if (tid.Length > 5)
  4704. {
  4705. List<string> tids = getTidByCtidLike(tid);
  4706. if (tids.Count > 0 && tids.Count < 10)
  4707. {
  4708. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4709. }
  4710. }
  4711. lw.Add(tid_sql);
  4712. }
  4713. if (buyernick.Length > 0)
  4714. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4715. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4716. if (dw.Length > 0) lw.Add(dw);
  4717. }
  4718. else
  4719. {
  4720. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4721. }
  4722. string posTag = CurrentUser.UserPost.Post.Code;
  4723. if (posTag == "Supplier")
  4724. {
  4725. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4726. }
  4727. else
  4728. {
  4729. string supplier = GetPostString("supplier");
  4730. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4731. }
  4732. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4733. lw.Add(string.Format("type != 'PDD' "));
  4734. lw.Add(string.Format("IsRefund!={0}", 2));
  4735. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4736. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4737. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4738. /*if (tid.Length > 0)
  4739. {
  4740. List<string> tids = new List<string>();
  4741. if (dt != null && dt.Rows.Count > 0)
  4742. {
  4743. foreach (DataRow item in dt.Rows)
  4744. {
  4745. tids.Add("'" + item["tid"] + "'");
  4746. }
  4747. }
  4748. if (tids.Count > 0)
  4749. {
  4750. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4751. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4752. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4753. dt = WebCache.GetData("view_erptradecell", dStruct);
  4754. }
  4755. }*/
  4756. if (dt != null)
  4757. {
  4758. foreach (DataRow dr in dt.Rows)
  4759. {
  4760. 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();
  4761. }
  4762. }
  4763. writeGridDataTableJson(dStruct.TotalCount, dt);
  4764. }
  4765. public void get_erp_pdddeliveryed()
  4766. {
  4767. DataStruct dStruct = GetPostStruct();
  4768. List<string> lw = new List<string>();
  4769. string tid = GetPostString("ctid");
  4770. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4771. string shopname = GetPostString("shopname");
  4772. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4773. string buyernick = GetPostString("buyer_nick");
  4774. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4775. string customer = GetPostString("customer");
  4776. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4777. string design = GetPostString("design");
  4778. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4779. string sellermemo = GetPostString("seller_memo");
  4780. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4781. string logistics = GetPostString("logistics");
  4782. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4783. string date1 = GetPostString("date1");
  4784. string date2 = GetPostString("date2");
  4785. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4786. //if (dw.Length > 0) lw.Add(dw);
  4787. string placedate1 = GetPostString("placedate1");
  4788. string placedate2 = GetPostString("placedate2");
  4789. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4790. if (fdw.Length > 0) lw.Add(fdw);
  4791. string devdate1 = GetPostString("deliverydate1");
  4792. string devdate2 = GetPostString("deliverydate2");
  4793. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4794. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4795. string price1 = GetPostString("price1");
  4796. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4797. string price2 = GetPostString("price2");
  4798. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4799. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4800. {
  4801. if (tid.Length > 0)
  4802. {
  4803. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4804. if (tid.Length > 5)
  4805. {
  4806. List<string> tids = getTidByCtidLike(tid);
  4807. if (tids.Count > 0 && tids.Count < 10)
  4808. {
  4809. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4810. }
  4811. }
  4812. lw.Add(tid_sql);
  4813. }
  4814. if (buyernick.Length > 0)
  4815. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4816. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4817. if (dw.Length > 0) lw.Add(dw);
  4818. }
  4819. else
  4820. {
  4821. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4822. }
  4823. string posTag = CurrentUser.UserPost.Post.Code;
  4824. if (posTag == "Supplier")
  4825. {
  4826. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4827. }
  4828. else
  4829. {
  4830. string supplier = GetPostString("supplier");
  4831. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4832. }
  4833. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4834. lw.Add(string.Format("type = 'PDD' "));
  4835. lw.Add(string.Format("IsRefund!={0}", 2));
  4836. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4837. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4838. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4839. /* if (tid.Length > 0)
  4840. {
  4841. List<string> tids = new List<string>();
  4842. if (dt != null && dt.Rows.Count > 0)
  4843. {
  4844. foreach (DataRow item in dt.Rows)
  4845. {
  4846. tids.Add("'" + item["tid"] + "'");
  4847. }
  4848. }
  4849. if (tids.Count > 0)
  4850. {
  4851. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4852. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4854. dt = WebCache.GetData("view_erptradecell", dStruct);
  4855. }
  4856. }*/
  4857. foreach (DataRow dr in dt.Rows)
  4858. {
  4859. 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();
  4860. }
  4861. writeGridDataTableJson(dStruct.TotalCount, dt);
  4862. }
  4863. public void get_erp_jddeliveryed()
  4864. {
  4865. DataStruct dStruct = GetPostStruct();
  4866. List<string> lw = new List<string>();
  4867. string tid = GetPostString("ctid");
  4868. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4869. string shopname = GetPostString("shopname");
  4870. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4871. string buyernick = GetPostString("buyer_nick");
  4872. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4873. string customer = GetPostString("customer");
  4874. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4875. string design = GetPostString("design");
  4876. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4877. string sellermemo = GetPostString("seller_memo");
  4878. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4879. string date1 = GetPostString("date1");
  4880. string date2 = GetPostString("date2");
  4881. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4882. //if (dw.Length > 0) lw.Add(dw);
  4883. string placedate1 = GetPostString("placedate1");
  4884. string placedate2 = GetPostString("placedate2");
  4885. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4886. if (fdw.Length > 0) lw.Add(fdw);
  4887. string devdate1 = GetPostString("deliverydate1");
  4888. string devdate2 = GetPostString("deliverydate2");
  4889. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4890. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4891. string price1 = GetPostString("price1");
  4892. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4893. string price2 = GetPostString("price2");
  4894. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4895. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4896. {
  4897. if (tid.Length > 0)
  4898. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4899. if (buyernick.Length > 0)
  4900. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4901. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4902. if (dw.Length > 0) lw.Add(dw);
  4903. }
  4904. else
  4905. {
  4906. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4907. }
  4908. string posTag = CurrentUser.UserPost.Post.Code;
  4909. if (posTag == "Supplier")
  4910. {
  4911. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4912. }
  4913. else
  4914. {
  4915. string supplier = GetPostString("supplier");
  4916. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4917. }
  4918. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4919. lw.Add(string.Format("type = 'JD' "));
  4920. lw.Add(string.Format("IsRefund!={0}", 2));
  4921. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4922. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4923. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4924. foreach (DataRow dr in dt.Rows)
  4925. {
  4926. 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();
  4927. }
  4928. writeGridDataTableJson(dStruct.TotalCount, dt);
  4929. }
  4930. public void get_erp_allplacelist()
  4931. {
  4932. DataStruct dStruct = GetPostStruct();
  4933. List<string> lw = new List<string>();
  4934. string tid = GetPostString("ctid");
  4935. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4936. string shopname = GetPostString("shopname");
  4937. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4938. string buyernick = GetPostString("buyer_nick");
  4939. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4940. string customer = GetPostString("customer");
  4941. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4942. string design = GetPostString("design");
  4943. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4944. string sellermemo = GetPostString("seller_memo");
  4945. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4946. string supplier = GetPostString("supplier");
  4947. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4948. string date1 = GetPostString("date1");
  4949. string date2 = GetPostString("date2");
  4950. string pldate1 = GetPostString("placedate1");
  4951. string pldate2 = GetPostString("placedate2");
  4952. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4953. //if (dw.Length > 0) lw.Add(dw);
  4954. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4955. {
  4956. if (tid.Length > 0)
  4957. {
  4958. string select_tid = getTidByCtid(tid);
  4959. lw.Add(string.Format("tid='{0}'", select_tid));
  4960. }
  4961. if (buyernick.Length > 0)
  4962. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4963. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4964. if (dw.Length > 0) lw.Add(dw);
  4965. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4966. if (dw_place.Length > 0) lw.Add(dw_place);
  4967. }
  4968. else
  4969. {
  4970. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4971. {
  4972. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4973. }
  4974. }
  4975. string price1 = GetPostString("price1");
  4976. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4977. string price2 = GetPostString("price2");
  4978. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4979. string posTag = CurrentUser.UserPost.Post.Code;
  4980. if (posTag == "Supplier")
  4981. {
  4982. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4983. }
  4984. lw.Add(string.Format("OrderState >= 6"));
  4985. lw.Add(string.Format("IsSample != 2 "));
  4986. //lw.Add(string.Format("isDianziOrder = 0 "));
  4987. lw.Add(string.Format("SupplierId > 0 "));
  4988. //lw.Add(string.Format("IsRefund<={0}", 1));
  4989. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4990. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4991. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4992. foreach (DataRow dr in dt.Rows)
  4993. {
  4994. 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();
  4995. }
  4996. writeGridDataTableJson(dStruct.TotalCount, dt);
  4997. }
  4998. public void get_erp_financeallplacelist()
  4999. {
  5000. DataStruct dStruct = GetPostStruct();
  5001. List<string> lw = new List<string>();
  5002. string tid = GetPostString("ctid");
  5003. string shopname = GetPostString("shopname");
  5004. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5005. string buyernick = GetPostString("buyer_nick");
  5006. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5007. string customer = GetPostString("customer");
  5008. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5009. string design = GetPostString("design");
  5010. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5011. string sellermemo = GetPostString("seller_memo");
  5012. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5013. string supplier = GetPostString("supplier");
  5014. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5015. string date1 = GetPostString("date1");
  5016. string date2 = GetPostString("date2");
  5017. string pldate1 = GetPostString("placedate1");
  5018. string pldate2 = GetPostString("placedate2");
  5019. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5020. {
  5021. if (tid.Length > 0)
  5022. {
  5023. string select_tid = getTidByCtid(tid);
  5024. lw.Add(string.Format("tid='{0}'", select_tid));
  5025. }
  5026. if (buyernick.Length > 0)
  5027. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5028. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5029. if (dw.Length > 0) lw.Add(dw);
  5030. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5031. if (dw_place.Length > 0) lw.Add(dw_place);
  5032. }
  5033. else
  5034. {
  5035. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5036. {
  5037. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5038. }
  5039. }
  5040. string price1 = GetPostString("price1");
  5041. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5042. string price2 = GetPostString("price2");
  5043. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5044. string posTag = CurrentUser.UserPost.Post.Code;
  5045. if (posTag == "Supplier")
  5046. {
  5047. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5048. }
  5049. //lw.Add(string.Format("OrderState >= 6"));
  5050. lw.Add(string.Format("IsSample != 2 "));
  5051. lw.Add(string.Format("isDianziOrder = 0 "));
  5052. //lw.Add(string.Format("IsRefund<={0}", 1));
  5053. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5054. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5055. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5056. foreach (DataRow dr in dt.Rows)
  5057. {
  5058. 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();
  5059. }
  5060. writeGridDataTableJson(dStruct.TotalCount, dt);
  5061. }
  5062. public void get_erp_expresslist()
  5063. {
  5064. int listtype = GetInt("ltype");
  5065. DataStruct dStruct = GetPostStruct();
  5066. List<string> lw = new List<string>();
  5067. string tid = GetPostString("tid");
  5068. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5069. string outsid = GetPostString("out_sid");
  5070. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5071. string importer = GetPostString("ImportUserName");
  5072. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5073. string file = GetPostString("import_file");
  5074. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5075. string printman = GetPostString("printman");
  5076. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5077. string date1 = GetPostString("date1");
  5078. string date2 = GetPostString("date2");
  5079. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5080. if (dw.Length > 0) lw.Add(dw);
  5081. string fdate1 = GetPostString("finishdate1");
  5082. string fdate2 = GetPostString("finishdate2");
  5083. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5084. if (fdw.Length > 0) lw.Add(fdw);
  5085. string supplierId = GetPostString("supplierId");
  5086. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5087. if (listtype == 1)
  5088. {
  5089. lw.Add(string.Format("importUserId !=0"));
  5090. }
  5091. string posTag = CurrentUser.UserPost.Post.Code;
  5092. if (posTag == "Supplier")
  5093. {
  5094. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5095. }
  5096. if (dStruct.PageSize != 100000)
  5097. {
  5098. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5099. }
  5100. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5101. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5102. writeGridDataTableJson(dStruct.TotalCount, dt);
  5103. }
  5104. public void set_erp_buchaorderdelivery()
  5105. {
  5106. if (UrlPostParmsCheck("ctid"))
  5107. {
  5108. string eid = GetPostString("ctid");
  5109. CeErpTradeCell entity = null;
  5110. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5111. if (entity != null)
  5112. {
  5113. if (entity.IsSample != 2)
  5114. {
  5115. returnErrorMsg("补差价单才能标记为已发货");
  5116. return;
  5117. }
  5118. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5119. entity.OrderState = 7;
  5120. entity.Update();
  5121. returnSuccessMsg("操作成功!");
  5122. return;
  5123. }
  5124. returnErrorMsg("找不到记录");
  5125. }
  5126. }
  5127. public void get_stdtemplates()
  5128. {
  5129. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5130. //string res = taobaoHelper.test();
  5131. string res = apiHelper.API_PrintTemplate();
  5132. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5133. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5134. {
  5135. int sidx = res.IndexOf("error_code");
  5136. int eidx = res.IndexOf("success");
  5137. string msg = res.Substring(sidx, eidx - sidx);
  5138. returnErrorMsg(msg);
  5139. return;
  5140. }
  5141. if (res.Length <= 0)
  5142. {
  5143. returnErrorMsg("模板数据为空!");
  5144. return;
  5145. }
  5146. ReturnSuccess(res);
  5147. }
  5148. public void cancel_print_order()
  5149. {
  5150. if (UrlPostParmsCheck("ctid"))
  5151. {
  5152. string ctid = GetPostString("ctid");
  5153. CeErpTradeCell entity = null;
  5154. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5155. if (entity != null)
  5156. {
  5157. string res = "";
  5158. string code = entity.LastBillWaybillCode;
  5159. if (code == "")
  5160. {
  5161. code = entity.OutSid;
  5162. }
  5163. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5164. XLog.SaveLog(0, "取消面单" + res);
  5165. }
  5166. }
  5167. }
  5168. public void set_erp_printwaybill()
  5169. {
  5170. if (UrlPostParmsCheck("ctid"))
  5171. {
  5172. string ctid = GetPostString("ctid");
  5173. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5174. string cpName = GetPostString("cpname");
  5175. string isTogether = GetPostString("together");
  5176. //var res_obj = new
  5177. //{
  5178. // restype = 1,
  5179. // 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\"}"
  5180. //};
  5181. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5182. //ReturnSuccess(ro_json);
  5183. //return;
  5184. bool isUseLastWayBillCode = false;
  5185. CeErpTradeCell entity = null;
  5186. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5187. if (entity != null)
  5188. {
  5189. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5190. {
  5191. isUseLastWayBillCode = true;
  5192. }
  5193. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5194. {
  5195. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5196. return;
  5197. }
  5198. }
  5199. string res = "";
  5200. Api_waybill_code_response_Obj fullObj = null;
  5201. string pData_str = "";
  5202. string curUseWayBillCode = "";
  5203. if (isUseLastWayBillCode == false)
  5204. {
  5205. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5206. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5207. if (res.IndexOf("failure") != -1)
  5208. {
  5209. //int idx = res.IndexOf("sub_message");
  5210. //int idx2 = res.IndexOf("flag");
  5211. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5212. string errMsgNeed = commonHelper.KeepChinese(res);
  5213. var res_objd = new
  5214. {
  5215. restype = 0,
  5216. data = "获取面单失败" + errMsgNeed
  5217. };
  5218. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5219. returnSuccess(ro_jsond);
  5220. if (res.IndexOf("停发") != -1)
  5221. {
  5222. entity.UnusualCon = "物流停发";
  5223. entity.Update();
  5224. }
  5225. //returnErrorMsg("获取面单失败,"+emsg);
  5226. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5227. return;
  5228. }
  5229. else if (res.IndexOf("errorMsg") != -1)
  5230. {
  5231. //int idx = res.IndexOf("errorMsg");
  5232. //int idx2 = res.IndexOf("}]}");
  5233. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5234. string errMsgNeed = commonHelper.KeepChinese(res);
  5235. var res_objf = new
  5236. {
  5237. restype = 0,
  5238. data = "获取面单失败2" + errMsgNeed
  5239. };
  5240. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5241. if (res.IndexOf("停发") != -1)
  5242. {
  5243. entity.UnusualCon = "物流停发";
  5244. entity.Update();
  5245. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5246. if (trade != null)
  5247. {
  5248. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5249. }
  5250. }
  5251. returnSuccess(ro_jsonf);
  5252. //returnErrorMsg("获取面单失败," + emsg);
  5253. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5254. return;
  5255. }
  5256. try
  5257. {
  5258. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5259. //res = res.Replace(" ", "");
  5260. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5261. }
  5262. catch (Exception ex)
  5263. {
  5264. XLog.SaveLog(0, "生成fullObj" + res);
  5265. var res_objf = new
  5266. {
  5267. restype = 0,
  5268. data = "生成fullObj发生错误" + ex.Message
  5269. };
  5270. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5271. returnSuccess(ro_jsonf);
  5272. return;
  5273. }
  5274. if (fullObj.response.data.content.Count > 0)
  5275. {
  5276. ContentItem codeObj = fullObj.response.data.content[0];
  5277. if (cpCode.IndexOf("SFFQ-") != -1)
  5278. {
  5279. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5280. }
  5281. else
  5282. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5283. curUseWayBillCode = codeObj.waybillCode;
  5284. }
  5285. else
  5286. {
  5287. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5288. var res_objf = new
  5289. {
  5290. restype = 0,
  5291. data = "生成fullObj找不到快递单号waybillCode"
  5292. };
  5293. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5294. returnSuccess(ro_jsonf);
  5295. return;
  5296. }
  5297. }
  5298. else
  5299. {
  5300. //使用上次打印的快递单号
  5301. if (cpCode == "SFFQ-LY")
  5302. {
  5303. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5304. }
  5305. else
  5306. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5307. curUseWayBillCode = entity.LastBillWaybillCode;
  5308. }
  5309. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5310. {
  5311. var res_obje = new
  5312. {
  5313. restype = 0,
  5314. data = "获取加密打印数据失败"
  5315. };
  5316. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5317. returnSuccess(ro_jsone);
  5318. entity.LastBillCpCode = cpCode;
  5319. entity.LastBillWaybillCode = curUseWayBillCode;
  5320. entity.Update();
  5321. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5322. //returnErrorMsg("获取加密打印数据失败");
  5323. return;
  5324. }
  5325. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5326. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5327. string btnType = "";
  5328. if (entity != null)
  5329. {
  5330. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5331. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5332. //cpcode是 YTO-CAINIAO
  5333. //string comCode = cpCode.Split('-')[0].ToString();
  5334. string apires = "";
  5335. if (ctid.IndexOf("N") != -1)
  5336. {
  5337. apires = "发货成功";
  5338. }
  5339. else
  5340. {
  5341. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5342. }
  5343. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5344. //打单后发货
  5345. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5346. {
  5347. try
  5348. {
  5349. btnType = "待发货";
  5350. entity.OutSid = curUseWayBillCode;
  5351. entity.OrderState = 7;
  5352. entity.IsUrgency = false;
  5353. entity.LastBillCpCode = "";
  5354. entity.LastBillWaybillCode = "";
  5355. entity.FinishDeliveryTime = DateTime.Now;
  5356. entity.IsReturn = 0;
  5357. entity.MemoOpt = 0;
  5358. entity.UpdateTime = DateTime.Now;
  5359. entity.Update();
  5360. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5361. //还要插入快递信息到 快递信息表
  5362. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5363. exinfo.tid = entity.ctid;
  5364. exinfo.out_sid = entity.OutSid;
  5365. exinfo.company_code = cpCode;
  5366. exinfo.company_name = cpName;
  5367. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5368. exinfo.deliveryType = "发货成功";
  5369. exinfo.print_time = DateTime.Now;
  5370. exinfo.printUser = CurrentUser.UserName;
  5371. exinfo.Create();
  5372. commonHelper.UpdateRelationOrder(entity.ctid);
  5373. CeErpSukuraData.createInfo(ctid, 4);
  5374. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5375. if (entity.SupplierId == 64)
  5376. {
  5377. commonHelper.sendCytExpress(exinfo);
  5378. }
  5379. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5380. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5381. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5382. if (isTogether == "1" && ceErpDeliverMark == null)
  5383. {
  5384. StringBuilder sqlsb = new StringBuilder();
  5385. 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);
  5386. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5387. }
  5388. if (ceErpDeliverMark != null)
  5389. {
  5390. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5391. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5392. {
  5393. List<string> list = new List<string>();
  5394. foreach (DataRow row in dt1.Rows)
  5395. {
  5396. list.Add("'" + row["ctid"] + "'");
  5397. }
  5398. DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
  5399. }
  5400. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5401. }
  5402. }
  5403. catch (Exception ex)
  5404. {
  5405. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5406. }
  5407. }
  5408. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5409. {
  5410. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5411. if (entity.OrderState == 6)
  5412. {
  5413. entity.OrderState = 7;
  5414. }
  5415. entity.UpdateTime = DateTime.Now;
  5416. entity.FinishDeliveryTime = DateTime.Now;
  5417. btnType = "已发货";
  5418. entity.Update();
  5419. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5420. exinfo.tid = entity.ctid;
  5421. exinfo.out_sid = entity.OutSid;
  5422. exinfo.company_code = cpCode;
  5423. exinfo.company_name = cpName;
  5424. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5425. exinfo.deliveryType = "发货成功";
  5426. exinfo.print_time = DateTime.Now;
  5427. exinfo.printUser = CurrentUser.UserName;
  5428. exinfo.Create();
  5429. commonHelper.UpdateRelationOrder(entity.ctid);
  5430. CeErpSukuraData.createInfo(entity.ctid, 4);
  5431. if (entity.SupplierId == 64)
  5432. {
  5433. commonHelper.sendCytExpress(exinfo);
  5434. }
  5435. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5436. if (isTogether == "1" && ceErpDeliverMark == null)
  5437. {
  5438. StringBuilder sqlsb = new StringBuilder();
  5439. 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);
  5440. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5441. }
  5442. if (ceErpDeliverMark != null)
  5443. {
  5444. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5445. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5446. {
  5447. List<string> list = new List<string>();
  5448. foreach (DataRow row in dt1.Rows)
  5449. {
  5450. list.Add("'" + row["ctid"] + "'");
  5451. }
  5452. DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
  5453. }
  5454. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5455. }
  5456. //不处理
  5457. }
  5458. else
  5459. {
  5460. entity.UpdateTime = DateTime.Now;
  5461. entity.LastBillCpCode = cpCode;
  5462. entity.LastBillWaybillCode = curUseWayBillCode;
  5463. entity.Update();
  5464. string errmsg = commonHelper.KeepChinese(apires);
  5465. var res_objz = new
  5466. {
  5467. restype = 0,
  5468. data = "打单后发货失败"
  5469. };
  5470. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5471. returnSuccess(ro_jsonz);
  5472. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5473. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5474. return;
  5475. }
  5476. }
  5477. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5478. var res_obj = new
  5479. {
  5480. restype = 1,
  5481. data = pData_str
  5482. };
  5483. string ro_json = JsonConvert.SerializeObject(res_obj);
  5484. ReturnSuccess(ro_json);
  5485. return;
  5486. }
  5487. }
  5488. private string GetUTF8String(byte[] vs)
  5489. {
  5490. throw new NotImplementedException();
  5491. }
  5492. public void set_erp_printwaybill_cn()
  5493. {
  5494. if (UrlPostParmsCheck("ctid"))
  5495. {
  5496. string ctid = GetPostString("ctid");
  5497. string cpCode = GetPostString("cpcode");
  5498. string cpName = GetPostString("cpname");
  5499. string tempUrl = GetPostString("tempurl");
  5500. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5501. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5502. //string res = taobaoHelper.test();
  5503. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5504. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5505. {
  5506. int sidx = res.IndexOf("errorMsg");
  5507. int eidx = res.IndexOf("}");
  5508. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5509. var res_objzxx = new
  5510. {
  5511. restype = 0,
  5512. data = msg
  5513. };
  5514. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5515. returnSuccess(ro_jsonzxx);
  5516. //returnErrorMsg(msg);
  5517. return;
  5518. }
  5519. int idx = res.IndexOf("waybillCode");
  5520. int idx2 = res.IndexOf("printData");
  5521. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5522. string eid = GetPostString("ctid");
  5523. CeErpTradeCell entity = null;
  5524. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5525. if (entity != null)
  5526. {
  5527. string osid = entity.OutSid;
  5528. entity.OutSid = osid + "," + outsid;
  5529. entity.FinishDeliveryTime = DateTime.Now;
  5530. entity.OrderState = 7;
  5531. entity.UpdateTime = DateTime.Now;
  5532. entity.IsReturn = 0;
  5533. entity.Update();
  5534. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5535. exinfo.tid = entity.ctid;
  5536. exinfo.out_sid = outsid;
  5537. exinfo.company_code = cpCode;
  5538. exinfo.company_name = cpName;
  5539. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5540. exinfo.deliveryType = "发货成功";
  5541. exinfo.print_time = DateTime.Now;
  5542. exinfo.printUser = CurrentUser.UserName;
  5543. exinfo.Create();
  5544. if (entity.SupplierId == 64)
  5545. {
  5546. commonHelper.sendCytExpress(exinfo);
  5547. }
  5548. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5549. }
  5550. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5551. var res_objz = new
  5552. {
  5553. restype = 1,
  5554. data = res
  5555. };
  5556. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5557. returnSuccess(ro_jsonz);
  5558. //ReturnSuccess(res);
  5559. }
  5560. }
  5561. ////打单,打印面单 获取面单号
  5562. //public void set_erp_printwaybill()
  5563. //{
  5564. // if (UrlPostParmsCheck("ctid"))
  5565. // {
  5566. // string ctid = GetPostString("ctid");
  5567. // string cpCode = GetPostString("cpcode");
  5568. // string tempUrl = GetPostString("tempurl");
  5569. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5570. // //string res = taobaoHelper.test();
  5571. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5572. // if (res.IndexOf("error_response") != -1)
  5573. // {
  5574. // int sidx = res.IndexOf("sub_msg");
  5575. // int eidx = res.IndexOf("request_id");
  5576. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5577. // returnErrorMsg(msg);
  5578. // return;
  5579. // }
  5580. // int idx = res.IndexOf("waybill_code");
  5581. // int idx2 = res.IndexOf("}]}");
  5582. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5583. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5584. // ReturnSuccess(res);
  5585. // }
  5586. //}
  5587. public void cancel_erp_aftersale()
  5588. {
  5589. if (UrlPostParmsCheck("ctid"))
  5590. {
  5591. string eid = GetPostString("ctid");
  5592. CeErpTradeCell entity = null;
  5593. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5594. if (entity != null)
  5595. {
  5596. //有过处理的售后,取消也不能删除 售 字,保留
  5597. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5598. {
  5599. entity.AfterSaleState = 4;
  5600. }
  5601. else
  5602. entity.AfterSaleState = 0;
  5603. entity.UpdateTime = DateTime.Now;
  5604. entity.Update();
  5605. returnSuccessMsg("操作成功!");
  5606. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5607. return;
  5608. }
  5609. returnErrorMsg("找不到订单记录");
  5610. }
  5611. }
  5612. public void get_erp_aftersalelist()
  5613. {
  5614. DataStruct dStruct = GetPostStruct();
  5615. List<string> lw = new List<string>();
  5616. int st = GetInt("st");
  5617. string tid = GetPostString("ctid");
  5618. if (st == 3)
  5619. {
  5620. if (tid.Length > 0)
  5621. {
  5622. string select_tid = getTidByCtid(tid);
  5623. lw.Add(string.Format("tid='{0}'", select_tid));
  5624. }
  5625. }
  5626. else
  5627. {
  5628. if (tid.Length > 0)
  5629. {
  5630. string select_tid = getTidByCtid(tid);
  5631. lw.Add(string.Format("tid='{0}'", select_tid));
  5632. }
  5633. }
  5634. string shopname = GetPostString("shopname");
  5635. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5636. string buyernick = GetPostString("buyer_nick");
  5637. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5638. string sellermemo = GetPostString("seller_memo");
  5639. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5640. string orderState = GetPostString("orderState");
  5641. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5642. string afterState = GetPostString("afterstate");
  5643. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5644. string date1 = GetPostString("date1");
  5645. string date2 = GetPostString("date2");
  5646. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5647. if (dw.Length > 0) lw.Add(dw);
  5648. string price1 = GetPostString("price1");
  5649. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5650. string price2 = GetPostString("price2");
  5651. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5652. //lw.Add(string.Format("IsRefund!={0}", 1));
  5653. string reason = GetPostString("reason");
  5654. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5655. string method = GetPostString("method");
  5656. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5657. string handler = GetPostString("handler");
  5658. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5659. string handledate1 = GetPostString("handledate1");
  5660. string handledate2 = GetPostString("handledate2");
  5661. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5662. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5663. string finish1 = GetPostString("finishdate1");
  5664. string finish2 = GetPostString("finishdate2");
  5665. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5666. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5667. string afterdate1 = GetPostString("afterdate1");
  5668. string afterdate2 = GetPostString("afterdate2");
  5669. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5670. if (afterDate.Length > 0) lw.Add(afterDate);
  5671. string supplier = GetPostString("supplier");
  5672. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5673. string responsible = GetPostString("responsibleman");
  5674. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5675. string customer = GetPostString("customer");
  5676. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5677. string design = GetPostString("design");
  5678. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5679. string afterMemoType = GetPostString("aftermemotype");
  5680. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5681. string posCode = CurrentUser.UserPost.Post.Code;
  5682. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5683. //{
  5684. // string vstate = GetPostString("vstate");
  5685. // if (vstate.Length > 0)
  5686. // {
  5687. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5688. // }
  5689. // if (posCode == "Supplier")
  5690. // {
  5691. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5692. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5693. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5694. // }
  5695. // else
  5696. // {
  5697. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5698. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5699. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5700. // {
  5701. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5702. // }
  5703. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5704. // {
  5705. // int orgid = CurrentUser.UserPost.OrgID;
  5706. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5707. // }
  5708. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5709. // {
  5710. // string shopid = CurrentUser.User.pemShop;
  5711. // lw.Add(string.Format("shopId in ({0})", shopid));
  5712. // }
  5713. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5714. // //{
  5715. // // int org_id = CurrentUser.UserPost.OrgID;
  5716. // // lw.Add(string.Format("OrgID={0}", org_id));
  5717. // //}
  5718. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5719. // }
  5720. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5721. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5722. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5723. //}
  5724. if (st == 5)
  5725. {
  5726. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5727. {
  5728. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5729. {
  5730. string shopid = CurrentUser.User.pemShop;
  5731. lw.Add(string.Format("shopId in ({0})", shopid));
  5732. }
  5733. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5734. {
  5735. int mrOrgid = CurrentUser.UserPost.OrgID;
  5736. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5737. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5738. }
  5739. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5740. //{
  5741. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5742. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5743. //}
  5744. else
  5745. {
  5746. string userIdStr = "";
  5747. if (posCode == "CustomerService")
  5748. {
  5749. userIdStr = CurrentUser.UserID + "_k";
  5750. }
  5751. else if (posCode == "Designer" || posCode == "wxDesigner")
  5752. {
  5753. userIdStr = CurrentUser.UserID + "_s";
  5754. }
  5755. else if (posCode == "Place")
  5756. {
  5757. userIdStr = CurrentUser.UserID + "_x";
  5758. }
  5759. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5760. }
  5761. }
  5762. string placedate1 = GetPostString("placedate1");
  5763. string placedate2 = GetPostString("placedate2");
  5764. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5765. if (dwplace.Length > 0) lw.Add(dwplace);
  5766. string supState = GetPostString("supState");
  5767. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5768. string searchType = GetPostString("searchType");
  5769. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5770. {
  5771. lw.Add(string.Format("BackNum>1"));
  5772. }
  5773. lw.Add(string.Format("AfterSaleState>0"));
  5774. if (ex_psize > 0)
  5775. {
  5776. if (CurrentUser.UserPost.Post.Code == "Finance")
  5777. dStruct.Order = "pay_time desc";
  5778. else
  5779. dStruct.Order = "HandleTime desc";
  5780. }
  5781. else
  5782. dStruct.Order = "HandleTime desc";
  5783. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5784. DataTable dt = WebCache.GetData("view_test", dStruct);
  5785. writeGridDataTableJson(dStruct.TotalCount, dt);
  5786. }
  5787. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5788. //{
  5789. // lw.Add(string.Format("AfterSaleState=4"));
  5790. // string code = CurrentUser.UserPost.Post.Code;
  5791. // if (code == "CustomerService")
  5792. // {
  5793. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5794. // }
  5795. // else if (code == "Designer" || code == "DesignerMr")
  5796. // {
  5797. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5798. // }
  5799. // else if (code == "Place" || code == "PlaceMr")
  5800. // {
  5801. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5802. // }
  5803. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5804. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5805. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5806. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5807. //}
  5808. //else //处理中的售后,待处理和处理中合并
  5809. //{
  5810. // if (afterState.Length <= 0)
  5811. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5812. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5813. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5814. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5815. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5816. //}
  5817. }
  5818. public void get_erp_disagreeftersalelist()
  5819. {
  5820. DataStruct dStruct = GetPostStruct();
  5821. List<string> lw = new List<string>();
  5822. int st = 2;
  5823. string tid = GetPostString("ctid");
  5824. if (tid.Length > 0)
  5825. {
  5826. string select_tid = getTidByCtid(tid);
  5827. lw.Add(string.Format("tid='{0}'", select_tid));
  5828. }
  5829. string shopname = GetPostString("shopname");
  5830. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5831. string buyernick = GetPostString("buyer_nick");
  5832. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5833. string sellermemo = GetPostString("seller_memo");
  5834. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5835. string orderState = GetPostString("orderState");
  5836. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5837. string afterState = GetPostString("afterstate");
  5838. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5839. string date1 = GetPostString("date1");
  5840. string date2 = GetPostString("date2");
  5841. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5842. if (dw.Length > 0) lw.Add(dw);
  5843. string price1 = GetPostString("price1");
  5844. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5845. string price2 = GetPostString("price2");
  5846. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5847. //lw.Add(string.Format("IsRefund!={0}", 1));
  5848. string reason = GetPostString("reason");
  5849. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5850. string method = GetPostString("method");
  5851. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5852. string handler = GetPostString("handler");
  5853. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5854. string handledate1 = GetPostString("handledate1");
  5855. string handledate2 = GetPostString("handledate2");
  5856. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5857. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5858. string afterdate1 = GetPostString("afterdate1");
  5859. string afterdate2 = GetPostString("afterdate2");
  5860. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5861. if (afterDate.Length > 0) lw.Add(afterDate);
  5862. string backdate1 = GetPostString("backdate1");
  5863. string backdate2 = GetPostString("backdate2");
  5864. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5865. if (backDate.Length > 0) lw.Add(backDate);
  5866. string supplier = GetPostString("supplier");
  5867. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5868. string responsible = GetPostString("responsibleman");
  5869. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5870. string customer = GetPostString("customer");
  5871. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5872. string design = GetPostString("design");
  5873. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5874. string afterSaleMemo = GetPostString("afterSaleMemo");
  5875. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5876. string afterMemoType = GetPostString("aftermemotype");
  5877. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5878. string aftersakereason = GetPostString("aftersakereason");
  5879. if (aftersakereason.Length > 0)
  5880. {
  5881. if (aftersakereason == "1")
  5882. {
  5883. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5884. }
  5885. if (aftersakereason == "2")
  5886. {
  5887. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5888. }
  5889. }
  5890. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5891. string poscode = CurrentUser.UserPost.Post.Code;
  5892. if (poscode != "SysAdmin")
  5893. {
  5894. string shopid = CurrentUser.User.pemShop;
  5895. lw.Add(string.Format("shopId in ({0})", shopid));
  5896. }
  5897. string searchType = GetPostString("searchType");
  5898. if (searchType == "wait")
  5899. {
  5900. lw.Add(string.Format("HandleTime is null"));
  5901. }
  5902. if (searchType == "handling")
  5903. {
  5904. lw.Add(string.Format("HandleTime is not null "));
  5905. }
  5906. if (searchType == "back" || searchType == "puBack")
  5907. {
  5908. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5909. }
  5910. if (searchType == "reBack")
  5911. {
  5912. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5913. }
  5914. if (searchType == "moreBack")
  5915. {
  5916. lw.Add(string.Format("backNum > 1"));
  5917. }
  5918. lw.Add(string.Format("(AfterSaleState=5)"));
  5919. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5920. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5921. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5922. writeGridDataTableJson(dStruct.TotalCount, dt);
  5923. }
  5924. public void get_erp_handlingaftersalelist()
  5925. {
  5926. DataStruct dStruct = GetPostStruct();
  5927. List<string> lw = new List<string>();
  5928. int st = 2;
  5929. string tid = GetPostString("ctid");
  5930. if (tid.Length > 0)
  5931. {
  5932. string select_tid = getTidByCtid(tid);
  5933. lw.Add(string.Format("tid='{0}'", select_tid));
  5934. }
  5935. string shopname = GetPostString("shopname");
  5936. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5937. string buyernick = GetPostString("buyer_nick");
  5938. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5939. string sellermemo = GetPostString("seller_memo");
  5940. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5941. string orderState = GetPostString("orderState");
  5942. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5943. string afterState = GetPostString("afterstate");
  5944. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5945. string date1 = GetPostString("date1");
  5946. string date2 = GetPostString("date2");
  5947. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5948. if (dw.Length > 0) lw.Add(dw);
  5949. string price1 = GetPostString("price1");
  5950. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5951. string price2 = GetPostString("price2");
  5952. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5953. //lw.Add(string.Format("IsRefund!={0}", 1));
  5954. string reason = GetPostString("reason");
  5955. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5956. string method = GetPostString("method");
  5957. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5958. string handler = GetPostString("handler");
  5959. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5960. string handledate1 = GetPostString("handledate1");
  5961. string handledate2 = GetPostString("handledate2");
  5962. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5963. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5964. string afterdate1 = GetPostString("afterdate1");
  5965. string afterdate2 = GetPostString("afterdate2");
  5966. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5967. if (afterDate.Length > 0) lw.Add(afterDate);
  5968. string supplier = GetPostString("supplier");
  5969. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5970. string responsible = GetPostString("responsibleman");
  5971. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5972. string customer = GetPostString("customer");
  5973. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5974. string design = GetPostString("design");
  5975. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5976. string afterSaleMemo = GetPostString("afterSaleMemo");
  5977. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5978. string afterMemoType = GetPostString("aftermemotype");
  5979. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5980. string afterresult = GetPostString("afterresult");
  5981. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5982. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5983. string poscode = CurrentUser.UserPost.Post.Code;
  5984. if (poscode != "SysAdmin")
  5985. {
  5986. string shopid = CurrentUser.User.pemShop;
  5987. lw.Add(string.Format("shopId in ({0})", shopid));
  5988. }
  5989. string searchType = GetPostString("searchType");
  5990. if (searchType == "wait")
  5991. {
  5992. lw.Add(string.Format("HandleTime is null"));
  5993. }
  5994. if (searchType == "documentary")
  5995. {
  5996. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5997. }
  5998. if (searchType == "handling")
  5999. {
  6000. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6001. }
  6002. if (searchType == "back" || searchType == "puBack")
  6003. {
  6004. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6005. }
  6006. if (searchType == "reBack")
  6007. {
  6008. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6009. }
  6010. if (afterState.Length <= 0)
  6011. {
  6012. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6013. }
  6014. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6015. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6016. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6017. writeGridDataTableJson(dStruct.TotalCount, dt);
  6018. }
  6019. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6020. //public void get_erp_back_handlingaftersalelist()
  6021. //{
  6022. // DataStruct dStruct = GetPostStruct();
  6023. // List<string> lw = new List<string>();
  6024. // string tid = GetPostString("ctid");
  6025. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6026. // string shopname = GetPostString("shopname");
  6027. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6028. // string buyernick = GetPostString("buyer_nick");
  6029. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6030. // string sellermemo = GetPostString("seller_memo");
  6031. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6032. // string orderState = GetPostString("orderState");
  6033. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6034. // string afterState = GetPostString("afterstate");
  6035. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6036. // string date1 = GetPostString("date1");
  6037. // string date2 = GetPostString("date2");
  6038. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6039. // if (dw.Length > 0) lw.Add(dw);
  6040. // string price1 = GetPostString("price1");
  6041. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6042. // string price2 = GetPostString("price2");
  6043. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6044. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6045. // string reason = GetPostString("reason");
  6046. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6047. // string method = GetPostString("method");
  6048. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6049. // string handler = GetPostString("handler");
  6050. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6051. // string handledate1 = GetPostString("handledate1");
  6052. // string handledate2 = GetPostString("handledate2");
  6053. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6054. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6055. // string afterdate1 = GetPostString("afterdate1");
  6056. // string afterdate2 = GetPostString("afterdate2");
  6057. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6058. // if (afterDate.Length > 0) lw.Add(afterDate);
  6059. // string supplier = GetPostString("supplier");
  6060. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6061. // string responsible = GetPostString("responsibleman");
  6062. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6063. // string customer = GetPostString("customer");
  6064. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6065. // string design = GetPostString("design");
  6066. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6067. // string afterMemoType = GetPostString("aftermemotype");
  6068. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6069. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6070. // if (afterState.Length <= 0)
  6071. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6072. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6073. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6074. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6075. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6076. //}
  6077. public void get_erp_aftersaleverifylist()
  6078. {
  6079. DataStruct dStruct = GetPostStruct();
  6080. List<string> lw = new List<string>();
  6081. string tid = GetPostString("ctid");
  6082. if (tid.Length > 0)
  6083. {
  6084. string select_tid = getTidByCtid(tid);
  6085. lw.Add(string.Format("tid='{0}'", select_tid));
  6086. }
  6087. string shopname = GetPostString("shopname");
  6088. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6089. string buyernick = GetPostString("buyer_nick");
  6090. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6091. string sellermemo = GetPostString("seller_memo");
  6092. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6093. string orderState = GetPostString("orderState");
  6094. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6095. //lw.Add(string.Format("IsRefund!={0}", 1));
  6096. string reason = GetPostString("reason");
  6097. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6098. string method = GetPostString("method");
  6099. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6100. string handler = GetPostString("handler");
  6101. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6102. string handledate1 = GetPostString("handledate1");
  6103. string handledate2 = GetPostString("handledate2");
  6104. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6105. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6106. string finish1 = GetPostString("finishdate1");
  6107. string finish2 = GetPostString("finishdate2");
  6108. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6109. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6110. string supplier = GetPostString("supplier");
  6111. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6112. string responsible = GetPostString("responsibleman");
  6113. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6114. string posCode = CurrentUser.UserPost.Post.Code;
  6115. string vstate = GetPostString("vstate");
  6116. if (vstate.Length > 0)
  6117. {
  6118. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6119. }
  6120. if (posCode == "Supplier")
  6121. {
  6122. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6123. lw.Add(string.Format("VerifyState = 0"));
  6124. lw.Add("type = 1");
  6125. lw.Add(string.Format("AfterSaleState={0}", 3));
  6126. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6127. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6128. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6129. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6130. writeGridDataTableJson(dStruct.TotalCount, dt);
  6131. }
  6132. else if (posCode == "logistics")
  6133. {
  6134. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6135. lw.Add(string.Format("VerifyState = 0"));
  6136. lw.Add("type = 2");
  6137. lw.Add(string.Format("AfterSaleState={0}", 3));
  6138. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6139. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6140. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6141. writeGridDataTableJson(dStruct.TotalCount, dt);
  6142. }
  6143. else
  6144. {
  6145. lw.Add(string.Format("(AfterSaleState = 3)"));
  6146. string reasonState = GetPostString("reasonState");
  6147. lw.Add("type = 0");
  6148. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6149. || posCode == "Summarize" || posCode == "Finance")
  6150. {
  6151. if (reasonState == "2")
  6152. {
  6153. lw.Add("VerifyState = 3");
  6154. }
  6155. else if (reasonState == "1")
  6156. {
  6157. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6158. }
  6159. else
  6160. {
  6161. lw.Add("VerifyState in (0,3)");
  6162. }
  6163. //不加条件,可以看全部
  6164. }
  6165. 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")
  6166. {
  6167. int orgid = CurrentUser.UserPost.OrgID;
  6168. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6169. if (string.IsNullOrEmpty(manageOrgId))
  6170. {
  6171. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6172. }
  6173. else
  6174. {
  6175. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6176. }
  6177. if (reasonState == "1")
  6178. {
  6179. lw.Add("VerifyState = 3");
  6180. }
  6181. else if (reasonState == "2")
  6182. {
  6183. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6184. }
  6185. else
  6186. {
  6187. }
  6188. }
  6189. else
  6190. {
  6191. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6192. }
  6193. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6194. //{
  6195. // int org_id = CurrentUser.UserPost.OrgID;
  6196. // lw.Add(string.Format("OrgID={0}", org_id));
  6197. //}
  6198. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6199. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6200. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6201. writeGridDataTableJson(dStruct.TotalCount, dt);
  6202. }
  6203. }
  6204. public void get_erp_finishaftersalelist()
  6205. {
  6206. DataStruct dStruct = GetPostStruct();
  6207. List<string> lw = new List<string>();
  6208. int st = 4;
  6209. string tid = GetPostString("ctid");
  6210. if (tid.Length > 0)
  6211. {
  6212. string select_tid = getTidByCtid(tid);
  6213. lw.Add(string.Format("tid='{0}'", select_tid));
  6214. }
  6215. string shopname = GetPostString("shopname");
  6216. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6217. //lw.Add(string.Format("IsRefund!={0}", 1));
  6218. string reason = GetPostString("reason");
  6219. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6220. string method = GetPostString("method");
  6221. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6222. string buyernick = GetPostString("buyer_nick");
  6223. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6224. string handler = GetPostString("handler");
  6225. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6226. string handledate1 = GetPostString("handledate1");
  6227. string handledate2 = GetPostString("handledate2");
  6228. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6229. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6230. string finish1 = GetPostString("finishdate1");
  6231. string finish2 = GetPostString("finishdate2");
  6232. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6233. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6234. string supplier = GetPostString("supplier");
  6235. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6236. string responsible = GetPostString("responsibleman");
  6237. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6238. string vstate = GetPostString("vstate");
  6239. if (vstate.Length > 0)
  6240. {
  6241. if ("3".Equals(vstate))
  6242. {
  6243. lw.Add(string.Format("IsTem=1"));
  6244. }
  6245. else
  6246. {
  6247. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6248. }
  6249. }
  6250. lw.Add(string.Format("AfterSaleState=4"));
  6251. string code = CurrentUser.UserPost.Post.Code;
  6252. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6253. {
  6254. //不加条件,可以看全部
  6255. }
  6256. else if (code == "Supplier")
  6257. {
  6258. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6259. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6260. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6261. }
  6262. else if (code == "logistics")
  6263. {
  6264. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6265. lw.Add("type = 2");
  6266. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6267. }
  6268. 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")
  6269. {
  6270. int orgid = CurrentUser.UserPost.OrgID;
  6271. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6272. if (string.IsNullOrEmpty(manageOrgIds))
  6273. {
  6274. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6275. }
  6276. else
  6277. {
  6278. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6279. }
  6280. }
  6281. else
  6282. {
  6283. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6284. }
  6285. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6286. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6287. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6288. writeGridDataTableJson(dStruct.TotalCount, dt);
  6289. }
  6290. public void handle_erp_aftersale()
  6291. {
  6292. if (UrlPostParmsCheck("ctid"))
  6293. {
  6294. string eid = GetPostString("ctid");
  6295. string responStr = GetPostString("AfterSaleResponsible");
  6296. if (responStr.Length <= 0)
  6297. {
  6298. returnErrorMsg("售后责任人不能为空");
  6299. return;
  6300. }
  6301. bool isDesign = false;
  6302. double designFree = 0.00;
  6303. int responsibleId = 0;
  6304. CeErpTradeCell entity = null;
  6305. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6306. if (entity != null)
  6307. {
  6308. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6309. string afterMethod = GetPostString("AfterSaleMethod");
  6310. if (isNeedNewOrder == 1)
  6311. {
  6312. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6313. bool ishav = true;
  6314. if (newentity == null)
  6315. {
  6316. newentity = entity.Clone() as CeErpTradeCell;
  6317. ishav = false;
  6318. newentity.ctid = "S_" + entity.ctid;
  6319. newentity.OrderState = 0;
  6320. //唯一标识
  6321. newentity.OrderSn = newentity.ctid;
  6322. string orderSn = dataHelper.getSaleOrderSn();
  6323. if (orderSn != "")
  6324. {
  6325. newentity.OrderSn = orderSn;
  6326. }
  6327. }
  6328. newentity.UpdateTime = DateTime.Now;
  6329. newentity.AfterSaleState = 0;
  6330. newentity.AfterSaleMethod = afterMethod;
  6331. if (!ishav)
  6332. {
  6333. string memo_str = newentity.seller_memo;
  6334. memo_str = memo_str.Replace("(", "(");
  6335. memo_str = memo_str.Replace(")", ")");
  6336. int sIndex = memo_str.IndexOf("(");
  6337. int eIndex = memo_str.IndexOf(")");
  6338. if (sIndex == -1 || eIndex == -1)
  6339. {
  6340. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6341. return;
  6342. }
  6343. string first = memo_str.Substring(0, sIndex + 1);
  6344. string memoCtid = newentity.OrderSn;
  6345. //if (memoCtid.IndexOf("C") != -1)
  6346. //{
  6347. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6348. //if (CIdx.IndexOf("+") != -1)
  6349. //{
  6350. //CIdx = "C" + CIdx.Split('+')[1];
  6351. //}
  6352. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6353. //}
  6354. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6355. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6356. string newMemo = first + memoCtid + last;
  6357. newentity.seller_memo = newMemo;
  6358. newentity.FinishPlaceTime = null;
  6359. newentity.UnusualTag = 0;
  6360. newentity.UnusualCon = "";
  6361. newentity.UnusualTime = null;
  6362. newentity.AfterSaleMemo = "";
  6363. newentity.AfterSaleMethod = afterMethod;
  6364. newentity.AfterSalePreTime = null;
  6365. newentity.AfterSaleReason = "";
  6366. newentity.AfterSaleResponsible = "";
  6367. newentity.AfterSaleState = 0;
  6368. newentity.AfterSaleTime = null;
  6369. newentity.AfterSaleUserId = 0;
  6370. newentity.AfterSaleSupplierState = 0;
  6371. newentity.LastBillWaybillCode = "";
  6372. newentity.LastBillCpCode = "";
  6373. newentity.FinishAfterSaleTime = null;
  6374. newentity.HandleTime = null;
  6375. newentity.IsSF = 0;
  6376. newentity.IsOldCustomer = 0;
  6377. newentity.UrgencyTime = null;
  6378. newentity.ResponsibleUserId = "";
  6379. newentity.IsVerifyToSupplier = false;
  6380. newentity.payment = 0;
  6381. newentity.CheckMemo = "";
  6382. newentity.OutSid = "";
  6383. newentity.CheckOrderTime = null;
  6384. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6385. }
  6386. newentity.isAfterSaleOrder = 1;
  6387. newentity.IsRefund = 0;
  6388. string receiveMobile = GetPostString("receiver_mobile");
  6389. if (receiveMobile.Length > 0)
  6390. {
  6391. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6392. if (trade != null)
  6393. {
  6394. trade.receiver_name = GetPostString("receiver_name");
  6395. trade.receiver_mobile = receiveMobile;
  6396. trade.receiver_state = GetPostString("receiver_state");
  6397. trade.receiver_city = GetPostString("receiver_city");
  6398. trade.receiver_district = GetPostString("receiver_district");
  6399. trade.receiver_address = GetPostString("receiver_address");
  6400. newentity.IsOffLineOrder = 1;
  6401. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6402. }
  6403. }
  6404. string st = GetPostString("ToState");
  6405. if (st.Length > 0)
  6406. {
  6407. if (newentity.OrderState <= 3)
  6408. {
  6409. newentity.WaitDesignTime = DateTime.Now;
  6410. newentity.StartDesignTime = null;
  6411. newentity.FinishDesignTime = null;
  6412. newentity.OrderState = 3;
  6413. if (st == "下单员")
  6414. {
  6415. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6416. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6417. {
  6418. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6419. }
  6420. }
  6421. else
  6422. {
  6423. newentity.WaitDesignTime = DateTime.Now;
  6424. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6425. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6426. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6427. {
  6428. DataRow user = dt1.Rows[0];
  6429. //找主管
  6430. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6431. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6432. if (dt != null && dt.Rows.Count > 0)
  6433. {
  6434. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6435. newentity.DesignUserId = designMr;
  6436. string key = "aftersale_order_" + designMr;
  6437. if (RedisHelper.HasKey(key))
  6438. {
  6439. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6440. list.Add(newentity.ctid);
  6441. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6442. }
  6443. }
  6444. //账号正常
  6445. if (user["State"].ToString() == "0")
  6446. {
  6447. newentity.DesignUserId = entity.DesignUserId;
  6448. string key = "aftersale_order_" + entity.DesignUserId;
  6449. if (RedisHelper.HasKey(key))
  6450. {
  6451. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6452. list.Add(newentity.ctid);
  6453. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6454. }
  6455. }
  6456. }
  6457. }
  6458. }
  6459. if (entity.IsXianHuo == 1)
  6460. {
  6461. newentity.OrderState = 6;
  6462. entity.FinishPlaceTime = DateTime.Now;
  6463. }
  6464. }
  6465. if (ishav)
  6466. {
  6467. newentity.Update();
  6468. }
  6469. else
  6470. {
  6471. newentity.Create();
  6472. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6473. newCellExtend.ctid = newentity.ctid;
  6474. newCellExtend.orderFrom = 20;
  6475. newCellExtend.orderType = 30;
  6476. if (st == "下单员")
  6477. {
  6478. }
  6479. else
  6480. {
  6481. newCellExtend.ReprintTime = DateTime.Now;
  6482. }
  6483. newCellExtend.Create();
  6484. }
  6485. if (st != "下单员")
  6486. {
  6487. designHelper.API_GetPrintData_CreateOrder(newentity);
  6488. }
  6489. }
  6490. //处理售后扩展
  6491. string resIdStr = GetPostString("ResponsibleUserId");
  6492. string refundFees = GetPostString("refundFrees");
  6493. int IsComplain = GetPostInt("isComplain");
  6494. int IsBad = GetPostInt("isBad");
  6495. string IsOriginal = GetPostString("isOriginal");
  6496. double diffResultPrice = GetPostDouble("diffResultPrice");
  6497. string textResult = GetPostString("textResult");
  6498. string supplierResponsible = GetPostString("supplierResponsible");
  6499. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6500. if (ceErpTradeAfterSaleExtend == null)
  6501. {
  6502. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6503. ceErpTradeAfterSaleExtend.tid = eid;
  6504. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6505. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6506. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6507. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6508. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6509. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6510. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6511. ceErpTradeAfterSaleExtend.Create();
  6512. }
  6513. else
  6514. {
  6515. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6516. {
  6517. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6518. }
  6519. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6520. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6521. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6522. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6523. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6524. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6525. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6526. ceErpTradeAfterSaleExtend.Update();
  6527. }
  6528. int gysid = GetPostInt("ResponsibleSupId");
  6529. if (entity.AfterSaleUserId == 0)
  6530. {
  6531. entity.AfterSaleUserId = CurrentUser.UserID;
  6532. }
  6533. entity.ResponsibleUserId = resIdStr;
  6534. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6535. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6536. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6537. {
  6538. CeErpTradeResponsible.DelByTid(eid, -1);
  6539. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6540. int backNum = 0;
  6541. if (number != null)
  6542. {
  6543. backNum = number.BackNum;
  6544. }
  6545. char[] separator = { ',' };
  6546. string[] sArray = resIdStr.Split(separator);
  6547. string[] refundFreeList = { };
  6548. if (refundFees.Length > 0)
  6549. {
  6550. refundFreeList = refundFees.Split(separator);
  6551. }
  6552. int index = -1;
  6553. foreach (string i in sArray)
  6554. {
  6555. index++;
  6556. if (i.Length <= 0) continue;
  6557. char[] separator2 = { '_' };
  6558. string idstr = i.Split(separator2)[0];
  6559. string idtype = i.Split(separator2)[1];
  6560. double refudFree = 0;
  6561. if (refundFreeList.Length > 0)
  6562. {
  6563. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6564. }
  6565. if (idtype == "s")
  6566. {
  6567. isDesign = true;
  6568. designFree = refudFree;
  6569. }
  6570. int userId = Convert.ToInt32(idstr);
  6571. int type = 0;
  6572. if (idtype == "g")
  6573. {
  6574. type = 1;
  6575. }
  6576. if (idtype == "w")
  6577. {
  6578. type = 2;
  6579. }
  6580. if (idtype == "t")
  6581. {
  6582. type = 3;
  6583. }
  6584. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6585. if (ceErpTradeResponsible == null)
  6586. {
  6587. ceErpTradeResponsible = new CeErpTradeResponsible();
  6588. ceErpTradeResponsible.tid = eid;
  6589. ceErpTradeResponsible.UserId = userId;
  6590. ceErpTradeResponsible.createdTime = DateTime.Now;
  6591. ceErpTradeResponsible.type = type;
  6592. if (type == 1)
  6593. {
  6594. ceErpTradeResponsible.IsSup = 1;
  6595. }
  6596. if (type == 2)
  6597. {
  6598. ceErpTradeResponsible.IsFlow = 1;
  6599. }
  6600. }
  6601. ceErpTradeResponsible.RefundFee = refudFree;
  6602. ceErpTradeResponsible.VerifyState = 0;
  6603. if (userId == 2125 || idtype == "w")
  6604. {
  6605. ceErpTradeResponsible.VerifyState = 1;
  6606. }
  6607. if (idtype == "w" && userId == 101)
  6608. {
  6609. ceErpTradeResponsible.VerifyState = 0;
  6610. }
  6611. if (ceErpTradeResponsible.ID > 0)
  6612. {
  6613. ceErpTradeResponsible.Update();
  6614. }
  6615. else
  6616. {
  6617. ceErpTradeResponsible.Create();
  6618. }
  6619. if (isDesign)
  6620. {
  6621. responsibleId = ceErpTradeResponsible.ID;
  6622. }
  6623. }
  6624. CeErpTradeResponsible.NumByTid(backNum, eid);
  6625. }
  6626. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6627. if (ceErpTradeCellExtend != null)
  6628. {
  6629. ceErpTradeCellExtend.returnVisit = 0;
  6630. ceErpTradeCellExtend.Update();
  6631. }
  6632. if (entity.HandleTime != null)
  6633. {
  6634. if (entity.AfterSaleState == 1)
  6635. {
  6636. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6637. }
  6638. else
  6639. {
  6640. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6641. }
  6642. }
  6643. else
  6644. {
  6645. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6646. entity.HandleTime = DateTime.Now;
  6647. }
  6648. bool isCompale = false;
  6649. if (entity.AfterSaleState == 5)
  6650. {
  6651. isCompale = true;
  6652. entity.AfterSaleState = 3;
  6653. }
  6654. entity.AfterSaleSupplierState = 0;
  6655. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6656. {
  6657. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6658. }
  6659. string sImgs = GetPostString("img");
  6660. entity.AfterSaleSupplierImg = sImgs;
  6661. entity.supRefundType = GetPostString("supRefundType");
  6662. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6663. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6664. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6665. entity.AfterSaleMemoType = GetPostString("MemoType");
  6666. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6667. {
  6668. //entity.AfterSaleSupplierState = 2;
  6669. }
  6670. string df = GetPostString("DeductFee");
  6671. if (df == "")
  6672. {
  6673. df = "0";
  6674. }
  6675. string rf = GetPostString("RefundFee");
  6676. if (rf == "")
  6677. {
  6678. rf = "0";
  6679. }
  6680. string pm = GetPostString("AfterSalePayment");
  6681. if (pm == "")
  6682. {
  6683. pm = "0";
  6684. }
  6685. entity.AfterSalePayment = Convert.ToDouble(pm);
  6686. entity.DeductFee = Convert.ToDouble(df);
  6687. entity.RefundFee = Convert.ToDouble(rf);
  6688. entity.UpdateTime = DateTime.Now;
  6689. entity.Update();
  6690. string toState = GetPostString("ToState");
  6691. string original = GetPostString("isOriginal");
  6692. ApiVo apiVo = new ApiVo();
  6693. apiVo.orderNumber = entity.ctid;
  6694. apiVo.actionName = "afterDesign";
  6695. apiVo.orderRemarks = entity.AfterSaleMethod;
  6696. apiVo.reasonRemarks = entity.AfterSaleReason;
  6697. apiVo.isDesign = isDesign;
  6698. apiVo.designFree = designFree;
  6699. apiVo.responsibleId = responsibleId;
  6700. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6701. if (toState == "设计师")
  6702. {
  6703. apiVo.isOriginal = Convert.ToBoolean(original);
  6704. }
  6705. designHelper.API_WorkCore(apiVo);//afterDesign
  6706. CeErpMethod methodSql = new CeErpMethod();
  6707. methodSql.con = entity.AfterSaleMethod;
  6708. methodSql.addTime = DateTime.Now;
  6709. methodSql.Create();
  6710. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6711. CeErpMethod.ExecuteNonQuery(delsql);
  6712. if (isCompale)
  6713. {
  6714. aftersale_data_change(entity.ctid);
  6715. }
  6716. returnSuccessMsg("操作成功!");
  6717. return;
  6718. }
  6719. returnErrorMsg("找不到订单记录");
  6720. }
  6721. }
  6722. public void ins_erp_toresponsible()
  6723. {
  6724. if (UrlPostParmsCheck("ctid"))
  6725. {
  6726. string eid = GetPostString("ctid");
  6727. CeErpTradeCell entity = null;
  6728. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6729. if (entity != null)
  6730. {
  6731. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6732. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6733. {
  6734. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6735. return;
  6736. }
  6737. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6738. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6739. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6740. if (entity.AfterSalePreTime == null)
  6741. {
  6742. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6743. {
  6744. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6745. }
  6746. }
  6747. entity.AfterSalePreTime = DateTime.Now;
  6748. //预完成给售后主管审核客户问题直接完成
  6749. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6750. {
  6751. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6752. {
  6753. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6754. }
  6755. }
  6756. ceErpTradeAfterSaleExtend.Update();
  6757. entity.AfterSaleState = 2;
  6758. entity.UpdateTime = DateTime.Now;
  6759. entity.Update();
  6760. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6761. aftersale_data_change(entity.ctid);
  6762. returnSuccessMsg("操作成功!");
  6763. return;
  6764. }
  6765. returnErrorMsg("找不到订单记录");
  6766. }
  6767. }
  6768. public void cancel_erp_aftersaleanddelnew()
  6769. {
  6770. if (UrlPostParmsCheck("ctid"))
  6771. {
  6772. string eid = GetPostString("ctid");
  6773. CeErpTradeCell entity = null;
  6774. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6775. if (entity != null)
  6776. {
  6777. entity.AfterSaleState = 0;
  6778. entity.AfterSaleReason = "";
  6779. entity.AfterSaleMethod = "";
  6780. entity.AfterSaleMemo = "";
  6781. entity.AfterSaleResponsible = "";
  6782. entity.ResponsibleUserId = "";
  6783. entity.DeductFee = 0;
  6784. entity.RefundFee = 0;
  6785. entity.IsArbitrate = 0;
  6786. CeErpTradeResponsible.DelByTid(eid, -1);
  6787. entity.Update();
  6788. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6789. if (after != null)
  6790. {
  6791. if (after.OrderState < 5)
  6792. CeErpTradeCell.DelByCtid("S_" + eid);
  6793. }
  6794. returnSuccessMsg("操作成功!");
  6795. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6796. return;
  6797. }
  6798. returnErrorMsg("找不到订单记录");
  6799. }
  6800. }
  6801. public void get_erp_aftersale_pregather()
  6802. {
  6803. List<string> lw = new List<string>();
  6804. int st = GetInt("st");
  6805. string tid = GetPostString("ctid");
  6806. if (tid.Length > 0)
  6807. {
  6808. string select_tid = getTidByCtid(tid);
  6809. lw.Add(string.Format("tid='{0}'", select_tid));
  6810. }
  6811. string shopname = GetPostString("shopname");
  6812. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6813. string buyernick = GetPostString("buyer_nick");
  6814. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6815. string sellermemo = GetPostString("seller_memo");
  6816. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6817. string orderState = GetPostString("orderState");
  6818. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6819. string reason = GetPostString("reason");
  6820. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6821. string method = GetPostString("method");
  6822. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6823. string handler = GetPostString("handler");
  6824. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6825. string handledate1 = GetPostString("handledate1");
  6826. string handledate2 = GetPostString("handledate2");
  6827. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6828. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6829. string supplier = GetPostString("supplier");
  6830. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6831. string responsible = GetPostString("responsibleman");
  6832. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6833. string customer = GetPostString("customer");
  6834. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6835. string design = GetPostString("design");
  6836. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6837. string afterMemoType = GetPostString("aftermemotype");
  6838. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6839. string afterSaleMemo = GetPostString("afterSaleMemo");
  6840. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6841. string afterresult = GetPostString("afterresult");
  6842. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6843. string poscode = CurrentUser.UserPost.Post.Code;
  6844. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6845. {
  6846. string shopid = CurrentUser.User.pemShop;
  6847. lw.Add(string.Format("shopId in ({0})", shopid));
  6848. }
  6849. var mainwhere = string.Join(" and ", lw.ToArray());
  6850. string ro_json = "";
  6851. string type = GetPostString("gather_type");
  6852. int number = 0;
  6853. if (poscode == "AfterSale")
  6854. {
  6855. //处理中
  6856. if (type == "Handling")
  6857. {
  6858. 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) : ""));
  6859. DataTable dt = null;
  6860. try
  6861. {
  6862. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6863. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6864. }
  6865. catch (Exception e)
  6866. {
  6867. dt = new DataTable();
  6868. }
  6869. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6870. return;
  6871. }
  6872. if (type == "Wait")
  6873. {
  6874. //待处理
  6875. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6876. DataTable dt1 = null;
  6877. try
  6878. {
  6879. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6880. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6881. }
  6882. catch (Exception e)
  6883. {
  6884. dt1 = new DataTable();
  6885. }
  6886. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6887. return;
  6888. }
  6889. if (type == "back")
  6890. {
  6891. //打回
  6892. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6893. DataTable dt2 = null;
  6894. try
  6895. {
  6896. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6897. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6898. }
  6899. catch (Exception e)
  6900. {
  6901. dt2 = new DataTable();
  6902. }
  6903. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6904. return;
  6905. }
  6906. if (type == "preCompletion")
  6907. {
  6908. //预完成
  6909. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6910. DataTable dt3 = null;
  6911. try
  6912. {
  6913. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6914. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6915. }
  6916. catch (Exception e)
  6917. {
  6918. dt3 = new DataTable();
  6919. }
  6920. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6921. return;
  6922. }
  6923. if (type == "documentary")
  6924. {
  6925. //跟单中
  6926. 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) : ""));
  6927. DataTable dt4 = null;
  6928. try
  6929. {
  6930. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6931. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6932. }
  6933. catch (Exception e)
  6934. {
  6935. dt4 = new DataTable();
  6936. }
  6937. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6938. return;
  6939. }
  6940. if (type == "reBack")
  6941. {
  6942. //被打回
  6943. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6944. DataTable dt1 = null;
  6945. try
  6946. {
  6947. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6948. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6949. }
  6950. catch (Exception e)
  6951. {
  6952. dt1 = new DataTable();
  6953. }
  6954. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6955. return;
  6956. }
  6957. }
  6958. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6959. {
  6960. if (type == "puBack")
  6961. {
  6962. //退回
  6963. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6964. DataTable dt = null;
  6965. try
  6966. {
  6967. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6968. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6969. }
  6970. catch (Exception e)
  6971. {
  6972. dt = new DataTable();
  6973. }
  6974. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6975. return;
  6976. }
  6977. if (type == "reBack")
  6978. {
  6979. //打回
  6980. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6981. DataTable dt1 = null;
  6982. try
  6983. {
  6984. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6985. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6986. }
  6987. catch (Exception e)
  6988. {
  6989. dt1 = new DataTable();
  6990. }
  6991. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6992. return;
  6993. }
  6994. if (type == "examEd")
  6995. {
  6996. //已审核
  6997. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6998. DataTable dt2 = null;
  6999. try
  7000. {
  7001. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7002. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7003. }
  7004. catch (Exception e)
  7005. {
  7006. dt2 = new DataTable();
  7007. }
  7008. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7009. return;
  7010. }
  7011. if (type == "waitExam")
  7012. {
  7013. //待审核
  7014. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7015. DataTable dt3 = null;
  7016. try
  7017. {
  7018. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7019. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7020. }
  7021. catch (Exception e)
  7022. {
  7023. dt3 = new DataTable();
  7024. }
  7025. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7026. return;
  7027. }
  7028. if (type == "Handling")
  7029. {
  7030. //处理中
  7031. 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) : ""));
  7032. DataTable dt4 = null;
  7033. try
  7034. {
  7035. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7036. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7037. }
  7038. catch (Exception e)
  7039. {
  7040. dt4 = new DataTable();
  7041. }
  7042. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7043. return;
  7044. }
  7045. if (type == "Wait")
  7046. {
  7047. //待处理
  7048. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7049. DataTable dt5 = null;
  7050. try
  7051. {
  7052. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7053. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7054. }
  7055. catch (Exception e)
  7056. {
  7057. dt5 = new DataTable();
  7058. }
  7059. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7060. return;
  7061. }
  7062. if (type == "documentary")
  7063. {
  7064. //跟单中
  7065. 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) : ""));
  7066. DataTable dt6 = null;
  7067. try
  7068. {
  7069. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7070. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7071. }
  7072. catch (Exception e)
  7073. {
  7074. dt6 = new DataTable();
  7075. }
  7076. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7077. return;
  7078. }
  7079. }
  7080. returnSuccess(ro_json);
  7081. }
  7082. public void end_erp_aftersale()
  7083. {
  7084. if (UrlPostParmsCheck("ctid"))
  7085. {
  7086. string eid = GetPostString("ctid");
  7087. CeErpTradeCell entity = null;
  7088. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7089. if (entity != null)
  7090. {
  7091. string stype = GetPostString("stype");
  7092. string typeStr = stype;
  7093. entity.AfterSaleState = 4;
  7094. entity.FinishAfterSaleTime = DateTime.Now;
  7095. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7096. entity.Update();
  7097. ApiVo apiVo = new ApiVo();
  7098. apiVo.orderNumber = entity.ctid;
  7099. apiVo.actionName = "afterOver";
  7100. designHelper.API_WorkCore(apiVo); //afterOver
  7101. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7102. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7103. CeErpSukuraData.createInfo(entity.ctid, 8);
  7104. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7105. returnSuccessMsg("操作成功!");
  7106. return;
  7107. }
  7108. returnErrorMsg("找不到订单记录");
  7109. }
  7110. }
  7111. public void ins_erp_finishaftersale()
  7112. {
  7113. if (UrlPostParmsCheck("id"))
  7114. {
  7115. string eid = GetPostString("id");
  7116. CeErpTradeResponsible entity = null;
  7117. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7118. if (entity != null)
  7119. {
  7120. entity.VerifyState = 1;
  7121. entity.VerifyTime = DateTime.Now;
  7122. entity.Update();
  7123. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7124. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7125. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7126. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7127. if (dt.Rows.Count <= 0)
  7128. {
  7129. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7130. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7131. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7132. CeErpSukuraData.createInfo(entity.tid, 8);
  7133. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7134. {
  7135. CeErpDesignerBill.Del(entity.tid);
  7136. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7137. }
  7138. }
  7139. returnSuccessMsg("操作成功!");
  7140. return;
  7141. }
  7142. returnErrorMsg("找不到订单记录");
  7143. }
  7144. }
  7145. public void upd_erp_arbitrateaftersale()
  7146. {
  7147. if (UrlPostParmsCheck("id"))
  7148. {
  7149. string eid = GetPostString("id");
  7150. CeErpTradeResponsible entity = null;
  7151. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7152. if (entity != null)
  7153. {
  7154. entity.IsArbitrate = 1;
  7155. entity.ArbitradeMemo = GetPostString("reason");
  7156. entity.VerifyState = 2;
  7157. entity.Update();
  7158. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7159. if (tradecell != null)
  7160. {
  7161. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7162. tradecell.IsArbitrate = 1;
  7163. tradecell.Update();
  7164. }
  7165. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7166. returnSuccessMsg("操作成功!");
  7167. return;
  7168. }
  7169. returnErrorMsg("找不到订单记录");
  7170. }
  7171. }
  7172. public void upd_erp_backaftersale()
  7173. {
  7174. if (UrlPostParmsCheck("tid"))
  7175. {
  7176. string eid = GetPostString("tid");
  7177. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7178. int backNum = 0;
  7179. if (number != null)
  7180. {
  7181. backNum = number.BackNum;
  7182. }
  7183. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7184. CeErpTradeCell entity = null;
  7185. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7186. if (entity != null)
  7187. {
  7188. entity.AfterSaleBackReason = GetPostString("backreason");
  7189. entity.AfterSaleState = 1;
  7190. entity.AfterSaleSupplierState = 0;
  7191. entity.UpdateTime = DateTime.Now;
  7192. entity.Update();
  7193. returnSuccessMsg("操作成功!");
  7194. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7195. return;
  7196. }
  7197. returnErrorMsg("找不到订单记录");
  7198. }
  7199. }
  7200. public void get_erp_supplieraftersalelist()
  7201. {
  7202. DataStruct dStruct = GetPostStruct();
  7203. List<string> lw = new List<string>();
  7204. string tid = GetPostString("ctid");
  7205. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7206. string shopname = GetPostString("shopname");
  7207. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7208. string buyernick = GetPostString("buyer_nick");
  7209. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7210. string sellermemo = GetPostString("seller_memo");
  7211. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7212. string orderState = GetPostString("orderState");
  7213. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7214. string afterState = GetPostString("afterstate");
  7215. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7216. string date1 = GetPostString("date1");
  7217. string date2 = GetPostString("date2");
  7218. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7219. if (dw.Length > 0) lw.Add(dw);
  7220. string price1 = GetPostString("price1");
  7221. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7222. string price2 = GetPostString("price2");
  7223. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7224. string reason = GetPostString("reason");
  7225. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7226. string method = GetPostString("method");
  7227. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7228. string handledate1 = GetPostString("handledate1");
  7229. string handledate2 = GetPostString("handledate2");
  7230. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7231. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7232. string handler = GetPostString("handler");
  7233. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7234. string afterdate1 = GetPostString("afterdate1");
  7235. string afterdate2 = GetPostString("afterdate2");
  7236. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7237. if (afterDate.Length > 0) lw.Add(afterDate);
  7238. string customer = GetPostString("customer");
  7239. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7240. string design = GetPostString("design");
  7241. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7242. string afterMemoType = GetPostString("aftermemotype");
  7243. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7244. string vstate = GetPostString("vstate");
  7245. if (vstate.Length > 0)
  7246. {
  7247. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7248. }
  7249. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7250. string supplier = GetPostString("supplier");
  7251. int supid = commonHelper.getSupplierIDByName(supplier);
  7252. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7253. string posCode = CurrentUser.UserPost.Post.Code;
  7254. if (posCode == "Supplier")
  7255. {
  7256. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7257. }
  7258. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7259. {
  7260. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7261. }
  7262. else
  7263. {
  7264. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7265. }
  7266. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7267. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7268. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7269. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7270. writeGridDataTableJson(dStruct.TotalCount, dt);
  7271. }
  7272. public void upd_erp_supverifyaftersale()
  7273. {
  7274. if (UrlPostParmsCheck("id"))
  7275. {
  7276. string id = GetPostString("id");
  7277. int st = GetPostInt("afterstate");
  7278. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7279. CeErpTradeCell entity = null;
  7280. if (ceErpTradeResponsible != null)
  7281. {
  7282. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7283. }
  7284. string afmemo = GetPostString("supmemo");
  7285. string image = GetPostString("image");
  7286. if (entity != null)
  7287. {
  7288. entity.AfterSaleSupplierState = st;
  7289. entity.AfterSaleSupplierMemo = afmemo;
  7290. if (st == 1)
  7291. {
  7292. ceErpTradeResponsible.VerifyState = 1;
  7293. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7294. ceErpTradeResponsible.Update();
  7295. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7296. if (isAll)
  7297. {
  7298. entity.AfterSaleState = 4;
  7299. entity.FinishAfterSaleTime = DateTime.Now;
  7300. }
  7301. }
  7302. else
  7303. {
  7304. CeErpTradeResponsible.dateByTid(entity.ctid);
  7305. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7306. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7307. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7308. if (num <= 1)
  7309. {
  7310. entity.AfterSaleState = 1;
  7311. }
  7312. else
  7313. {
  7314. entity.AfterSaleState = 5;
  7315. }
  7316. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7317. if (ceErpTradeAfterSaleExtend != null)
  7318. {
  7319. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7320. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7321. ceErpTradeAfterSaleExtend.Update();
  7322. }
  7323. else
  7324. {
  7325. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7326. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7327. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7328. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7329. ceErpTradeAfterSaleExtend.Create();
  7330. }
  7331. }
  7332. if (entity.AfterSaleState == 4)
  7333. {
  7334. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7335. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7336. {
  7337. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7338. }
  7339. ApiVo apiVo = new ApiVo();
  7340. apiVo.orderNumber = entity.ctid;
  7341. apiVo.actionName = "afterOver";
  7342. designHelper.API_WorkCore(apiVo); //afterOver
  7343. }
  7344. entity.UpdateTime = DateTime.Now;
  7345. entity.Update();
  7346. returnSuccessMsg("操作成功!");
  7347. CeErpSukuraData.createInfo(entity.ctid, 8);
  7348. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7349. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7350. return;
  7351. }
  7352. returnErrorMsg("找不到订单记录");
  7353. }
  7354. }
  7355. public void upd_erp_masteraftersale()
  7356. {
  7357. if (UrlPostParmsCheck("id"))
  7358. {
  7359. string id = GetPostString("id");
  7360. int st = GetPostInt("afterstate");
  7361. string afmemo = GetPostString("supmemo");
  7362. string image = GetPostString("image");
  7363. string textResult = GetPostString("textResult");
  7364. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7365. if (ceErpTradeResponsible != null)
  7366. {
  7367. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7368. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7369. ceErpTradeResponsible.Update();
  7370. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7371. if (entity != null)
  7372. {
  7373. entity.AfterSaleSupplierState = st;
  7374. entity.AfterSaleSupplierMemo = afmemo;
  7375. if (st == 1)
  7376. {
  7377. }
  7378. else
  7379. {
  7380. CeErpTradeResponsible.dateByTid(entity.ctid);
  7381. //退回到售后
  7382. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7383. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7384. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7385. if (num <= 1)
  7386. {
  7387. entity.AfterSaleState = 1;
  7388. }
  7389. else
  7390. {
  7391. entity.AfterSaleState = 5;
  7392. }
  7393. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7394. if (ceErpTradeAfterSaleExtend != null)
  7395. {
  7396. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7397. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7398. ceErpTradeAfterSaleExtend.Update();
  7399. }
  7400. else
  7401. {
  7402. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7403. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7404. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7405. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7406. ceErpTradeAfterSaleExtend.Create();
  7407. }
  7408. }
  7409. entity.UpdateTime = DateTime.Now;
  7410. entity.Update();
  7411. returnSuccessMsg("操作成功!");
  7412. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7413. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7414. return;
  7415. }
  7416. }
  7417. returnErrorMsg("找不到订单记录");
  7418. }
  7419. }
  7420. public void upd_erp_personaftersale()
  7421. {
  7422. if (UrlPostParmsCheck("id"))
  7423. {
  7424. string id = GetPostString("id");
  7425. int st = GetPostInt("afterstate");
  7426. string afmemo = GetPostString("supmemo");
  7427. string image = GetPostString("image");
  7428. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7429. if (ceErpTradeResponsible != null)
  7430. {
  7431. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7432. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7433. ceErpTradeResponsible.Update();
  7434. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7435. if (entity != null)
  7436. {
  7437. entity.AfterSaleSupplierMemo = afmemo;
  7438. entity.AfterSaleSupplierState = st;
  7439. if (st == 1)
  7440. {
  7441. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7442. if (isAll)
  7443. {
  7444. entity.AfterSaleState = 4;
  7445. entity.FinishAfterSaleTime = DateTime.Now;
  7446. }
  7447. }
  7448. else
  7449. {
  7450. CeErpTradeResponsible.dateByTid(entity.ctid);
  7451. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7452. if (ceErpTradeAfterSaleExtend != null)
  7453. {
  7454. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7455. ceErpTradeAfterSaleExtend.Update();
  7456. }
  7457. else
  7458. {
  7459. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7460. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7461. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7462. ceErpTradeAfterSaleExtend.Create();
  7463. }
  7464. //退回到主管
  7465. //entity.AfterSaleState = 2;
  7466. }
  7467. if (entity.AfterSaleState == 4)
  7468. {
  7469. ApiVo apiVo = new ApiVo();
  7470. apiVo.orderNumber = entity.ctid;
  7471. apiVo.actionName = "afterOver";
  7472. designHelper.API_WorkCore(apiVo); //afterOver
  7473. }
  7474. entity.UpdateTime = DateTime.Now;
  7475. entity.Update();
  7476. returnSuccessMsg("操作成功!");
  7477. CeErpSukuraData.createInfo(entity.ctid, 8);
  7478. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7479. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7480. return;
  7481. }
  7482. }
  7483. returnErrorMsg("找不到订单记录");
  7484. }
  7485. }
  7486. public void set_erp_supplierrefundtag()
  7487. {
  7488. if (UrlPostParmsCheck("ctid"))
  7489. {
  7490. string eid = GetPostString("ctid");
  7491. CeErpTradeCell entity = null;
  7492. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7493. if (entity != null)
  7494. {
  7495. entity.IsSupplierRefund = GetPostInt("tag");
  7496. entity.Update();
  7497. returnSuccessMsg("操作成功!");
  7498. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7499. return;
  7500. }
  7501. returnErrorMsg("找不到订单记录");
  7502. }
  7503. }
  7504. public void get_erp_refundlist()
  7505. {
  7506. DataStruct dStruct = GetPostStruct();
  7507. List<string> lw = new List<string>();
  7508. string tid = GetPostString("tid");
  7509. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7510. //string rid = GetPostString("refund_id");
  7511. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7512. string shopname = GetPostString("shopname");
  7513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7514. string buyernick = GetPostString("buyer_nick");
  7515. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7516. string customer = GetPostString("customer");
  7517. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7518. string design = GetPostString("design");
  7519. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7520. string sellermemo = GetPostString("seller_memo");
  7521. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7522. //string date1 = GetPostString("date1");
  7523. //string date2 = GetPostString("date2");
  7524. //string dateType = GetPostString("dateType");
  7525. //if (dateType.Length > 0)
  7526. //{
  7527. // if (dateType == "1001") dateType = "0";
  7528. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7529. // if (searchDT.Count == 2)
  7530. // {
  7531. // date1 = searchDT[0].ToString();
  7532. // date2 = searchDT[1].ToString();
  7533. // }
  7534. //}
  7535. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7536. //if (dw.Length > 0) lw.Add(dw);
  7537. string redate1 = GetPostString("refunddate1");
  7538. string redate2 = GetPostString("refunddate2");
  7539. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7540. if (dwdate.Length > 0) lw.Add(dwdate);
  7541. string price1 = GetPostString("price1");
  7542. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7543. string price2 = GetPostString("price2");
  7544. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7545. string ispartrefund = GetPostString("ispartrefund");
  7546. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7547. string refundState = GetPostString("refundvstate");
  7548. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7549. int st = GetInt("st");
  7550. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7551. {
  7552. string responsible = GetPostString("responsibleman");
  7553. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7554. lw.Add(string.Format("RefundState>={0}", st));
  7555. string code = CurrentUser.UserPost.Post.Code;
  7556. if (code == "CustomerService")
  7557. {
  7558. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7559. }
  7560. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7561. {
  7562. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7563. }
  7564. else if (code == "Place" || code == "PlaceMr")
  7565. {
  7566. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7567. }
  7568. dStruct.Order = "RefundState asc,created desc";
  7569. }
  7570. else if (st == 10)
  7571. {
  7572. string responsible = GetPostString("responsibleman");
  7573. if (responsible == "空白")
  7574. {
  7575. lw.Add(string.Format("ResponsibleUserName = ''"));
  7576. }
  7577. else if (responsible.Length > 0)
  7578. {
  7579. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7580. }
  7581. lw.Add(string.Format("RefundState>=0"));
  7582. dStruct.Order = "created desc";
  7583. }
  7584. else
  7585. {
  7586. string responsible = GetPostString("responsibleman");
  7587. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7588. lw.Add(string.Format("RefundState={0}", st));
  7589. dStruct.Order = "created desc";
  7590. }
  7591. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7592. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7593. dt.Columns.Add("refund_fees");
  7594. foreach (DataRow dr in dt.Rows)
  7595. {
  7596. String status = dr["status"].ToString();
  7597. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7598. {
  7599. dr["refund_fees"] = dr["refund_fee"];
  7600. }
  7601. else
  7602. {
  7603. dr["refund_fees"] = "0.0";
  7604. }
  7605. }
  7606. writeGridDataTableJson(dStruct.TotalCount, dt);
  7607. }
  7608. public void get_erp_refunddesignlist()
  7609. {
  7610. DataStruct dStruct = GetPostStruct();
  7611. List<string> lw = new List<string>();
  7612. string tid = GetPostString("tid");
  7613. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7614. string shopname = GetPostString("shopname");
  7615. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7616. string buyernick = GetPostString("buyer_nick");
  7617. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7618. string customer = GetPostString("customer");
  7619. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7620. string design = GetPostString("design");
  7621. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7622. string sellermemo = GetPostString("seller_memo");
  7623. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7624. string redate1 = GetPostString("refunddate1");
  7625. string redate2 = GetPostString("refunddate2");
  7626. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7627. if (dwdate.Length > 0) lw.Add(dwdate);
  7628. string price1 = GetPostString("price1");
  7629. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7630. string price2 = GetPostString("price2");
  7631. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7632. string ispartrefund = GetPostString("ispartrefund");
  7633. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7634. string designerorg = GetPostString("designerorg");
  7635. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7636. string refundState = GetPostString("refundState");
  7637. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7638. int myOrgid = CurrentUser.UserPost.OrgID;
  7639. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7640. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7641. {
  7642. if (CurrentUser.User.TeamIds.Length > 0)
  7643. {
  7644. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7645. }
  7646. else
  7647. {
  7648. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7649. }
  7650. }
  7651. else if ("SysAdmin".Equals(myOrgCode))
  7652. {
  7653. }
  7654. else
  7655. {
  7656. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7657. {
  7658. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7659. }
  7660. else
  7661. {
  7662. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7663. }
  7664. }
  7665. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7666. dStruct.Order = "created desc";
  7667. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7668. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7669. dt.Columns.Add("refund_fees");
  7670. foreach (DataRow dr in dt.Rows)
  7671. {
  7672. String status = dr["status"].ToString();
  7673. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7674. {
  7675. dr["refund_fees"] = dr["refund_fee"];
  7676. }
  7677. else
  7678. {
  7679. dr["refund_fees"] = "0.0";
  7680. }
  7681. }
  7682. writeGridDataTableJson(dStruct.TotalCount, dt);
  7683. }
  7684. public void handle_erp_refundtag()
  7685. {
  7686. if (UrlPostParmsCheck("refund_id"))
  7687. {
  7688. string eid = GetPostString("refund_id");
  7689. string respMan = GetPostString("ResponsibleName");
  7690. if (respMan.Length <= 0)
  7691. {
  7692. returnErrorMsg("责任人不能为空");
  7693. return;
  7694. }
  7695. CeErpTradeRefund entity = null;
  7696. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7697. if (entity != null)
  7698. {
  7699. entity.ResponsibleUserName = respMan;
  7700. string userid = GetPostString("ResponsibleUserId");
  7701. if (userid.Length > 0)
  7702. {
  7703. entity.ResponsibleUserId = userid;
  7704. }
  7705. entity.Memo = GetPostString("Memo");
  7706. if (respMan.IndexOf("客服") != -1 ||
  7707. respMan.IndexOf("设计师") != -1 ||
  7708. respMan.IndexOf("下单员") != -1)
  7709. {
  7710. entity.RefundState = 2;
  7711. }
  7712. else
  7713. {
  7714. entity.RefundState = 3;
  7715. }
  7716. entity.modified = DateTime.Now;
  7717. entity.Update();
  7718. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7719. returnSuccessMsg("操作成功!");
  7720. return;
  7721. }
  7722. returnErrorMsg("找不到订单记录");
  7723. }
  7724. }
  7725. public void handle_erp_designrefundtag()
  7726. {
  7727. if (UrlPostParmsCheck("refund_id"))
  7728. {
  7729. string eid = GetPostString("refund_id");
  7730. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7731. if (ceErpTradeCellExtend == null)
  7732. {
  7733. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7734. ceErpTradeCellExtend.ctid = eid;
  7735. }
  7736. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7737. if (ceErpTradeCellExtend.ID > 0)
  7738. {
  7739. ceErpTradeCellExtend.Update();
  7740. }
  7741. else
  7742. {
  7743. ceErpTradeCellExtend.Create();
  7744. }
  7745. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7746. returnSuccessMsg("操作成功!");
  7747. return;
  7748. }
  7749. returnErrorMsg("找不到订单记录");
  7750. }
  7751. public void upd_erp_refundverify()
  7752. {
  7753. if (UrlPostParmsCheck("refund_id"))
  7754. {
  7755. string eid = GetPostString("refund_id");
  7756. CeErpTradeRefund entity = null;
  7757. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7758. if (entity != null)
  7759. {
  7760. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7761. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7762. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7763. {
  7764. entity.RefundState = 2;
  7765. }
  7766. else
  7767. {
  7768. entity.RefundState = 3;
  7769. }
  7770. entity.Update();
  7771. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7772. returnSuccessMsg("操作成功!");
  7773. return;
  7774. }
  7775. returnErrorMsg("找不到订单记录");
  7776. }
  7777. }
  7778. public void upd_erp_refundapprove()
  7779. {
  7780. if (UrlPostParmsCheck("refund_id"))
  7781. {
  7782. string eid = GetPostString("refund_id");
  7783. CeErpTradeRefund entity = null;
  7784. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7785. if (entity != null)
  7786. {
  7787. int apr = GetPostInt("approve");
  7788. if (apr == 0)
  7789. {
  7790. entity.RefundState = 1;
  7791. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7792. }
  7793. else if (apr == 1)
  7794. {
  7795. entity.RefundState = 3;
  7796. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7797. }
  7798. entity.modified = DateTime.Now;
  7799. entity.Update();
  7800. returnSuccessMsg("操作成功!");
  7801. return;
  7802. }
  7803. returnErrorMsg("找不到订单记录");
  7804. }
  7805. }
  7806. public void get_erp_billlist()
  7807. {
  7808. DataStruct dStruct = GetPostStruct();
  7809. List<string> lw = new List<string>();
  7810. string title = GetPostString("title");
  7811. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7812. string tid = GetPostString("tid");
  7813. string tids = GetPostString("tids");
  7814. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7815. if (tids.Length > 0)
  7816. {
  7817. tids = "'" + tids + "'";
  7818. tids = tids.Replace(",", "','");
  7819. lw.Add(string.Format("tid in ({0})", tids));
  7820. }
  7821. string shopname = GetPostString("shopname");
  7822. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7823. string buyernick = GetPostString("buyer_nick");
  7824. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7825. string customer = GetPostString("customer");
  7826. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7827. string date1 = GetPostString("date1");
  7828. string date2 = GetPostString("date2");
  7829. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7830. if (dw.Length > 0) lw.Add(dw);
  7831. string price1 = GetPostString("price1");
  7832. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7833. string price2 = GetPostString("price2");
  7834. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7835. string returndate1 = GetPostString("returndate1");
  7836. string returndate2 = GetPostString("returndate2");
  7837. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7838. if (dw1.Length > 0) lw.Add(dw1);
  7839. string billtype = GetPostString("billtype");
  7840. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7841. string billstate = GetPostString("billstate");
  7842. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7843. string usershop = CurrentUser.User.pemShop;
  7844. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7845. dStruct.Order = "createTime desc";
  7846. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7847. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7848. //foreach (DataRow dr in dt.Rows)
  7849. //{
  7850. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7851. //}
  7852. writeGridDataTableJson(dStruct.TotalCount, dt);
  7853. }
  7854. public void modify_erp_billinfo()
  7855. {
  7856. if (UrlPostParmsCheck("ID"))
  7857. {
  7858. string eid = GetPostString("ID");
  7859. CeErpBill bill_entity = null;
  7860. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7861. if (bill_entity != null)
  7862. {
  7863. bill_entity.tid = GetPostString("tid");
  7864. bill_entity.title = GetPostString("title");
  7865. bill_entity.tax = GetPostString("tax");
  7866. bill_entity.bank = GetPostString("bank");
  7867. bill_entity.bankac = GetPostString("bankac");
  7868. bill_entity.address = GetPostString("address");
  7869. bill_entity.phone = GetPostString("phone");
  7870. bill_entity.price = GetPostString("price");
  7871. bill_entity.productId = GetPostInt("ProductName");
  7872. bill_entity.num = GetPostInt("num");
  7873. bill_entity.unit = GetPostString("unit");
  7874. bill_entity.type = GetPostString("type");
  7875. bill_entity.sendType = GetPostString("SendType");
  7876. bill_entity.email = GetPostString("email");
  7877. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7878. bill_entity.shopName = GetPostString("ShopName");
  7879. bill_entity.applymemo = GetPostString("applymemo");
  7880. bill_entity.modifyTime = DateTime.Now;
  7881. bill_entity.createTime = DateTime.Now;
  7882. bill_entity.state = 0;
  7883. bill_entity.Update();
  7884. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7885. returnSuccessMsg("发票修改成功!");
  7886. return;
  7887. }
  7888. returnErrorMsg("找不到对应记录");
  7889. }
  7890. }
  7891. public void set_erp_invoicing()
  7892. {
  7893. if (UrlPostParmsCheck("id"))
  7894. {
  7895. try
  7896. {
  7897. string eid = GetPostString("id");
  7898. CeErpBill bill_entity = null;
  7899. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7900. if (bill_entity != null)
  7901. {
  7902. int ComId = GetPostInt("ComId");
  7903. //string memo = GetPostString("Memo");
  7904. int allInfo = GetPostInt("allinfo");
  7905. string clert = CurrentUser.User.Name;
  7906. //string detailValue = GetPostString("detailvalue");
  7907. string billId = bill_entity.billOrderId;
  7908. string[] billIdList = billId.Split(',');
  7909. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7910. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7911. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7912. {
  7913. billCount += 1;
  7914. }
  7915. if (billId.Length <= 0 || billIdList.Length != billCount)
  7916. {
  7917. bill_entity.billOrderId = "";
  7918. string prebill = "ltb";
  7919. for (int idx = 1; idx <= billCount; idx++)
  7920. {
  7921. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7922. string billoid = prebill + idx + dtstr;
  7923. bill_entity.billOrderId += billoid;
  7924. if (idx < billCount)
  7925. {
  7926. bill_entity.billOrderId += ",";
  7927. }
  7928. }
  7929. }
  7930. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7931. if (bill_entity.state == 5)
  7932. {
  7933. string errMsg = bill_entity.failerror;
  7934. string[] errlist = errMsg.Split('|');
  7935. string[] errTags = new string[errlist.Length];
  7936. for (int itag = 0; itag < errlist.Length; itag++)
  7937. {
  7938. if (errlist[itag].Length <= 0) continue;
  7939. errTags[itag] = errlist[itag].Split('&')[0];
  7940. }
  7941. for (int iii = 0; iii < errTags.Length; iii++)
  7942. {
  7943. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7944. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7945. if (billOrderList.Length >= erroBillOrderTag)
  7946. {
  7947. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7948. if (needModifyBillId.Length <= 19)
  7949. {
  7950. needModifyBillId = needModifyBillId + "1";
  7951. }
  7952. else
  7953. {
  7954. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7955. last = last + 1;
  7956. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7957. }
  7958. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7959. }
  7960. }
  7961. }
  7962. bool isHaveBillSucces = false;
  7963. string totalRes = "";
  7964. bill_entity.failerror = "";
  7965. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7966. {
  7967. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7968. totalRes += res;
  7969. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7970. {
  7971. isHaveBillSucces = true;
  7972. bill_entity.comId = ComId;
  7973. bill_entity.state = 1;
  7974. bill_entity.executeTime = DateTime.Now;
  7975. bill_entity.executeUser = clert;
  7976. }
  7977. else
  7978. {
  7979. bill_entity.state = 5;
  7980. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7981. }
  7982. }
  7983. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7984. bill_entity.Update();
  7985. if (isHaveBillSucces)
  7986. {
  7987. StringBuilder sql = new StringBuilder();
  7988. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7989. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7990. }
  7991. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7992. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7993. {
  7994. returnErrorMsg("开票失败");
  7995. }
  7996. else
  7997. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7998. return;
  7999. }
  8000. returnErrorMsg("找不到对应记录");
  8001. }
  8002. catch (Exception ex)
  8003. {
  8004. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8005. returnErrorMsg("操作失败");
  8006. }
  8007. }
  8008. }
  8009. public void get_erp_invoicing_back()
  8010. {
  8011. if (UrlPostParmsCheck("id"))
  8012. {
  8013. try
  8014. {
  8015. string id = GetPostString("id");
  8016. CeErpBill entiy = CeErpBill.Get(id);
  8017. if (entiy != null)
  8018. {
  8019. if (entiy.state == 0)
  8020. {
  8021. returnErrorMsg("发票还未开具");
  8022. return;
  8023. }
  8024. string[] billOrderList = entiy.billOrderId.Split(',');
  8025. int iTag = 0;
  8026. entiy.fplsh = "";
  8027. entiy.fpdm = "";
  8028. entiy.fphm = "";
  8029. foreach (string billOrderId in billOrderList)
  8030. {
  8031. iTag++;
  8032. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8033. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8034. {
  8035. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8036. try
  8037. {
  8038. Invoicing_get_response_Obj iObj = null;
  8039. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8040. if (iObj != null)
  8041. {
  8042. entiy.state = 2;
  8043. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8044. entiy.fpdm += iObj.list[0].c_fpdm;
  8045. entiy.fphm += iObj.list[0].c_fphm;
  8046. if (iTag < billOrderList.Length)
  8047. {
  8048. entiy.fplsh += ",";
  8049. entiy.fpdm += ",";
  8050. entiy.fphm += ",";
  8051. }
  8052. entiy.Update();
  8053. }
  8054. StringBuilder sql = new StringBuilder();
  8055. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8056. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8057. returnSuccessMsg("开票成功");
  8058. }
  8059. catch (Exception ex)
  8060. {
  8061. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8062. }
  8063. return;
  8064. }
  8065. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8066. {
  8067. var res_obj = new
  8068. {
  8069. data = "开票中"
  8070. };
  8071. string ro_json = JsonConvert.SerializeObject(res_obj);
  8072. returnSuccess(ro_json);
  8073. return;
  8074. }
  8075. else
  8076. {
  8077. int eidx = res.IndexOf("c_resultmsg");
  8078. int lidx = res.IndexOf("c_status");
  8079. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8080. entiy.state = 5;
  8081. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8082. entiy.Update();
  8083. returnErrorMsg("开票失败");
  8084. return;
  8085. }
  8086. }
  8087. }
  8088. }
  8089. catch (Exception ex)
  8090. {
  8091. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8092. }
  8093. return;
  8094. }
  8095. }
  8096. public void get_erp_invoicing()
  8097. {
  8098. if (UrlPostParmsCheck("id"))
  8099. {
  8100. try
  8101. {
  8102. string id = GetPostString("id");
  8103. CeErpBill entiy = CeErpBill.Get(id);
  8104. if (entiy != null)
  8105. {
  8106. if (entiy.state == 0)
  8107. {
  8108. returnErrorMsg("发票还未开具");
  8109. return;
  8110. }
  8111. if (entiy.sendType == "纸质发票")
  8112. {
  8113. if (entiy.img.Length <= 0)
  8114. {
  8115. returnErrorMsg("查无纸质发票");
  8116. return;
  8117. }
  8118. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8119. returnSuccess(returnres);
  8120. return;
  8121. }
  8122. string[] billOrderList = entiy.billOrderId.Split(',');
  8123. int iTag = 0;
  8124. string fpUrl = "";
  8125. entiy.fplsh = "";
  8126. entiy.fpdm = "";
  8127. entiy.fphm = "";
  8128. foreach (string billOrderId in billOrderList)
  8129. {
  8130. iTag++;
  8131. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8132. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8133. {
  8134. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8135. Invoicing_get_response_Obj iObj = null;
  8136. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8137. if (iObj != null)
  8138. {
  8139. //entiy.state = 2;
  8140. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8141. entiy.fpdm += iObj.list[0].c_fpdm;
  8142. entiy.fphm += iObj.list[0].c_fphm;
  8143. if (iTag < billOrderList.Length)
  8144. {
  8145. entiy.fplsh += ",";
  8146. entiy.fpdm += ",";
  8147. entiy.fphm += ",";
  8148. }
  8149. entiy.Update();
  8150. fpUrl += iObj.list[0].c_url + ",";
  8151. }
  8152. //returnSuccess(res);
  8153. StringBuilder sql = new StringBuilder();
  8154. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8155. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8156. }
  8157. else
  8158. {
  8159. int eidx = res.IndexOf("c_resultmsg");
  8160. //int lidx = res.IndexOf("c_status");
  8161. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8162. //开票失败
  8163. entiy.state = 5;
  8164. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8165. entiy.Update();
  8166. returnErrorMsg("开票失败");
  8167. return;
  8168. }
  8169. }
  8170. var returnObj = new
  8171. {
  8172. data = fpUrl
  8173. };
  8174. string ro_json = JsonConvert.SerializeObject(returnObj);
  8175. returnSuccess(ro_json);
  8176. }
  8177. }
  8178. catch (Exception ex)
  8179. {
  8180. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8181. }
  8182. return;
  8183. }
  8184. }
  8185. public void save_erp_billimg()
  8186. {
  8187. if (UrlPostParmsCheck("id"))
  8188. {
  8189. string eid = GetPostString("id");
  8190. CeErpBill bill_entity = null;
  8191. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8192. if (bill_entity != null)
  8193. {
  8194. bill_entity.img = GetPostString("img");
  8195. bill_entity.executeTime = DateTime.Now;
  8196. bill_entity.state = 2;
  8197. bill_entity.Update();
  8198. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8199. returnSuccessMsg("保存成功");
  8200. }
  8201. return;
  8202. }
  8203. }
  8204. public void upd_erp_billreturnback()
  8205. {
  8206. if (UrlPostParmsCheck("id"))
  8207. {
  8208. int eid = GetPostInt("id");
  8209. CeErpBill bill_entity = null;
  8210. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8211. if (bill_entity != null)
  8212. {
  8213. bill_entity.state = 3;
  8214. bill_entity.returnReason = GetPostString("reason");
  8215. bill_entity.Update();
  8216. returnSuccessMsg("驳回成功!");
  8217. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8218. }
  8219. return;
  8220. }
  8221. }
  8222. public void cancel_erp_bill()
  8223. {
  8224. if (UrlPostParmsCheck("id"))
  8225. {
  8226. int eid = GetPostInt("id");
  8227. int detailValue = GetPostInt("detailvalue");
  8228. CeErpBill bill_entity = null;
  8229. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8230. string cres = "";
  8231. string gres = "";
  8232. if (bill_entity != null)
  8233. {
  8234. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8235. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8236. {
  8237. int iTag = 0;
  8238. bill_entity.fplsh = "";
  8239. bill_entity.fpdm = "";
  8240. bill_entity.fphm = "";
  8241. foreach (string billOrderId in billOrderList)
  8242. {
  8243. iTag++;
  8244. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8245. if (gres.IndexOf("success") != -1)
  8246. {
  8247. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8248. Invoicing_get_response_Obj iObj = null;
  8249. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8250. if (iObj != null)
  8251. {
  8252. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8253. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8254. bill_entity.fphm += iObj.list[0].c_fphm;
  8255. if (iTag < billOrderList.Length)
  8256. {
  8257. bill_entity.fplsh += ",";
  8258. bill_entity.fpdm += ",";
  8259. bill_entity.fphm += ",";
  8260. }
  8261. bill_entity.Update();
  8262. }
  8263. }
  8264. else
  8265. {
  8266. returnErrorMsg(gres);
  8267. return;
  8268. }
  8269. }
  8270. }
  8271. if (bill_entity.sendType == "纸质发票")
  8272. {
  8273. //作废
  8274. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8275. //if (DateTime.Now.Month == extime.Month)
  8276. //{
  8277. //cres = taobaoHelper.cancel_invoicing(eid);
  8278. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8279. //{
  8280. bill_entity.state = 4;//已作废
  8281. bill_entity.Update();
  8282. returnSuccessMsg("发票已作废");
  8283. return;
  8284. //}
  8285. //else
  8286. //{
  8287. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8288. // bill_entity.Update();
  8289. // returnErrorMsg(cres);
  8290. // return;
  8291. //}
  8292. //}
  8293. //else
  8294. //{
  8295. // returnErrorMsg("纸质发票只能作废本月的发票");
  8296. // return;
  8297. //}
  8298. }
  8299. //红冲
  8300. int redTag = 0;
  8301. string[] fpdmList = bill_entity.fpdm.Split(',');
  8302. string[] fphmList = bill_entity.fphm.Split(',');
  8303. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8304. {
  8305. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8306. return;
  8307. }
  8308. foreach (string billOrderId in billOrderList)
  8309. {
  8310. redTag++;
  8311. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8312. cres += onecres;
  8313. cres += ",";
  8314. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8315. {
  8316. bill_entity.state = 4;//已作废
  8317. //bill_entity.Update();
  8318. //returnSuccessMsg("发票已红冲");
  8319. }
  8320. else if (onecres.IndexOf("重复冲红") != -1)
  8321. {
  8322. bill_entity.state = 4;//已作废
  8323. //bill_entity.Update();
  8324. //returnSuccessMsg("发票已红冲");
  8325. }
  8326. else
  8327. {
  8328. string errmsg = commonHelper.KeepChinese(onecres);
  8329. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8330. }
  8331. }
  8332. bill_entity.Update();
  8333. if (cres.IndexOf("失败") != -1)
  8334. returnErrorMsg("红冲失败");
  8335. else
  8336. returnSuccessMsg("发票已红冲");
  8337. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8338. return;
  8339. }
  8340. return;
  8341. }
  8342. }
  8343. public void del_erp_billorder()
  8344. {
  8345. if (UrlPostParmsCheck("id"))
  8346. {
  8347. string eid = GetPostString("id");
  8348. CeErpBill.Del(eid);
  8349. CeErpBill bill = CeErpBill.Get(eid);
  8350. if (bill != null)
  8351. {
  8352. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8353. }
  8354. returnSuccessMsg("删除成功");
  8355. }
  8356. }
  8357. public void finish_erp_bill()
  8358. {
  8359. if (UrlPostParmsCheck("ids"))
  8360. {
  8361. string eids = GetPostString("ids");
  8362. string[] list = eids.Split(',');
  8363. foreach (string eid in list)
  8364. {
  8365. CeErpBill bill = CeErpBill.Get(eid);
  8366. if (bill != null)
  8367. {
  8368. bill.state = 2;
  8369. bill.Update();
  8370. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8371. }
  8372. }
  8373. returnSuccessMsg("操作成功");
  8374. }
  8375. }
  8376. public void get_erp_returncash()
  8377. {
  8378. DataStruct dStruct = GetPostStruct();
  8379. List<string> lw = new List<string>();
  8380. string tid = GetPostString("tid");
  8381. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8382. string shopname = GetPostString("shopname");
  8383. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8384. string buyernick = GetPostString("buyer_nick");
  8385. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8386. string customer = GetPostString("customer");
  8387. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8388. string returndate1 = GetPostString("returndate1");
  8389. string returndate2 = GetPostString("returndate2");
  8390. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8391. if (dw.Length > 0) lw.Add(dw);
  8392. string finishDate1 = GetPostString("finishdate1");
  8393. string finishDate2 = GetPostString("finishdate2");
  8394. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8395. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8396. string returntype = GetPostString("returntype");
  8397. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8398. string returnvstate = GetPostString("returnvstate");
  8399. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8400. dStruct.Order = "created desc";
  8401. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8402. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8403. writeGridDataTableJson(dStruct.TotalCount, dt);
  8404. }
  8405. public void get_erp_staygoods()
  8406. {
  8407. DataStruct dStruct = GetPostStruct();
  8408. List<string> lw = new List<string>();
  8409. string tid = GetPostString("tid");
  8410. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8411. string shopname = GetPostString("shopname");
  8412. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8413. string wangwang = GetPostString("wangwang");
  8414. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8415. string customer = GetPostString("customer");
  8416. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8417. string returndate1 = GetPostString("returndate1");
  8418. string returndate2 = GetPostString("returndate2");
  8419. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8420. if (dw.Length > 0) lw.Add(dw);
  8421. string finishDate1 = GetPostString("finishdate1");
  8422. string finishDate2 = GetPostString("finishdate2");
  8423. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8424. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8425. string returnvstate = GetPostString("returnvstate");
  8426. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8427. string persuadetype = GetPostString("persuadetype");
  8428. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8429. string customerOrg = GetPostString("customerOrg");
  8430. if (customerOrg.Length > 0)
  8431. {
  8432. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8433. }
  8434. dStruct.Order = "creata_time desc";
  8435. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8436. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8437. writeGridDataTableJson(dStruct.TotalCount, dt);
  8438. }
  8439. public void upd_erp_staygoods()
  8440. {
  8441. if (UrlPostParmsCheck("id"))
  8442. {
  8443. int eid = GetPostInt("id");
  8444. CeErpStayGoods entity = null;
  8445. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8446. if (entity != null)
  8447. {
  8448. entity.audit_type = 1;
  8449. entity.audit_time = DateTime.Now;
  8450. entity.audit_u_id = CurrentUser.UserID;
  8451. entity.audit_u_name = CurrentUser.UserName;
  8452. entity.Update();
  8453. returnSuccessMsg("审核成功!");
  8454. return;
  8455. }
  8456. returnErrorMsg("找不到订单记录");
  8457. }
  8458. }
  8459. public void upd_erp_stayGoodsback()
  8460. {
  8461. if (UrlPostParmsCheck("id"))
  8462. {
  8463. int eid = GetPostInt("id");
  8464. CeErpStayGoods entity = null;
  8465. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8466. if (entity != null)
  8467. {
  8468. entity.audit_text = GetPostString("reason");
  8469. entity.audit_type = 2;
  8470. entity.audit_time = DateTime.Now;
  8471. entity.audit_u_id = CurrentUser.UserID;
  8472. entity.audit_u_name = CurrentUser.UserName;
  8473. entity.Update();
  8474. returnSuccessMsg("退回成功!");
  8475. return;
  8476. }
  8477. returnErrorMsg("找不到订单记录");
  8478. }
  8479. }
  8480. public void upd_erp_returncashverify()
  8481. {
  8482. if (UrlPostParmsCheck("ID"))
  8483. {
  8484. int eid = GetPostInt("ID");
  8485. CeErpReturnCash entity = null;
  8486. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8487. if (entity != null)
  8488. {
  8489. entity.cashstate = 1;
  8490. entity.verifytime = DateTime.Now;
  8491. entity.verifyuserid = CurrentUser.UserID;
  8492. entity.Update();
  8493. returnSuccessMsg("审核成功!");
  8494. return;
  8495. }
  8496. returnErrorMsg("找不到订单记录");
  8497. }
  8498. }
  8499. public void upd_all_erp_returncashverify()
  8500. {
  8501. if (UrlPostParmsCheck("ID"))
  8502. {
  8503. String[] list = GetPostString("ID").Split(',');
  8504. CeErpReturnCash entity = null;
  8505. for (int i = 0; i < list.Length; i++)
  8506. {
  8507. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8508. if (entity != null)
  8509. {
  8510. if (entity.cashstate == 1)
  8511. {
  8512. returnErrorMsg("已审核过的订单不需要在审核!");
  8513. return;
  8514. }
  8515. entity.cashstate = 1;
  8516. entity.verifytime = DateTime.Now;
  8517. entity.verifyuserid = CurrentUser.UserID;
  8518. entity.Update();
  8519. }
  8520. }
  8521. returnSuccessMsg("审核成功!");
  8522. return;
  8523. }
  8524. }
  8525. public void upd_erp_returncashback()
  8526. {
  8527. if (UrlPostParmsCheck("ID"))
  8528. {
  8529. int eid = GetPostInt("ID");
  8530. CeErpReturnCash entity = null;
  8531. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8532. if (entity != null)
  8533. {
  8534. entity.backreason = GetPostString("reason");
  8535. entity.cashstate = 2;
  8536. entity.verifytime = DateTime.Now;
  8537. entity.verifyuserid = CurrentUser.UserID;
  8538. entity.Update();
  8539. returnSuccessMsg("退回成功!");
  8540. return;
  8541. }
  8542. returnErrorMsg("找不到订单记录");
  8543. }
  8544. }
  8545. public void upd_erp_returnprice()
  8546. {
  8547. if (UrlPostParmsCheck("ID"))
  8548. {
  8549. int eid = GetPostInt("ID");
  8550. CeErpReturnCash entity = null;
  8551. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8552. if (entity != null)
  8553. {
  8554. if (entity.cashstate == 1)
  8555. {
  8556. returnErrorMsg("审核通过了不能改");
  8557. return;
  8558. }
  8559. entity.returnprice = GetPostDouble("returnprice");
  8560. entity.Update();
  8561. returnSuccessMsg("修改成功!");
  8562. return;
  8563. }
  8564. returnErrorMsg("找不到订单记录");
  8565. }
  8566. }
  8567. public void del_erp_returncash()
  8568. {
  8569. if (UrlPostParmsCheck("ID"))
  8570. {
  8571. int eid = GetPostInt("ID");
  8572. CeErpReturnCash.Del(eid);
  8573. returnSuccessMsg("操作成功");
  8574. return;
  8575. }
  8576. }
  8577. public void test_for_do_sql()
  8578. {
  8579. string sql = GetPostString("sqlstr");
  8580. if (sql.Length > 0)
  8581. {
  8582. try
  8583. {
  8584. DbHelper.DbConn.ExecuteNonQuery(sql);
  8585. var res_obj = new
  8586. {
  8587. data = "成功",
  8588. };
  8589. string ro_json = JsonConvert.SerializeObject(res_obj);
  8590. returnSuccess(ro_json);
  8591. }
  8592. catch (Exception ex)
  8593. {
  8594. var res_obj = new
  8595. {
  8596. data = ex.Message,
  8597. };
  8598. string ro_json = JsonConvert.SerializeObject(res_obj);
  8599. returnSuccess(ro_json);
  8600. }
  8601. }
  8602. }
  8603. public void get_user_info()
  8604. {
  8605. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8606. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8607. }
  8608. public void get_total_data()
  8609. {
  8610. int userId = CurrentUser.UserID;
  8611. string sql = "";
  8612. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8613. {
  8614. 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);
  8615. }
  8616. else
  8617. {
  8618. 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 " +
  8619. "(select ID from CE_ErpUser where ID = {0}) d " +
  8620. "left join " +
  8621. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8622. ") a on d.ID = a.id left join " +
  8623. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8624. ") b on a.id = b.id1 left join" +
  8625. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8626. ") c on a.id = c.id2;", userId);
  8627. }
  8628. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8629. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8630. }
  8631. public void get_date_area_total_data2()
  8632. {
  8633. int userId = CurrentUser.UserID;
  8634. string date_type = GetPostString("timetype");
  8635. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8636. string sql = "";
  8637. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8638. {
  8639. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8640. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8641. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8642. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8643. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8644. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8645. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8646. ") a on e.ID = a.id left join " +
  8647. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8648. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8649. ") b on a.id = b.id1 " +
  8650. "left join " +
  8651. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8652. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8653. ") c on a.id = c.id2 " +
  8654. "left join " +
  8655. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8656. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8657. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8658. }
  8659. else
  8660. {
  8661. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8662. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8663. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8664. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8665. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8666. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8667. ") a on e.ID = a.id left join " +
  8668. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8669. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8670. ") c on a.id = c.id2 " +
  8671. "left join " +
  8672. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8673. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8674. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8675. }
  8676. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8677. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8678. }
  8679. public void get_date_area_total_data()
  8680. {
  8681. int userId = CurrentUser.UserID;
  8682. string date_type = GetPostString("timetype");
  8683. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8684. string date1 = searchDT[0].ToString();
  8685. string date2 = searchDT[1].ToString();
  8686. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8687. {
  8688. SqlParameter[] sqlParameter ={
  8689. new SqlParameter("@userId", SqlDbType.Int,4),
  8690. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8691. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8692. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8693. };
  8694. sqlParameter[0].Value = userId;
  8695. sqlParameter[1].Value = date1;
  8696. sqlParameter[2].Value = date2;
  8697. sqlParameter[3].Direction = ParameterDirection.Output;
  8698. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8699. string res = sqlParameter[3].Value.ToString();
  8700. var res_obj = new
  8701. {
  8702. data = res
  8703. };
  8704. string ro_json = JsonConvert.SerializeObject(res_obj);
  8705. returnSuccess(ro_json);
  8706. }
  8707. else
  8708. {
  8709. SqlParameter[] sqlParameter ={
  8710. new SqlParameter("@userId", SqlDbType.Int,4),
  8711. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8712. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8713. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8714. };
  8715. sqlParameter[0].Value = userId;
  8716. sqlParameter[1].Value = date1;
  8717. sqlParameter[2].Value = date2;
  8718. sqlParameter[3].Direction = ParameterDirection.Output;
  8719. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8720. string res = sqlParameter[3].Value.ToString();
  8721. var res_obj = new
  8722. {
  8723. data = res
  8724. };
  8725. string ro_json = JsonConvert.SerializeObject(res_obj);
  8726. returnSuccess(ro_json);
  8727. }
  8728. //writeGridDataViewJson(dt.Rows.Count, dv);
  8729. }
  8730. public void get_order_list()
  8731. {
  8732. string strFields = GetPostString("paraFields");
  8733. string strOrder = GetPostString("paraOrder");
  8734. string strWhere = GetPostString("paraWhere");
  8735. string strPageSize = GetPostString("paraPageSize");
  8736. DataStruct dStruct = GetPostStruct();
  8737. dStruct.PageSize = int.Parse(strPageSize);
  8738. dStruct.Fileds = strFields;
  8739. dStruct.Order = strOrder;
  8740. dStruct.MainWhere = strWhere;
  8741. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8742. writeGridDataTableJson(dStruct.TotalCount, dt);
  8743. }
  8744. ////获取待开始订单列表
  8745. //public void get_wait_design_order_list()
  8746. //{
  8747. // string date_type = GetPostString("date_type");
  8748. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8749. // DataStruct dStruct = GetPostStruct();
  8750. // dStruct.PageSize = 1000;
  8751. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8752. // List<string> lw = new List<string>();
  8753. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8754. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8755. // dStruct.Order = "WaitDesignTime asc";
  8756. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8757. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8758. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8759. //}
  8760. //获取完成单量排名
  8761. public void get_finish_order_count_ranking()
  8762. {
  8763. /* string date_type = GetPostString("date_type");
  8764. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8765. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8766. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8767. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8768. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8769. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8770. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8771. writeGridDataTableJson(0, new DataTable());
  8772. }
  8773. public void get_finish_order_amount_ranking()
  8774. {
  8775. /*string date_type = GetPostString("date_type");
  8776. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8777. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8778. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8779. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8780. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8781. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8782. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8783. writeGridDataTableJson(0, new DataTable());
  8784. }
  8785. public void get_finish_refund_count_ranking()
  8786. {
  8787. string date_type = GetPostString("date_type");
  8788. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8789. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8790. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8791. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8792. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8793. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8794. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8795. writeGridDataTableJson(dt.Rows.Count, dt);
  8796. }
  8797. public void get_finish_refund_amount_ranking()
  8798. {
  8799. string date_type = GetPostString("date_type");
  8800. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8801. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8802. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8803. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8804. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8805. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8806. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8807. writeGridDataTableJson(dt.Rows.Count, dt);
  8808. }
  8809. public void set_erp_finishorder_director()
  8810. {
  8811. if (UrlPostParmsCheck("ctid"))
  8812. {
  8813. string eid = GetPostString("ctid");
  8814. CeErpTradeCell entity = null;
  8815. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8816. if (entity != null)
  8817. {
  8818. entity.OrderState = 8;
  8819. entity.Update();
  8820. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8821. returnSuccessMsg("操作成功!");
  8822. return;
  8823. }
  8824. returnErrorMsg("找不到记录");
  8825. }
  8826. }
  8827. public void get_erp_placeregistlist()
  8828. {
  8829. DataStruct dStruct = GetPostStruct();
  8830. List<string> lw = new List<string>();
  8831. string outsid = GetPostString("outsid");
  8832. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8833. string memo = GetPostString("memo");
  8834. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8835. string filename = GetPostString("filename");
  8836. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8837. string islate = GetPostString("islate");
  8838. if (islate.Length > 0)
  8839. {
  8840. if (islate == "1")
  8841. lw.Add(string.Format("OutLate>0"));
  8842. else
  8843. lw.Add(string.Format("OutLate=0"));
  8844. }
  8845. string placedate1 = GetPostString("placedate1");
  8846. string placedate2 = GetPostString("placedate2");
  8847. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8848. if (dw.Length > 0) lw.Add(dw);
  8849. string deliveryDate1 = GetPostString("deliverydate1");
  8850. string deliveryDate2 = GetPostString("deliverydate2");
  8851. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8852. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8853. dStruct.Order = "ID desc";
  8854. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8855. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8856. writeGridDataTableJson(dStruct.TotalCount, dt);
  8857. }
  8858. public void ins_erp_placeregist()
  8859. {
  8860. if (UrlPostParmsCheck("id"))
  8861. {
  8862. string eid = GetPostString("id");
  8863. CeErpPlaceRegister entity = null;
  8864. if (eid == "0")//新增
  8865. {
  8866. entity = new CeErpPlaceRegister();
  8867. string xdTime = GetPostString("placeTime");
  8868. if (xdTime.Length > 0)
  8869. {
  8870. entity.PlactTime = Convert.ToDateTime(xdTime);
  8871. }
  8872. string fhTime = GetPostString("deliveryTime");
  8873. if (fhTime.Length > 0)
  8874. {
  8875. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8876. }
  8877. string preTime = GetPostString("preOutTime");
  8878. if (preTime.Length > 0)
  8879. {
  8880. entity.PreOutTime = Convert.ToDateTime(preTime);
  8881. }
  8882. entity.DeliveryCount = GetPostInt("deliveryCount");
  8883. entity.ReceiveCount = GetPostInt("receiveCount");
  8884. entity.OutSid = GetPostString("outSid");
  8885. entity.FileName = GetPostString("fileName");
  8886. entity.Memo = GetPostString("memo");
  8887. entity.AddUserId = CurrentUser.UserID;
  8888. entity.CreateTime = DateTime.Now;
  8889. entity.Img = GetPostString("img");
  8890. entity.Supplier = GetPostInt("supplier");
  8891. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8892. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8893. {
  8894. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8895. DateTime dt2 = (DateTime)entity.PreOutTime;
  8896. TimeSpan span = dt1.Subtract(dt2);
  8897. if (span.Days > 0)
  8898. {
  8899. entity.OutLate = span.Days;
  8900. }
  8901. }
  8902. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8903. entity.Create();
  8904. returnSuccessMsg("添加成功!");
  8905. return;
  8906. }
  8907. else //修改
  8908. {
  8909. entity = CeErpPlaceRegister.Get(eid);
  8910. if (entity != null)
  8911. {
  8912. string xdTime = GetPostString("placeTime");
  8913. if (xdTime.Length > 0)
  8914. {
  8915. entity.PlactTime = Convert.ToDateTime(xdTime);
  8916. }
  8917. string fhTime = GetPostString("deliveryTime");
  8918. if (fhTime.Length > 0)
  8919. {
  8920. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8921. }
  8922. string preTime = GetPostString("preOutTime");
  8923. if (preTime.Length > 0)
  8924. {
  8925. entity.PreOutTime = Convert.ToDateTime(preTime);
  8926. }
  8927. entity.DeliveryCount = GetPostInt("deliveryCount");
  8928. entity.ReceiveCount = GetPostInt("receiveCount");
  8929. if (entity.DeliveryCount == entity.ReceiveCount)
  8930. {
  8931. entity.CurState = "已完成";
  8932. }
  8933. else
  8934. {
  8935. entity.CurState = "未完成";
  8936. }
  8937. entity.OutSid = GetPostString("outSid");
  8938. entity.FileName = GetPostString("fileName");
  8939. entity.Memo = GetPostString("memo");
  8940. entity.Img = GetPostString("img");
  8941. entity.Supplier = GetPostInt("supplier");
  8942. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8943. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8944. {
  8945. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8946. DateTime dt2 = (DateTime)entity.PreOutTime;
  8947. TimeSpan span = dt1.Subtract(dt2);
  8948. if (span.Days > 0)
  8949. {
  8950. entity.OutLate = span.Days;
  8951. }
  8952. }
  8953. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8954. entity.Update();
  8955. returnSuccessMsg("修改成功");
  8956. return;
  8957. }
  8958. returnErrorMsg("找不到对应的记录");
  8959. return;
  8960. }
  8961. }
  8962. returnErrorMsg("缺少必要参数");
  8963. }
  8964. public void del_erp_placeregist()
  8965. {
  8966. string eid = GetPostString("id");
  8967. CeErpPlaceRegister.Del(eid);
  8968. returnSuccessMsg("删除成功!");
  8969. return;
  8970. }
  8971. public void ins_erp_placeregistbyorder()
  8972. {
  8973. string ctid = GetPostString("ctid");
  8974. if (ctid.Length > 0)
  8975. {
  8976. StringBuilder sql = new StringBuilder();
  8977. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8978. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8979. if (dt.Rows.Count > 0)
  8980. {
  8981. foreach (DataRow dr in dt.Rows)
  8982. {
  8983. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8984. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8985. entity.AddUserId = CurrentUser.UserID;
  8986. entity.tid = dr["tid"].ToString();
  8987. entity.Did = Convert.ToString(dr["ctid"]);
  8988. entity.splitTag = dr["SplitTag"].ToString();
  8989. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8990. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8991. if (pre_ctid.Length > 0)
  8992. {
  8993. sellmemo = sellmemo.Replace(pre_ctid, "");
  8994. }
  8995. sellmemo = sellmemo.Replace("[", "");
  8996. sellmemo = sellmemo.Replace("]", "");
  8997. entity.FileName = sellmemo;
  8998. string count = dr["ProductCount"].ToString();
  8999. int usecount = commonHelper.getIntCountFromString(count);
  9000. entity.DeliveryCount = usecount;
  9001. entity.CurState = "未完成";
  9002. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9003. {
  9004. entity.Supplier = 24;//dl手提袋定制
  9005. }
  9006. else
  9007. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9008. entity.CreateTime = DateTime.Now;
  9009. entity.Create();
  9010. }
  9011. returnSuccessMsg("操作成功");
  9012. return;
  9013. }
  9014. returnErrorMsg("没有找到对应订单");
  9015. return;
  9016. }
  9017. returnErrorMsg("缺少订单编号");
  9018. return;
  9019. }
  9020. public void get_erp_persuadelist()
  9021. {
  9022. DataStruct dStruct = GetPostStruct();
  9023. List<string> lw = new List<string>();
  9024. string ctid = GetPostString("ctid");
  9025. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9026. string shopname = GetPostString("shopname");
  9027. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9028. string buyernick = GetPostString("buyer_nick");
  9029. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9030. string customer = GetPostString("customer");
  9031. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9032. string returndate1 = GetPostString("returndate1");
  9033. string returndate2 = GetPostString("returndate2");
  9034. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9035. if (dw.Length > 0) lw.Add(dw);
  9036. string finishDate1 = GetPostString("finishdate1");
  9037. string finishDate2 = GetPostString("finishdate2");
  9038. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9039. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9040. string persuadetype = GetPostString("persuadetype");
  9041. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9042. string returnvstate = GetPostString("returnvstate");
  9043. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9044. dStruct.Order = "created desc";
  9045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9046. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9047. writeGridDataTableJson(dStruct.TotalCount, dt);
  9048. }
  9049. public void upd_erp_returnpersuadeback()
  9050. {
  9051. if (UrlPostParmsCheck("ID"))
  9052. {
  9053. int eid = GetPostInt("ID");
  9054. CeErpPersuade entity = null;
  9055. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9056. if (entity != null)
  9057. {
  9058. entity.backreason = GetPostString("reason");
  9059. entity.pstate = 2;
  9060. entity.verifytime = DateTime.Now;
  9061. entity.verifyuserid = CurrentUser.UserID;
  9062. entity.Update();
  9063. returnSuccessMsg("退回成功!");
  9064. return;
  9065. }
  9066. returnErrorMsg("找不到订单记录");
  9067. }
  9068. }
  9069. public void upd_erp_returnpersuadeverify()
  9070. {
  9071. if (UrlPostParmsCheck("ID"))
  9072. {
  9073. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9074. {
  9075. returnErrorMsg("暂无权限审核");
  9076. return;
  9077. }
  9078. int eid = GetPostInt("ID");
  9079. CeErpPersuade entity = null;
  9080. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9081. if (entity != null)
  9082. {
  9083. entity.pstate = 1;
  9084. entity.verifytime = DateTime.Now;
  9085. entity.verifyuserid = CurrentUser.UserID;
  9086. entity.Update();
  9087. returnSuccessMsg("审核成功!");
  9088. return;
  9089. }
  9090. returnErrorMsg("找不到订单记录");
  9091. }
  9092. }
  9093. public void del_erp_persuade()
  9094. {
  9095. if (UrlPostParmsCheck("ID"))
  9096. {
  9097. int eid = GetPostInt("ID");
  9098. CeErpPersuade.Del(eid);
  9099. returnSuccessMsg("操作成功");
  9100. return;
  9101. }
  9102. }
  9103. public void get_erp_oldcustoupload()
  9104. {
  9105. DataStruct dStruct = GetPostStruct();
  9106. List<string> lw = new List<string>();
  9107. string buyernick = GetPostString("buyer_nick");
  9108. if (buyernick.Length > 0)
  9109. {
  9110. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9111. }
  9112. else
  9113. return;
  9114. dStruct.Order = "pay_time desc";
  9115. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9116. DataTable dt = null;
  9117. dt = WebCache.GetData("view_erptradecell", dStruct);
  9118. writeGridDataTableJson(dStruct.TotalCount, dt);
  9119. }
  9120. public void get_erp_checkorderlist()
  9121. {
  9122. DataStruct dStruct = GetPostStruct();
  9123. List<string> lw = new List<string>();
  9124. string tid = GetPostString("ctid");
  9125. if (tid.Length > 0)
  9126. {
  9127. string select_tid = getTidByCtid(tid);
  9128. lw.Add(string.Format("tid='{0}'", select_tid));
  9129. }
  9130. string shopname = GetPostString("shopname");
  9131. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9132. string buyernick = GetPostString("buyer_nick");
  9133. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9134. string customer = GetPostString("customer");
  9135. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9136. string design = GetPostString("design");
  9137. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9138. string orderState = GetPostString("orderState");
  9139. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9140. string address = GetPostString("address");
  9141. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9142. string sellermemo = GetPostString("seller_memo");
  9143. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9144. string supplier = GetPostString("supplier");
  9145. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9146. {
  9147. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9148. }
  9149. else
  9150. {
  9151. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9152. }
  9153. string date1 = GetPostString("date1");
  9154. string date2 = GetPostString("date2");
  9155. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9156. if (dw.Length > 0) lw.Add(dw);
  9157. string placedate1 = GetPostString("placedate1");
  9158. string placedate2 = GetPostString("placedate2");
  9159. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9160. if (fdw.Length > 0) lw.Add(fdw);
  9161. string price1 = GetPostString("price1");
  9162. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9163. string price2 = GetPostString("price2");
  9164. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9165. string checkst = GetPostString("checkstate");
  9166. if (checkst.Length > 0 && "10".Equals(checkst))
  9167. {
  9168. lw.Add(string.Format("CheckOut>0"));
  9169. }
  9170. else
  9171. {
  9172. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9173. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9174. }
  9175. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9176. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9177. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9178. writeGridDataTableJson(dStruct.TotalCount, dt);
  9179. }
  9180. public void ins_erp_startCheck()
  9181. {
  9182. if (UrlPostParmsCheck("ctid"))
  9183. {
  9184. string eid = GetPostString("ctid");
  9185. CeErpTradeCell entity = null;
  9186. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9187. if (entity != null)
  9188. {
  9189. entity.MemoOpt = 4;
  9190. entity.UpdateTime = DateTime.Now;
  9191. entity.Update();
  9192. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9193. CeErpSukuraData.createInfo(entity.ctid, 6);
  9194. returnSuccessMsg("操作成功!");
  9195. return;
  9196. }
  9197. returnErrorMsg("找不到记录");
  9198. }
  9199. }
  9200. public void upd_erp_sendXlw()
  9201. {
  9202. if (UrlPostParmsCheck("ctid"))
  9203. {
  9204. string eid = GetPostString("ctid");
  9205. CeErpTradeCell entity = null;
  9206. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9207. if (entity != null)
  9208. {
  9209. if (entity.IsSendGift == 1)
  9210. {
  9211. returnErrorMsg("请勿重复标记");
  9212. return;
  9213. }
  9214. entity.IsSendGift = 1;
  9215. entity.Update();
  9216. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9217. returnSuccessMsg("操作成功!");
  9218. return;
  9219. }
  9220. returnErrorMsg("找不到记录");
  9221. }
  9222. }
  9223. public void cancel_sendXlw()
  9224. {
  9225. if (UrlPostParmsCheck("ctid"))
  9226. {
  9227. string eid = GetPostString("ctid");
  9228. CeErpTradeCell entity = null;
  9229. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9230. if (entity != null)
  9231. {
  9232. if (entity.IsSendGift == 0)
  9233. {
  9234. returnErrorMsg("未标记小礼物");
  9235. return;
  9236. }
  9237. entity.IsSendGift = 0;
  9238. entity.Update();
  9239. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9240. returnSuccessMsg("操作成功!");
  9241. return;
  9242. }
  9243. returnErrorMsg("找不到记录");
  9244. }
  9245. }
  9246. public void get_erp_designbill()
  9247. {
  9248. DataStruct dStruct = GetPostStruct();
  9249. List<string> lw = new List<string>();
  9250. int isMy = GetInt("my");
  9251. if (isMy == 1)
  9252. {
  9253. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9254. }
  9255. string tid = GetPostString("tid");
  9256. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9257. string userName = GetPostString("design");
  9258. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9259. string price1 = GetPostString("price1");
  9260. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9261. string price2 = GetPostString("price2");
  9262. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9263. string rePrice1 = GetPostString("rePrice1");
  9264. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9265. string rePrice2 = GetPostString("rePrice2");
  9266. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9267. string designerType = GetPostString("designerType");
  9268. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9269. string orderState = GetPostString("orderState");
  9270. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9271. string endTime1 = GetPostString("endTime1");
  9272. string endTime2 = GetPostString("endTime2");
  9273. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9274. if (dw.Length > 0) lw.Add(dw);
  9275. string isDk = GetPostString("isDk");
  9276. if (isDk == "1")
  9277. {
  9278. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9279. }
  9280. else if (isDk == "0")
  9281. {
  9282. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9283. }
  9284. dStruct.Order = "oid, create_time desc";
  9285. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9286. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9287. writeGridDataTableJson(dStruct.TotalCount, dt);
  9288. }
  9289. public void upd_erp_designerbill()
  9290. {
  9291. if (UrlPostParmsCheck("ID"))
  9292. {
  9293. string eid = GetPostString("ID");
  9294. CeErpDesignerBill entity = null;
  9295. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9296. if (entity != null)
  9297. {
  9298. if (GetPostDouble("designerpirce") > 0)
  9299. {
  9300. entity.realPrice = GetPostDouble("designerpirce");
  9301. entity.update_time = DateTime.Now;
  9302. entity.update_u_id = CurrentUser.UserID;
  9303. entity.update_u_name = CurrentUser.UserName;
  9304. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9305. entity.Update();
  9306. returnSuccessMsg("操作成功!");
  9307. return;
  9308. }
  9309. else
  9310. {
  9311. entity.price = GetPostDouble("price");
  9312. entity.update_time = DateTime.Now;
  9313. entity.update_u_id = CurrentUser.UserID;
  9314. entity.update_u_name = CurrentUser.UserName;
  9315. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9316. entity.Update();
  9317. returnSuccessMsg("操作成功!");
  9318. return;
  9319. }
  9320. }
  9321. returnErrorMsg("找不到记录");
  9322. }
  9323. }
  9324. public void audit_erp_designerbill()
  9325. {
  9326. if (UrlPostParmsCheck("ID"))
  9327. {
  9328. string eid = GetPostString("ID");
  9329. CeErpDesignerBill entity = null;
  9330. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9331. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9332. if (entity != null)
  9333. {
  9334. entity.realPrice = GetPostDouble("designerpirce");
  9335. entity.update_time = DateTime.Now;
  9336. entity.update_u_id = CurrentUser.UserID;
  9337. entity.update_u_name = CurrentUser.UserName;
  9338. entity.isAudit = 1;
  9339. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9340. entity.Update();
  9341. if (orderEntity != null)
  9342. {
  9343. orderEntity.IsReadTag = 3;
  9344. orderEntity.Update();
  9345. }
  9346. returnSuccessMsg("操作成功!");
  9347. return;
  9348. }
  9349. returnErrorMsg("找不到记录");
  9350. }
  9351. }
  9352. public void all_audit_erp_designerbill()
  9353. {
  9354. if (UrlPostParmsCheck("idList"))
  9355. {
  9356. string[] list = GetPostString("idList").Split(',');
  9357. CeErpDesignerBill entity = null;
  9358. for (int i = 0; i < list.Length; i++)
  9359. {
  9360. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9361. if (entity == null) return;
  9362. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9363. if (orderEntity == null) return;
  9364. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9365. entity.update_time = DateTime.Now;
  9366. entity.update_u_id = CurrentUser.UserID;
  9367. entity.update_u_name = CurrentUser.UserName;
  9368. entity.isAudit = 1;
  9369. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9370. entity.Update();
  9371. orderEntity.IsReadTag = 3;
  9372. orderEntity.Update();
  9373. }
  9374. returnSuccessMsg("操作成功!");
  9375. return;
  9376. }
  9377. }
  9378. public void get_erp_sameorders()
  9379. {
  9380. if (UrlPostParmsCheck("ctid"))
  9381. {
  9382. string eid = GetPostString("ctid");
  9383. CeErpTradeCell entity = null;
  9384. entity = CeErpTradeCell.GetByCtid(eid);
  9385. if (entity != null)
  9386. {
  9387. StringBuilder sql = new StringBuilder();
  9388. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9389. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9390. var res = new
  9391. {
  9392. data = dt.Rows.Count
  9393. };
  9394. string ro_jsond = JsonConvert.SerializeObject(res);
  9395. returnSuccess(ro_jsond);
  9396. return;
  9397. }
  9398. returnErrorMsg("未找到订单");
  9399. return;
  9400. }
  9401. returnErrorMsg("缺少必要的参数");
  9402. }
  9403. public void get_erp_islasthavesameorder()
  9404. {
  9405. if (UrlPostParmsCheck("ctid"))
  9406. {
  9407. string eid = GetPostString("ctid");
  9408. string[] ctidList = eid.Split(',');
  9409. StringBuilder sql = new StringBuilder();
  9410. string tisCtid = "";
  9411. foreach (string ctid in ctidList)
  9412. {
  9413. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9414. if (entity != null)
  9415. {
  9416. sql = new StringBuilder();
  9417. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9418. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9419. if (dth.Rows.Count > 0)
  9420. {
  9421. tisCtid += entity.ctid;
  9422. tisCtid += ",";
  9423. }
  9424. }
  9425. }
  9426. if (tisCtid.Length > 0)
  9427. {
  9428. var res = new
  9429. {
  9430. data = tisCtid
  9431. };
  9432. string ro_jsond = JsonConvert.SerializeObject(res);
  9433. returnSuccess(ro_jsond);
  9434. }
  9435. else
  9436. {
  9437. var res = new
  9438. {
  9439. data = ""
  9440. };
  9441. string ro_jsond = JsonConvert.SerializeObject(res);
  9442. returnSuccess(ro_jsond);
  9443. }
  9444. return;
  9445. }
  9446. returnErrorMsg("缺少必要的参数");
  9447. }
  9448. public void file_client_down_url()
  9449. {
  9450. if (!UrlPostParmsCheck("userId"))
  9451. {
  9452. returnErrorMsg("缺少必要的参数");
  9453. }
  9454. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9455. }
  9456. public void checkout_form_data()
  9457. {
  9458. if (!UrlPostParmsCheck("tid"))
  9459. {
  9460. returnErrorMsg("缺少必要的参数");
  9461. }
  9462. string tid = GetPostString("tid");
  9463. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9464. if (ceErpOrderFormData != null)
  9465. {
  9466. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9467. returnSuccess(ro_jsond);
  9468. return;
  9469. }
  9470. returnErrorMsg("尚未有文件!");
  9471. }
  9472. public void back_supplier_audit()
  9473. {
  9474. int userId = CurrentUser.UserID;
  9475. StringBuilder sql = new StringBuilder();
  9476. 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);
  9477. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9478. if (dt.Rows.Count > 0)
  9479. {
  9480. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9481. }
  9482. else
  9483. {
  9484. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9485. }
  9486. }
  9487. public void back_supplier_query()
  9488. {
  9489. string eid = GetPostString("ctid");
  9490. if (eid != "")
  9491. {
  9492. StringBuilder sql = new StringBuilder();
  9493. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9494. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9495. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9496. }
  9497. else
  9498. {
  9499. returnErrorMsg("找不到订单记录");
  9500. return;
  9501. }
  9502. }
  9503. public void verified_to_order()
  9504. {
  9505. int userId = CurrentUser.UserID;
  9506. StringBuilder sql = new StringBuilder();
  9507. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9508. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9509. if (dt.Rows.Count > 0)
  9510. {
  9511. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9512. }
  9513. else
  9514. {
  9515. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9516. }
  9517. }
  9518. public void upd_supplier_audit()
  9519. {
  9520. if (UrlPostParmsCheck("ctid"))
  9521. {
  9522. string eid = GetPostString("ctid");
  9523. string reason = GetPostString("returnreason");
  9524. CeErpTradeCell entity = null;
  9525. CeWithdraw withdraw = null;
  9526. withdraw = CeWithdraw.GetByTid(eid);
  9527. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9528. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9529. {
  9530. if (withdraw != null)
  9531. {
  9532. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9533. {
  9534. returnSuccessMsg("您没有权限操作!");
  9535. return;
  9536. }
  9537. else
  9538. {
  9539. if (reason.Equals("1"))
  9540. {
  9541. if (entity.OrderState == -1)
  9542. {
  9543. if (entity.FinishPlaceTime == null)
  9544. {
  9545. entity.OrderState = 2;
  9546. }
  9547. else
  9548. {
  9549. entity.OrderState = 6;
  9550. }
  9551. }
  9552. entity.Update();
  9553. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9554. if (withdraw != null)
  9555. {
  9556. withdraw.status = int.Parse(reason);
  9557. withdraw.Update();
  9558. }
  9559. returnSuccessMsg("操作成功!");
  9560. return;
  9561. }
  9562. else
  9563. {
  9564. withdraw.status = int.Parse(reason);
  9565. withdraw.acknowledgingtime = DateTime.Now;
  9566. withdraw.Update();
  9567. returnSuccessMsg("查看详细请点击线下订单查询");
  9568. return;
  9569. }
  9570. }
  9571. }
  9572. // 第一个字符是 'N'
  9573. }
  9574. if (eid[0] != 'N')
  9575. {
  9576. }
  9577. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9578. {
  9579. entity.IsVerifyToSupplier = false;
  9580. entity.IsReturn = 1;
  9581. entity.ReturnTime = DateTime.Now;
  9582. entity.ReturnReason = reason;
  9583. if (entity.OrderState == 6)
  9584. {
  9585. entity.OrderState = 5;
  9586. }
  9587. entity.Update();
  9588. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9589. if (withdraw != null)
  9590. {
  9591. withdraw.status = int.Parse(reason);
  9592. withdraw.Update();
  9593. }
  9594. returnSuccessMsg("操作成功!");
  9595. return;
  9596. }
  9597. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9598. {
  9599. ;
  9600. if (withdraw != null)
  9601. {
  9602. withdraw.status = int.Parse(reason);
  9603. withdraw.acknowledgingtime = DateTime.Now;
  9604. withdraw.Update();
  9605. returnSuccessMsg("供应商取消撤回!");
  9606. return;
  9607. }
  9608. }
  9609. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9610. {
  9611. if (entity.OrderState == -1)
  9612. {
  9613. if (entity.FinishPlaceTime == null)
  9614. {
  9615. entity.OrderState = 2;
  9616. }
  9617. else
  9618. {
  9619. entity.OrderState = 3;
  9620. }
  9621. commonHelper.getCytPrice(entity);
  9622. }
  9623. entity.Update();
  9624. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9625. if (withdraw != null)
  9626. {
  9627. withdraw.status = int.Parse(reason);
  9628. withdraw.Update();
  9629. }
  9630. returnSuccessMsg("操作成功!");
  9631. return;
  9632. }
  9633. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9634. {
  9635. if (withdraw == null)
  9636. {
  9637. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9638. return;
  9639. }
  9640. }
  9641. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9642. {
  9643. if (withdraw != null)
  9644. {
  9645. withdraw.status = int.Parse(reason);
  9646. withdraw.acknowledgingtime = DateTime.Now;
  9647. withdraw.Update();
  9648. returnSuccessMsg("查看详细请点击线下订单查询");
  9649. return;
  9650. }
  9651. }
  9652. return;
  9653. }
  9654. }
  9655. //校验报价
  9656. public void refund_order_tip()
  9657. {
  9658. int userid = CurrentUser.UserID;
  9659. int sectionId = CurrentUser.UserPost.OrgID;
  9660. StringBuilder sql = new StringBuilder();
  9661. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9662. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9663. List<string> ids = new List<string>();
  9664. if (dth.Rows.Count > 0)
  9665. {
  9666. foreach (DataRow dr in dth.Rows)
  9667. {
  9668. ids.Add(dr["ID"].ToString());
  9669. }
  9670. try
  9671. {
  9672. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9673. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9674. }
  9675. catch (Exception ex)
  9676. {
  9677. }
  9678. }
  9679. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9680. }
  9681. public void refund_order_Design()
  9682. {
  9683. int userid = CurrentUser.UserID;
  9684. int sectionId = CurrentUser.UserPost.OrgID;
  9685. StringBuilder sql = new StringBuilder();
  9686. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9687. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9688. List<string> ids = new List<string>();
  9689. if (dth.Rows.Count > 0)
  9690. {
  9691. foreach (DataRow dr in dth.Rows)
  9692. {
  9693. ids.Add(dr["ID"].ToString());
  9694. }
  9695. try
  9696. {
  9697. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9698. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9699. }
  9700. catch (Exception ex)
  9701. {
  9702. }
  9703. }
  9704. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9705. }
  9706. public void change_order_info()
  9707. {
  9708. int userid = CurrentUser.UserID;
  9709. StringBuilder sql = new StringBuilder();
  9710. 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);
  9711. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9712. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9713. }
  9714. public void change_win_mome()
  9715. {
  9716. if (UrlPostParmsCheck("id,ctid"))
  9717. {
  9718. string id = GetPostString("id");
  9719. string ctid = GetPostString("ctid");
  9720. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9721. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9722. if (ce == null || ceErpMessageTip == null)
  9723. {
  9724. returnSuccessMsg("未找到对应的订单!");
  9725. return;
  9726. }
  9727. if (ce.OrderState >= 5)
  9728. {
  9729. returnSuccessMsg("已上传文件无法修改!");
  9730. return;
  9731. }
  9732. int type = GetPostInt("type");
  9733. string content = GetPostString("content");
  9734. if (type == 0)
  9735. {
  9736. content = content.Replace("(", "(");
  9737. content = content.Replace(")", ")");
  9738. string check = MidStrEx(content, "(", ")").Trim();
  9739. if (string.IsNullOrEmpty(check))
  9740. {
  9741. returnSuccessMsg("文件名格式不正确");
  9742. return;
  9743. }
  9744. }
  9745. ce.seller_memo = content;
  9746. ce.Update();
  9747. ceErpMessageTip.isVisit = true;
  9748. ceErpMessageTip.Update();
  9749. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9750. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9751. ApiVo apiVo = new ApiVo();
  9752. apiVo.orderNumber = ce.ctid;
  9753. apiVo.actionName = "demandDesign";
  9754. apiVo.orderRemarks = content;
  9755. apiVo.demandExamine = type + 1;
  9756. designHelper.API_WorkCore(apiVo);//demandDesign
  9757. returnSuccessMsg("修改成功!");
  9758. }
  9759. }
  9760. public static string MidStrEx(string sourse, string startstr, string endstr)
  9761. {
  9762. string result = string.Empty;
  9763. int startindex, endindex;
  9764. try
  9765. {
  9766. startindex = sourse.IndexOf(startstr);
  9767. if (startindex == -1)
  9768. return result;
  9769. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9770. endindex = tmpstr.IndexOf(endstr);
  9771. if (endindex == -1)
  9772. return result;
  9773. result = tmpstr.Remove(endindex);
  9774. }
  9775. catch (Exception ex)
  9776. {
  9777. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9778. }
  9779. return result;
  9780. }
  9781. public void refund_order_list()
  9782. {
  9783. int userid = CurrentUser.UserID;
  9784. int sectionId = CurrentUser.UserPost.OrgID;
  9785. StringBuilder sql = new StringBuilder();
  9786. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9787. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9788. DataStruct dStruct = GetPostStruct();
  9789. DataTable dt = null;
  9790. List<string> ids = new List<string>();
  9791. List<string> tids = new List<string>();
  9792. if (dth.Rows.Count > 0)
  9793. {
  9794. foreach (DataRow dr in dth.Rows)
  9795. {
  9796. tids.Add("'" + dr["tid"].ToString() + "'");
  9797. ids.Add(dr["id"].ToString());
  9798. }
  9799. try
  9800. {
  9801. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9802. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9803. List<string> lw = new List<string>();
  9804. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9805. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9806. dt = WebCache.GetData("view_orderlist", dStruct);
  9807. }
  9808. catch (Exception ex)
  9809. {
  9810. }
  9811. }
  9812. writeGridDataTableJson(dStruct.TotalCount, dt);
  9813. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9814. }
  9815. //新增
  9816. public void order_batch_downloads()
  9817. {
  9818. string ceid = GetPostString("tid");
  9819. String[] tid = ceid.Split(',');
  9820. order_batch_caiyingtong(tid);
  9821. /* (string success, string errors) = UploadFiles(tid);
  9822. returnSuccessMsg(success + errors);*/
  9823. return;
  9824. }
  9825. //报价接口
  9826. public void Get_To_Quote()
  9827. {
  9828. string ceid = GetPostString("ctid");
  9829. if (ceid != null)
  9830. {
  9831. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9832. if (entity != null)
  9833. {
  9834. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9835. {
  9836. return;
  9837. }
  9838. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9839. double price = 0;
  9840. if (cp == null)
  9841. {
  9842. JObject jsonObject12 = new JObject
  9843. {
  9844. { "UserId", "77886" },
  9845. { "Pwd", "lt666888" },
  9846. { "Filename", entity.seller_memo }
  9847. };
  9848. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9849. JObject jsonObjects1 = JObject.Parse(response1);
  9850. string ms1g = (string)jsonObjects1["msg"];
  9851. if (ms1g == "报价成功")
  9852. {
  9853. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9854. string data = (string)jsonObject1["price"];
  9855. 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 + "');";
  9856. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9857. returnSuccessMsg("获取报价成功:" + data);
  9858. price = Convert.ToDouble(data);
  9859. }
  9860. else
  9861. {
  9862. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9863. return;
  9864. }
  9865. }
  9866. String[] beizhu = entity.seller_memo.Split('-');
  9867. String chanp = "";
  9868. if (beizhu.Length > 0)
  9869. {
  9870. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9871. }
  9872. else
  9873. {
  9874. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9875. }
  9876. JObject jsonObject = new JObject
  9877. {
  9878. { "UserId", "77886" },
  9879. { "Pwd", "lt666888" },
  9880. { "Filename", chanp }
  9881. };
  9882. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9883. JObject jsonObjects = JObject.Parse(response);
  9884. string msg = (string)jsonObjects["msg"];
  9885. if (msg == "报价成功")
  9886. {
  9887. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9888. string data = (string)jsonObject1["price"];
  9889. 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 + "');";
  9890. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9891. returnSuccessMsg("获取报价成功:" + data);
  9892. price = Convert.ToDouble(data);
  9893. }
  9894. else
  9895. {
  9896. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9897. return;
  9898. }
  9899. if (price > 0)
  9900. {
  9901. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9902. if (ceErpTradeCellExtend == null)
  9903. {
  9904. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9905. ceErpTradeCellExtend.ctid = entity.ctid;
  9906. ceErpTradeCellExtend.payment_cyt = price;
  9907. ceErpTradeCellExtend.Create();
  9908. }
  9909. else
  9910. {
  9911. ceErpTradeCellExtend.payment_cyt = price;
  9912. ceErpTradeCellExtend.Update();
  9913. }
  9914. }
  9915. return;
  9916. }
  9917. }
  9918. else
  9919. {
  9920. returnErrorMsg("请至少选择一条数据");
  9921. return;
  9922. }
  9923. }
  9924. //新增
  9925. public void order_To_Supplier()
  9926. {
  9927. string ceid = GetPostString("tid");
  9928. String[] tid = ceid.Split(',');
  9929. if (tid.Length > 0)
  9930. {
  9931. try
  9932. {
  9933. for (int i = 0; i < tid.Length; i++)
  9934. {
  9935. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9936. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9937. entity.SupplierId = suid;
  9938. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9939. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9940. entity.Update();
  9941. }
  9942. }
  9943. catch (Exception ex)
  9944. {
  9945. returnErrorMsg("自动匹配供应商失败");
  9946. return;
  9947. }
  9948. }
  9949. else
  9950. {
  9951. returnErrorMsg("请至少选择一条数据");
  9952. return;
  9953. }
  9954. returnSuccessMsg("自动匹配供应商成功");
  9955. return;
  9956. }
  9957. public (string, string) UploadFiles(string[] urls)
  9958. {
  9959. string success = "";
  9960. string errors = "";
  9961. int userid = CurrentUser.UserID;
  9962. foreach (string url in urls)
  9963. {
  9964. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9965. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9966. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9967. {
  9968. JObject jsonObject = new JObject
  9969. {
  9970. { "Userid", "77886" },
  9971. { "pwd", "cyt86435015" },
  9972. { "content", base64FileContent },
  9973. { "ext", Path.GetExtension(fileName) }
  9974. };
  9975. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9976. JObject jsonObjects = JObject.Parse(response);
  9977. string msg = (string)jsonObjects["msg"];
  9978. if (msg.Equals("上传成功"))
  9979. {
  9980. success += url + " 上传成功";
  9981. }
  9982. else
  9983. {
  9984. errors += url + " 上传失败";
  9985. }
  9986. }
  9987. else
  9988. {
  9989. errors += url + " 格式出现问题";
  9990. }
  9991. }
  9992. if (urls.Length == 0)
  9993. {
  9994. return (success, errors);
  9995. }
  9996. return (success, errors);
  9997. }
  9998. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9999. {
  10000. return true; //总是接受
  10001. }
  10002. public static string HttpPost(string url, string param = null)
  10003. {
  10004. HttpWebRequest request;
  10005. //如果是发送HTTPS请求
  10006. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10007. {
  10008. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10009. request = WebRequest.Create(url) as HttpWebRequest;
  10010. request.ProtocolVersion = HttpVersion.Version10;
  10011. }
  10012. else
  10013. {
  10014. request = WebRequest.Create(url) as HttpWebRequest;
  10015. }
  10016. request.Method = "POST";
  10017. request.ContentType = "application/json";
  10018. request.Accept = "*/*";
  10019. request.Timeout = 120000;
  10020. request.AllowAutoRedirect = false;
  10021. StreamWriter requestStream = null;
  10022. WebResponse response = null;
  10023. string responseStr = null;
  10024. try
  10025. {
  10026. requestStream = new StreamWriter(request.GetRequestStream());
  10027. requestStream.Write(param);
  10028. requestStream.Close();
  10029. response = request.GetResponse();
  10030. if (response != null)
  10031. {
  10032. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10033. responseStr = reader.ReadToEnd();
  10034. reader.Close();
  10035. }
  10036. }
  10037. catch (Exception ex)
  10038. {
  10039. return ex.Message;
  10040. }
  10041. finally
  10042. {
  10043. request = null;
  10044. requestStream = null;
  10045. response = null;
  10046. }
  10047. return responseStr;
  10048. }
  10049. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10050. {
  10051. string base64FileContent;
  10052. string fileName;
  10053. using (WebClient webClient = new WebClient())
  10054. {
  10055. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10056. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10057. {
  10058. using (Stream stream = response.GetResponseStream())
  10059. {
  10060. using (MemoryStream memoryStream = new MemoryStream())
  10061. {
  10062. stream.CopyTo(memoryStream);
  10063. byte[] fileBytes = memoryStream.ToArray();
  10064. base64FileContent = Convert.ToBase64String(fileBytes);
  10065. fileName = response.Headers["Content-Disposition"];
  10066. if (!string.IsNullOrEmpty(fileName))
  10067. {
  10068. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10069. if (index >= 0)
  10070. {
  10071. fileName = fileName.Substring(index + 9).Trim('\"');
  10072. }
  10073. }
  10074. else
  10075. {
  10076. fileName = Path.GetFileName(downloadUrl);
  10077. }
  10078. }
  10079. }
  10080. }
  10081. }
  10082. return (fileName, base64FileContent);
  10083. }
  10084. //新增
  10085. public void order_batch_caiyingtong(string[] downloadUrls)
  10086. {
  10087. try
  10088. {
  10089. //遍历文件
  10090. DataStruct dStruct = GetPostStruct();
  10091. DataTable dt = null;
  10092. int userid = CurrentUser.UserID;
  10093. List<string> ids = new List<string>();//失败组
  10094. List<string> tids = new List<string>();
  10095. using (WebClient webClient = new WebClient())
  10096. {
  10097. foreach (var url in downloadUrls)
  10098. {
  10099. try
  10100. {
  10101. tids.Add("'" + url + "'");
  10102. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10103. if (entity != null)
  10104. {
  10105. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10106. if (cp == null)
  10107. {
  10108. JObject jsonObject = new JObject
  10109. {
  10110. { "Userid", "77886" },
  10111. { "pwd", "lt666888" },
  10112. { "Filename",entity.seller_memo }
  10113. };
  10114. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10115. JObject jsonObjects = JObject.Parse(response);
  10116. string msg = (string)jsonObjects["msg"];
  10117. if (msg == "报价成功")
  10118. {
  10119. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10120. DownloadAndConvertToBase64(url1);
  10121. }
  10122. else
  10123. {
  10124. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10125. }
  10126. }
  10127. else
  10128. {
  10129. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10130. JObject jsonObject = new JObject
  10131. {
  10132. { "Userid", "77886" },
  10133. { "pwd", "lt666888" },
  10134. { "Filename",chanp }
  10135. };
  10136. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10137. JObject jsonObjects = JObject.Parse(response);
  10138. string msg = (string)jsonObjects["msg"];
  10139. if (msg == "报价成功")
  10140. {
  10141. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10142. DownloadAndConvertToBase64(url1);
  10143. }
  10144. else
  10145. {
  10146. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10147. }
  10148. }
  10149. }
  10150. // 上传文件到FTP
  10151. }
  10152. catch (Exception ex)
  10153. {
  10154. Console.WriteLine($"An error occurred: {ex.Message}");
  10155. }
  10156. }
  10157. List<string> lw = new List<string>();
  10158. lw.Add(string.Format("( OrderState < 6 )"));
  10159. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10160. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10161. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10162. if (dt.Rows.Count > 0)
  10163. {
  10164. foreach (DataRow dr in dt.Rows)
  10165. {
  10166. ids.Add(dr["ctid"].ToString());
  10167. }
  10168. }
  10169. String ErrorMsgs = "";
  10170. foreach (String id in ids)
  10171. {
  10172. ErrorMsgs += id + ",";
  10173. }
  10174. if (ErrorMsgs.Length > 1)
  10175. {
  10176. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10177. }
  10178. if (ErrorMsgs.Length < 1)
  10179. {
  10180. ErrorMsgs = "上传成功";
  10181. returnSuccessMsg(ErrorMsgs);
  10182. }
  10183. else
  10184. {
  10185. returnErrorMsg("以下订单" + ErrorMsgs);
  10186. }
  10187. }
  10188. // 删除文件夹及其内容
  10189. /* Directory.Delete(localDirectory, true);*/
  10190. }
  10191. catch { }
  10192. }
  10193. public void get_center_data()
  10194. {
  10195. int userId = CurrentUser.UserID;
  10196. string postCode = CurrentUser.UserPost.Post.Code;
  10197. List<string> lw = new List<string>();
  10198. List<string> ww = new List<string>();
  10199. DateTime currentTime = DateTime.Now;
  10200. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10201. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10202. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10203. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10204. string sql = " SELECT ";
  10205. string startTime = "2023-10-01 11:22:31";
  10206. //设计
  10207. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10208. {
  10209. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10210. 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));
  10211. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10212. 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));
  10213. }
  10214. //客服
  10215. else if (postCode == "CustomerService" || postCode == "Director")
  10216. {
  10217. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10218. 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));
  10219. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10220. 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));
  10221. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10222. 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));
  10223. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10224. 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));
  10225. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10226. 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));
  10227. }
  10228. //售后
  10229. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10230. {
  10231. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10232. 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));
  10233. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10234. 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));
  10235. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10236. 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));
  10237. }
  10238. //下单部
  10239. else if (postCode == "Place" || postCode == "PlaceMr")
  10240. {
  10241. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10242. 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));
  10243. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10244. 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));
  10245. }
  10246. //车间
  10247. else if (postCode == "Supplier")
  10248. {
  10249. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10250. 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));
  10251. }
  10252. DataTable dt = new DataTable();
  10253. if (lw.Count > 0)
  10254. {
  10255. sql += string.Join(" , ", lw);
  10256. sql += " FROM ";
  10257. sql += string.Join(" , ", ww);
  10258. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10259. }
  10260. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10261. }
  10262. public void get_center_data_list()
  10263. {
  10264. int userId = CurrentUser.UserID;
  10265. string postCode = CurrentUser.UserPost.Post.Code;
  10266. string shopIds = CurrentUser.User.pemShop;
  10267. DataStruct dStruct = GetPostStruct();
  10268. List<string> lw = new List<string>();
  10269. DateTime currentTime = DateTime.Now;
  10270. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10271. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10272. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10273. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10274. string startTime = "2023-10-01 11:22:31";
  10275. int order_type = GetPostInt("order_type");
  10276. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10277. {
  10278. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10279. if (order_type == 0)
  10280. {
  10281. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10282. }
  10283. else if (order_type == 3)
  10284. {
  10285. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10286. }
  10287. else
  10288. {
  10289. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10290. }
  10291. }
  10292. //客服
  10293. if (postCode == "CustomerService" || postCode == "Director")
  10294. {
  10295. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10296. if (order_type == 0)
  10297. {
  10298. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10299. }
  10300. else if (order_type == 1)
  10301. {
  10302. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10303. }
  10304. else if (order_type == 2)
  10305. {
  10306. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10307. }
  10308. else if (order_type == 3)
  10309. {
  10310. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10311. }
  10312. else if (order_type == 4)
  10313. {
  10314. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10315. }
  10316. else
  10317. {
  10318. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10319. }
  10320. }
  10321. //售后
  10322. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10323. {
  10324. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10325. if (shopIds != "")
  10326. {
  10327. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10328. }
  10329. if (order_type == 2)
  10330. {
  10331. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10332. }
  10333. else if (order_type == 4)
  10334. {
  10335. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10336. }
  10337. else if (order_type == 5)
  10338. {
  10339. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10340. }
  10341. else
  10342. {
  10343. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10344. }
  10345. }
  10346. //下单部
  10347. if (postCode == "Place" || postCode == "PlaceMr")
  10348. {
  10349. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10350. if (shopIds != "")
  10351. {
  10352. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10353. }
  10354. else if (order_type == 1)
  10355. {
  10356. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10357. }
  10358. else if (order_type == 2)
  10359. {
  10360. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10361. }
  10362. else
  10363. {
  10364. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10365. }
  10366. }
  10367. //车间
  10368. if (postCode == "Supplier")
  10369. {
  10370. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10371. if (order_type == 5)
  10372. {
  10373. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10374. }
  10375. else
  10376. {
  10377. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10378. }
  10379. }
  10380. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10381. dStruct.Fileds = "tid,ctid";
  10382. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10383. writeGridDataTableJson(dStruct.TotalCount, dt);
  10384. }
  10385. public void aftersale_audit_master()
  10386. {
  10387. if (UrlPostParmsCheck("ctid"))
  10388. {
  10389. string ctid = GetPostString("ctid");
  10390. if (ctid.Length > 0)
  10391. {
  10392. bool result = aftersale_data_change(ctid);
  10393. if (result)
  10394. {
  10395. returnSuccessMsg("修改成功!");
  10396. return;
  10397. }
  10398. }
  10399. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10400. }
  10401. }
  10402. public void aftersale_batch_audit_master()
  10403. {
  10404. if (UrlPostParmsCheck("ctids"))
  10405. {
  10406. string ctids = GetPostString("ctids");
  10407. if (ctids.Length > 0)
  10408. {
  10409. List<string> list = new List<string>();
  10410. string[] ctid_list = ctids.Split(',');
  10411. foreach (var item in ctid_list)
  10412. {
  10413. bool result = aftersale_data_change(item);
  10414. if (!result)
  10415. {
  10416. list.Add(item);
  10417. }
  10418. }
  10419. if (list.Count > 0)
  10420. {
  10421. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10422. return;
  10423. }
  10424. returnSuccessMsg("修改成功!");
  10425. return;
  10426. }
  10427. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10428. }
  10429. }
  10430. public bool aftersale_data_change(string ctid)
  10431. {
  10432. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10433. if (ceErpTradeCell != null)
  10434. {
  10435. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10436. ceErpTradeCell.AfterSaleSupplierState = 0;
  10437. StringBuilder sql = new StringBuilder();
  10438. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10439. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10440. CeErpTradeResponsible.DelByTid(ctid, 0);
  10441. 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 == "不理赔")
  10442. {
  10443. CeErpTradeResponsible.DelByTid(ctid, 1);
  10444. ceErpTradeCell.AfterSaleSupplierState = 1;
  10445. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10446. ceErpTradeCell.AfterSaleState = 4;
  10447. }
  10448. else
  10449. {
  10450. ceErpTradeCell.AfterSaleState = 3;
  10451. }
  10452. bool needCyt = false;
  10453. if (dt != null)
  10454. {
  10455. if (dt.Rows.Count == 1)
  10456. {
  10457. bool isEnd = false;
  10458. foreach (DataRow dr in dt.Rows)
  10459. {
  10460. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10461. {
  10462. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10463. isEnd = true;
  10464. }
  10465. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10466. {
  10467. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10468. isEnd = true;
  10469. }
  10470. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10471. {
  10472. needCyt = true;
  10473. }
  10474. }
  10475. if (isEnd)
  10476. {
  10477. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10478. ceErpTradeCell.AfterSaleState = 4;
  10479. ceErpTradeCell.AfterSaleSupplierState = 1;
  10480. }
  10481. }
  10482. else
  10483. {
  10484. bool isAll = true;
  10485. foreach (DataRow dr in dt.Rows)
  10486. {
  10487. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10488. {
  10489. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10490. continue;
  10491. }
  10492. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10493. {
  10494. string path = "";
  10495. int OrgID = 0;
  10496. if (!Convert.IsDBNull(dr["OrgPath"]))
  10497. {
  10498. path = dr["OrgPath"].ToString();
  10499. }
  10500. if (!Convert.IsDBNull(dr["OrgID"]))
  10501. {
  10502. OrgID = Convert.ToInt32(dr["OrgID"]);
  10503. }
  10504. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10505. {
  10506. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10507. continue;
  10508. }
  10509. }
  10510. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10511. {
  10512. needCyt = true;
  10513. }
  10514. isAll = false;
  10515. }
  10516. if (isAll)
  10517. {
  10518. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10519. ceErpTradeCell.AfterSaleState = 4;
  10520. ceErpTradeCell.AfterSaleSupplierState = 1;
  10521. }
  10522. }
  10523. }
  10524. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10525. {
  10526. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10527. }
  10528. if (ceErpTradeCell.AfterSaleState == 4)
  10529. {
  10530. ApiVo apiVo = new ApiVo();
  10531. apiVo.orderNumber = ceErpTradeCell.ctid;
  10532. apiVo.actionName = "afterOver";
  10533. designHelper.API_WorkCore(apiVo); //afterOver
  10534. }
  10535. ceErpTradeCell.Update();
  10536. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10537. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10538. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10539. return true;
  10540. }
  10541. return false;
  10542. }
  10543. public void get_erp_wechatorder()
  10544. {
  10545. DataStruct dStruct = GetPostStruct();
  10546. List<string> lw = new List<string>();
  10547. string tid = GetPostString("tid");
  10548. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10549. string shopname = GetPostString("shopname");
  10550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10551. string buyernick = GetPostString("buyer_nick");
  10552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10553. string customer = GetPostString("customer");
  10554. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10555. string returndate1 = GetPostString("returndate1");
  10556. string returndate2 = GetPostString("returndate2");
  10557. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10558. if (dw.Length > 0) lw.Add(dw);
  10559. string finishDate1 = GetPostString("finishdate1");
  10560. string finishDate2 = GetPostString("finishdate2");
  10561. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10562. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10563. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10564. dStruct.Order = "created desc";
  10565. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10566. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10567. writeGridDataTableJson(dStruct.TotalCount, dt);
  10568. }
  10569. public void get_erp_wechatlist_sumprice()
  10570. {
  10571. DataStruct dStruct = GetPostStruct();
  10572. List<string> lw = new List<string>();
  10573. string tid = GetPostString("tid");
  10574. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10575. string shopname = GetPostString("shopname");
  10576. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10577. string buyernick = GetPostString("buyer_nick");
  10578. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10579. string customer = GetPostString("customer");
  10580. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10581. string returndate1 = GetPostString("returndate1");
  10582. string returndate2 = GetPostString("returndate2");
  10583. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10584. if (dw.Length > 0) lw.Add(dw);
  10585. string finishDate1 = GetPostString("finishdate1");
  10586. string finishDate2 = GetPostString("finishdate2");
  10587. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10588. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10589. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10590. string mainWhere = string.Join(" and ", lw.ToArray());
  10591. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10592. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10593. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10594. decimal total = 0;
  10595. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10596. {
  10597. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10598. }
  10599. var res = new
  10600. {
  10601. data = total
  10602. };
  10603. string ro_jsond = JsonConvert.SerializeObject(res);
  10604. returnSuccess(ro_jsond);
  10605. return;
  10606. }
  10607. public void get_erp_qr_waitdeliverylist()
  10608. {
  10609. DataStruct dStruct = GetPostStruct();
  10610. List<string> lw = new List<string>();
  10611. string tid = GetPostString("ctid");
  10612. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10613. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10614. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10615. var res_objz = new
  10616. {
  10617. restype = 1,
  10618. data = dt
  10619. };
  10620. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10621. returnSuccess(ro_jsonz);
  10622. }
  10623. public void get_erp_yield_list()
  10624. {
  10625. DataStruct dStruct = GetPostStruct();
  10626. List<string> lw = new List<string>();
  10627. string tid = GetPostString("ctid");
  10628. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10629. string shopname = GetPostString("shopname");
  10630. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10631. string buyernick = GetPostString("buyer_nick");
  10632. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10633. //if (tid.Length == 0 && buyernick.Length == 0)
  10634. //{
  10635. // lw.Add(string.Format("IsRefund<={0}", 1));
  10636. //}
  10637. string customer = GetPostString("customer");
  10638. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10639. string design = GetPostString("design");
  10640. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10641. string orderState = GetPostString("orderState");
  10642. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10643. string address = GetPostString("address");
  10644. 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));
  10645. string sellermemo = GetPostString("seller_memo");
  10646. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10647. string supplier = GetPostString("supplier");
  10648. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10649. string OrderArea = GetPostString("order_area");
  10650. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10651. string placedate1 = GetPostString("placedate1");
  10652. string placedate2 = GetPostString("placedate2");
  10653. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10654. if (fdw.Length > 0) lw.Add(fdw);
  10655. string price1 = GetPostString("price1");
  10656. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10657. string price2 = GetPostString("price2");
  10658. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10659. string unusualCon = GetPostString("unusualcon");
  10660. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10661. string posTag = CurrentUser.UserPost.Post.Code;
  10662. if (posTag == "Supplier")
  10663. {
  10664. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10665. }
  10666. lw.Add(string.Format("OrderState = 6 "));
  10667. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10668. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10669. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10670. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10671. writeGridDataTableJson(dStruct.TotalCount, dt);
  10672. }
  10673. public void change_erp_sup_state()
  10674. {
  10675. if (UrlPostParmsCheck("ctid"))
  10676. {
  10677. string ctid = GetPostString("ctid");
  10678. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10679. if (ceErpTradeCell != null)
  10680. {
  10681. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10682. if (ceErpTradeCellExtend == null)
  10683. {
  10684. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10685. ceErpTradeCellExtend.ctid = ctid;
  10686. ceErpTradeCellExtend.SupState = 1;
  10687. ceErpTradeCellExtend.Create();
  10688. }
  10689. else
  10690. {
  10691. ceErpTradeCellExtend.SupState = 1;
  10692. ceErpTradeCellExtend.Update();
  10693. }
  10694. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10695. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10696. return;
  10697. }
  10698. returnErrorMsg("找不到订单");
  10699. }
  10700. }
  10701. public void supplier_all_downs()
  10702. {
  10703. if (UrlPostParmsCheck("tids"))
  10704. {
  10705. string tids = GetPostString("tids");
  10706. if (tids != null && tids.Length > 0)
  10707. {
  10708. StringBuilder sql = new StringBuilder();
  10709. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10710. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10711. sql = new StringBuilder();
  10712. 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, "下载设计文件");
  10713. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10714. string[] list = tids.Split(',');
  10715. foreach (string ctid in list)
  10716. {
  10717. CeErpSukuraData.createInfo(ctid, 3);
  10718. }
  10719. designHelper.api_approveDesign(tids); //approveDesign
  10720. returnSuccessMsg("下载成功!");
  10721. return;
  10722. }
  10723. returnErrorMsg("下载订单更新失败");
  10724. }
  10725. }
  10726. public void uploaderFileSuccess()
  10727. {
  10728. if (UrlPostParmsCheck("fileName"))
  10729. {
  10730. string fileName = GetPostString("fileName");
  10731. ApiVo apiVo = new ApiVo();
  10732. apiVo.orderNumber = fileName;
  10733. apiVo.actionName = "finishDesign";
  10734. designHelper.API_WorkCore(apiVo);//finishDesign
  10735. returnSuccessMsg("");
  10736. }
  10737. }
  10738. public void get_sample2_order()
  10739. {
  10740. if (UrlPostParmsCheck("ctid"))
  10741. {
  10742. string ctid = GetPostString("ctid");
  10743. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10744. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10745. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10746. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10747. double total = 0.0;
  10748. double order_price = 0.0;
  10749. if (dt_bu.Rows.Count > 0)
  10750. {
  10751. foreach (DataRow dr in dt_bu.Rows)
  10752. {
  10753. total += Convert.ToDouble(dr["payment"]);
  10754. }
  10755. }
  10756. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10757. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10758. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10759. string tid = ctid.Replace("S_", "");
  10760. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10761. double paymant = 0.0;
  10762. if (entity != null)
  10763. {
  10764. paymant = entity.payment;
  10765. }
  10766. string return_reason = "";
  10767. if (dt_after != null && dt_after.Rows.Count > 0)
  10768. {
  10769. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10770. }
  10771. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10772. }
  10773. }
  10774. public void get_erp_design_status()
  10775. {
  10776. string designName = GetPostString("designName");
  10777. DataStruct dStruct = GetPostStruct();
  10778. if (designName.Length > 0)
  10779. {
  10780. 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";
  10781. sql_user += " and Name like '%" + designName + "%'";
  10782. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10783. List<string> ids_list = new List<string>();
  10784. if (user_table.Rows.Count > 0)
  10785. {
  10786. foreach (DataRow item in user_table.Rows)
  10787. {
  10788. ids_list.Add(item["id"].ToString());
  10789. string ids_s = item["TeamIds"].ToString();
  10790. if (ids_s.Length > 0)
  10791. {
  10792. ids_list.AddRange(ids_s.Split(','));
  10793. }
  10794. }
  10795. }
  10796. HashSet<string> set = new HashSet<string>(ids_list);
  10797. ids_list = set.ToList();
  10798. if (ids_list.Count > 0)
  10799. {
  10800. 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));
  10801. dStruct.MainWhere = sql;
  10802. DataTable dt = null;
  10803. dt = WebCache.GetData("view_ErpUser", dStruct);
  10804. writeGridDataTableJson(dStruct.TotalCount, dt);
  10805. }
  10806. }
  10807. }
  10808. public void change_erp_order_price()
  10809. {
  10810. string ctid = GetPostString("ctid");
  10811. double price = GetPostDouble("price");
  10812. if (ctid.Length > 0)
  10813. {
  10814. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10815. if (ceErpTradeCellExtend == null)
  10816. {
  10817. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10818. ceErpTradeCellExtend.ctid = ctid;
  10819. ceErpTradeCellExtend.payment_cyt = price;
  10820. ceErpTradeCellExtend.Create();
  10821. }
  10822. else
  10823. {
  10824. ceErpTradeCellExtend.payment_cyt = price;
  10825. ceErpTradeCellExtend.Update();
  10826. }
  10827. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10828. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10829. {
  10830. ceErpDataSendOrderInfo.isSync = false;
  10831. ceErpDataSendOrderInfo.Update();
  10832. }
  10833. if (ceErpDataSendOrderInfo == null)
  10834. {
  10835. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10836. ceErpDataSendOrderInfo.isSync = false;
  10837. ceErpDataSendOrderInfo.ctid = ctid;
  10838. ceErpDataSendOrderInfo.Create();
  10839. }
  10840. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10841. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10842. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10843. if (dth != null && dth.Rows.Count > 0)
  10844. {
  10845. dataSendOrderBean dataSendOrderBean = null;
  10846. foreach (DataRow item in dth.Rows)
  10847. {
  10848. try
  10849. {
  10850. dataSendOrderBean = new dataSendOrderBean();
  10851. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10852. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10853. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10854. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10855. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10856. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10857. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10858. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10859. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10860. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10861. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10862. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10863. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10864. if (result != null)
  10865. {
  10866. if ("0".Equals(result.errcode))
  10867. {
  10868. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10869. }
  10870. else
  10871. {
  10872. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10873. }
  10874. }
  10875. }
  10876. catch (Exception ex)
  10877. {
  10878. }
  10879. }
  10880. }
  10881. returnSuccessMsg("修改成功!");
  10882. return;
  10883. }
  10884. returnErrorMsg("找不到订单");
  10885. }
  10886. public void find_he_together()
  10887. {
  10888. string ctid = GetPostString("ctid");
  10889. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10890. List<string> list = new List<string>();
  10891. if (ceErpTradeCell != null)
  10892. {
  10893. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10894. {
  10895. 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);
  10896. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10897. if (table != null && table.Rows.Count > 0)
  10898. {
  10899. foreach (TableRow row in table.Rows)
  10900. {
  10901. }
  10902. }
  10903. }
  10904. }
  10905. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10906. }
  10907. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10908. {
  10909. //chy----19
  10910. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10911. //GD-CYT-----64
  10912. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10913. //ZHX----3
  10914. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10915. //JK----97
  10916. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10917. //ZT----70
  10918. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10919. //LHCY-----98
  10920. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10921. //XD-----90
  10922. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10923. //CYCY-----14
  10924. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10925. };
  10926. //其他改名
  10927. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10928. {
  10929. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10930. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10931. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10932. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10933. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10934. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10935. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10936. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10937. };
  10938. //不统计
  10939. List<int> no_suppliers = new List<int>()
  10940. {
  10941. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10942. };
  10943. //配件单
  10944. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10945. {
  10946. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10947. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10948. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10949. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10950. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10951. {"旗杆",new List<string>(){ "班旗" } },
  10952. {"牙签",new List<string>(){ "不干胶" } }
  10953. };
  10954. public void get_place_order_data()
  10955. {
  10956. string date1 = GetPostString("date1");
  10957. string date2 = GetPostString("date2");
  10958. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10959. DateTime start = DateTime.Parse(starttime);
  10960. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10961. DateTime end = DateTime.Parse(endtime);
  10962. if (date1 != null && date1.Length > 0)
  10963. {
  10964. DateTime dateTime = DateTime.Parse(date1);
  10965. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10966. start = DateTime.Parse(starttime);
  10967. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10968. end = DateTime.Parse(endtime);
  10969. }
  10970. if (date2 != null && date2.Length > 0)
  10971. {
  10972. DateTime dateTime = DateTime.Parse(date2);
  10973. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10974. end = DateTime.Parse(endtime);
  10975. }
  10976. 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);
  10977. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10978. //不干胶-----1,卡片-----29
  10979. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10980. foreach (DataRow row in data.Rows)
  10981. {
  10982. int productId = Convert.ToInt32(row["ProductId"]);
  10983. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10984. if (no_suppliers.Contains(supplierId))
  10985. {
  10986. continue;
  10987. }
  10988. string seller_memo = row["seller_memo"].ToString();
  10989. bool ispj = false;//是否配件单
  10990. bool isfirst = true;//第一个配
  10991. maps.Keys.ForEach(key =>
  10992. {
  10993. //备注包含配件
  10994. if (seller_memo.Contains(key) && isfirst)
  10995. {
  10996. List<string> list = maps[key];
  10997. ispj = true;
  10998. isfirst = false;
  10999. for (int i = 0; i < list.Count; i++)
  11000. {
  11001. if (seller_memo.Contains(list[i]))
  11002. {
  11003. ispj = false;
  11004. break;
  11005. }
  11006. }
  11007. }
  11008. });
  11009. if (ispj)
  11010. {
  11011. continue;
  11012. }
  11013. seller_memo = seller_memo.Replace("UV", "uv");
  11014. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11015. //吊牌归到卡片
  11016. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11017. seller_memo = seller_memo.Replace("卡套", "卡片");
  11018. seller_memo = seller_memo.Replace("封套", "卡片");
  11019. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11020. seller_memo = seller_memo.Replace("腰封", "卡片");
  11021. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11022. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11023. seller_memo = seller_memo.Replace("横幅", "条幅");
  11024. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11025. string map_key = "";
  11026. string type = "";
  11027. if (supplierMap.ContainsKey(supplierId))
  11028. {
  11029. foreach (var kvp in supplierMap[supplierId])
  11030. {
  11031. if (seller_memo.Contains(kvp.Key))
  11032. {
  11033. map_key = kvp.Value;
  11034. type = kvp.Value;
  11035. break;
  11036. }
  11037. }
  11038. }
  11039. if (map_key == "")
  11040. {
  11041. type = "其他";
  11042. map_key = "其他";
  11043. }
  11044. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11045. {
  11046. map_key = suppliers[supplierId];
  11047. }
  11048. if (supplierId == 70)
  11049. {
  11050. supplierId = 70;
  11051. }
  11052. map_key += "_" + row["SupplierName"].ToString();
  11053. Dictionary<string, int> map = null;
  11054. if (other_map.ContainsKey(map_key))
  11055. {
  11056. other_map.TryGetValue(map_key, out map);
  11057. }
  11058. else
  11059. {
  11060. map = new Dictionary<string, int>();
  11061. map.Add("dayDev", 0);//当天出货
  11062. map.Add("dayTotal", 0);//下单总数
  11063. map.Add("payTotal", 0);//500以上
  11064. map.Add("today", 0);//当天出货数量
  11065. map.Add("unusua", 0);//异常数
  11066. other_map.Add(map_key, map);
  11067. other_map.TryGetValue(map_key, out map);
  11068. }
  11069. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11070. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11071. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11072. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11073. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11074. {
  11075. map["dayTotal"]++;
  11076. if (supplierId == 97)
  11077. {
  11078. supplierId = 97;
  11079. }
  11080. }
  11081. if (Convert.ToDecimal(row["payment"]) >= 500)
  11082. {
  11083. map["payTotal"]++;
  11084. }
  11085. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11086. {
  11087. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11088. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11089. {
  11090. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11091. {
  11092. map["today"]++;
  11093. }
  11094. }
  11095. else
  11096. {
  11097. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11098. {
  11099. map["today"]++;
  11100. }
  11101. else
  11102. {
  11103. if (supplierId == 119)
  11104. {
  11105. Debug.WriteLine(row["seller_memo"].ToString());
  11106. }
  11107. }
  11108. }
  11109. }
  11110. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11111. {
  11112. map["unusua"]++;
  11113. }
  11114. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11115. //GD-CYT-----64
  11116. DateTime two = palceTimeStart.AddHours(14);
  11117. DateTime three = palceTimeStart.AddHours(15);
  11118. DateTime four = palceTimeStart.AddHours(16);
  11119. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11120. {
  11121. //下午四点前 500-1000
  11122. string count = row["ProductCount"].ToString();
  11123. if (count != null && count.Length > 0)
  11124. {
  11125. int productCount = commonHelper.getPlaceProductCount(count);
  11126. if (productCount >= 500 && productCount <= 1000)
  11127. {
  11128. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11129. {
  11130. map["dayDev"]++;
  11131. }
  11132. }
  11133. }
  11134. }
  11135. //UV
  11136. else if ("uv".Equals(type))
  11137. {
  11138. //ZT----70
  11139. //ZHX----3
  11140. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11141. {
  11142. map["dayDev"]++;
  11143. }
  11144. //JK----97
  11145. //HZX----105
  11146. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11147. {
  11148. map["dayDev"]++;
  11149. if (supplierId == 97)
  11150. {
  11151. supplierId = 97;
  11152. }
  11153. }
  11154. }
  11155. //帆布---52|条幅---27
  11156. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11157. {
  11158. //LHCY-----98
  11159. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11160. {
  11161. map["dayDev"]++;
  11162. }
  11163. }
  11164. //条幅
  11165. else if ("条幅".Equals(type))
  11166. {
  11167. //XD-----90
  11168. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11169. {
  11170. map["dayDev"]++;
  11171. }
  11172. }
  11173. //桌布
  11174. else if ("桌布".Equals(type))
  11175. {
  11176. //XD-----90
  11177. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11178. {
  11179. map["dayDev"]++;
  11180. }
  11181. }
  11182. //DL---10
  11183. //AYTW---119
  11184. //FS-CYT-DY ----80
  11185. //JK----97
  11186. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11187. {
  11188. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11189. {
  11190. map["dayDev"]++;
  11191. }
  11192. }
  11193. }
  11194. DataTable dt = new DataTable();
  11195. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11196. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11197. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11198. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11199. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11200. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11201. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11202. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11203. other_map.Keys.ForEach(key =>
  11204. {
  11205. DataRow dr = dt.NewRow();
  11206. Dictionary<string, int> map = other_map[key];
  11207. string[] key_list = key.Split('_');
  11208. dr[0] = key_list[0];
  11209. dr[1] = key_list[1];
  11210. if (key_list.Length > 2)
  11211. {
  11212. dr[1] += "(" + key_list[2] + ")";
  11213. }
  11214. dr[2] = map["dayTotal"];
  11215. dr[3] = map["payTotal"];
  11216. dr[4] = map["today"];
  11217. dr[5] = map["unusua"];
  11218. dr[6] = map["dayDev"];
  11219. double rate = 0.00;
  11220. if (map["dayDev"] > 0)
  11221. {
  11222. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11223. }
  11224. dr[7] = rate.ToString();
  11225. dt.Rows.Add(dr);
  11226. });
  11227. DataView dv = new DataView(dt);
  11228. dv.Sort = "SupplierName";
  11229. //dv.Sort = "AllOrder desc";
  11230. DataTable dtNew = dv.ToTable();
  11231. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11232. }
  11233. public void check_order_desing_info()
  11234. {
  11235. string ctid = GetPostString("ctid");
  11236. if (!string.IsNullOrEmpty(ctid))
  11237. {
  11238. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11239. if (ceErpTradeCell != null)
  11240. {
  11241. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11242. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11243. return;
  11244. }
  11245. returnErrorMsg("找不到订单");
  11246. return;
  11247. }
  11248. returnErrorMsg("找不到订单");
  11249. }
  11250. public void get_timeout_detail()
  11251. {
  11252. string poscode = CurrentUser.UserPost.Post.Code;
  11253. DataStruct dStruct = GetPostStruct();
  11254. List<string> lw = new List<string>();
  11255. string id = GetPostString("id");
  11256. string pay_date1 = GetPostString("pay_date1");
  11257. string pay_date2 = GetPostString("pay_date2");
  11258. int type = GetPostInt("type");
  11259. if (type == 0)
  11260. {
  11261. if (pay_date1.Length > 0)
  11262. {
  11263. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11264. }
  11265. if (pay_date2.Length > 0)
  11266. {
  11267. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11268. }
  11269. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11270. }
  11271. if (type == 1)
  11272. {
  11273. if (pay_date1.Length > 0)
  11274. {
  11275. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11276. }
  11277. if (pay_date2.Length > 0)
  11278. {
  11279. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11280. }
  11281. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11282. }
  11283. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11284. DataTable dt = null;
  11285. dt = WebCache.GetData("view_orderlist", dStruct);
  11286. writeGridDataTableJson(dStruct.TotalCount, dt);
  11287. }
  11288. public void saveUrgentChargePrice()
  11289. {
  11290. string ctid = GetPostString("ctid");
  11291. if (!string.IsNullOrEmpty(ctid))
  11292. {
  11293. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11294. if (ceErpTradeCell != null)
  11295. {
  11296. double price = GetPostDouble("price");
  11297. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11298. if (ceErpTradeCellExtend == null)
  11299. {
  11300. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11301. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11302. }
  11303. ceErpTradeCellExtend.urgentCharge = price;
  11304. if (ceErpTradeCellExtend.ID > 0)
  11305. {
  11306. ceErpTradeCellExtend.Update();
  11307. }
  11308. else
  11309. {
  11310. ceErpTradeCellExtend.Save();
  11311. }
  11312. returnSuccessMsg("修改成功!");
  11313. return;
  11314. }
  11315. returnErrorMsg("找不到订单");
  11316. return;
  11317. }
  11318. returnErrorMsg("找不到订单");
  11319. }
  11320. public void finish_erp_order()
  11321. {
  11322. string ctid = GetPostString("ctid");
  11323. if (!string.IsNullOrEmpty(ctid))
  11324. {
  11325. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11326. {
  11327. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11328. if (ceErpTradeCell != null)
  11329. {
  11330. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11331. ceErpTradeCell.Update();
  11332. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11333. returnSuccessMsg("修改成功!");
  11334. return;
  11335. }
  11336. }
  11337. }
  11338. returnErrorMsg("找不到订单");
  11339. }
  11340. public void get_trade_order_list()
  11341. {
  11342. string tid = GetPostString("tid");
  11343. if (!string.IsNullOrEmpty(tid))
  11344. {
  11345. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11346. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11347. writeGridDataTableJson(data.Rows.Count, data);
  11348. return;
  11349. }
  11350. returnErrorMsg("找不到订单");
  11351. }
  11352. public void save_cell_spu()
  11353. {
  11354. string ctid = GetPostString("ctid");
  11355. string spu_id = GetPostString("spu_id");
  11356. if (!string.IsNullOrEmpty(ctid))
  11357. {
  11358. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11359. if (ceErpTradeCellExtend == null)
  11360. {
  11361. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11362. ceErpTradeCellExtend.ctid = ctid;
  11363. }
  11364. ceErpTradeCellExtend.spu_id = spu_id;
  11365. if (ceErpTradeCellExtend.ID == 0)
  11366. {
  11367. ceErpTradeCellExtend.Create();
  11368. }
  11369. else
  11370. {
  11371. ceErpTradeCellExtend.Update();
  11372. }
  11373. returnSuccessMsg("修改成功!");
  11374. return;
  11375. }
  11376. returnErrorMsg("找不到订单");
  11377. }
  11378. public void change_express_info()
  11379. {
  11380. string ctid = GetPostString("ctid");
  11381. string transNo = GetPostString("transNo");
  11382. string transCom = GetPostString("transCom");
  11383. if (!string.IsNullOrEmpty(ctid))
  11384. {
  11385. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11386. if (ceErpTradeCellExtend == null)
  11387. {
  11388. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11389. ceErpTradeCellExtend.ctid = ctid;
  11390. }
  11391. ceErpTradeCellExtend.modExpressNo = transNo;
  11392. ceErpTradeCellExtend.modExpressCom = transCom;
  11393. ceErpTradeCellExtend.readMod = 2;
  11394. if (ceErpTradeCellExtend.ID == 0)
  11395. {
  11396. ceErpTradeCellExtend.Create();
  11397. }
  11398. else
  11399. {
  11400. ceErpTradeCellExtend.Update();
  11401. }
  11402. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11403. returnSuccessMsg("修改成功!");
  11404. return;
  11405. }
  11406. returnErrorMsg("找不到订单");
  11407. }
  11408. public void get_change_express_list()
  11409. {
  11410. DataStruct dStruct = GetPostStruct();
  11411. List<string> lw = new List<string>();
  11412. int st = 2;
  11413. string tid = GetPostString("ctid");
  11414. if (tid.Length > 0)
  11415. {
  11416. string select_tid = getTidByCtid(tid);
  11417. lw.Add(string.Format("tid='{0}'", select_tid));
  11418. }
  11419. string shopname = GetPostString("shopname");
  11420. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11421. string buyernick = GetPostString("buyer_nick");
  11422. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11423. string sellermemo = GetPostString("seller_memo");
  11424. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11425. string supplier = GetPostString("supplier");
  11426. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11427. string customer = GetPostString("customer");
  11428. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11429. string design = GetPostString("design");
  11430. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11431. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11432. string poscode = CurrentUser.UserPost.Post.Code;
  11433. if (poscode != "SysAdmin")
  11434. {
  11435. string shopid = CurrentUser.User.pemShop;
  11436. lw.Add(string.Format("shopId in ({0})", shopid));
  11437. }
  11438. lw.Add("readMod = 2");
  11439. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11440. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11441. writeGridDataTableJson(dStruct.TotalCount, dt);
  11442. }
  11443. public void deal_express_complete()
  11444. {
  11445. string ctid = GetPostString("ctid");
  11446. if (!string.IsNullOrEmpty(ctid))
  11447. {
  11448. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11449. if (ceErpTradeCellExtend == null)
  11450. {
  11451. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11452. ceErpTradeCellExtend.ctid = ctid;
  11453. }
  11454. ceErpTradeCellExtend.readMod = 1;
  11455. if (ceErpTradeCellExtend.ID == 0)
  11456. {
  11457. ceErpTradeCellExtend.Create();
  11458. }
  11459. else
  11460. {
  11461. ceErpTradeCellExtend.Update();
  11462. }
  11463. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11464. returnSuccessMsg("修改成功!");
  11465. return;
  11466. }
  11467. returnErrorMsg("找不到订单");
  11468. }
  11469. public void aftersale_return_visit()
  11470. {
  11471. string ctid = GetPostString("ctid");
  11472. if (!string.IsNullOrEmpty(ctid))
  11473. {
  11474. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11475. if (ceErpTradeCellExtend == null)
  11476. {
  11477. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11478. ceErpTradeCellExtend.ctid = ctid;
  11479. }
  11480. ceErpTradeCellExtend.returnVisit = 1;
  11481. if (ceErpTradeCellExtend.ID == 0)
  11482. {
  11483. ceErpTradeCellExtend.Create();
  11484. }
  11485. else
  11486. {
  11487. ceErpTradeCellExtend.Update();
  11488. }
  11489. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11490. if (ceErpTradeAfterSaleExtend != null)
  11491. {
  11492. ceErpTradeAfterSaleExtend.TextResult = "";
  11493. ceErpTradeAfterSaleExtend.Update();
  11494. }
  11495. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11496. returnSuccessMsg("修改成功!");
  11497. return;
  11498. }
  11499. returnErrorMsg("找不到订单");
  11500. }
  11501. public void orderPlaceInfo()
  11502. {
  11503. string ctids = GetPostString("ctids");
  11504. string[] list = ctids.Split(',');
  11505. foreach (string ctid in list)
  11506. {
  11507. CeErpSukuraData.createInfo(ctid, 3);
  11508. }
  11509. StringBuilder sql = new StringBuilder();
  11510. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11511. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11512. designHelper.api_approveDesign(ctids); //approveDesign
  11513. returnSuccessMsg("");
  11514. }
  11515. public void get_issue_list()
  11516. {
  11517. DataStruct dStruct = GetPostStruct();
  11518. List<string> lw = new List<string>();
  11519. int st = 2;
  11520. string tid = GetPostString("ctid");
  11521. if (tid.Length > 0)
  11522. {
  11523. string select_tid = getTidByCtid(tid);
  11524. lw.Add(string.Format("tid='{0}'", select_tid));
  11525. }
  11526. string shopname = GetPostString("shopname");
  11527. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11528. string buyernick = GetPostString("buyer_nick");
  11529. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11530. string sellermemo = GetPostString("seller_memo");
  11531. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11532. string supplier = GetPostString("supplier");
  11533. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11534. string customer = GetPostString("customer");
  11535. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11536. string design = GetPostString("design");
  11537. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11538. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11539. string poscode = CurrentUser.UserPost.Post.Code;
  11540. if (poscode != "SysAdmin")
  11541. {
  11542. string shopid = CurrentUser.User.pemShop;
  11543. lw.Add(string.Format("shopId in ({0})", shopid));
  11544. }
  11545. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11546. {
  11547. lw.Add("IssueState = 1");
  11548. }
  11549. lw.Add("IssueState > 0");
  11550. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11551. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11552. writeGridDataTableJson(dStruct.TotalCount, dt);
  11553. }
  11554. public void saveIssueContent()
  11555. {
  11556. string ctid = GetPostString("ctid");
  11557. if (!string.IsNullOrEmpty(ctid))
  11558. {
  11559. string content = GetPostString("content");
  11560. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11561. if (ceErpTradeAfterSaleExtend == null)
  11562. {
  11563. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11564. ceErpTradeAfterSaleExtend.tid = ctid;
  11565. }
  11566. ceErpTradeAfterSaleExtend.IssueContent = content;
  11567. ceErpTradeAfterSaleExtend.IssueState = 1;
  11568. if (ceErpTradeAfterSaleExtend.ID > 0)
  11569. {
  11570. ceErpTradeAfterSaleExtend.Update();
  11571. }
  11572. else
  11573. {
  11574. ceErpTradeAfterSaleExtend.Create();
  11575. }
  11576. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11577. returnSuccessMsg("添加成功!");
  11578. return;
  11579. }
  11580. returnErrorMsg("找不到订单");
  11581. }
  11582. public void dealIssueContent()
  11583. {
  11584. string ctid = GetPostString("ctid");
  11585. if (!string.IsNullOrEmpty(ctid))
  11586. {
  11587. string content = GetPostString("content");
  11588. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11589. if (ceErpTradeAfterSaleExtend != null)
  11590. {
  11591. ceErpTradeAfterSaleExtend.IssueState = 2;
  11592. ceErpTradeAfterSaleExtend.Update();
  11593. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11594. returnSuccessMsg("修改完成!");
  11595. return;
  11596. }
  11597. }
  11598. returnErrorMsg("找不到订单");
  11599. }
  11600. public void set_tid_attachments()
  11601. {
  11602. string tid = GetPostString("tid");
  11603. string atta = GetPostString("atta");
  11604. if (!string.IsNullOrEmpty(tid))
  11605. {
  11606. if (string.IsNullOrEmpty(atta))
  11607. {
  11608. returnErrorMsg("文件地址为空");
  11609. return;
  11610. }
  11611. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11612. if (ceErpTradeCell != null)
  11613. {
  11614. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11615. if (ceErpTrade == null)
  11616. {
  11617. returnErrorMsg("找不到订单");
  11618. return;
  11619. }
  11620. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11621. bool isSend = false;
  11622. if (dt != null && dt.Rows.Count > 0)
  11623. {
  11624. foreach (DataRow row in dt.Rows)
  11625. {
  11626. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11627. {
  11628. isSend = true;
  11629. }
  11630. }
  11631. if (isSend)
  11632. {
  11633. returnErrorMsg("已发货无法修改");
  11634. return;
  11635. }
  11636. ceErpTrade.Attachments = atta;
  11637. ceErpTrade.Update();
  11638. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11639. returnSuccessMsg("上传成功!");
  11640. return;
  11641. }
  11642. }
  11643. }
  11644. returnErrorMsg("找不到订单");
  11645. }
  11646. public void get_tid_attachments()
  11647. {
  11648. string tid = GetPostString("tid");
  11649. if (!string.IsNullOrEmpty(tid))
  11650. {
  11651. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11652. if (ceErpTradeCell != null)
  11653. {
  11654. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11655. if (ceErpTrade == null)
  11656. {
  11657. returnErrorMsg("找不到订单");
  11658. return;
  11659. }
  11660. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11661. return;
  11662. }
  11663. }
  11664. returnErrorMsg("找不到订单");
  11665. }
  11666. public void check_erp_sameorders()
  11667. {
  11668. if (UrlPostParmsCheck("ctid"))
  11669. {
  11670. string eid = GetPostString("ctid");
  11671. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11672. if (entity != null)
  11673. {
  11674. StringBuilder sql = new StringBuilder();
  11675. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11676. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11677. List<string> ids = new List<string>();
  11678. if (dt != null && dt.Rows.Count > 1)
  11679. {
  11680. bool needhe = false;
  11681. foreach (DataRow dr in dt.Rows)
  11682. {
  11683. ids.Add("'" + dr["ctid"] + "'");
  11684. //备注有合包
  11685. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11686. {
  11687. needhe = true;
  11688. }
  11689. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11690. {
  11691. needhe = true;
  11692. }
  11693. //顺丰快递
  11694. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11695. {
  11696. needhe = true;
  11697. }
  11698. }
  11699. if (!needhe)
  11700. {
  11701. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11702. return;
  11703. }
  11704. sql = new StringBuilder();
  11705. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11706. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11707. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11708. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11709. foreach (DataRow dr in dt.Rows)
  11710. {
  11711. dr["dstate"] = 0;
  11712. dr["dnumber"] = 0;
  11713. foreach (DataRow row in dt1.Rows)
  11714. {
  11715. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11716. {
  11717. dr["dstate"] = 2;
  11718. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11719. }
  11720. }
  11721. if (eid.Equals(dr["ctid"].ToString()))
  11722. {
  11723. dr["dstate"] = 1;
  11724. }
  11725. }
  11726. }
  11727. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11728. return;
  11729. }
  11730. returnErrorMsg("未找到订单");
  11731. return;
  11732. }
  11733. returnErrorMsg("缺少必要的参数");
  11734. }
  11735. public void get_mark_number()
  11736. {
  11737. string eid = GetPostString("ctid");
  11738. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11739. if (entity != null)
  11740. {
  11741. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  11742. int current = 1;
  11743. if (ceErpDeliverMark == null)
  11744. {
  11745. StringBuilder sql = new StringBuilder();
  11746. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11747. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11748. List<string> ids = new List<string>();
  11749. if (dt != null && dt.Rows.Count > 1)
  11750. {
  11751. foreach (DataRow dr in dt.Rows)
  11752. {
  11753. ids.Add("'" + dr["ctid"] + "'");
  11754. }
  11755. //查询已有的编号
  11756. sql = new StringBuilder();
  11757. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11758. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11759. if (dt1 == null || dt1.Rows.Count == 0)
  11760. {
  11761. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  11762. List<int> list_number = new List<int>();
  11763. foreach (DataRow row in numbers.Rows)
  11764. {
  11765. list_number.Add(Convert.ToInt32(row["markNumber"]));
  11766. }
  11767. //查询空余编号
  11768. for (int i = 0; i < list_number.Count + 2; i++)
  11769. {
  11770. if (!list_number.Contains(current))
  11771. {
  11772. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  11773. //防止查询过程中有新数据生成
  11774. if (ceErpDeliverMark1 == null)
  11775. {
  11776. break;
  11777. }
  11778. }
  11779. current++;
  11780. }
  11781. }
  11782. else
  11783. {
  11784. foreach (DataRow row in dt1.Rows)
  11785. {
  11786. current = Convert.ToInt32(row["markNumber"]);
  11787. }
  11788. }
  11789. ceErpDeliverMark = new CeErpDeliverMark();
  11790. ceErpDeliverMark.ctid = eid;
  11791. ceErpDeliverMark.createtime = DateTime.Now;
  11792. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11793. if (ceErpTrade != null)
  11794. {
  11795. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  11796. }
  11797. ceErpDeliverMark.markNumber = current;
  11798. ceErpDeliverMark.Create();
  11799. }
  11800. }
  11801. else
  11802. {
  11803. current = ceErpDeliverMark.markNumber;
  11804. }
  11805. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  11806. return;
  11807. }
  11808. }
  11809. }
  11810. }