sync.order.cs 604 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //apiHelper.Api_SyncOrderByTime("598825");
  55. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  56. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  57. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  58. //banniuApiHelper.sendLogisticsInfo(null);
  59. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  60. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  61. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  62. //int sid = commonHelper.autoDistributeToSupplier(entity);
  63. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  64. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1744213772000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1744818568000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":270.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2214103531955/O1CN01DdUiJW1QJRIWIiuyV_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4295347347682697938\",\"refSkuId\":\"0\",\"refSpuId\":\"795632307774\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":30.0,\"singleFee\":270.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【优惠价】纸质书签定制古风可手写硬卡纸制作来图定做创意卡片打印logo高档异形卡书法古典标签小卡印刷中国风文创设计\",\"totalFee\":270.0,\"totalPrice\":30.0,\"totalSellPrice\":30.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1744213828000,\"openBuyerId\":\"AAHnRHraABkUZRPgSx30RW3E\",\"openBuyerNick\":\"s**\",\"openSellerNick\":\"福同鑫旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1744212346000,\"payTime\":1744213768000,\"payment\":270.0,\"platServiceFee\":0.0,\"posCode\":\"futongxin\",\"posId\":613307,\"postFee\":240.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"成都市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"成华区\",\"receiverId\":\"d3709f8bce7faa8f6cc4587ff26feb66$\",\"receiverState\":\"四川省\",\"receiverTown\":\"猛追湾街道\",\"refOid\":\"4295347347682697938\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"40x110mm-1000张-卡片-300克铜板纸-双面印刷覆哑膜直角裁切-summer67821-条条-打孔配流苏\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":270.0,\"totalPrice\":30.0,\"totalSellPrice\":30.0,\"type\":\"SALE\"}}");
  65. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. string select_tid = getTidByCtid(tid);
  110. lw.Add(string.Format("tid='{0}'", select_tid));
  111. }
  112. if (buyernick.Length > 0)
  113. {
  114. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  115. }
  116. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  117. if (dw.Length > 0)
  118. {
  119. lw.Add(dw);
  120. }
  121. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  122. {
  123. string usershop = CurrentUser.User.pemShop;
  124. lw.Add(string.Format("ShopId in ({0})", usershop));
  125. }
  126. }
  127. else
  128. {
  129. if (ex_psize == 0)
  130. {
  131. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  132. }
  133. if (PKey != "admin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. paramsCount++;
  138. }
  139. }
  140. string uploaddate1 = GetPostString("uploaddate1");
  141. string uploaddate2 = GetPostString("uploaddate2");
  142. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  143. if (update.Length > 0) lw.Add(update);
  144. string deliverydate1 = GetPostString("deliverydate1");
  145. string deliverydate2 = GetPostString("deliverydate2");
  146. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  147. if (deliverydate.Length > 0)
  148. {
  149. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  150. };
  151. string shopname = GetPostString("shopname");
  152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  153. string addwechat = GetPostString("addwechat");
  154. if (addwechat.Length > 0)
  155. {
  156. int addWt = Convert.ToInt32(addwechat);
  157. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  158. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  159. }
  160. string customer = GetPostString("customer");
  161. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  162. string design = GetPostString("design");
  163. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  164. string orderState = GetPostString("orderState");
  165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  166. string address = GetPostString("address");
  167. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  168. string sellermemo = GetPostString("seller_memo");
  169. if (sellermemo.Length > 0)
  170. {
  171. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  172. }
  173. string backReason = GetPostString("backReason");
  174. if (backReason.Length > 0)
  175. {
  176. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  177. }
  178. string apdate1 = GetPostString("apdate1");
  179. string apdate2 = GetPostString("apdate2");
  180. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  181. if (dwap.Length > 0) lw.Add(dwap);
  182. string price1 = GetPostString("price1");
  183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  184. string price2 = GetPostString("price2");
  185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  186. string isoldcustomer = GetPostString("isoldcus");
  187. string finishdate1 = GetPostString("finishdate1");
  188. string finishdate2 = GetPostString("finishdate2");
  189. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  190. bool isFinish = false;
  191. if (finishdate.Length > 0)
  192. {
  193. lw.Add(finishdate);
  194. isFinish = true;
  195. paramsCount++;
  196. }
  197. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  198. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  199. if (ex_psize > 0)
  200. {
  201. int UserID = CurrentUser.UserID;
  202. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  203. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  204. {
  205. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  206. }
  207. dStruct.Order = "pay_time desc";
  208. }
  209. string isNew = GetPostString("isNew");
  210. if (isNew == "true")
  211. {
  212. lw.Add(string.Format("IsNew = {0}", 1));
  213. }
  214. string overtime = GetPostString("overtime");
  215. if (overtime == "1")
  216. {
  217. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  218. }
  219. String usePost = CurrentUser.UserPost.Post.Code;
  220. if (usePost.Equals("Operation") == true)
  221. {
  222. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. else
  225. {
  226. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  227. }
  228. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  229. if (dStruct.PageSize == 100000)
  230. {
  231. dStruct.Order = "";
  232. }
  233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  234. DataTable dt = null;
  235. string tablename = "view_orderlist";
  236. if (isFinish)
  237. {
  238. tablename = "view_orderlist_end";
  239. }
  240. dt = WebCache.GetData(tablename, dStruct);
  241. if (dt != null && dt.Rows.Count > 0)
  242. {
  243. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  244. foreach (DataRow dr in dt.Rows)
  245. {
  246. try
  247. {
  248. if (dr["refund_fees"] != null)
  249. {
  250. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  251. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  252. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  253. if (payment == refund_fees)
  254. {
  255. dr["refund_fees"] = Math.Round(refund_fees, 2);
  256. }
  257. else if (refund_fees == total_fee)
  258. {
  259. dr["refund_fees"] = payment;
  260. }
  261. else
  262. {
  263. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  264. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  265. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  266. }
  267. }
  268. // 对象操作
  269. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  270. ceErpTradeCell.ctid = dr["ctid"].ToString();
  271. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  272. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  273. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  274. if (dStruct.PageSize != 100000)
  275. {
  276. if (dr["DispatchSort"].ToString() == "2")
  277. {
  278. dr["gongchuang"] = 200;
  279. }
  280. else
  281. {
  282. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  283. dr["gongchuang"] = response.code;
  284. }
  285. }
  286. }
  287. catch (NullReferenceException ex)
  288. {
  289. // 处理空引用异常
  290. dr["refund_fees"] = "0.00";
  291. }
  292. }
  293. }
  294. writeGridDataTableJson(dStruct.TotalCount, dt);
  295. }
  296. public void get_erp_orderlist_sumprice()
  297. {
  298. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  299. return;
  300. List<string> lw = new List<string>();
  301. string tid = GetPostString("ctid");
  302. string date1 = GetPostString("date1");
  303. string date2 = GetPostString("date2");
  304. if (tid.Length > 0 || date1.Length > 0)
  305. {
  306. lw.Add(string.Format("ctid like '%{0}%'", tid));
  307. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  308. if (dw.Length > 0) lw.Add(dw);
  309. }
  310. else
  311. {
  312. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  313. }
  314. string shopname = GetPostString("shopname");
  315. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  316. string buyernick = GetPostString("buyer_nick");
  317. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  318. string customer = GetPostString("customer");
  319. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  320. string design = GetPostString("design");
  321. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  322. string orderState = GetPostString("orderState");
  323. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  324. string address = GetPostString("address");
  325. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  326. string sellermemo = GetPostString("seller_memo");
  327. if (sellermemo.Length > 0)
  328. {
  329. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  330. }
  331. string apdate1 = GetPostString("apdate1");
  332. string apdate2 = GetPostString("apdate2");
  333. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  334. if (dwap.Length > 0) lw.Add(dwap);
  335. string price1 = GetPostString("price1");
  336. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  337. string price2 = GetPostString("price2");
  338. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  339. string isoldcustomer = GetPostString("isoldcus");
  340. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  341. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  342. if (PKey != "admin")
  343. {
  344. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  345. lw.Add(string.Format("shopId in ({0})", usershop));
  346. }
  347. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  348. string mainWhere = string.Join(" and ", lw.ToArray());
  349. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  350. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  351. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  352. decimal total = 0;
  353. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  354. {
  355. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  356. }
  357. var res = new
  358. {
  359. data = total
  360. };
  361. string ro_jsond = JsonConvert.SerializeObject(res);
  362. returnSuccess(ro_jsond);
  363. return;
  364. }
  365. public void get_erp_CustomerServiceGather()
  366. {
  367. string userWhere = "", orderWhere = "";
  368. List<string> lw = new List<string>();
  369. string customer = GetPostString("customer");
  370. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  371. string shopname = GetPostString("shopname");
  372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  373. string date1 = GetPostString("date1");
  374. string date2 = GetPostString("date2");
  375. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  376. if (dw.Length > 0) lw.Add(dw);
  377. orderWhere = string.Join(" and ", lw.ToArray());
  378. string sql = string.Format("select a.Name CusName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitRelease,0) WaitRelease, isnull(e.WaitRob,0) WaitRob, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  379. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  380. "left join " +
  381. "( " +
  382. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  383. ") as b on a.ID = b.CustomerUserId " +
  384. "left join " +
  385. "( " +
  386. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  387. ") as d on a.ID = d.CustomerUserId " +
  388. "left join " +
  389. "( " +
  390. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  391. ") as e on a.ID = e.CustomerUserId " +
  392. "left join " +
  393. "( " +
  394. " select CustomerUserId, RefundCount, RefundSum from " +
  395. " ( " +
  396. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  397. " from CE_ErpTradeRefund a " +
  398. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  399. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  400. " group by CustomerUserId " +
  401. " ) as a " +
  402. ") as f on a.ID = f.CustomerUserId " +
  403. "where a.PostCode = 'CustomerService'",
  404. userWhere, orderWhere);
  405. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  406. writeGridDataTableJson(dt.Rows.Count, dt);
  407. //writeGridDataTableJson(dt.Rows.Count, dt);
  408. }
  409. //设计汇总
  410. public void get_erp_DesignerGather()
  411. {
  412. string userWhere = "", orderWhere = "";
  413. List<string> lw = new List<string>();
  414. string Designer = GetPostString("designer");
  415. int org = GetPostInt("org");
  416. if (Designer.Length > 0)
  417. {
  418. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  419. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  420. }
  421. else if (org > 0)
  422. {
  423. userWhere = string.Format(" where OrgID ={0}", org);
  424. }
  425. string shopname = GetPostString("shopname");
  426. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  427. string state = GetPostString("state");
  428. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  429. string OrderArea = GetPostString("order_area");
  430. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  431. string date1 = GetPostString("date1");
  432. string date2 = GetPostString("date2");
  433. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  434. if (dw.Length > 0) lw.Add(dw);
  435. string UpDate1 = GetPostString("UpDate1");
  436. string UpDate2 = GetPostString("UpDate2");
  437. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  438. if (dw.Length > 0) lw.Add(dw);
  439. orderWhere = string.Join(" and ", lw.ToArray());
  440. string sql = string.Format("select *,cast(cast(z.DesignFinish as float) / (case z.AllOrder when 0 then 1 else z.AllOrder end) * 100 as numeric(18,2)) as FinalizationRate from (" +
  441. "select a.Name DesignerName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitDesign,0) WaitDesign, isnull(e.Designing,0) Designing, isnull(g.DesignFinish,0) DesignFinish, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  442. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  443. "left join " +
  444. "( " +
  445. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  446. ") as b on a.ID = b.DesignUserId " +
  447. "left join " +
  448. "( " +
  449. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  450. ") as d on a.ID = d.DesignUserId " +
  451. "left join " +
  452. "( " +
  453. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  454. ") as e on a.ID = e.DesignUserId " +
  455. "left join " +
  456. "( " +
  457. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  458. ") as g on a.ID = g.DesignUserId " +
  459. "left join " +
  460. "( " +
  461. " select CustomerUserId, RefundCount, RefundSum from " +
  462. " ( " +
  463. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  464. " from CE_ErpTradeRefund a " +
  465. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  466. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  467. " group by CustomerUserId " +
  468. " ) as a " +
  469. ") as f on a.ID = f.CustomerUserId " +
  470. "where a.PostCode = 'Designer') as z",
  471. userWhere, orderWhere);
  472. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  473. writeGridDataTableJson(dt.Rows.Count, dt);
  474. }
  475. //删除tradecell的订单
  476. public void del_erp_cellorder()
  477. {
  478. if (UrlPostParmsCheck("ctid"))
  479. {
  480. string eid = GetPostString("ctid");
  481. CeErpTradeCell.DelByCtid(eid);
  482. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  483. returnSuccessMsg("删除成功");
  484. }
  485. }
  486. public void clear_erp_refundstate()
  487. {
  488. if (UrlPostParmsCheck("ids"))
  489. {
  490. string eids = GetPostString("ids");
  491. string[] ctidList = eids.Split(',');
  492. foreach (string ctid in ctidList)
  493. {
  494. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  495. if (entity != null)
  496. {
  497. entity.IsRefund = 0;
  498. entity.Update();
  499. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  500. }
  501. else
  502. continue;
  503. }
  504. returnSuccessMsg("操作成功");
  505. return;
  506. }
  507. returnErrorMsg("缺少必要参数");
  508. }
  509. public void set_erp_urgency()
  510. {
  511. if (UrlPostParmsCheck("ctid"))
  512. {
  513. string eid = GetPostString("ctid");
  514. CeErpTradeCell entity = null;
  515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  516. if (entity != null)
  517. {
  518. string utime = GetPostString("urgencytime");
  519. if (utime.Length > 0)
  520. {
  521. entity.UrgencyTime = Convert.ToDateTime(utime);
  522. }
  523. else
  524. {
  525. returnErrorMsg("请选择加急时间");
  526. return;
  527. }
  528. if (entity.OrderState <= 4)
  529. {
  530. //entity.seller_memo = entity.seller_memo + "-加急";
  531. string smemo = entity.seller_memo;
  532. int kindex = smemo.IndexOf(")");
  533. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  534. if (lastoneStr != "-")
  535. {
  536. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  537. }
  538. string prememo = smemo.Substring(0, kindex + 2);
  539. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  540. int lastkindex = lastmemo.IndexOf("(");
  541. DateTime urgtime = Convert.ToDateTime(utime);
  542. string newlastmemo = "";
  543. if (lastkindex == 0)
  544. {
  545. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  546. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  547. }
  548. else
  549. {
  550. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  551. }
  552. entity.seller_memo = prememo + newlastmemo;
  553. }
  554. entity.IsUrgency = true;
  555. entity.UpdateTime = DateTime.Now;
  556. entity.Update();
  557. ApiVo apiVo = new ApiVo();
  558. apiVo.orderNumber = entity.ctid;
  559. apiVo.actionName = "changeDesign";
  560. apiVo.orderRemarks = entity.seller_memo;
  561. apiVo.remarkSign = 3;
  562. designHelper.API_WorkCore(apiVo); //changeDesign
  563. CeErpSukuraData.createInfo(entity.ctid, 7);
  564. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  565. returnSuccessMsg("设置成功!");
  566. return;
  567. }
  568. returnErrorMsg("找不到记录");
  569. }
  570. }
  571. public void set_erp_reset()
  572. {
  573. if (UrlPostParmsCheck("ctid"))
  574. {
  575. string eid = GetPostString("ctid");
  576. CeErpTradeCell entity = null;
  577. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  578. if (entity != null)
  579. {
  580. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  581. {
  582. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  583. {
  584. returnErrorMsg("财务要求已下单已发货无法重置");
  585. return;
  586. }
  587. }
  588. entity.IsUrgency = false;
  589. entity.seller_memo = "";
  590. entity.OtherMemo = "";
  591. entity.OrderState = 0;
  592. entity.IsReturn = 0;
  593. //entity.IsRefund = 0;
  594. entity.MemoOpt = 0;
  595. entity.AfterSaleState = 0;
  596. entity.AfterSaleResponsible = "";
  597. entity.AfterSaleUserId = 0;
  598. entity.IsNeedBill = 0;
  599. entity.CustomerUserId = 0;
  600. entity.DesignUserId = 0;
  601. entity.SupplierId = 0;
  602. entity.PlaceUserId = 0;
  603. entity.ptid = "";
  604. entity.IsSample = 0;
  605. entity.IsXianHuo = 0;
  606. entity.isDianziOrder = 0;
  607. entity.DispatchSort = 0;
  608. entity.FinishPlaceTime = null;
  609. entity.Update();
  610. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  611. if (trade != null)
  612. {
  613. trade.seller_memo = "";
  614. trade.Update();
  615. }
  616. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  617. returnSuccessMsg("重置成功!");
  618. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  619. if (desginBill != null)
  620. {
  621. desginBill.isDel = 1;
  622. desginBill.Update();
  623. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  624. }
  625. ApiVo apiVo = new ApiVo();
  626. apiVo.orderNumber = entity.ctid;
  627. apiVo.actionName = "resetDesign";
  628. designHelper.API_WorkCore(apiVo);//resetDesign
  629. return;
  630. }
  631. returnErrorMsg("找不到记录");
  632. }
  633. }
  634. public void save_erp_sellermemo()
  635. {
  636. if (UrlPostParmsCheck("ctid"))
  637. {
  638. string ctid = GetPostString("ctid");
  639. CeErpTradeCell entity = null;
  640. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  641. if (entity != null)
  642. {
  643. string memo = GetPostString("seller_memo");
  644. memo = memo.Replace(" ", "");
  645. if (memo.Contains("补差"))
  646. {
  647. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  648. return;
  649. }
  650. if (entity.seller_memo != memo)
  651. {
  652. if (entity.IsSample == 2)
  653. {
  654. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  655. return;
  656. }
  657. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  658. {
  659. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  660. {
  661. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  662. return;
  663. }
  664. }
  665. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  666. }
  667. commonHelper.getCytPrice(entity);
  668. int memoopt = GetPostInt("MemoOpt");
  669. Boolean ismemoopt = false;
  670. if (memoopt > 0)
  671. {
  672. string stropt = "";
  673. if (memoopt == 1)
  674. {
  675. stropt = "“改稿”";
  676. ismemoopt = true;
  677. }
  678. else if (memoopt == 2)
  679. {
  680. stropt = "“定稿”";
  681. }
  682. else if (memoopt == 3)
  683. {
  684. stropt = "“查货”";
  685. CeErpSukuraData.createInfo(entity.ctid, 6);
  686. }
  687. entity.MemoOpt = Convert.ToInt32(memoopt);
  688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  689. }
  690. if (entity.OrderState < 5)
  691. {
  692. memo = memo.Replace("(", "(");
  693. memo = memo.Replace(")", ")");
  694. }
  695. entity.seller_memo = memo;
  696. entity.UpdateTime = DateTime.Now;
  697. entity.Update();
  698. ApiVo apiVo = new ApiVo();
  699. apiVo.orderNumber = entity.ctid;
  700. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  701. apiVo.orderRemarks = memo;
  702. apiVo.remarkSign = memoopt;
  703. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  704. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  705. returnSuccessMsg("保存成功!");
  706. return;
  707. }
  708. returnErrorMsg("找不到记录");
  709. }
  710. }
  711. public void ins_erp_checkorder()
  712. {
  713. if (UrlPostParmsCheck("ctid"))
  714. {
  715. string ctid = GetPostString("ctid");
  716. CeErpTradeCell entity = null;
  717. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  718. if (entity != null)
  719. {
  720. if (entity.OrderState < 6)
  721. {
  722. returnErrorMsg("下单完成后才可查货");
  723. return;
  724. }
  725. /*if (entity.OrderState > 6)
  726. {
  727. returnErrorMsg("订单已发货");
  728. return;
  729. }*/
  730. if (entity.FinishPlaceTime != null)
  731. {
  732. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  733. {
  734. returnErrorMsg("下单时间不足,无法查货");
  735. return;
  736. }
  737. }
  738. entity.MemoOpt = 3;
  739. entity.CheckOrderTime = DateTime.Now;
  740. entity.UpdateTime = DateTime.Now;
  741. entity.Update();
  742. CeErpSukuraData.createInfo(entity.ctid, 6);
  743. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  744. returnSuccessMsg("操作成功!");
  745. return;
  746. }
  747. returnErrorMsg("找不到记录");
  748. }
  749. }
  750. public void save_erp_othermemo()
  751. {
  752. if (UrlPostParmsCheck("ctid"))
  753. {
  754. string ctid = GetPostString("ctid");
  755. CeErpTradeCell entity = null;
  756. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  757. if (entity != null)
  758. {
  759. entity.OtherMemo = GetPostString("otherMemo");
  760. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  761. {
  762. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  763. StringBuilder sql = new StringBuilder();
  764. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  765. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  766. if (dt != null && dt.Rows.Count > 0)
  767. {
  768. foreach (DataRow dr in dt.Rows)
  769. {
  770. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  771. {
  772. //品类一直
  773. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  774. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  775. if (ceErpSampleCustomer == null)
  776. {
  777. ceErpSampleCustomer = new CeErpSampleCustomer();
  778. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  779. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  780. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  781. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  782. ceErpSampleCustomer.shopId = entity.ShopId;
  783. }
  784. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  785. ceErpSampleCustomer.lastTid = entity.tid;
  786. if (ceErpSampleCustomer.ID > 0)
  787. {
  788. ceErpSampleCustomer.Update();
  789. }
  790. else
  791. {
  792. ceErpSampleCustomer.Create();
  793. }
  794. }
  795. }
  796. }
  797. }
  798. //if (entity.IsOldCustomer == 1)
  799. //{
  800. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  801. //{
  802. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  803. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  804. //}
  805. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  806. //{
  807. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  808. // {
  809. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  810. // {
  811. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  813. // }
  814. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  815. // {
  816. // entity.OrderState = 2;
  817. // entity.DesignUserId = 0;
  818. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  819. // }
  820. // else
  821. // {
  822. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  823. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  824. // }
  825. // }
  826. //}
  827. //}
  828. entity.Update();
  829. returnSuccessMsg("保存成功!");
  830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  831. return;
  832. }
  833. returnErrorMsg("找不到记录");
  834. }
  835. }
  836. public void save_erp_customermemo()
  837. {
  838. if (UrlPostParmsCheck("ctid"))
  839. {
  840. string ctid = GetPostString("ctid");
  841. CeErpTradeCell entity = null;
  842. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  843. if (entity != null)
  844. {
  845. entity.CustomerMemo = GetPostString("CustomerMemo");
  846. entity.Update();
  847. ApiVo apiVo = new ApiVo();
  848. apiVo.orderNumber = entity.ctid;
  849. apiVo.actionName = "followRemarks";
  850. apiVo.orderRemarks = entity.CustomerMemo;
  851. designHelper.API_WorkCore(apiVo);//followRemarks
  852. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  853. returnSuccessMsg("保存成功!");
  854. return;
  855. }
  856. returnErrorMsg("找不到记录");
  857. }
  858. }
  859. public void upd_erp_addmemotag()
  860. {
  861. if (UrlPostParmsCheck("ctid"))
  862. {
  863. ;
  864. string eid = GetPostString("ctid");
  865. string sfTagstr = GetPostString("memotag");
  866. CeErpTradeCell entity = null;
  867. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  868. if (entity != null)
  869. {
  870. if (entity.OrderState == 0)
  871. {
  872. returnErrorMsg("请先领单");
  873. return;
  874. }
  875. //撤销顺丰
  876. if (sfTagstr == "撤销顺丰")
  877. {
  878. entity.IsSF = 0;
  879. string reMsg = "";
  880. string oldmemo = entity.seller_memo;
  881. if (entity.OrderState < 5)
  882. {
  883. oldmemo = oldmemo.Replace("顺丰到付", "");
  884. oldmemo = oldmemo.Replace("顺丰寄付", "");
  885. entity.seller_memo = oldmemo;
  886. }
  887. else
  888. {
  889. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  890. {
  891. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  892. }
  893. }
  894. entity.Update();
  895. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  896. api.orderNumber = entity.ctid;
  897. api.actionName = "followRemarks";
  898. api.orderRemarks = entity.seller_memo;
  899. api.isSf = entity.IsSF.ToString();
  900. designHelper.API_WorkCore(api);//followRemarks
  901. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  902. returnSuccessMsg("撤销成功!" + reMsg);
  903. return;
  904. }
  905. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  906. {
  907. //string oldmemo = entity.seller_memo;
  908. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  909. string sfStr = GetPostString("memotag");
  910. string smemo = entity.seller_memo;
  911. int kindex = smemo.IndexOf(")");
  912. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  913. if (lastoneStr != "-")
  914. {
  915. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  916. }
  917. string prememo = smemo.Substring(0, kindex + 2);
  918. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  919. int lastkindex = lastmemo.IndexOf("(");
  920. string newlastmemo = "";
  921. if (lastkindex == 0)
  922. {
  923. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  924. newlastmemo = "(" + sfStr + "." + useLastmemo;
  925. }
  926. else
  927. {
  928. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  929. }
  930. entity.seller_memo = prememo + newlastmemo;
  931. }
  932. string sfTagMSg = "";
  933. if (sfTagstr == "顺丰寄付")
  934. {
  935. entity.IsSF = 1;
  936. sfTagMSg = "顺丰寄付";
  937. }
  938. else if (sfTagstr == "顺丰到付")
  939. {
  940. entity.IsSF = 2;
  941. sfTagMSg = "顺丰到付";
  942. }
  943. entity.Update();
  944. ApiVo apiVo = new ApiVo();
  945. apiVo.orderNumber = entity.ctid;
  946. apiVo.actionName = "orderRemarks";
  947. apiVo.orderRemarks = entity.seller_memo;
  948. apiVo.isSf = entity.IsSF.ToString();
  949. designHelper.API_WorkCore(apiVo);//orderRemarks
  950. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  951. returnSuccessMsg("标记成功!");
  952. return;
  953. }
  954. returnErrorMsg("找不到记录");
  955. }
  956. }
  957. public void upd_erp_ordertag()
  958. {
  959. if (UrlPostParmsCheck("ctid"))
  960. {
  961. string eid = GetPostString("ctid");
  962. CeErpTradeCell entity = null;
  963. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  964. if (entity != null)
  965. {
  966. int tag = GetPostInt("wechattag");
  967. //if(tag==4 && entity.IsSample == 2)
  968. //{
  969. // returnErrorMsg("补差价单不能标记微信单");
  970. // return;
  971. //}
  972. entity.wechatTag = tag;
  973. entity.Update();
  974. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  975. if (tag == 1)
  976. {
  977. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  978. if (cash == null)
  979. {
  980. CeErpTrade main = CeErpTrade.Get(entity.tid);
  981. cash = new CeErpReturnCash();
  982. cash.tid = entity.tid;
  983. cash.seller_nick = main.seller_nick;
  984. cash.payment = trade.payment;
  985. cash.buyer_nick = main.buyer_nick;
  986. cash.cashstate = 0;
  987. cash.rtype = "微信返现";
  988. cash.returnprice = 0;
  989. cash.created = DateTime.Now;
  990. cash.con = "订单标记微信单";
  991. cash.img = "";
  992. cash.applyuserid = CurrentUser.UserID;
  993. cash.Create();
  994. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  995. }
  996. else
  997. {
  998. cash.cashstate = 0;
  999. cash.Update();
  1000. }
  1001. CeErpSukuraData.createInfo(entity.ctid, 9);
  1002. }
  1003. else if (tag == 2)
  1004. {
  1005. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1006. if (cash == null)
  1007. {
  1008. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1009. cash = new CeErpReturnCash();
  1010. cash.tid = entity.tid;
  1011. cash.seller_nick = main.seller_nick;
  1012. cash.payment = trade.payment;
  1013. cash.buyer_nick = main.buyer_nick;
  1014. cash.cashstate = 0;
  1015. cash.rtype = "推购返现";
  1016. cash.returnprice = 5;
  1017. cash.created = DateTime.Now;
  1018. cash.con = "订单标记推购单";
  1019. cash.img = "";
  1020. cash.applyuserid = CurrentUser.UserID;
  1021. cash.Create();
  1022. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1023. }
  1024. else
  1025. {
  1026. cash.cashstate = 0;
  1027. cash.Update();
  1028. }
  1029. CeErpSukuraData.createInfo(entity.ctid, 9);
  1030. }
  1031. else if (tag == 3)
  1032. {
  1033. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1034. if (pers == null)
  1035. {
  1036. pers = new CeErpPersuade();
  1037. pers.ctid = entity.ctid;
  1038. pers.pstate = 0;
  1039. pers.created = DateTime.Now;
  1040. pers.applyuserid = CurrentUser.UserID;
  1041. pers.Create();
  1042. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1043. }
  1044. else
  1045. {
  1046. pers.pstate = 0;
  1047. pers.Update();
  1048. }
  1049. }
  1050. else if (tag == 4 || tag == 5)
  1051. {
  1052. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1053. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1054. if (pers == null)
  1055. {
  1056. pers = new CeErpStayGoods();
  1057. pers.t_id = entity.tid;
  1058. pers.status = "待审核";
  1059. pers.audit_type = 0;
  1060. if (tag == 4)
  1061. {
  1062. pers.stay_type = "微信推购";
  1063. }
  1064. else
  1065. {
  1066. pers.stay_type = "旺旺推购";
  1067. }
  1068. if (entity.IsXianHuo == 0)
  1069. {
  1070. pers.product_id = entity.ProductId;
  1071. }
  1072. pers.wangwang = main.buyer_nick;
  1073. pers.shop_name = main.seller_nick;
  1074. pers.creata_time = DateTime.Now;
  1075. pers.create_u_id = CurrentUser.UserID;
  1076. pers.create_u_name = CurrentUser.UserName;
  1077. pers.Create();
  1078. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1079. }
  1080. else
  1081. {
  1082. pers.audit_type = 0;
  1083. pers.Update();
  1084. }
  1085. CeErpSukuraData.createInfo(entity.ctid, 10);
  1086. }
  1087. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1088. returnSuccessMsg("标记成功!");
  1089. return;
  1090. }
  1091. returnErrorMsg("找不到记录");
  1092. }
  1093. }
  1094. public void upd_erp_ordertag_cancel()
  1095. {
  1096. if (UrlPostParmsCheck("ctid"))
  1097. {
  1098. string eid = GetPostString("ctid");
  1099. CeErpTradeCell entity = null;
  1100. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1101. if (entity != null)
  1102. {
  1103. entity.wechatTag = 0;
  1104. entity.Update();
  1105. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1106. if (pers != null)
  1107. {
  1108. pers.status = "取消推购";
  1109. pers.audit_type = 3;
  1110. pers.Update();
  1111. }
  1112. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1113. returnSuccessMsg("标记成功!");
  1114. return;
  1115. }
  1116. returnErrorMsg("找不到记录");
  1117. }
  1118. }
  1119. public void upd_erp_addweichattag()
  1120. {
  1121. if (UrlPostParmsCheck("ctid"))
  1122. {
  1123. ;
  1124. string eid = GetPostString("ctid");
  1125. CeErpTradeCell entity = null;
  1126. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1127. if (entity != null)
  1128. {
  1129. if (entity.IsAddWechat > 0)
  1130. {
  1131. returnErrorMsg("此单已经标记过了");
  1132. return;
  1133. }
  1134. string sql = string.Format("select * from view_erptradecell where IsAddWechat>0 and buyer_nick=(select buyer_nick from ce_erptrade where tid='{0}')", entity.tid);
  1135. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1136. if (dt.Rows.Count > 0)
  1137. {
  1138. entity.IsAddWechat = 2;
  1139. }
  1140. else
  1141. {
  1142. entity.IsAddWechat = 1;
  1143. }
  1144. entity.Update();
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1146. returnSuccessMsg("标记成功!");
  1147. return;
  1148. }
  1149. returnErrorMsg("找不到记录");
  1150. }
  1151. }
  1152. public void upd_erp_getmyorder()
  1153. {
  1154. if (UrlPostParmsCheck("ctid"))
  1155. {
  1156. ;
  1157. string eid = GetPostString("ctid");
  1158. CeErpTradeCell entity = null;
  1159. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1160. if (entity != null)
  1161. {
  1162. if (entity.ctid.IndexOf("C") != -1)
  1163. {
  1164. StringBuilder sql = new StringBuilder();
  1165. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1166. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1167. if (dt.Rows.Count > 0)
  1168. {
  1169. decimal total = 0;
  1170. foreach (DataRow dr in dt.Rows)
  1171. {
  1172. total += Convert.ToDecimal(dr["payment"]);
  1173. }
  1174. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1175. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1176. {
  1177. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1178. return;
  1179. }
  1180. }
  1181. }
  1182. entity.CustomerUserId = CurrentUser.UserID;
  1183. if (entity.OrderState < 2)
  1184. {
  1185. entity.OrderState = 2;
  1186. if (entity.ShopId != 0)
  1187. {
  1188. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1189. }
  1190. }
  1191. entity.UpdateTime = DateTime.Now;
  1192. entity.Update();
  1193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1194. returnSuccessMsg("领单成功!");
  1195. return;
  1196. }
  1197. returnErrorMsg("找不到记录");
  1198. }
  1199. }
  1200. public void getmyorder_from_init()
  1201. {
  1202. if (UrlPostParmsCheck("ctid"))
  1203. {
  1204. string eid = GetPostString("ctid");
  1205. CeErpTradeCell entity = null;
  1206. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1207. if (entity != null)
  1208. {
  1209. string sellerMemo = GetPostString("sellerMemo");
  1210. if (sellerMemo.Length > 0)
  1211. {
  1212. entity.seller_memo = sellerMemo;
  1213. }
  1214. string oterhMemo = GetPostString("otherMemo");
  1215. if (oterhMemo.Length > 0)
  1216. {
  1217. entity.OtherMemo = oterhMemo;
  1218. }
  1219. int urg = GetPostInt("urgency");
  1220. entity.IsUrgency = (urg == 1 ? true : false);
  1221. int wechat = GetPostInt("wechat");
  1222. int command = GetPostInt("command");
  1223. if (wechat == 1)
  1224. {
  1225. entity.wechatTag = 1;
  1226. }
  1227. if (command == 1)
  1228. {
  1229. entity.wechatTag = 2;
  1230. }
  1231. string pPro = GetPostString("pprofession");
  1232. if (pPro.Length > 0)
  1233. {
  1234. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1235. string spro = GetPostString("profession");
  1236. if (spro.Length > 0)
  1237. {
  1238. entity.ProfessionId = Convert.ToInt32(spro);
  1239. }
  1240. }
  1241. string proId = GetPostString("productId");
  1242. if (proId.Length > 0)
  1243. {
  1244. entity.ProductId = Convert.ToInt32(proId);
  1245. }
  1246. entity.Material = GetPostString("material");
  1247. entity.Craft = GetPostString("craft");
  1248. entity.CustomerUserId = CurrentUser.UserID;
  1249. if (entity.OrderState < 2)
  1250. {
  1251. entity.OrderState = 2;
  1252. if (entity.ShopId != 0)
  1253. {
  1254. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1255. }
  1256. }
  1257. entity.Update();
  1258. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1259. returnSuccessMsg("领单成功!");
  1260. return;
  1261. }
  1262. returnErrorMsg("找不到记录");
  1263. }
  1264. }
  1265. public void upd_erp_setrelationorder()
  1266. {
  1267. if (UrlPostParmsCheck("ctid"))
  1268. {
  1269. ;
  1270. string eid = GetPostString("ctid");
  1271. string ftid = GetPostString("ftid");
  1272. CeErpTradeCell entity = null;
  1273. CeErpTradeCell fentity = null;
  1274. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1275. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1276. if (fentity == null)
  1277. {
  1278. returnErrorMsg("找不到关联的主订单");
  1279. return;
  1280. }
  1281. if (entity != null)
  1282. {
  1283. if (entity.OrderState >= 5)
  1284. {
  1285. returnErrorMsg("本单已经设计完成无法关联");
  1286. return;
  1287. }
  1288. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1289. {
  1290. returnErrorMsg("线下单续审核后才能关联!");
  1291. return;
  1292. }
  1293. entity.ptid = ftid;
  1294. entity.OrderState = fentity.OrderState;
  1295. //entity.status = fentity.status;
  1296. entity.CustomerUserId = fentity.CustomerUserId;
  1297. entity.DesignUserId = fentity.DesignUserId;
  1298. entity.seller_memo = "补差价单:" + ftid;
  1299. entity.IsSample = 2;
  1300. entity.Update();
  1301. ApiVo apiVo = new ApiVo();
  1302. apiVo.orderNumber = ftid;
  1303. apiVo.payment = entity.payment;
  1304. apiVo.actionName = "repairDesign";
  1305. designHelper.API_WorkCore(apiVo);//repairDesign
  1306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1307. returnSuccessMsg("关联成功!");
  1308. return;
  1309. }
  1310. else
  1311. returnErrorMsg("找不到记录");
  1312. }
  1313. }
  1314. public void download_erp_neworder()
  1315. {
  1316. string seller = GetPostString("seller_nick");
  1317. string tid = GetPostString("tid");
  1318. if (seller.Length <= 0 || tid.Length <= 0)
  1319. {
  1320. returnErrorMsg("数据错误");
  1321. }
  1322. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1323. //{
  1324. // returnErrorMsg("找不到店铺Sessionkey");
  1325. //}
  1326. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1327. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1328. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1329. if (res.IndexOf("refOid") == -1)
  1330. {
  1331. returnErrorMsg("下载订单数据失败");
  1332. return;
  1333. }
  1334. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1335. returnSuccessMsg("下载完成");
  1336. //tmcHelper.createNewOrder(res);
  1337. //CeErpTrade entr = null;
  1338. //entr = CeErpTrade.Get(tid);
  1339. //if (entr != null)
  1340. //{
  1341. // returnSuccess("下载成功");
  1342. // //下载成功之后,Cell表生成对应的订单;
  1343. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1344. //}
  1345. //else
  1346. //{
  1347. // returnErrorMsg("下载失败或者创建订单失败");
  1348. //}
  1349. }
  1350. public void set_erp_atersale()
  1351. {
  1352. if (UrlPostParmsCheck("ctid"))
  1353. {
  1354. string eid = GetPostString("ctid");
  1355. string reason = GetPostString("AfterSaleReason");
  1356. CeErpTradeCell entity = null;
  1357. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1358. if (entity != null)
  1359. {
  1360. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1361. {
  1362. returnErrorMsg("此订单已经在售后");
  1363. return;
  1364. }
  1365. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1366. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1367. entity.AfterSaleTime = DateTime.Now;
  1368. entity.Update();
  1369. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1370. returnSuccessMsg("转售后成功!");
  1371. return;
  1372. }
  1373. returnErrorMsg("找不到记录");
  1374. }
  1375. }
  1376. public void set_erp_withdraw()
  1377. {
  1378. if (UrlPostParmsCheck("ctid"))
  1379. {
  1380. try
  1381. {
  1382. string eid = GetPostString("ctid");//商品id
  1383. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1384. CeWithdraw ceWithdrawSelect = null;
  1385. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1386. if (ceWithdrawSelect != null)
  1387. {
  1388. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1389. {
  1390. ceWithdrawSelect.status = -1;
  1391. ceWithdrawSelect.Update();
  1392. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1393. returnSuccessMsg("重新发起审核成功");
  1394. return;
  1395. }
  1396. else
  1397. {
  1398. returnSuccessMsg("请勿重复申请!");
  1399. return;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1405. if (string.IsNullOrEmpty(CustomerUserId))
  1406. {
  1407. CustomerUserId = "-1";
  1408. }
  1409. int Userid = CurrentUser.UserID;//用户id
  1410. CeWithdraw ceWithdraw = new CeWithdraw();
  1411. ceWithdraw.tid = eid;
  1412. ceWithdraw.userid = Userid;
  1413. ceWithdraw.providerid = CustomerUserId;
  1414. ceWithdraw.status = 3;
  1415. ceWithdraw.creationtime = DateTime.Now;
  1416. ceWithdraw.Create();
  1417. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1418. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1419. return;
  1420. }
  1421. }
  1422. catch
  1423. {
  1424. returnErrorMsg("申请撤回订单失败");
  1425. return;
  1426. }
  1427. }
  1428. }
  1429. public void ins_erp_billinfo()
  1430. {
  1431. if (UrlPostParmsCheck("ctid"))
  1432. {
  1433. string eid = GetPostString("ctid");
  1434. CeErpTradeCell entity = null;
  1435. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1436. if (entity != null)
  1437. {
  1438. CeErpBill bill = CeErpBill.GetByTid(eid);
  1439. bool isHave = false;
  1440. if (bill != null)
  1441. {
  1442. isHave = true;
  1443. if (bill.state != 4)
  1444. {
  1445. returnErrorMsg("此单已经申请过发票了");
  1446. return;
  1447. }
  1448. }
  1449. if (entity.IsNeedBill == 0)
  1450. {
  1451. entity.IsNeedBill = 1;
  1452. }
  1453. entity.Update();
  1454. string errjson = "";
  1455. try
  1456. {
  1457. CeErpBill bill_entity = new CeErpBill();
  1458. bill_entity.tid = entity.tid;
  1459. bill_entity.title = GetPostString("title");
  1460. string taxstr = GetPostString("tax");
  1461. taxstr = taxstr.Replace(" ", "");
  1462. bill_entity.tax = taxstr;
  1463. bill_entity.bank = GetPostString("bank");
  1464. string bankacstr = GetPostString("bankac");
  1465. bankacstr = bankacstr.Replace(" ", "");
  1466. bill_entity.bankac = bankacstr;
  1467. bill_entity.address = GetPostString("address");
  1468. bill_entity.phone = GetPostString("phone");
  1469. bill_entity.price = GetPostString("price");
  1470. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1471. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1472. {
  1473. billCount += 1;
  1474. }
  1475. string prebill = "ltb";
  1476. for (int idx = 1; idx <= billCount; idx++)
  1477. {
  1478. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1479. string billoid = prebill + idx + dtstr;
  1480. bill_entity.billOrderId += billoid;
  1481. if (idx < billCount)
  1482. {
  1483. bill_entity.billOrderId += ",";
  1484. }
  1485. }
  1486. bill_entity.productId = GetPostInt("ProductName");
  1487. bill_entity.num = GetPostInt("num");
  1488. bill_entity.unit = GetPostString("unit");
  1489. bill_entity.type = GetPostString("type");
  1490. bill_entity.sendType = GetPostString("SendType");
  1491. bill_entity.email = GetPostString("email");
  1492. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1493. bill_entity.shopName = GetPostString("ShopName");
  1494. bill_entity.applymemo = GetPostString("applyMemo");
  1495. bill_entity.createTime = DateTime.Now;
  1496. bill_entity.state = 0;
  1497. bill_entity.userId = CurrentUser.UserID;
  1498. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1499. bill_entity.Create();
  1500. }
  1501. catch (Exception ex)
  1502. {
  1503. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1504. returnErrorMsg("创建发票出错!");
  1505. return;
  1506. }
  1507. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1508. returnSuccessMsg("发票申请成功!");
  1509. return;
  1510. }
  1511. returnErrorMsg("找不到记录");
  1512. }
  1513. }
  1514. public void ins_erp_neworder()
  1515. {
  1516. if (UrlPostParmsCheck("receiver_name"))
  1517. {
  1518. CeErpTrade entity = new CeErpTrade();
  1519. string plat_form = GetPostString("platform");
  1520. string preStr = "N_";
  1521. if (plat_form == "拼多多")
  1522. {
  1523. preStr = "P_";
  1524. }
  1525. else if (plat_form == "阿里巴巴")
  1526. {
  1527. preStr = "A_";
  1528. }
  1529. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1530. entity.seller_nick = GetPostString("seller_nick");
  1531. entity.buyer_nick = GetPostString("buyer_nick");
  1532. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1533. entity.total_fee = entity.payment;
  1534. entity.pay_time = DateTime.Now;
  1535. entity.status = "NOT_SHIPPED";
  1536. entity.receiver_name = GetPostString("receiver_name");
  1537. entity.receiver_mobile = GetPostString("receiver_mobile");
  1538. entity.receiver_state = GetPostString("receiver_state");
  1539. entity.receiver_city = GetPostString("receiver_city");
  1540. entity.receiver_district = GetPostString("receiver_district");
  1541. entity.receiver_address = GetPostString("receiver_address");
  1542. if (entity.receiver_state == "" || entity.receiver_city == "")
  1543. {
  1544. returnErrorMsg("收件地址不能为空");
  1545. return;
  1546. }
  1547. int shopId = 0;
  1548. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1549. if (nShop != null)
  1550. {
  1551. shopId = nShop.ID;
  1552. }
  1553. if (shopId != 34 && entity.payment == 0)
  1554. {
  1555. returnErrorMsg("公司自用的单金额才能为0");
  1556. return;
  1557. }
  1558. entity.Create();
  1559. CeErpTradeCell entitycell = new CeErpTradeCell();
  1560. entitycell.ctid = entity.tid;
  1561. entitycell.tid = entity.tid;
  1562. entitycell.ShopId = shopId;
  1563. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1564. entitycell.OrderState = 0;
  1565. entitycell.pay_time = entity.pay_time;
  1566. entitycell.IsOffLineOrder = 1;
  1567. entitycell.Create();
  1568. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1569. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1570. return;
  1571. }
  1572. }
  1573. public void ins_erp_neworder2()
  1574. {
  1575. if (UrlPostParmsCheck("receiver_name"))
  1576. {
  1577. //string plat_form = GetPostString("platform");
  1578. string preStr = "X_";
  1579. string memo = GetPostString("memo");
  1580. string productId = GetPostString("productId");
  1581. string primg = GetPostString("proofimg");
  1582. string sellerNick = GetPostString("seller_nick");
  1583. string addFrom = GetPostString("addfrom");
  1584. if (addFrom == "1")
  1585. {
  1586. preStr = "N_";
  1587. }
  1588. int shopId = 0;
  1589. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1590. if (nShop != null)
  1591. {
  1592. shopId = nShop.ID;
  1593. }
  1594. else
  1595. {
  1596. returnErrorMsg("找不到对应店铺");
  1597. return;
  1598. }
  1599. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1600. {
  1601. returnErrorMsg("必须上传付款凭证");
  1602. return;
  1603. }
  1604. CeErpTrade entity = new CeErpTrade();
  1605. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1606. entity.seller_nick = sellerNick;
  1607. entity.buyer_nick = GetPostString("buyer_nick");
  1608. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1609. entity.total_fee = entity.payment;
  1610. entity.pay_time = DateTime.Now;
  1611. entity.status = "NOT_SHIPPED";
  1612. entity.receiver_name = GetPostString("receiver_name");
  1613. entity.receiver_mobile = GetPostString("receiver_mobile");
  1614. entity.receiver_state = GetPostString("receiver_state");
  1615. entity.receiver_city = GetPostString("receiver_city");
  1616. entity.receiver_district = GetPostString("receiver_district");
  1617. entity.receiver_address = GetPostString("receiver_address");
  1618. entity.seller_memo = memo;
  1619. entity.orderFrom = 20;
  1620. entity.orderType = 15;
  1621. if (entity.receiver_state == "" || entity.receiver_city == "")
  1622. {
  1623. returnErrorMsg("收件地址不能为空");
  1624. return;
  1625. }
  1626. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1627. {
  1628. returnErrorMsg("公司自用的单金额才能为0");
  1629. return;
  1630. }
  1631. entity.Create();
  1632. string toWhere = GetPostString("towhere");
  1633. CeErpTradeCell entitycell = new CeErpTradeCell();
  1634. entitycell.ctid = entity.tid;
  1635. //唯一标识
  1636. entitycell.OrderSn = entity.tid;
  1637. string orderSn = dataHelper.getSaleOrderSn();
  1638. if (orderSn != "")
  1639. {
  1640. entitycell.OrderSn = orderSn;
  1641. }
  1642. entitycell.tid = entity.tid;
  1643. //if (preStr == "X_")
  1644. //{
  1645. entitycell.IsOffLineOrder = 1;
  1646. //}
  1647. entitycell.CustomerUserId = CurrentUser.UserID;
  1648. entitycell.PayProofImg = primg;
  1649. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1650. entitycell.ProductId = Convert.ToInt32(productId);
  1651. entitycell.ShopId = shopId;
  1652. entitycell.UpdateTime = DateTime.Now;
  1653. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1654. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1655. {
  1656. entitycell.IsXianHuo = 1;
  1657. }
  1658. entitycell.pay_time = entity.pay_time;
  1659. if (toWhere == "1")
  1660. {
  1661. entitycell.OrderState = 2;
  1662. }
  1663. else
  1664. {
  1665. entitycell.OrderState = 6;
  1666. entitycell.FinishPlaceTime = entitycell.pay_time;
  1667. }
  1668. if (shopId == 94)
  1669. {
  1670. entitycell.OrderState = 4;
  1671. entitycell.WaitDesignTime = entitycell.pay_time;
  1672. entitycell.StartDesignTime = entitycell.pay_time;
  1673. entitycell.DesignUserId = 218;
  1674. }
  1675. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1676. {
  1677. entitycell.OrderState = -1;//修改12-5
  1678. CeWithdraw ceWithdraw = new CeWithdraw();
  1679. ceWithdraw.tid = entity.tid;
  1680. ceWithdraw.providerid = "-1";
  1681. ceWithdraw.status = -1;
  1682. ceWithdraw.creationtime = DateTime.Now;
  1683. ceWithdraw.userid = 1337;
  1684. ceWithdraw.Create();
  1685. }
  1686. entitycell.Create();
  1687. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1688. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1689. {
  1690. addPlaceRegist(entitycell, CurrentUser.UserID);
  1691. }
  1692. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1693. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1694. return;
  1695. }
  1696. }
  1697. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1698. {
  1699. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1700. entity.PlactTime = tradecell.pay_time;
  1701. entity.AddUserId = userid;
  1702. entity.FileName = tradecell.seller_memo;
  1703. entity.Supplier = 24;
  1704. entity.CreateTime = DateTime.Now;
  1705. entity.Did = tradecell.ctid;
  1706. entity.tid = tradecell.tid;
  1707. entity.splitTag = tradecell.SplitTag;
  1708. entity.CurState = "未完成";
  1709. entity.Create();
  1710. }
  1711. public void get_erp_offlinelist()
  1712. {
  1713. DataStruct dStruct = GetPostStruct();
  1714. List<string> lw = new List<string>();
  1715. string tid = GetPostString("ctid");
  1716. string date1 = GetPostString("date1");
  1717. string date2 = GetPostString("date2");
  1718. if (tid.Length > 0 || date1.Length > 0)
  1719. {
  1720. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1721. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1722. if (dw.Length > 0) lw.Add(dw);
  1723. }
  1724. else
  1725. {
  1726. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1727. }
  1728. string shopname = GetPostString("shopname");
  1729. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1730. string buyernick = GetPostString("buyer_nick");
  1731. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1732. string customer = GetPostString("customer");
  1733. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1734. string design = GetPostString("design");
  1735. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1736. string orderState = GetPostString("orderState");
  1737. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1738. string address = GetPostString("address");
  1739. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  1740. string sellermemo = GetPostString("seller_memo");
  1741. if (sellermemo.Length > 0)
  1742. {
  1743. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1744. }
  1745. string price1 = GetPostString("price1");
  1746. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1747. string price2 = GetPostString("price2");
  1748. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1749. //if (PKey != "admin")
  1750. //{
  1751. // string usershop = CurrentUser.User.pemShop;
  1752. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1753. //}
  1754. //if (ex_psize > 0)
  1755. //{
  1756. dStruct.Order = "pay_time desc";
  1757. //}
  1758. //else
  1759. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1760. lw.Add(string.Format("IsOffLineOrder=1"));
  1761. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1762. DataTable dt = null;
  1763. dt = WebCache.GetData("view_erptradecell", dStruct);
  1764. writeGridDataTableJson(dStruct.TotalCount, dt);
  1765. }
  1766. public void get_erp_returncashrecord()
  1767. {
  1768. DataStruct dStruct = GetPostStruct();
  1769. List<string> lw = new List<string>();
  1770. string tid = GetPostString("ctid");
  1771. if (tid.Length > 0)
  1772. {
  1773. lw.Add(string.Format("tid like '%{0}%'", tid));
  1774. dStruct.Order = "id desc";
  1775. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1776. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1777. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1778. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1779. return;
  1780. }
  1781. returnErrorMsg("id数据错误!");
  1782. }
  1783. public void ins_erp_returncashrecord()
  1784. {
  1785. if (UrlPostParmsCheck("tid"))
  1786. {
  1787. string tid = GetPostString("tid");
  1788. string retype = GetPostString("type");
  1789. StringBuilder sql = new StringBuilder();
  1790. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1791. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1792. if (dt.Rows.Count > 0)
  1793. {
  1794. returnErrorMsg("相同返现类型记录已存在");
  1795. return;
  1796. }
  1797. CeErpReturnCash entity = new CeErpReturnCash();
  1798. entity.tid = tid;
  1799. entity.seller_nick = GetPostString("seller_nick");
  1800. string pment = GetPostString("payment");
  1801. if (pment.Length > 0)
  1802. {
  1803. entity.payment = Convert.ToDouble(pment);
  1804. }
  1805. entity.buyer_nick = GetPostString("buyer_nick");
  1806. entity.cashstate = 0;
  1807. entity.rtype = retype;
  1808. string rPrice = GetPostString("returnprice");
  1809. if (rPrice.Length > 0)
  1810. {
  1811. entity.returnprice = Convert.ToDouble(rPrice);
  1812. }
  1813. entity.created = DateTime.Now;
  1814. entity.con = GetPostString("con");
  1815. entity.img = GetPostString("img");
  1816. entity.applyuserid = CurrentUser.UserID;
  1817. entity.Create();
  1818. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1819. returnSuccessMsg("操作成功!");
  1820. return;
  1821. }
  1822. }
  1823. public void set_erp_predelivery()
  1824. {
  1825. if (UrlPostParmsCheck("ctid"))
  1826. {
  1827. string eid = GetPostString("ctid");
  1828. CeErpTradeCell entity = null;
  1829. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1830. if (entity != null)
  1831. {
  1832. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1833. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1834. //{
  1835. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1836. // return;
  1837. //}
  1838. entity.IsPreDelivery = 1;
  1839. entity.Update();
  1840. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1841. returnSuccessMsg("预发货成功!");
  1842. return;
  1843. //string shop = GetPostString("seller_nick");
  1844. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1845. //string comName = GetPostString("comName");
  1846. //string comCode = GetPostString("comCode");
  1847. //string outSid = GetPostString("outSid");//运单号
  1848. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1849. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1850. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1851. //string apires = "";
  1852. //if (deliveryType == "虚拟发货")
  1853. //{
  1854. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1855. //}
  1856. //else
  1857. //{
  1858. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1859. //}
  1860. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1861. ////{
  1862. //if (apires.IndexOf("发货成功") != -1)
  1863. //{
  1864. // if (deliveryType != "虚拟发货")
  1865. // {
  1866. // //还要插入快递信息到 快递信息表
  1867. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1868. // exinfo.tid = eid;
  1869. // exinfo.out_sid = outSid;
  1870. // exinfo.company_code = comCode;
  1871. // exinfo.company_name = comName;
  1872. // exinfo.delivery_memo = deliveryMemo;
  1873. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1874. // exinfo.deliveryType = deliveryType;
  1875. // exinfo.Create();
  1876. // }
  1877. // returnSuccessMsg("发货成功!");
  1878. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1879. //}
  1880. //else
  1881. //{
  1882. // returnErrorMsg("淘宝发货失败!!");
  1883. //}
  1884. //return;
  1885. }
  1886. returnErrorMsg("找不到订单记录");
  1887. }
  1888. }
  1889. public void get_erp_unusuallist()
  1890. {
  1891. DataStruct dStruct = GetPostStruct();
  1892. List<string> lw = new List<string>();
  1893. string tid = GetPostString("ctid");
  1894. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1895. string shopname = GetPostString("shopname");
  1896. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1897. string buyernick = GetPostString("buyer_nick");
  1898. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1899. string ResponsibleMan = GetPostString("responsible");
  1900. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1901. string date1 = GetPostString("date1");
  1902. string date2 = GetPostString("date2");
  1903. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1904. if (dw.Length > 0) lw.Add(dw);
  1905. string price1 = GetPostString("price1");
  1906. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1907. string price2 = GetPostString("price2");
  1908. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1909. string orderState = GetPostString("orderState");
  1910. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1911. string sellermemo = GetPostString("seller_memo");
  1912. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1913. lw.Add(string.Format("UnusualTag > 0"));
  1914. lw.Add(string.Format("IsRefund<={0}", 1));
  1915. dStruct.Order = "pay_time desc";
  1916. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1917. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1918. writeGridDataTableJson(dStruct.TotalCount, dt);
  1919. }
  1920. public void set_erp_unusualtonomal()
  1921. {
  1922. if (UrlPostParmsCheck("ctid"))
  1923. {
  1924. string eid = GetPostString("ctid");
  1925. CeErpTradeCell entity = null;
  1926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1927. if (entity != null)
  1928. {
  1929. entity.UnusualTag = -1;
  1930. entity.Update();
  1931. returnSuccessMsg("忽略成功!");
  1932. return;
  1933. }
  1934. returnErrorMsg("找不到记录");
  1935. }
  1936. }
  1937. public void ins_erp_unusualreason()
  1938. {
  1939. if (UrlPostParmsCheck("ctid"))
  1940. {
  1941. string eid = GetPostString("ctid");
  1942. CeErpTradeCell entity = null;
  1943. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1944. if (entity != null)
  1945. {
  1946. entity.MemoOpt = 4;
  1947. entity.UnusualCon = GetPostString("con");
  1948. entity.Update();
  1949. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1950. if (trade != null)
  1951. {
  1952. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1953. }
  1954. //查货是否超时
  1955. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1956. if (ceErpTradeCellExtend == null)
  1957. {
  1958. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1959. ceErpTradeCellExtend.ctid = entity.ctid;
  1960. }
  1961. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1962. {
  1963. ceErpTradeCellExtend.CheckOut += 1;
  1964. }
  1965. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1966. if (ceErpTradeCellExtend.ID > 0)
  1967. {
  1968. ceErpTradeCellExtend.Update();
  1969. }
  1970. else
  1971. {
  1972. ceErpTradeCellExtend.Create();
  1973. }
  1974. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1975. returnSuccessMsg("操作成功!");
  1976. return;
  1977. }
  1978. returnErrorMsg("找不到记录");
  1979. }
  1980. }
  1981. public void upd_erp_sampleorder()
  1982. {
  1983. if (UrlPostParmsCheck("ctid"))
  1984. {
  1985. string eid = GetPostString("ctid");
  1986. string[] eArr = eid.Split(',');
  1987. if (eArr.Length > 1)
  1988. {
  1989. List<string> eLst = new List<string>();
  1990. for (int i = 0; i < eArr.Length; i++)
  1991. {
  1992. eLst.Add("'" + eArr[i] + "'");
  1993. }
  1994. eid = string.Join(",", eLst.ToArray());
  1995. }
  1996. else
  1997. {
  1998. eid = "'" + eid + "'";
  1999. }
  2000. StringBuilder sql = new StringBuilder();
  2001. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2002. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2003. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2004. if (dt.Rows.Count > 0)
  2005. {
  2006. string errmsg = "";
  2007. foreach (DataRow dr in dt.Rows)
  2008. {
  2009. StringBuilder sqlsb = new StringBuilder();
  2010. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2011. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2012. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2013. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2014. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2015. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2016. {
  2017. continue;
  2018. }
  2019. else
  2020. {
  2021. string emsg = commonHelper.KeepChinese(apires);
  2022. errmsg += emsg;
  2023. }
  2024. }
  2025. if (errmsg.Length > 0)
  2026. {
  2027. returnErrorMsg(errmsg);
  2028. return;
  2029. }
  2030. returnSuccessMsg("操作成功");
  2031. return;
  2032. }
  2033. returnErrorMsg("找不到记录");
  2034. }
  2035. }
  2036. public void upd_erp_transcustomer()
  2037. {
  2038. if (UrlPostParmsCheck("ctid"))
  2039. {
  2040. string eid = GetPostString("ctid");
  2041. int userid = GetPostInt("CustomerUserId");
  2042. CeErpTradeCell entity = null;
  2043. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2044. if (entity != null)
  2045. {
  2046. //string[] mlist = entity.seller_memo.Split('-');
  2047. //string sql = "select * from view_erpuser where id=" + userid;
  2048. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2049. //if (dt != null && dt.Rows.Count > 0)
  2050. //{
  2051. // string nmemo = "";
  2052. // for(int i = 0; i < mlist.Length - 1; i++)
  2053. // {
  2054. // nmemo += mlist[i];
  2055. // nmemo += "-";
  2056. // }
  2057. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2058. // entity.seller_memo = nmemo;
  2059. //}
  2060. entity.CustomerUserId = userid;
  2061. entity.Update();
  2062. returnSuccessMsg("操作成功!");
  2063. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2064. return;
  2065. }
  2066. returnErrorMsg("找不到记录");
  2067. }
  2068. }
  2069. public void upd_erp_transdesigner()
  2070. {
  2071. if (UrlPostParmsCheck("ctid"))
  2072. {
  2073. string eids = GetPostString("ctid");
  2074. string[] ctidList = eids.Split(',');
  2075. int userid = GetPostInt("DesignUserId");
  2076. foreach (string ctid in ctidList)
  2077. {
  2078. CeErpTradeCell entity = null;
  2079. CeErpDesignerBill entitys = null;
  2080. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2081. entitys = CeErpDesignerBill.GetByTid(ctid);
  2082. if (entity != null)
  2083. {
  2084. if (entity.OrderState > 4)
  2085. {
  2086. continue;
  2087. }
  2088. //存在退款不能流转
  2089. if (entity.IsRefund > 0)
  2090. {
  2091. continue;
  2092. }
  2093. entity.DesignUserId = userid;
  2094. entity.WaitDesignTime = DateTime.Now;
  2095. entity.Update();
  2096. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2097. }
  2098. }
  2099. returnSuccessMsg("操作成功!");
  2100. }
  2101. }
  2102. public void upd_erp_distributedesigner()
  2103. {
  2104. if (UrlPostParmsCheck("ctid"))
  2105. {
  2106. string eid = GetPostString("ctid");
  2107. int userid = GetPostInt("DesignUserId");
  2108. string[] idlist = eid.Split(',');
  2109. if (idlist.Length <= 0)
  2110. {
  2111. returnErrorMsg("订单不能为空");
  2112. return;
  2113. }
  2114. foreach (string ctid in idlist)
  2115. {
  2116. CeErpTradeCell entity = null;
  2117. CeErpDesignerBill entitys = null;
  2118. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2119. else continue;
  2120. if (entity != null)
  2121. {
  2122. if (userid == 2125 || userid == 3542)
  2123. { }
  2124. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2125. {
  2126. returnErrorMsg("金额错误的订单无法指派");
  2127. return;
  2128. }
  2129. if (entity.OrderState >= 5)
  2130. {
  2131. returnErrorMsg("已经设计完成无法指派");
  2132. return;
  2133. }
  2134. if (entity.OrderState == -1)
  2135. {
  2136. returnErrorMsg("审核中的订单无法指派");
  2137. return;
  2138. }
  2139. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2140. {
  2141. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2142. return;
  2143. }
  2144. //157赖橙帆 159林晨
  2145. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479)
  2146. {
  2147. returnErrorMsg("指派设计共创无法再次指派!");
  2148. return;
  2149. }
  2150. entity.OrderState = 3;
  2151. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2152. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2153. {
  2154. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2155. entity.SupplierId = suid;
  2156. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2157. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2158. }
  2159. if (userid == 2125 && entity.seller_memo != "")
  2160. {
  2161. apiDesign.API_GetPrintData_CreateOrder(entity);
  2162. }
  2163. if (userid == 3542 && entity.seller_memo != "")
  2164. {
  2165. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2166. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2167. if (response.msg != "设计共创:成功")
  2168. {
  2169. returnErrorMsg(response.msg);
  2170. return;
  2171. }
  2172. entity.DispatchSort = 2;
  2173. }
  2174. else
  2175. {
  2176. if (entity.DispatchSort == 2)
  2177. {
  2178. ApiVo apiVo = new ApiVo();
  2179. apiVo.actionName = "closeDesign";
  2180. apiVo.orderNumber = entity.ctid;
  2181. designHelper.API_WorkCore(apiVo);//closeDesign
  2182. }
  2183. entity.DispatchSort = 0;
  2184. }
  2185. entity.DesignUserId = userid;
  2186. entity.WaitDesignTime = DateTime.Now;
  2187. entity.UpdateTime = DateTime.Now;
  2188. entity.Update();
  2189. string name = commonHelper.getUserNameById(userid);
  2190. commonHelper.UpdateRelationOrder(entity.ctid);
  2191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2192. }
  2193. }
  2194. returnSuccessMsg("操作成功!");
  2195. return;
  2196. }
  2197. }
  2198. public string getTidByCtid(string ctid)
  2199. {
  2200. string tid = "";
  2201. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2202. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2203. if (dataTable != null && dataTable.Rows.Count > 0)
  2204. {
  2205. tid = dataTable.Rows[0]["tid"].ToString();
  2206. }
  2207. return tid;
  2208. }
  2209. public List<string> getTidByCtidLike(string ctid)
  2210. {
  2211. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2212. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2213. List<string> list = new List<string>();
  2214. if (dataTable != null && dataTable.Rows.Count > 0)
  2215. {
  2216. foreach (DataRow item in dataTable.Rows)
  2217. {
  2218. list.Add("'" + item["tid"].ToString() + "'");
  2219. }
  2220. }
  2221. return list;
  2222. }
  2223. public void get_erp_myorderlist()
  2224. {
  2225. DataStruct dStruct = GetPostStruct();
  2226. List<string> lw = new List<string>();
  2227. string tid = GetPostString("ctid");
  2228. if (tid.Length > 0)
  2229. {
  2230. string select_tid = getTidByCtid(tid);
  2231. lw.Add(string.Format("tid='{0}'", select_tid));
  2232. }
  2233. else
  2234. {
  2235. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2236. }
  2237. //12-1 修改
  2238. string urgent = GetPostString("urgent");
  2239. string back = GetPostString("back");
  2240. string offlineSearch = GetPostString("offlineSearch");
  2241. if (!string.IsNullOrWhiteSpace(urgent))
  2242. {
  2243. if (urgent.Equals("true"))
  2244. {
  2245. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2246. }
  2247. }
  2248. if (!string.IsNullOrWhiteSpace(back))
  2249. {
  2250. if (back.Equals("true"))
  2251. {
  2252. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2253. }
  2254. }
  2255. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2256. {
  2257. if (offlineSearch.Equals("true"))
  2258. {
  2259. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2260. }
  2261. }
  2262. //end
  2263. string shopname = GetPostString("shopname");
  2264. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2265. string buyernick = GetPostString("buyer_nick");
  2266. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2267. string design = GetPostString("design");
  2268. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2269. string orderState = GetPostString("orderState");
  2270. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2271. string sellermemo = GetPostString("seller_memo");
  2272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2273. string date1 = GetPostString("date1");
  2274. string date2 = GetPostString("date2");
  2275. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2276. if (dw.Length > 0) lw.Add(dw);
  2277. string price1 = GetPostString("price1");
  2278. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2279. string price2 = GetPostString("price2");
  2280. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2281. string urgency = GetPostString("urgency");
  2282. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2283. string after = GetPostString("after");
  2284. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2285. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2286. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2287. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2289. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2290. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2291. if (dt != null && dt.Rows.Count > 0)
  2292. {
  2293. foreach (DataRow dr in dt.Rows)
  2294. {
  2295. try
  2296. {
  2297. // 对象操作
  2298. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2299. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2300. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2301. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2302. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2303. if (dStruct.PageSize != 100000)
  2304. {
  2305. if (dr["DispatchSort"].ToString() == "2")
  2306. {
  2307. dr["gongchuang"] = 200;
  2308. }
  2309. else
  2310. {
  2311. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2312. dr["gongchuang"] = response.code;
  2313. }
  2314. }
  2315. }
  2316. catch (NullReferenceException ex)
  2317. {
  2318. }
  2319. }
  2320. }
  2321. writeGridDataTableJson(dStruct.TotalCount, dt);
  2322. }
  2323. public void get_erp_myreturnorderlist()
  2324. {
  2325. DataStruct dStruct = GetPostStruct();
  2326. List<string> lw = new List<string>();
  2327. string tid = GetPostString("ctid");
  2328. if (tid.Length > 0)
  2329. {
  2330. string select_tid = getTidByCtid(tid);
  2331. lw.Add(string.Format("tid='{0}'", select_tid));
  2332. }
  2333. else
  2334. {
  2335. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2336. }
  2337. string shopname = GetPostString("shopname");
  2338. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2339. string buyernick = GetPostString("buyer_nick");
  2340. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2341. string design = GetPostString("design");
  2342. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2343. string orderState = GetPostString("orderState");
  2344. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2345. string sellermemo = GetPostString("seller_memo");
  2346. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2347. string date1 = GetPostString("date1");
  2348. string date2 = GetPostString("date2");
  2349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2350. if (dw.Length > 0) lw.Add(dw);
  2351. string price1 = GetPostString("price1");
  2352. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2353. string price2 = GetPostString("price2");
  2354. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2355. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2356. {
  2357. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2358. }
  2359. else
  2360. {
  2361. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2362. }
  2363. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2364. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2365. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2366. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2367. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2368. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2369. if (dt != null && dt.Rows.Count > 0)
  2370. {
  2371. foreach (DataRow dr in dt.Rows)
  2372. {
  2373. try
  2374. {
  2375. // 对象操作
  2376. if (dStruct.PageSize != 100000)
  2377. {
  2378. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2379. dr["gongchuang"] = response.code;
  2380. }
  2381. }
  2382. catch (NullReferenceException ex)
  2383. {
  2384. // 处理空引用异常
  2385. }
  2386. }
  2387. }
  2388. writeGridDataTableJson(dStruct.TotalCount, dt);
  2389. }
  2390. public void get_erp_myorderlist_pregather()
  2391. {
  2392. string date1 = GetPostString("date1");
  2393. string date2 = GetPostString("date2");
  2394. int userId = CurrentUser.UserID; //客服id
  2395. string orderWhere = "";
  2396. List<string> lw = new List<string>();
  2397. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2398. if (dw.Length > 0) lw.Add(dw);
  2399. lw.Add(string.Format("CustomerUserId={0}", userId));
  2400. lw.Add(string.Format("OrderState<9"));
  2401. orderWhere = string.Join(" and ", lw.ToArray());
  2402. string orderWhere2 = "";
  2403. List<string> lw2 = new List<string>();
  2404. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2405. if (dw2.Length > 0) lw2.Add(dw2);
  2406. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2407. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2408. string sql = string.Format("select *" +
  2409. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2410. "left join(select CustomerUserId, count(ctid) as dCount from View_ErpTradeCell where OrderState = 6 and " + orderWhere2 + " group by CustomerUserId) b on a.CustomerUserId = b.CustomerUserId " +
  2411. "left join(select CustomerUserId, count(ctid) as jCount from View_ErpTradeCell where IsUrgency = 1 and " + orderWhere + " group by CustomerUserId) c on a.CustomerUserId = c.CustomerUserId " +
  2412. "left join(select CustomerUserId, count(ctid) as sCount from View_ErpTradeCell where AfterSaleState > 0 and CHARINDEX(','+CONVERT(varchar," + userId + ")+'_k,',','+ResponsibleUserId+',')>0 and " + orderWhere + " group by CustomerUserId) d on a.CustomerUserId = d.CustomerUserId");
  2413. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2414. //writeGridDataTableJson(dt.Rows.Count, dt);
  2415. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2416. }
  2417. public void upd_erp_publishorder()
  2418. {
  2419. if (UrlPostParmsCheck("ctid"))
  2420. {
  2421. string eid = GetPostString("ctid");
  2422. CeErpTradeCell entity = null;
  2423. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2424. if (entity != null)
  2425. {
  2426. entity.OrderState = 0; //发布后,变为待抢单
  2427. entity.Update();
  2428. commonHelper.UpdateRelationOrder(entity.ctid);
  2429. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2430. returnSuccessMsg("发布成功!");
  2431. return;
  2432. }
  2433. returnErrorMsg("找不到记录");
  2434. }
  2435. }
  2436. public void get_erp_my_tiporder()
  2437. {
  2438. StringBuilder sql = new StringBuilder();
  2439. int userId = 0;
  2440. if (CurrentUser != null) userId = CurrentUser.UserID;
  2441. string posCode = CurrentUser.UserPost.Post.Code;
  2442. string isTipedAfterSaleVerify = GetPostString("af");
  2443. DataTable dt = new DataTable();
  2444. if (posCode != "Supplier")
  2445. {
  2446. if (posCode == "CustomerService" || posCode == "Director")
  2447. {
  2448. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2449. }
  2450. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2451. {
  2452. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2453. }
  2454. else
  2455. {
  2456. string teamIds = CurrentUser.User.TeamIds;
  2457. if (teamIds == "")
  2458. {
  2459. teamIds = "0";
  2460. }
  2461. sql.AppendFormat("select * from ce_erptradecell where (DesignUserId={0} or DesignUserId in (select ID from view_erpuser where OnDuty=0 and ID in ({1}))) and OrderState in (3,4) and IsReadTag>0 ", userId, teamIds);
  2462. }
  2463. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2464. }
  2465. if (dt.Rows.Count <= 0)
  2466. {
  2467. string key = "aftersale_order_" + userId;
  2468. if (RedisHelper.HasKey(key))
  2469. {
  2470. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2471. dt.Columns.Add("ctid", typeof(string));
  2472. dt.Columns.Add("IsReadTag", typeof(int));
  2473. foreach (var i in list)
  2474. {
  2475. DataRow data = dt.NewRow();
  2476. data["ctid"] = i;
  2477. data["IsReadTag"] = 4;
  2478. dt.Rows.Add(data);
  2479. }
  2480. RedisHelper.StringDelete(key);
  2481. }
  2482. }
  2483. if (dt.Rows.Count <= 0)
  2484. {
  2485. sql = new StringBuilder();
  2486. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2487. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2488. }
  2489. if (posCode == "Supplier")
  2490. {
  2491. string ids = CurrentUser.User.pemVend;
  2492. if (ids != null && ids.Length > 0)
  2493. {
  2494. string[] ids_list = ids.Split(',');
  2495. foreach (var item in ids_list)
  2496. {
  2497. string key = "return_order_" + item;
  2498. if (RedisHelper.HasKey(key))
  2499. {
  2500. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2501. dt.Columns.Add("ctid", typeof(string));
  2502. dt.Columns.Add("IsReadTag", typeof(int));
  2503. foreach (var i in list)
  2504. {
  2505. DataRow data = dt.NewRow();
  2506. data["ctid"] = i;
  2507. data["IsReadTag"] = 1;
  2508. dt.Rows.Add(data);
  2509. }
  2510. RedisHelper.StringDelete(key);
  2511. }
  2512. }
  2513. }
  2514. if (dt.Rows.Count <= 0)
  2515. {
  2516. sql = new StringBuilder();
  2517. sql.AppendFormat("select MemoOpt,SupplierId,ctid from ce_erptradecell where SupplierId in ({0}) and MemoOpt=3 and DATEDIFF(MINUTE,CheckOrderTime,GETDATE())<=3", CurrentUser.User.pemVend);
  2518. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2519. }
  2520. }
  2521. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2522. }
  2523. public void reset_erp_tiporder()
  2524. {
  2525. string ids = GetPostString("ids");
  2526. string[] ctidList = ids.Split(',');
  2527. foreach (string ctid in ctidList)
  2528. {
  2529. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2530. if (enty != null)
  2531. {
  2532. enty.IsReadTag = 0;
  2533. enty.Update();
  2534. }
  2535. }
  2536. returnSuccessMsg("成功!");
  2537. return;
  2538. }
  2539. public void get_erp_designlist()
  2540. {
  2541. DataStruct dStruct = GetPostStruct();
  2542. List<string> lw = new List<string>();
  2543. string tid = GetPostString("ctid");
  2544. if (tid.Length > 0)
  2545. {
  2546. string select_tid = getTidByCtid(tid);
  2547. lw.Add(string.Format("tid='{0}'", select_tid));
  2548. }
  2549. string shopname = GetPostString("shopname");
  2550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2551. string buyernick = GetPostString("buyer_nick");
  2552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2553. string customer = GetPostString("customer");
  2554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2555. string design = GetPostString("design");
  2556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2557. string orderState = GetPostString("orderState");
  2558. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2559. lw.Add(string.Format("OrderState<6"));
  2560. string address = GetPostString("address");
  2561. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2562. string sellermemo = GetPostString("seller_memo");
  2563. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2564. string date1 = GetPostString("date1");
  2565. string date2 = GetPostString("date2");
  2566. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2567. if (dw.Length > 0) lw.Add(dw);
  2568. string apdate1 = GetPostString("apdate1");
  2569. string apdate2 = GetPostString("apdate2");
  2570. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2571. if (dwap.Length > 0) lw.Add(dwap);
  2572. string price1 = GetPostString("price1");
  2573. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2574. string price2 = GetPostString("price2");
  2575. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2576. string designTime = GetPostString("designtime");
  2577. if (designTime.Length > 0)
  2578. {
  2579. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2580. }
  2581. string usershop = CurrentUser.User.pemShop;
  2582. if (usershop.Length > 0)
  2583. {
  2584. lw.Add(string.Format("shopId in ({0})", usershop));
  2585. }
  2586. int myOrgid = CurrentUser.UserPost.OrgID;
  2587. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2588. if (myOrgCode.IndexOf("Designer") != -1)
  2589. {
  2590. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2591. {
  2592. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2593. }
  2594. else
  2595. {
  2596. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2597. }
  2598. }
  2599. else
  2600. {
  2601. string orgId = GetPostString("designerhd");
  2602. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2603. }
  2604. if (tid.Length > 0 || buyernick.Length > 0)
  2605. {
  2606. lw.Add(string.Format("OrderState >= 3"));
  2607. }
  2608. else
  2609. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2610. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2611. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2612. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2613. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2614. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2615. if (dt != null && dt.Rows.Count > 0)
  2616. {
  2617. foreach (DataRow dr in dt.Rows)
  2618. {
  2619. try
  2620. {
  2621. // 对象操作
  2622. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2623. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2624. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2625. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2626. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2627. if (dStruct.PageSize != 100000)
  2628. {
  2629. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2630. dr["gongchuang"] = response.code;
  2631. }
  2632. }
  2633. catch (NullReferenceException ex)
  2634. {
  2635. }
  2636. }
  2637. }
  2638. writeGridDataTableJson(dStruct.TotalCount, dt);
  2639. }
  2640. public void get_erp_mydesignlist()
  2641. {
  2642. DataStruct dStruct = GetPostStruct();
  2643. List<string> lw = new List<string>();
  2644. string tid = GetPostString("ctid");
  2645. if (tid.Length > 0)
  2646. {
  2647. string select_tid = getTidByCtid(tid);
  2648. lw.Add(string.Format("tid='{0}'", select_tid));
  2649. }
  2650. string shopname = GetPostString("shopname");
  2651. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2652. string buyernick = GetPostString("buyer_nick");
  2653. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2654. string customer = GetPostString("customer");
  2655. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2656. string orderState = GetPostString("orderState");
  2657. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2658. //lw.Add(string.Format("OrderState<6"));
  2659. string date1 = GetPostString("date1");
  2660. string date2 = GetPostString("date2");
  2661. string dw = GetDateWhere("pay_time", date1, date2);
  2662. if (dw.Length > 0) lw.Add(dw);
  2663. string apdate1 = GetPostString("apdate1");
  2664. string apdate2 = GetPostString("apdate2");
  2665. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2666. if (dwap.Length > 0) lw.Add(dwap);
  2667. string price1 = GetPostString("price1");
  2668. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2669. string price2 = GetPostString("price2");
  2670. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2671. string olddownload = GetPostString("olddown");
  2672. if (olddownload == "1")
  2673. {
  2674. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2675. }
  2676. else if (olddownload == "2")
  2677. {
  2678. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2679. }
  2680. string sellermemo = GetPostString("seller_memo");
  2681. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2682. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2683. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2684. {
  2685. if (CurrentUser.User.TeamIds.Length > 0)
  2686. {
  2687. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2688. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2689. else
  2690. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2691. }
  2692. else
  2693. {
  2694. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2695. }
  2696. }
  2697. if (tid.Length <= 0)
  2698. {
  2699. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2700. }
  2701. lw.Add(string.Format("IsReturn!=3"));
  2702. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2703. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2704. string teamids = CurrentUser.User.TeamIds.ToString();
  2705. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2706. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2707. if (dt != null && dt.Rows.Count > 0)
  2708. {
  2709. foreach (DataRow dr in dt.Rows)
  2710. {
  2711. try
  2712. {
  2713. // 对象操作
  2714. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2715. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2716. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2717. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2718. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2719. if (dStruct.PageSize != 100000)
  2720. {
  2721. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2722. dr["gongchuang"] = response.code;
  2723. }
  2724. }
  2725. catch (NullReferenceException ex)
  2726. {
  2727. }
  2728. }
  2729. }
  2730. writeGridDataTableJson(dStruct.TotalCount, dt);
  2731. }
  2732. public void set_erp_startdesign()
  2733. {
  2734. if (UrlPostParmsCheck("ctid"))
  2735. {
  2736. string eid = GetPostString("ctid");
  2737. CeErpTradeCell entity = null;
  2738. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2739. if (entity != null)
  2740. {
  2741. if (entity.OrderState != 3)
  2742. {
  2743. returnErrorMsg("请刷新,订单已经设计了");
  2744. return;
  2745. }
  2746. entity.StartDesignTime = DateTime.Now;
  2747. entity.OrderState = 4;
  2748. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2749. {
  2750. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2751. entity.SupplierId = suid;
  2752. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2753. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2754. }
  2755. entity.UpdateTime = DateTime.Now;
  2756. //entity.MakeSupplier = suname;
  2757. entity.Update();
  2758. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2759. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2760. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2761. commonHelper.getCytPrice(entity);
  2762. returnSuccessMsg("操作成功!");
  2763. return;
  2764. }
  2765. returnErrorMsg("找不到记录");
  2766. }
  2767. }
  2768. public void ins_erp_designselfmemo()
  2769. {
  2770. if (UrlPostParmsCheck("ctid"))
  2771. {
  2772. string eid = GetPostString("ctid");
  2773. string con = GetPostString("con");
  2774. CeErpTradeCell entity = null;
  2775. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2776. if (entity != null)
  2777. {
  2778. entity.DesignSelfMemo = con;
  2779. entity.Update();
  2780. returnSuccessMsg("操作成功!");
  2781. return;
  2782. }
  2783. returnErrorMsg("找不到记录");
  2784. }
  2785. }
  2786. public void ins_erp_designprice()
  2787. {
  2788. if (UrlPostParmsCheck("ctid"))
  2789. {
  2790. string eid = GetPostString("ctid");
  2791. int uid = CurrentUser.UserID;
  2792. string userName = CurrentUser.UserName;
  2793. CeErpTradeCell entity = null;
  2794. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2795. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2796. if (entitys == null)
  2797. {
  2798. entitys = new CeErpDesignerBill();
  2799. }
  2800. if (entity != null)
  2801. {
  2802. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2803. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2804. entity.StartDesignTime = DateTime.Now;
  2805. entity.OrderState = 4;
  2806. string suname = "";
  2807. if (entity.SupplierId == 0)
  2808. {
  2809. int sid = commonHelper.autoDistributeToSupplier(entity);
  2810. entity.SupplierId = sid;
  2811. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2812. }
  2813. entity.Update();
  2814. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2815. if (ceErpUserPost != null)
  2816. {
  2817. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2818. if (ceErpPost != null)
  2819. {
  2820. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2821. {
  2822. entitys.tid = entity.ctid;
  2823. entitys.oid = entity.tid;
  2824. entitys.uid = uid;
  2825. entitys.userName = userName;
  2826. entitys.designerType = 1;
  2827. entitys.designerTypeText = "内部设计师";
  2828. entitys.price = Convert.ToDouble(GetPostString("price"));
  2829. entitys.designNum = GetPostInt("designNum");
  2830. entitys.modifyNum = GetPostInt("modifyNum");
  2831. entitys.designSize = GetPostString("designSize");
  2832. entitys.modifySize = GetPostString("modifySize");
  2833. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2834. {
  2835. entitys.create_time = DateTime.Now;
  2836. entitys.create_u_id = uid;
  2837. entitys.create_u_name = userName;
  2838. entitys.Save();
  2839. }
  2840. else
  2841. {
  2842. entitys.update_time = DateTime.Now;
  2843. entitys.update_u_id = uid;
  2844. entitys.update_u_name = userName;
  2845. entitys.Update();
  2846. }
  2847. }
  2848. }
  2849. }
  2850. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2851. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2852. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2853. if (suname != "")
  2854. {
  2855. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2856. }
  2857. commonHelper.getCytPrice(entity);
  2858. returnSuccessMsg("操作成功!");
  2859. return;
  2860. }
  2861. returnErrorMsg("找不到记录");
  2862. }
  2863. }
  2864. public void upload_erp_filecomplete()
  2865. {
  2866. if (UrlPostParmsCheck("ctid"))
  2867. {
  2868. string eid = GetPostString("ctid");
  2869. CeErpTradeCell entity = null;
  2870. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2871. if (entity != null)
  2872. {
  2873. entity.OrderState = 5; //设计完成
  2874. entity.Update();
  2875. returnSuccessMsg(eid + "上传成功,设计完成!");
  2876. return;
  2877. }
  2878. returnErrorMsg("找不到订单记录");
  2879. }
  2880. }
  2881. public void get_erp_designovertimelist()
  2882. {
  2883. DataStruct dStruct = GetPostStruct();
  2884. List<string> lw = new List<string>();
  2885. string tid = GetPostString("ctid");
  2886. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2887. string shopname = GetPostString("shopname");
  2888. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2889. string buyernick = GetPostString("buyer_nick");
  2890. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2891. string ResponsibleMan = GetPostString("responsible");
  2892. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2893. string date1 = GetPostString("date1");
  2894. string date2 = GetPostString("date2");
  2895. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2896. if (dw.Length > 0) lw.Add(dw);
  2897. string price1 = GetPostString("price1");
  2898. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2899. string price2 = GetPostString("price2");
  2900. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2901. string orderState = GetPostString("orderState");
  2902. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2903. string sellermemo = GetPostString("seller_memo");
  2904. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2905. lw.Add(string.Format("UnusualTag=3"));
  2906. lw.Add(string.Format("IsRefund<={0}", 1));
  2907. dStruct.Order = "WaitDesignTime desc";
  2908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2910. writeGridDataTableJson(dStruct.TotalCount, dt);
  2911. }
  2912. //设计管理 获取抢单大厅列表
  2913. public void get_erp_grabinglist()
  2914. {
  2915. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2916. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2917. bool oldOrder = false;
  2918. if (org != null)
  2919. {
  2920. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2921. }
  2922. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2923. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2924. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2925. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2926. //先处理订单数据
  2927. if (dt.Rows.Count > 0)
  2928. {
  2929. Dictionary<string, int> design = null;
  2930. int count = 0;
  2931. foreach (DataRow row in dt.Rows)
  2932. {
  2933. if (map.ContainsKey(row["ShopId"].ToString()))
  2934. {
  2935. map.TryGetValue(row["ShopId"].ToString(), out design);
  2936. }
  2937. else
  2938. {
  2939. design = new Dictionary<string, int>();
  2940. }
  2941. if (design.ContainsKey(row["ProductId"].ToString()))
  2942. {
  2943. design.TryGetValue(row["ProductId"].ToString(), out count);
  2944. }
  2945. count++;
  2946. design[row["ProductId"].ToString()] = count;
  2947. map[row["ShopId"].ToString()] = design;
  2948. }
  2949. }
  2950. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2951. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2952. //把店铺排序和技能排序分类
  2953. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2954. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2955. if (design_dt.Rows.Count > 0)
  2956. {
  2957. Dictionary<string, string> design = null;
  2958. List<string> shopIds = null;
  2959. foreach (DataRow row in design_dt.Rows)
  2960. {
  2961. if ("0".Equals(row["designId"].ToString()))
  2962. {
  2963. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2964. {
  2965. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2966. }
  2967. else
  2968. {
  2969. shopIds = new List<string>();
  2970. }
  2971. shopIds.Add(row["shopId"].ToString());
  2972. shop_orders[row["orders"].ToString()] = shopIds;
  2973. }
  2974. else
  2975. {
  2976. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2977. {
  2978. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2979. }
  2980. else
  2981. {
  2982. design = new Dictionary<string, string>();
  2983. }
  2984. design[row["orders"].ToString()] = row["designId"].ToString();
  2985. design_orders[row["shopId"].ToString()] = design;
  2986. }
  2987. }
  2988. //处理成key value后根据key排序
  2989. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2990. foreach (List<string> val in shop_orders.Values)
  2991. {
  2992. if (val != null)
  2993. {
  2994. foreach (string key in val)
  2995. {
  2996. if (design_orders.ContainsKey(key.ToString()))
  2997. {
  2998. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2999. }
  3000. }
  3001. }
  3002. }
  3003. }
  3004. //校验哪个优先级有订单
  3005. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3006. foreach (string key in shop_orders.Keys)
  3007. {
  3008. List<string> ids = null;
  3009. shop_orders.TryGetValue(key, out ids);
  3010. //id为shopid
  3011. foreach (string id in ids)
  3012. {
  3013. Dictionary<string, int> list = null;
  3014. Dictionary<string, string> desing = null;
  3015. map.TryGetValue(id, out list);
  3016. design_orders.TryGetValue(id, out desing);
  3017. if (list != null && desing != null)
  3018. {
  3019. foreach (var item in desing)
  3020. {
  3021. int count = 0;
  3022. if (list.ContainsKey(item.Value))
  3023. {
  3024. list.TryGetValue(item.Value, out count);
  3025. if (count > 0)
  3026. {
  3027. designIds[id] = item.Value;
  3028. break;
  3029. }
  3030. }
  3031. }
  3032. }
  3033. }
  3034. if (designIds.Count > 0)
  3035. {
  3036. break;
  3037. }
  3038. }
  3039. DataTable table = new DataTable();
  3040. table.Columns.Add("tid", typeof(string));
  3041. table.Columns.Add("ctid", typeof(string));
  3042. table.Columns.Add("seller_nick", typeof(string));
  3043. table.Columns.Add("productName", typeof(string));
  3044. table.Columns.Add("pay_time", typeof(string));
  3045. table.Columns.Add("seller_memo", typeof(string));
  3046. if (designIds.Count > 0)
  3047. {
  3048. string shopId = "";
  3049. string productId = "";
  3050. foreach (var designInfo in designIds)
  3051. {
  3052. shopId = designInfo.Key;
  3053. productId = designInfo.Value;
  3054. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3055. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3056. if (dt.Rows.Count > 0)
  3057. {
  3058. foreach (DataRow row in dt.Rows)
  3059. {
  3060. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3061. {
  3062. DataRow data = table.NewRow();
  3063. data["ctid"] = row["ctid"].ToString();
  3064. data["tid"] = row["tid"].ToString();
  3065. data["seller_nick"] = ceErpShop.ShopName;
  3066. data["pay_time"] = row["pay_time"].ToString();
  3067. data["seller_memo"] = row["seller_memo"].ToString();
  3068. data["productName"] = ceErpProduct.PType;
  3069. table.Rows.Add(data);
  3070. }
  3071. }
  3072. }
  3073. }
  3074. }
  3075. writeGridDataTableJson(table.Rows.Count, table);
  3076. }
  3077. private object rushLockObject = new object();
  3078. public void set_erp_grabingorder()
  3079. {
  3080. if (UrlPostParmsCheck("ctid"))
  3081. {
  3082. int total = CurrentUser.User.Person.Total;
  3083. int userId = CurrentUser.User.ID;
  3084. int noFinish = CurrentUser.User.Person.NoFinish;
  3085. int finalization = CurrentUser.User.Person.Finalization;
  3086. string eids = GetPostString("ctid");
  3087. string key = "RushKey_" + userId;
  3088. int count = 0;
  3089. if (erpRedis.RedisHelper.KeyExists(key))
  3090. {
  3091. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3092. if (redisCount != null)
  3093. {
  3094. count = Convert.ToInt32(redisCount);
  3095. }
  3096. }
  3097. if (count >= total)
  3098. {
  3099. returnErrorMsg("半小时内已经抢" + total + "单");
  3100. return;
  3101. }
  3102. string[] ctidlist = eids.Split(',');
  3103. if (count + ctidlist.Length > total)
  3104. {
  3105. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3106. return;
  3107. }
  3108. int itag = 0;
  3109. lock (rushLockObject)
  3110. {
  3111. if (ctidlist.Length > 0)
  3112. {
  3113. string[] dtList = new string[ctidlist.Length];
  3114. for (int i = 0; i < ctidlist.Length; i++)
  3115. {
  3116. dtList[i] = "'" + ctidlist[i] + "'";
  3117. }
  3118. 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"));
  3119. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3120. if (dt_user.Rows.Count > 0)
  3121. {
  3122. int doing = 0;//未定稿
  3123. int finish = 0;//已完成
  3124. foreach (DataRow dr in dt_user.Rows)
  3125. {
  3126. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3127. {
  3128. doing++;
  3129. }
  3130. else
  3131. {
  3132. finish++;
  3133. }
  3134. }
  3135. if (doing >= noFinish)
  3136. {
  3137. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3138. return;
  3139. }
  3140. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3141. {
  3142. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3143. return;
  3144. }
  3145. }
  3146. //校验选择单子状态
  3147. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3148. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3149. if (dt.Rows.Count > 0)
  3150. {
  3151. List<string> list = new List<string>();
  3152. foreach (DataRow dr in dt.Rows)
  3153. {
  3154. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3155. {
  3156. list.Add(dr["ctid"].ToString());
  3157. }
  3158. }
  3159. if (list.Count > 0)
  3160. {
  3161. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3162. return;
  3163. }
  3164. }
  3165. foreach (string ctid in ctidlist)
  3166. {
  3167. CeErpTradeCell entity = null;
  3168. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3169. if (entity != null)
  3170. {
  3171. entity.OrderState = 3;
  3172. entity.DesignUserId = CurrentUser.UserID;
  3173. entity.WaitDesignTime = DateTime.Now;
  3174. entity.StartDesignTime = DateTime.Now;
  3175. entity.Update();
  3176. commonHelper.UpdateRelationOrder(entity.ctid);
  3177. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3179. itag++;
  3180. }
  3181. }
  3182. }
  3183. }
  3184. count += ctidlist.Length;
  3185. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3186. if (itag == 0)
  3187. returnErrorMsg("没有找到相关订单");
  3188. else
  3189. returnSuccessMsg("抢单成功!");
  3190. return;
  3191. }
  3192. }
  3193. public void get_erp_waitorderlist()
  3194. {
  3195. DataStruct dStruct = GetPostStruct();
  3196. List<string> lw = new List<string>();
  3197. string tid = GetPostString("ctid");
  3198. if (tid.Length > 0)
  3199. {
  3200. string select_tid = getTidByCtid(tid);
  3201. lw.Add(string.Format("tid='{0}'", select_tid));
  3202. }
  3203. string shopname = GetPostString("shopname");
  3204. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3205. string buyernick = GetPostString("buyer_nick");
  3206. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3207. string customer = GetPostString("customer");
  3208. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3209. string design = GetPostString("design");
  3210. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3211. string orderState = GetPostString("orderState");
  3212. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3213. string supplier = GetPostString("supplier");
  3214. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3215. string sellermemo = GetPostString("seller_memo");
  3216. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3217. string otherMemo = GetPostString("otherMemo");
  3218. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3219. string address = GetPostString("address");
  3220. 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));
  3221. string date1 = GetPostString("date1");
  3222. string date2 = GetPostString("date2");
  3223. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3224. if (dw.Length > 0) lw.Add(dw);
  3225. string price1 = GetPostString("price1");
  3226. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3227. string price2 = GetPostString("price2");
  3228. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3229. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3230. lw.Add(string.Format("IsSample != 2 "));
  3231. lw.Add(string.Format("OrderState = 5 "));
  3232. lw.Add(string.Format("IsRefund<={0}", 1));
  3233. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3234. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3235. string pagesize = GetPostString("pagesize");
  3236. if (pagesize != null)
  3237. {
  3238. dStruct.PageSize = 200;
  3239. }
  3240. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3241. if (dt != null)
  3242. {
  3243. foreach (DataRow dr in dt.Rows)
  3244. {
  3245. 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();
  3246. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3247. {
  3248. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3249. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3250. entity.SupplierId = suid;
  3251. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3252. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3253. entity.Update();
  3254. }
  3255. }
  3256. }
  3257. writeGridDataTableJson(dStruct.TotalCount, dt);
  3258. }
  3259. public void get_erp_supplierwaitorderlist()
  3260. {
  3261. DataStruct dStruct = GetPostStruct();
  3262. List<string> lw = new List<string>();
  3263. string tid = GetPostString("ctid");
  3264. if (tid.Length > 0)
  3265. {
  3266. string select_tid = getTidByCtid(tid);
  3267. lw.Add(string.Format("tid='{0}'", select_tid));
  3268. }
  3269. string shopname = GetPostString("shopname");
  3270. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3271. string sellermemo = GetPostString("seller_memo");
  3272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3273. string date1 = GetPostString("date1");
  3274. string date2 = GetPostString("date2");
  3275. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3276. if (dw.Length > 0) lw.Add(dw);
  3277. lw.Add(string.Format("OrderState = 5 "));
  3278. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3279. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3280. {
  3281. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3282. }
  3283. string supplier = GetPostString("supplier");
  3284. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3285. {
  3286. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3287. }
  3288. lw.Add(string.Format("IsRefund<={0}", 1));
  3289. dStruct.Order = "FinishDesignTime desc";
  3290. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3291. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3292. if (dt != null)
  3293. {
  3294. foreach (DataRow dr in dt.Rows)
  3295. {
  3296. 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();
  3297. }
  3298. }
  3299. writeGridDataTableJson(dStruct.TotalCount, dt);
  3300. }
  3301. public void upd_erp_verifytosupplier()
  3302. {
  3303. if (UrlPostParmsCheck("ctid"))
  3304. {
  3305. string eids = GetPostString("ctid");
  3306. CeErpTradeCell entity = null;
  3307. string[] eidsList = eids.Split(',');
  3308. if (eidsList.Length <= 0)
  3309. {
  3310. returnErrorMsg("订单号不能空");
  3311. return;
  3312. }
  3313. List<string> tLst = new List<string>();
  3314. foreach (string ctidstr in eidsList)
  3315. {
  3316. tLst.Add("'" + ctidstr + "'");
  3317. CeErpDataSendOrderInfo.createObject(ctidstr);
  3318. }
  3319. string needtids = string.Join(",", tLst.ToArray());
  3320. StringBuilder sql = new StringBuilder();
  3321. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3322. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3323. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3324. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3325. returnSuccessMsg("操作成功!");
  3326. return;
  3327. /**foreach (string ctidstr in eidsList)
  3328. {
  3329. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3330. if (entity != null)
  3331. {
  3332. if (entity.SupplierId == 0)
  3333. {
  3334. continue;
  3335. }
  3336. entity.IsVerifyToSupplier = true;
  3337. if (entity.IsReturn == 1) //1是供应商打回
  3338. {
  3339. entity.IsReturn = 0;
  3340. }
  3341. entity.FinishPlaceTime = DateTime.Now;
  3342. entity.PlaceUserId = CurrentUser.UserID;
  3343. entity.Update();
  3344. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3345. }
  3346. }
  3347. returnSuccessMsg("操作成功!");
  3348. return;**/
  3349. }
  3350. }
  3351. public void upd_erp_supplierback()
  3352. {
  3353. if (UrlPostParmsCheck("ctid"))
  3354. {
  3355. string eid = GetPostString("ctid");
  3356. string reason = GetPostString("returnreason");
  3357. CeErpTradeCell entity = null;
  3358. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3359. if (entity != null)
  3360. {
  3361. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3362. {
  3363. string key = "return_order_" + entity.SupplierId;
  3364. List<string> list = new List<string>();
  3365. if (RedisHelper.HasKey(key))
  3366. {
  3367. object data = RedisHelper.StringGet(key);
  3368. list = Convert.ToString(data).Split(',').ToList();
  3369. }
  3370. list.Add(eid);
  3371. RedisHelper.StringSet(key, string.Join(",", list));
  3372. }
  3373. entity.IsVerifyToSupplier = false;
  3374. entity.IsReturn = 1;
  3375. entity.ReturnTime = DateTime.Now;
  3376. entity.ReturnReason = reason;
  3377. if (entity.OrderState == 6)
  3378. {
  3379. entity.OrderState = 5;
  3380. }
  3381. entity.Update();
  3382. CeErpSukuraData.createInfo(entity.ctid, 5);
  3383. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3384. returnSuccessMsg("操作成功!");
  3385. return;
  3386. }
  3387. returnErrorMsg("找不到订单记录");
  3388. }
  3389. }
  3390. public void upd_erp_toaftersaleorder()
  3391. {
  3392. if (UrlPostParmsCheck("ctid"))
  3393. {
  3394. string eid = GetPostString("ctid");
  3395. string reason = GetPostString("returnreason");
  3396. CeErpTradeCell entity = null;
  3397. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3398. if (entity != null)
  3399. {
  3400. if (entity.isAfterSaleOrder != 1)
  3401. {
  3402. returnErrorMsg("带S的售后单才能打回给售后");
  3403. return;
  3404. }
  3405. if (entity.OrderState >= 5)
  3406. {
  3407. returnErrorMsg("已经设计完成了不能打回给售后");
  3408. return;
  3409. }
  3410. entity.OrderState = 0;
  3411. entity.IsReturn = 3;
  3412. entity.ReturnTime = DateTime.Now;
  3413. entity.UpdateTime = DateTime.Now;
  3414. entity.ReturnReason = reason;
  3415. entity.Update();
  3416. CeErpSukuraData.createInfo(entity.ctid, 5);
  3417. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3418. returnSuccessMsg("操作成功!");
  3419. return;
  3420. }
  3421. returnErrorMsg("找不到订单记录");
  3422. }
  3423. }
  3424. public void upd_erp_aftersaletodesign()
  3425. {
  3426. if (UrlPostParmsCheck("ctid"))
  3427. {
  3428. string eid = GetPostString("ctid");
  3429. CeErpTradeCell entity = null;
  3430. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3431. if (entity != null)
  3432. {
  3433. entity.OrderState = 3;
  3434. entity.IsReturn = 0;
  3435. entity.UpdateTime = DateTime.Now;
  3436. entity.Update();
  3437. CeErpSukuraData.createInfo(entity.ctid, 5);
  3438. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3439. returnSuccessMsg("操作成功!");
  3440. return;
  3441. }
  3442. returnErrorMsg("找不到订单记录");
  3443. }
  3444. }
  3445. public void assign_erp_supplier()
  3446. {
  3447. if (UrlPostParmsCheck("ctid"))
  3448. {
  3449. string eids = GetPostString("ctid");
  3450. int sid = GetPostInt("SupplierName");
  3451. string fromTag = GetPostString("tag");
  3452. string[] eidList = eids.Split(',');
  3453. if (eidList.Length <= 0)
  3454. {
  3455. returnErrorMsg("指派不能为空");
  3456. return;
  3457. }
  3458. string errMsg = "";
  3459. string suname = commonHelper.getSupplierNameById(sid);
  3460. foreach (string ctid in eidList)
  3461. {
  3462. CeErpTradeCell entity = null;
  3463. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3464. if (entity != null)
  3465. {
  3466. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3467. {
  3468. errMsg += (ctid + "指派失败!!!");
  3469. continue;
  3470. }
  3471. entity.SupplierId = sid;
  3472. entity.Update();
  3473. commonHelper.UpdateRelationOrder(entity.ctid);
  3474. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3475. if (entity.OrderState >= 6)
  3476. {
  3477. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3478. //{
  3479. // string msl = entity.MakeSupplier;
  3480. // string[] mslist = msl.Split(',');
  3481. // 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);
  3482. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3483. //}
  3484. //else
  3485. //{
  3486. StringBuilder sql = new StringBuilder();
  3487. 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);
  3488. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3489. //}
  3490. }
  3491. }
  3492. else
  3493. {
  3494. continue;
  3495. }
  3496. }
  3497. if (errMsg.Length > 0)
  3498. {
  3499. returnErrorMsg(errMsg);
  3500. return;
  3501. }
  3502. returnSuccessMsg("操作成功!");
  3503. return;
  3504. }
  3505. }
  3506. public void assign_erp_makesupplier()
  3507. {
  3508. if (UrlPostParmsCheck("ctid"))
  3509. {
  3510. string eids = GetPostString("ctid");
  3511. string sname = GetPostString("SupplierName");
  3512. string[] eidList = eids.Split(',');
  3513. if (eidList.Length <= 0)
  3514. {
  3515. returnErrorMsg("指派不能为空");
  3516. return;
  3517. }
  3518. List<string> tLst = new List<string>();
  3519. foreach (string ctid in eidList)
  3520. {
  3521. CeErpTradeCell entity = null;
  3522. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3523. if (entity != null)
  3524. {
  3525. entity.MakeSupplier = sname;
  3526. entity.Update();
  3527. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3528. tLst.Add("'" + ctid + "'");
  3529. }
  3530. else
  3531. {
  3532. continue;
  3533. }
  3534. }
  3535. string ctids = string.Join(",", tLst.ToArray());
  3536. StringBuilder sql2 = new StringBuilder();
  3537. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3538. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3539. returnSuccessMsg("操作成功!");
  3540. return;
  3541. }
  3542. }
  3543. public void ins_erp_returnreason()
  3544. {
  3545. if (UrlPostParmsCheck("ctid"))
  3546. {
  3547. string eid = GetPostString("ctid");
  3548. CeErpTradeCell entity = null;
  3549. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3550. string userpost = CurrentUser.UserPost.Post.Code;
  3551. if (entity != null)
  3552. {
  3553. bool isPlace = false;
  3554. if (entity.OrderState > 6)
  3555. {
  3556. returnErrorMsg("已发货无法打回!");
  3557. return;
  3558. }
  3559. if (entity.OrderState == 6)
  3560. {
  3561. isPlace = true;
  3562. }
  3563. bool isNeedUpdateCell2 = false;
  3564. if (entity.OrderState >= 6)
  3565. {
  3566. isNeedUpdateCell2 = true;
  3567. }
  3568. int returnTag = 2;
  3569. if (userpost == "Supplier")
  3570. {
  3571. returnTag = 1;
  3572. }
  3573. int toType = GetPostInt("totype");
  3574. string fromType = "3";
  3575. if (entity.OrderState < 5)
  3576. {
  3577. fromType = "3";
  3578. }
  3579. else
  3580. {
  3581. fromType = "4";
  3582. }
  3583. if (entity.IsXianHuo == 0)
  3584. {
  3585. if (returnTag == 2)
  3586. {
  3587. if (toType == 1)
  3588. {
  3589. entity.OrderState = 0;
  3590. entity.ReturnUserType = 1;
  3591. string clearman = GetPostString("clearman");
  3592. if (!string.IsNullOrEmpty(clearman))
  3593. {
  3594. entity.DesignUserId = 0;
  3595. }
  3596. }
  3597. else
  3598. {
  3599. entity.OrderState = 3;
  3600. entity.ReturnUserType = 2;
  3601. }
  3602. entity.IsReadTag = 1;
  3603. }
  3604. else if (returnTag == 1)
  3605. {
  3606. entity.OrderState = 5;
  3607. }
  3608. entity.IsVerifyToSupplier = false;
  3609. }
  3610. if (entity.IsXianHuo == 1)
  3611. {
  3612. entity.OrderState = 5;
  3613. }
  3614. entity.UnusualTag = 0;
  3615. entity.UnusualTime = null;
  3616. entity.UnusualCon = "";
  3617. entity.IsReturn = returnTag;
  3618. entity.ReturnTime = DateTime.Now;
  3619. entity.UpdateTime = DateTime.Now;
  3620. entity.ReturnReason = GetPostString("returnreason");
  3621. entity.Update();
  3622. if (entity.OrderState == 3)
  3623. {
  3624. ApiVo apiVo = new ApiVo();
  3625. apiVo.orderNumber = entity.ctid;
  3626. apiVo.actionName = "rebutDesign";
  3627. apiVo.orderRemarks = entity.ReturnReason;
  3628. designHelper.API_WorkCore(apiVo);//rebutDesign
  3629. }
  3630. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3631. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3632. {
  3633. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3634. }
  3635. CeErpSukuraData.createInfo(entity.ctid, 5);
  3636. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3637. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3638. if (isPlace)
  3639. {
  3640. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3641. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3642. if (dth != null && dth.Rows.Count > 0)
  3643. {
  3644. dataSendOrderBean dataSendOrderBean = null;
  3645. foreach (DataRow item in dth.Rows)
  3646. {
  3647. try
  3648. {
  3649. dataSendOrderBean = new dataSendOrderBean();
  3650. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3651. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3652. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3653. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3654. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3655. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3656. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3657. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3658. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3659. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3660. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3661. dataSendOrderBean.Radio1723534706288 = "打回";
  3662. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3663. if (result != null)
  3664. {
  3665. if ("0".Equals(result.errcode))
  3666. {
  3667. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3668. }
  3669. else
  3670. {
  3671. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3672. }
  3673. }
  3674. }
  3675. catch (Exception ex)
  3676. {
  3677. }
  3678. }
  3679. }
  3680. }
  3681. if (isNeedUpdateCell2)
  3682. {
  3683. if (entity.MakeSupplier.IndexOf(",") != -1)
  3684. {
  3685. StringBuilder sql2 = new StringBuilder();
  3686. 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);
  3687. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3688. }
  3689. else
  3690. {
  3691. StringBuilder sql2 = new StringBuilder();
  3692. 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);
  3693. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3694. }
  3695. }
  3696. returnSuccessMsg("操作成功!");
  3697. return;
  3698. }
  3699. returnErrorMsg("找不到订单记录");
  3700. }
  3701. }
  3702. public void cyt_erp_returnreason()
  3703. {
  3704. if (UrlPostParmsCheck("ctid"))
  3705. {
  3706. string eid = GetPostString("ctid");
  3707. CeErpTradeCell entity = null;
  3708. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3709. string userpost = CurrentUser.UserPost.Post.Code;
  3710. if (entity != null)
  3711. {
  3712. if (entity.OrderState > 6)
  3713. {
  3714. returnErrorMsg("已发货无法打回!");
  3715. return;
  3716. }
  3717. JObject jsonObject = new JObject
  3718. {
  3719. { "Userid", "77886" },
  3720. { "Pwd", "lt666888" },
  3721. { "LTOrderId",eid }
  3722. };
  3723. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3724. JObject jsonObjects = JObject.Parse(response);
  3725. string msg = (string)jsonObjects["msg"];
  3726. if (msg != "取消成功")
  3727. {
  3728. returnErrorMsg(msg);
  3729. return;
  3730. }
  3731. bool isNeedUpdateCell2 = false;
  3732. if (entity.OrderState >= 6)
  3733. {
  3734. isNeedUpdateCell2 = true;
  3735. }
  3736. int returnTag = 2;
  3737. if (userpost == "Supplier")
  3738. {
  3739. returnTag = 1;
  3740. }
  3741. if (entity.IsXianHuo == 0)
  3742. {
  3743. if (returnTag == 2)
  3744. {
  3745. int toType = GetPostInt("totype");
  3746. if (toType == 1)
  3747. {
  3748. entity.OrderState = 0;
  3749. entity.ReturnUserType = 1;
  3750. }
  3751. else
  3752. {
  3753. entity.OrderState = 4;
  3754. entity.ReturnUserType = 2;
  3755. }
  3756. entity.IsReadTag = 1;
  3757. }
  3758. else if (returnTag == 1)
  3759. {
  3760. entity.OrderState = 5;
  3761. }
  3762. entity.IsVerifyToSupplier = false;
  3763. }
  3764. entity.UnusualTag = 0;
  3765. entity.UnusualTime = null;
  3766. entity.UnusualCon = "";
  3767. entity.IsReturn = returnTag;
  3768. entity.ReturnTime = DateTime.Now;
  3769. entity.ReturnReason = GetPostString("returnreason");
  3770. entity.Update();
  3771. if (entity.OrderState == 4)
  3772. {
  3773. ApiVo apiVo = new ApiVo();
  3774. apiVo.orderNumber = entity.ctid;
  3775. apiVo.actionName = "rebutDesign";
  3776. apiVo.orderRemarks = entity.ReturnReason;
  3777. designHelper.API_WorkCore(apiVo);//rebutDesign
  3778. }
  3779. CeErpSukuraData.createInfo(entity.ctid, 5);
  3780. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3781. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3782. if (isNeedUpdateCell2)
  3783. {
  3784. if (entity.MakeSupplier.IndexOf(",") != -1)
  3785. {
  3786. StringBuilder sql2 = new StringBuilder();
  3787. 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);
  3788. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3789. }
  3790. else
  3791. {
  3792. StringBuilder sql2 = new StringBuilder();
  3793. 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);
  3794. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3795. }
  3796. }
  3797. returnSuccessMsg("操作成功!");
  3798. return;
  3799. }
  3800. returnErrorMsg("找不到订单记录");
  3801. }
  3802. }
  3803. public void upd_erp_xianhuoreturntag()
  3804. {
  3805. if (UrlPostParmsCheck("ctid"))
  3806. {
  3807. string eids = GetPostString("ctid");
  3808. string[] ctids = eids.Split(',');
  3809. foreach (string ctid in ctids)
  3810. {
  3811. CeErpTradeCell entity = null;
  3812. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3813. if (entity != null)
  3814. {
  3815. entity.IsReturn = 0;
  3816. entity.Update();
  3817. CeErpSukuraData.createInfo(entity.ctid, 5);
  3818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3819. }
  3820. }
  3821. returnSuccessMsg("操作成功!");
  3822. return;
  3823. }
  3824. }
  3825. public void get_erp_waitdeliverylist()
  3826. {
  3827. DataStruct dStruct = GetPostStruct();
  3828. List<string> lw = new List<string>();
  3829. string tid = GetPostString("ctid");
  3830. if (tid.Length > 0)
  3831. {
  3832. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3833. if (tid.Length > 5)
  3834. {
  3835. List<string> tids = getTidByCtidLike(tid);
  3836. if (tids.Count > 0 && tids.Count < 10)
  3837. {
  3838. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3839. }
  3840. }
  3841. lw.Add(tid_sql);
  3842. }
  3843. string shopname = GetPostString("shopname");
  3844. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3845. string buyernick = GetPostString("buyer_nick");
  3846. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3847. //if (tid.Length == 0 && buyernick.Length == 0)
  3848. //{
  3849. // lw.Add(string.Format("IsRefund<={0}", 1));
  3850. //}
  3851. string customer = GetPostString("customer");
  3852. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3853. string design = GetPostString("design");
  3854. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3855. string orderState = GetPostString("orderState");
  3856. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3857. string address = GetPostString("address");
  3858. 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));
  3859. string sellermemo = GetPostString("seller_memo");
  3860. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3861. string supplier = GetPostString("supplier");
  3862. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3863. string OrderArea = GetPostString("order_area");
  3864. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3865. string placedate1 = GetPostString("placedate1");
  3866. string placedate2 = GetPostString("placedate2");
  3867. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3868. if (fdw.Length > 0) lw.Add(fdw);
  3869. string price1 = GetPostString("price1");
  3870. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3871. string price2 = GetPostString("price2");
  3872. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3873. string unusualCon = GetPostString("unusualcon");
  3874. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3875. string otherMemo = GetPostString("otherMemo");
  3876. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3877. string posTag = CurrentUser.UserPost.Post.Code;
  3878. if (posTag == "Supplier")
  3879. {
  3880. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3881. }
  3882. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3883. lw.Add(string.Format("type != 'PDD' "));
  3884. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3885. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3886. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3887. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3888. writeGridDataTableJson(dStruct.TotalCount, dt);
  3889. }
  3890. public void get_erp_changedeliverylist()
  3891. {
  3892. DataStruct dStruct = GetPostStruct();
  3893. List<string> lw = new List<string>();
  3894. string tid = GetPostString("ctid");
  3895. if (tid.Length > 0)
  3896. {
  3897. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3898. if (tid.Length > 5)
  3899. {
  3900. List<string> tids = getTidByCtidLike(tid);
  3901. if (tids.Count > 0 && tids.Count < 10)
  3902. {
  3903. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3904. }
  3905. }
  3906. lw.Add(tid_sql);
  3907. }
  3908. string shopname = GetPostString("shopname");
  3909. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3910. string buyernick = GetPostString("buyer_nick");
  3911. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3912. //if (tid.Length == 0 && buyernick.Length == 0)
  3913. //{
  3914. // lw.Add(string.Format("IsRefund<={0}", 1));
  3915. //}
  3916. string customer = GetPostString("customer");
  3917. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3918. string design = GetPostString("design");
  3919. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3920. string orderState = GetPostString("orderState");
  3921. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3922. string address = GetPostString("address");
  3923. 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));
  3924. string sellermemo = GetPostString("seller_memo");
  3925. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3926. string supplier = GetPostString("supplier");
  3927. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3928. string OrderArea = GetPostString("order_area");
  3929. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3930. string placedate1 = GetPostString("placedate1");
  3931. string placedate2 = GetPostString("placedate2");
  3932. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3933. if (fdw.Length > 0) lw.Add(fdw);
  3934. string price1 = GetPostString("price1");
  3935. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3936. string price2 = GetPostString("price2");
  3937. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3938. string unusualCon = GetPostString("unusualcon");
  3939. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3940. string otherMemo = GetPostString("otherMemo");
  3941. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3942. string posTag = CurrentUser.UserPost.Post.Code;
  3943. if (posTag == "Supplier")
  3944. {
  3945. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3946. }
  3947. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3948. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3949. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3950. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3951. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3952. /*if (tid.Length > 0)
  3953. {
  3954. List<string> tids = new List<string>();
  3955. if (dt != null && dt.Rows.Count > 0)
  3956. {
  3957. foreach (DataRow item in dt.Rows)
  3958. {
  3959. tids.Add("'" + item["tid"] + "'");
  3960. }
  3961. }
  3962. if (tids.Count > 0)
  3963. {
  3964. lw.RemoveAt(0);
  3965. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3967. dt = WebCache.GetData("view_erptradecell", dStruct);
  3968. }
  3969. }*/
  3970. writeGridDataTableJson(dStruct.TotalCount, dt);
  3971. }
  3972. public void get_erp_pddderiving()
  3973. {
  3974. DataStruct dStruct = GetPostStruct();
  3975. List<string> lw = new List<string>();
  3976. string tid = GetPostString("ctid");
  3977. if (tid.Length > 0)
  3978. {
  3979. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3980. if (tid.Length > 5)
  3981. {
  3982. List<string> tids = getTidByCtidLike(tid);
  3983. if (tids.Count > 0 && tids.Count < 10)
  3984. {
  3985. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3986. }
  3987. }
  3988. lw.Add(tid_sql);
  3989. }
  3990. string shopname = GetPostString("shopname");
  3991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3992. string buyernick = GetPostString("buyer_nick");
  3993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3994. //if (tid.Length == 0 && buyernick.Length == 0)
  3995. //{
  3996. // lw.Add(string.Format("IsRefund<={0}", 1));
  3997. //}
  3998. string customer = GetPostString("customer");
  3999. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4000. string design = GetPostString("design");
  4001. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4002. string orderState = GetPostString("orderState");
  4003. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4004. string address = GetPostString("address");
  4005. 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));
  4006. string sellermemo = GetPostString("seller_memo");
  4007. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4008. string supplier = GetPostString("supplier");
  4009. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4010. string OrderArea = GetPostString("order_area");
  4011. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4012. string placedate1 = GetPostString("placedate1");
  4013. string placedate2 = GetPostString("placedate2");
  4014. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4015. if (fdw.Length > 0) lw.Add(fdw);
  4016. string price1 = GetPostString("price1");
  4017. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4018. string price2 = GetPostString("price2");
  4019. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4020. string unusualCon = GetPostString("unusualcon");
  4021. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4022. string posTag = CurrentUser.UserPost.Post.Code;
  4023. if (posTag == "Supplier")
  4024. {
  4025. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4026. }
  4027. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4028. lw.Add(string.Format("type = 'PDD' "));
  4029. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4030. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4032. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4033. /*if (tid.Length > 0)
  4034. {
  4035. List<string> tids = new List<string>();
  4036. if (dt != null && dt.Rows.Count > 0)
  4037. {
  4038. foreach (DataRow item in dt.Rows)
  4039. {
  4040. tids.Add("'" + item["tid"] + "'");
  4041. }
  4042. }
  4043. if (tids.Count > 0)
  4044. {
  4045. lw.RemoveAt(0);
  4046. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4047. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4048. dt = WebCache.GetData("view_erptradecell", dStruct);
  4049. }
  4050. }*/
  4051. writeGridDataTableJson(dStruct.TotalCount, dt);
  4052. }
  4053. public void get_erp_jdderiving()
  4054. {
  4055. DataStruct dStruct = GetPostStruct();
  4056. List<string> lw = new List<string>();
  4057. string tid = GetPostString("ctid");
  4058. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4059. string shopname = GetPostString("shopname");
  4060. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4061. string buyernick = GetPostString("buyer_nick");
  4062. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4063. //if (tid.Length == 0 && buyernick.Length == 0)
  4064. //{
  4065. // lw.Add(string.Format("IsRefund<={0}", 1));
  4066. //}
  4067. string customer = GetPostString("customer");
  4068. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4069. string design = GetPostString("design");
  4070. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4071. string orderState = GetPostString("orderState");
  4072. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4073. string address = GetPostString("address");
  4074. 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));
  4075. string sellermemo = GetPostString("seller_memo");
  4076. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4077. string supplier = GetPostString("supplier");
  4078. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4079. string OrderArea = GetPostString("order_area");
  4080. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4081. string placedate1 = GetPostString("placedate1");
  4082. string placedate2 = GetPostString("placedate2");
  4083. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4084. if (fdw.Length > 0) lw.Add(fdw);
  4085. string price1 = GetPostString("price1");
  4086. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4087. string price2 = GetPostString("price2");
  4088. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4089. string unusualCon = GetPostString("unusualcon");
  4090. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4091. string posTag = CurrentUser.UserPost.Post.Code;
  4092. if (posTag == "Supplier")
  4093. {
  4094. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4095. }
  4096. lw.Add(string.Format("OrderState = 6 "));
  4097. lw.Add(string.Format("type = 'JD' "));
  4098. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4099. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4100. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4101. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4102. writeGridDataTableJson(dStruct.TotalCount, dt);
  4103. }
  4104. public void get_erp_demoorderlist()
  4105. {
  4106. DataStruct dStruct = GetPostStruct();
  4107. List<string> lw = new List<string>();
  4108. string tid = GetPostString("ctid");
  4109. if (tid.Length > 0)
  4110. {
  4111. string select_tid = getTidByCtid(tid);
  4112. lw.Add(string.Format("tid='{0}'", select_tid));
  4113. }
  4114. string shopname = GetPostString("shopname");
  4115. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4116. string buyernick = GetPostString("buyer_nick");
  4117. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4118. string customer = GetPostString("customer");
  4119. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4120. string design = GetPostString("design");
  4121. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4122. string orderState = GetPostString("orderState");
  4123. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4124. string address = GetPostString("address");
  4125. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4126. string sellermemo = GetPostString("seller_memo");
  4127. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4128. string supplier = GetPostString("supplier");
  4129. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4130. string OrderArea = GetPostString("order_area");
  4131. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4132. string date1 = GetPostString("date1");
  4133. string date2 = GetPostString("date2");
  4134. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4135. if (dw.Length > 0) lw.Add(dw);
  4136. string price1 = GetPostString("price1");
  4137. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4138. string price2 = GetPostString("price2");
  4139. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4140. string posTag = CurrentUser.UserPost.Post.Code;
  4141. if (posTag == "Supplier")
  4142. {
  4143. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4144. }
  4145. //lw.Add(string.Format("OrderState = 6 "));
  4146. lw.Add(string.Format("IsSample={0}", 3));
  4147. lw.Add(string.Format("IsRefund<={0}", 1));
  4148. dStruct.Order = "pay_time desc";
  4149. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4150. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4151. writeGridDataTableJson(dStruct.TotalCount, dt);
  4152. }
  4153. public void save_erp_checkmemo()
  4154. {
  4155. if (UrlPostParmsCheck("ctid"))
  4156. {
  4157. string ctid = GetPostString("ctid");
  4158. CeErpTradeCell entity = null;
  4159. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4160. if (entity != null)
  4161. {
  4162. entity.CheckMemo = GetPostString("CheckMemo");
  4163. entity.Update();
  4164. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4165. if (trade != null)
  4166. {
  4167. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4168. }
  4169. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4170. returnSuccessMsg("保存成功!");
  4171. return;
  4172. }
  4173. returnErrorMsg("找不到记录");
  4174. }
  4175. }
  4176. public void get_erp_returnlist()
  4177. {
  4178. DataStruct dStruct = GetPostStruct();
  4179. List<string> lw = new List<string>();
  4180. string tid = GetPostString("ctid");
  4181. if (tid.Length > 0)
  4182. {
  4183. string select_tid = getTidByCtid(tid);
  4184. lw.Add(string.Format("tid='{0}'", select_tid));
  4185. }
  4186. string shopname = GetPostString("shopname");
  4187. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4188. string buyernick = GetPostString("buyer_nick");
  4189. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4190. string customer = GetPostString("customer");
  4191. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4192. string design = GetPostString("design");
  4193. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4194. string orderState = GetPostString("orderState");
  4195. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4196. string address = GetPostString("address");
  4197. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4198. string sellermemo = GetPostString("seller_memo");
  4199. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4200. string supplier = GetPostString("supplier");
  4201. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4202. string date1 = GetPostString("date1");
  4203. string date2 = GetPostString("date2");
  4204. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4205. if (dw.Length > 0) lw.Add(dw);
  4206. string bdate1 = GetPostString("backdate1");
  4207. string bdate2 = GetPostString("backdate2");
  4208. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4209. if (dw_back.Length > 0) lw.Add(dw_back);
  4210. string price1 = GetPostString("price1");
  4211. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4212. string price2 = GetPostString("price2");
  4213. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4214. lw.Add(string.Format("IsReturn>0"));
  4215. lw.Add(string.Format("IsXianHuo=0"));
  4216. lw.Add(string.Format("IsReturn!=3"));
  4217. string backtype = GetPostString("backtype");
  4218. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4219. dStruct.Order = "FinishDesignTime desc";
  4220. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4221. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4222. writeGridDataTableJson(dStruct.TotalCount, dt);
  4223. }
  4224. public void get_erp_today_sumreturn()
  4225. {
  4226. DataStruct dStruct = GetPostStruct();
  4227. List<string> lw = new List<string>();
  4228. string bdate1 = GetPostString("returnTimeS");
  4229. string bdate2 = GetPostString("returnTimeE");
  4230. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4231. if (dw_back.Length > 0) lw.Add(dw_back);
  4232. lw.Add(string.Format("IsReturn=0"));
  4233. lw.Add(string.Format("IsXianHuo=0"));
  4234. string mainWhere = string.Join(" and ", lw.ToArray());
  4235. string sql = "";
  4236. if (dw_back.Length > 0)
  4237. {
  4238. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4239. }
  4240. else
  4241. {
  4242. 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 + "'";
  4243. }
  4244. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4245. decimal total = 0, today_finish = 0;
  4246. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4247. {
  4248. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4249. }
  4250. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4251. {
  4252. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4253. }
  4254. var res = new
  4255. {
  4256. data = total,
  4257. data1 = today_finish,
  4258. };
  4259. string ro_jsond = JsonConvert.SerializeObject(res);
  4260. returnSuccess(ro_jsond);
  4261. return;
  4262. }
  4263. public void get_erp_allreturnlist()
  4264. {
  4265. DataStruct dStruct = GetPostStruct();
  4266. List<string> lw = new List<string>();
  4267. string tid = GetPostString("ctid");
  4268. if (tid.Length > 0)
  4269. {
  4270. string select_tid = getTidByCtid(tid);
  4271. lw.Add(string.Format("tid='{0}'", select_tid));
  4272. }
  4273. string shopname = GetPostString("shopname");
  4274. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4275. string buyernick = GetPostString("buyer_nick");
  4276. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4277. string customer = GetPostString("customer");
  4278. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4279. string design = GetPostString("design");
  4280. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4281. string orderState = GetPostString("orderState");
  4282. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4283. string address = GetPostString("address");
  4284. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4285. string sellermemo = GetPostString("seller_memo");
  4286. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4287. string supplier = GetPostString("supplier");
  4288. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4289. string date1 = GetPostString("date1");
  4290. string date2 = GetPostString("date2");
  4291. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4292. if (dw.Length > 0) lw.Add(dw);
  4293. string bdate1 = GetPostString("backdate1");
  4294. string bdate2 = GetPostString("backdate2");
  4295. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4296. if (dw_back.Length > 0) lw.Add(dw_back);
  4297. string price1 = GetPostString("price1");
  4298. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4299. string price2 = GetPostString("price2");
  4300. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4301. string backreason = GetPostString("backreason");
  4302. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4303. lw.Add(string.Format("IsXianHuo=0"));
  4304. lw.Add(string.Format("ReturnTime != ''"));
  4305. string backtype = GetPostString("backtype");
  4306. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4307. dStruct.Order = "FinishDesignTime desc";
  4308. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4309. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4310. writeGridDataTableJson(dStruct.TotalCount, dt);
  4311. }
  4312. public void get_erp_aftersalereturnlist()
  4313. {
  4314. DataStruct dStruct = GetPostStruct();
  4315. List<string> lw = new List<string>();
  4316. string tid = GetPostString("ctid");
  4317. if (tid.Length > 0)
  4318. {
  4319. string select_tid = getTidByCtid(tid);
  4320. lw.Add(string.Format("tid='{0}'", select_tid));
  4321. }
  4322. string shopname = GetPostString("shopname");
  4323. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4324. string buyernick = GetPostString("buyer_nick");
  4325. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4326. string customer = GetPostString("customer");
  4327. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4328. string design = GetPostString("design");
  4329. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4330. string orderState = GetPostString("orderState");
  4331. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4332. string address = GetPostString("address");
  4333. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4334. string sellermemo = GetPostString("seller_memo");
  4335. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4336. string supplier = GetPostString("supplier");
  4337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4338. string date1 = GetPostString("date1");
  4339. string date2 = GetPostString("date2");
  4340. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4341. if (dw.Length > 0) lw.Add(dw);
  4342. string bdate1 = GetPostString("backdate1");
  4343. string bdate2 = GetPostString("backdate2");
  4344. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4345. if (dw_back.Length > 0) lw.Add(dw_back);
  4346. string price1 = GetPostString("price1");
  4347. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4348. string price2 = GetPostString("price2");
  4349. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4350. lw.Add(string.Format("IsReturn=3"));
  4351. string backtype = GetPostString("backtype");
  4352. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4353. string backreason = GetPostString("backreason");
  4354. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4355. dStruct.Order = "ReturnTime desc";
  4356. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4357. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4358. writeGridDataTableJson(dStruct.TotalCount, dt);
  4359. }
  4360. public void get_erp_xianhuoreturnlist()
  4361. {
  4362. DataStruct dStruct = GetPostStruct();
  4363. List<string> lw = new List<string>();
  4364. string tid = GetPostString("ctid");
  4365. if (tid.Length > 0)
  4366. {
  4367. string select_tid = getTidByCtid(tid);
  4368. lw.Add(string.Format("tid='{0}'", select_tid));
  4369. }
  4370. string shopname = GetPostString("shopname");
  4371. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4372. string buyernick = GetPostString("buyer_nick");
  4373. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4374. string customer = GetPostString("customer");
  4375. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4376. string design = GetPostString("design");
  4377. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4378. string orderState = GetPostString("orderState");
  4379. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4380. string address = GetPostString("address");
  4381. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4382. string sellermemo = GetPostString("seller_memo");
  4383. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4384. string supplier = GetPostString("supplier");
  4385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4386. string OrderArea = GetPostString("order_area");
  4387. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4388. string date1 = GetPostString("date1");
  4389. string date2 = GetPostString("date2");
  4390. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4391. if (dw.Length > 0) lw.Add(dw);
  4392. string price1 = GetPostString("price1");
  4393. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4394. string price2 = GetPostString("price2");
  4395. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4396. string posTag = CurrentUser.UserPost.Post.Code;
  4397. if (posTag == "Supplier")
  4398. {
  4399. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4400. }
  4401. lw.Add(string.Format("OrderState=6 "));
  4402. lw.Add(string.Format("IsXianHuo=1 "));
  4403. lw.Add(string.Format("IsReturn>0 "));
  4404. lw.Add(string.Format("IsReturn!=3"));
  4405. lw.Add(string.Format("IsRefund<={0}", 1));
  4406. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4407. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4408. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4409. writeGridDataTableJson(dStruct.TotalCount, dt);
  4410. }
  4411. public void set_erp_orderdelivery()
  4412. {
  4413. if (UrlPostParmsCheck("ctid"))
  4414. {
  4415. string eid = GetPostString("ctid");
  4416. CeErpTradeCell entity = null;
  4417. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4418. if (entity != null)
  4419. {
  4420. if (entity.OrderState >= 7)
  4421. {
  4422. returnErrorMsg("此单已发货,无需重复发货");
  4423. return;
  4424. }
  4425. if (entity.OrderState != 6)
  4426. {
  4427. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4428. return;
  4429. }
  4430. string shop = GetPostString("seller_nick");
  4431. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4432. string comName = GetPostString("comName");
  4433. string comCode = GetPostString("comCode");
  4434. string outSid = GetPostString("outSid");
  4435. string deliveryType = GetPostString("deliveryType");
  4436. string deliveryMemo = GetPostString("deliveryMemo");
  4437. outSid = outSid.Trim();
  4438. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4439. if (mainEn == null)
  4440. {
  4441. returnErrorMsg("找不到原始订单记录");
  4442. return;
  4443. }
  4444. bool isInitOrderDeliv = false;
  4445. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4446. {
  4447. isInitOrderDeliv = true;
  4448. }
  4449. string apires = "";
  4450. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4451. 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)
  4452. {
  4453. apires = "发货成功true";
  4454. }
  4455. else
  4456. {
  4457. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4458. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4459. }
  4460. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4461. {
  4462. entity.OrderState = 7;//发货后订单已发货
  4463. entity.OutSid = outSid;
  4464. entity.MemoOpt = 0;
  4465. entity.UpdateTime = DateTime.Now;
  4466. entity.FinishDeliveryTime = DateTime.Now;
  4467. entity.Update();
  4468. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4469. commonHelper.UpdateRelationOrder(entity.ctid);
  4470. //还要插入快递信息到 快递信息表
  4471. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4472. exinfo.tid = eid;
  4473. exinfo.out_sid = outSid;
  4474. exinfo.company_code = comCode;
  4475. exinfo.company_name = comName;
  4476. exinfo.delivery_memo = deliveryMemo;
  4477. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4478. exinfo.deliveryType = deliveryType;
  4479. exinfo.Create();
  4480. returnSuccessMsg("发货操作成功!");
  4481. commonHelper.UpdateRelationOrder(entity.ctid);
  4482. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4483. CeErpSukuraData.createInfo(entity.ctid, 4);
  4484. if (entity.SupplierId == 64)
  4485. {
  4486. commonHelper.sendCytExpress(exinfo);
  4487. }
  4488. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4489. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4490. }
  4491. else
  4492. {
  4493. string errmsg = commonHelper.KeepChinese(apires);
  4494. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4495. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4496. }
  4497. return;
  4498. }
  4499. returnErrorMsg("找不到订单记录");
  4500. }
  4501. }
  4502. public void set_erp_multidelivery()
  4503. {
  4504. string eids = GetPostString("tids");
  4505. string[] eidList = eids.Split(',');
  4506. if (eidList.Length <= 0)
  4507. {
  4508. returnErrorMsg("发货不能为空");
  4509. return;
  4510. }
  4511. foreach (string ctid in eidList)
  4512. {
  4513. if (ctid.Length <= 0) continue;
  4514. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4515. if (expInfo != null)
  4516. {
  4517. StringBuilder sql = new StringBuilder();
  4518. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4519. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4520. if (dt.Rows.Count > 0)
  4521. {
  4522. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4523. {
  4524. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4525. expInfo.state = "异常";
  4526. expInfo.isMultiDelivery = 1;
  4527. expInfo.Update();
  4528. continue;
  4529. }
  4530. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4531. {
  4532. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4533. expInfo.state = "异常";
  4534. expInfo.Update();
  4535. continue;
  4536. }
  4537. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4538. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4539. bool isInitOrderDeliv = false;
  4540. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4541. {
  4542. isInitOrderDeliv = true;
  4543. expInfo.isMultiDelivery = 1;
  4544. }
  4545. if (ctid.IndexOf("N") != -1)
  4546. {
  4547. StringBuilder sqlbucha = new StringBuilder();
  4548. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4549. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4550. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4551. commonHelper.UpdateRelationOrder(ctid);
  4552. expInfo.delivery_memo = "发货成功";
  4553. expInfo.state = "发货成功";
  4554. expInfo.isMultiDelivery = 1;
  4555. expInfo.Update();
  4556. }
  4557. else
  4558. {
  4559. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4560. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4561. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4562. {
  4563. expInfo.delivery_memo = "发货成功";
  4564. expInfo.state = "发货成功";
  4565. expInfo.isMultiDelivery = 1;
  4566. expInfo.Update();
  4567. commonHelper.UpdateRelationOrder(ctid);
  4568. CeErpSukuraData.createInfo(ctid, 4);
  4569. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4570. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4571. }
  4572. else
  4573. {
  4574. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4575. expInfo.state = "异常";
  4576. expInfo.Update();
  4577. }
  4578. }
  4579. }
  4580. }
  4581. }
  4582. returnSuccessMsg("操作完成");
  4583. }
  4584. public void reset_erp_memoopt()
  4585. {
  4586. if (UrlPostParmsCheck("ctid"))
  4587. {
  4588. string eid = GetPostString("ctid");
  4589. CeErpTradeCell entity = null;
  4590. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4591. if (entity != null)
  4592. {
  4593. string stropt = "";
  4594. if (entity.MemoOpt == 1)
  4595. {
  4596. stropt = "“改稿”";
  4597. }
  4598. else if (entity.MemoOpt == 2)
  4599. {
  4600. stropt = "“定稿”";
  4601. }
  4602. else if (entity.MemoOpt == 3)
  4603. {
  4604. stropt = "“完成查货”";
  4605. CeErpSukuraData.createInfo(entity.ctid, 6);
  4606. }
  4607. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4608. entity.UpdateTime = DateTime.Now;
  4609. entity.MemoOpt = 0;
  4610. entity.Update();
  4611. returnSuccessMsg("操作成功!");
  4612. return;
  4613. }
  4614. returnErrorMsg("找不到记录");
  4615. }
  4616. }
  4617. public void get_erp_deliveryunusual()
  4618. {
  4619. DataStruct dStruct = GetPostStruct();
  4620. List<string> lw = new List<string>();
  4621. string tid = GetPostString("ctid");
  4622. if (tid.Length > 0)
  4623. {
  4624. string select_tid = getTidByCtid(tid);
  4625. lw.Add(string.Format("tid='{0}'", select_tid));
  4626. }
  4627. string shopname = GetPostString("shopname");
  4628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4629. string buyernick = GetPostString("buyer_nick");
  4630. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4631. string customer = GetPostString("customer");
  4632. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4633. string design = GetPostString("design");
  4634. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4635. string sellermemo = GetPostString("seller_memo");
  4636. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4637. string supplier = GetPostString("supplier");
  4638. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4639. string date1 = GetPostString("date1");
  4640. string date2 = GetPostString("date2");
  4641. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4642. if (dw.Length > 0) lw.Add(dw);
  4643. string placedate1 = GetPostString("placedate1");
  4644. string placedate2 = GetPostString("placedate2");
  4645. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4646. if (dw_place.Length > 0) lw.Add(dw_place);
  4647. string price1 = GetPostString("price1");
  4648. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4649. string price2 = GetPostString("price2");
  4650. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4651. string unusualCon = GetPostString("unusualcon");
  4652. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4653. string posTag = CurrentUser.UserPost.Post.Code;
  4654. if (posTag == "Supplier")
  4655. {
  4656. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4657. }
  4658. lw.Add(string.Format("OrderState = 6"));
  4659. lw.Add(string.Format("UnusualTag = 5"));
  4660. lw.Add(string.Format("IsRefund<={0}", 1));
  4661. dStruct.Order = "FinishPlaceTime desc";
  4662. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4663. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4664. writeGridDataTableJson(dStruct.TotalCount, dt);
  4665. }
  4666. public void get_erp_deliveryedlist()
  4667. {
  4668. DataStruct dStruct = GetPostStruct();
  4669. List<string> lw = new List<string>();
  4670. string tid = GetPostString("ctid");
  4671. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4672. string shopname = GetPostString("shopname");
  4673. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4674. string buyernick = GetPostString("buyer_nick");
  4675. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4676. string customer = GetPostString("customer");
  4677. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4678. string design = GetPostString("design");
  4679. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4680. string sellermemo = GetPostString("seller_memo");
  4681. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4682. string logistics = GetPostString("logistics");
  4683. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4684. string date1 = GetPostString("date1");
  4685. string date2 = GetPostString("date2");
  4686. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4687. //if (dw.Length > 0) lw.Add(dw);
  4688. string placedate1 = GetPostString("placedate1");
  4689. string placedate2 = GetPostString("placedate2");
  4690. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4691. if (fdw.Length > 0) lw.Add(fdw);
  4692. string devdate1 = GetPostString("deliverydate1");
  4693. string devdate2 = GetPostString("deliverydate2");
  4694. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4695. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4696. string price1 = GetPostString("price1");
  4697. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4698. string price2 = GetPostString("price2");
  4699. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4700. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4701. {
  4702. if (tid.Length > 0)
  4703. {
  4704. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4705. if (tid.Length > 5)
  4706. {
  4707. List<string> tids = getTidByCtidLike(tid);
  4708. if (tids.Count > 0 && tids.Count < 10)
  4709. {
  4710. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4711. }
  4712. }
  4713. lw.Add(tid_sql);
  4714. }
  4715. if (buyernick.Length > 0)
  4716. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4717. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4718. if (dw.Length > 0) lw.Add(dw);
  4719. }
  4720. else
  4721. {
  4722. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4723. }
  4724. string posTag = CurrentUser.UserPost.Post.Code;
  4725. if (posTag == "Supplier")
  4726. {
  4727. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4728. }
  4729. else
  4730. {
  4731. string supplier = GetPostString("supplier");
  4732. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4733. }
  4734. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4735. lw.Add(string.Format("type != 'PDD' "));
  4736. lw.Add(string.Format("IsRefund!={0}", 2));
  4737. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4738. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4739. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4740. /*if (tid.Length > 0)
  4741. {
  4742. List<string> tids = new List<string>();
  4743. if (dt != null && dt.Rows.Count > 0)
  4744. {
  4745. foreach (DataRow item in dt.Rows)
  4746. {
  4747. tids.Add("'" + item["tid"] + "'");
  4748. }
  4749. }
  4750. if (tids.Count > 0)
  4751. {
  4752. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4753. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4754. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4755. dt = WebCache.GetData("view_erptradecell", dStruct);
  4756. }
  4757. }*/
  4758. if (dt != null)
  4759. {
  4760. foreach (DataRow dr in dt.Rows)
  4761. {
  4762. 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();
  4763. }
  4764. }
  4765. writeGridDataTableJson(dStruct.TotalCount, dt);
  4766. }
  4767. public void get_erp_pdddeliveryed()
  4768. {
  4769. DataStruct dStruct = GetPostStruct();
  4770. List<string> lw = new List<string>();
  4771. string tid = GetPostString("ctid");
  4772. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4773. string shopname = GetPostString("shopname");
  4774. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4775. string buyernick = GetPostString("buyer_nick");
  4776. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4777. string customer = GetPostString("customer");
  4778. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4779. string design = GetPostString("design");
  4780. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4781. string sellermemo = GetPostString("seller_memo");
  4782. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4783. string logistics = GetPostString("logistics");
  4784. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4785. string date1 = GetPostString("date1");
  4786. string date2 = GetPostString("date2");
  4787. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4788. //if (dw.Length > 0) lw.Add(dw);
  4789. string placedate1 = GetPostString("placedate1");
  4790. string placedate2 = GetPostString("placedate2");
  4791. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4792. if (fdw.Length > 0) lw.Add(fdw);
  4793. string devdate1 = GetPostString("deliverydate1");
  4794. string devdate2 = GetPostString("deliverydate2");
  4795. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4796. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4797. string price1 = GetPostString("price1");
  4798. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4799. string price2 = GetPostString("price2");
  4800. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4801. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4802. {
  4803. if (tid.Length > 0)
  4804. {
  4805. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4806. if (tid.Length > 5)
  4807. {
  4808. List<string> tids = getTidByCtidLike(tid);
  4809. if (tids.Count > 0 && tids.Count < 10)
  4810. {
  4811. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4812. }
  4813. }
  4814. lw.Add(tid_sql);
  4815. }
  4816. if (buyernick.Length > 0)
  4817. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4818. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4819. if (dw.Length > 0) lw.Add(dw);
  4820. }
  4821. else
  4822. {
  4823. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4824. }
  4825. string posTag = CurrentUser.UserPost.Post.Code;
  4826. if (posTag == "Supplier")
  4827. {
  4828. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4829. }
  4830. else
  4831. {
  4832. string supplier = GetPostString("supplier");
  4833. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4834. }
  4835. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4836. lw.Add(string.Format("type = 'PDD' "));
  4837. lw.Add(string.Format("IsRefund!={0}", 2));
  4838. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4839. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4840. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4841. /* if (tid.Length > 0)
  4842. {
  4843. List<string> tids = new List<string>();
  4844. if (dt != null && dt.Rows.Count > 0)
  4845. {
  4846. foreach (DataRow item in dt.Rows)
  4847. {
  4848. tids.Add("'" + item["tid"] + "'");
  4849. }
  4850. }
  4851. if (tids.Count > 0)
  4852. {
  4853. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4854. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4855. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4856. dt = WebCache.GetData("view_erptradecell", dStruct);
  4857. }
  4858. }*/
  4859. foreach (DataRow dr in dt.Rows)
  4860. {
  4861. 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();
  4862. }
  4863. writeGridDataTableJson(dStruct.TotalCount, dt);
  4864. }
  4865. public void get_erp_jddeliveryed()
  4866. {
  4867. DataStruct dStruct = GetPostStruct();
  4868. List<string> lw = new List<string>();
  4869. string tid = GetPostString("ctid");
  4870. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4871. string shopname = GetPostString("shopname");
  4872. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4873. string buyernick = GetPostString("buyer_nick");
  4874. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4875. string customer = GetPostString("customer");
  4876. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4877. string design = GetPostString("design");
  4878. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4879. string sellermemo = GetPostString("seller_memo");
  4880. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4881. string date1 = GetPostString("date1");
  4882. string date2 = GetPostString("date2");
  4883. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4884. //if (dw.Length > 0) lw.Add(dw);
  4885. string placedate1 = GetPostString("placedate1");
  4886. string placedate2 = GetPostString("placedate2");
  4887. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4888. if (fdw.Length > 0) lw.Add(fdw);
  4889. string devdate1 = GetPostString("deliverydate1");
  4890. string devdate2 = GetPostString("deliverydate2");
  4891. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4892. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4893. string price1 = GetPostString("price1");
  4894. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4895. string price2 = GetPostString("price2");
  4896. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4897. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4898. {
  4899. if (tid.Length > 0)
  4900. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4901. if (buyernick.Length > 0)
  4902. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4903. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4904. if (dw.Length > 0) lw.Add(dw);
  4905. }
  4906. else
  4907. {
  4908. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4909. }
  4910. string posTag = CurrentUser.UserPost.Post.Code;
  4911. if (posTag == "Supplier")
  4912. {
  4913. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4914. }
  4915. else
  4916. {
  4917. string supplier = GetPostString("supplier");
  4918. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4919. }
  4920. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4921. lw.Add(string.Format("type = 'JD' "));
  4922. lw.Add(string.Format("IsRefund!={0}", 2));
  4923. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4924. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4925. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4926. foreach (DataRow dr in dt.Rows)
  4927. {
  4928. 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();
  4929. }
  4930. writeGridDataTableJson(dStruct.TotalCount, dt);
  4931. }
  4932. public void get_erp_allplacelist()
  4933. {
  4934. DataStruct dStruct = GetPostStruct();
  4935. List<string> lw = new List<string>();
  4936. string tid = GetPostString("ctid");
  4937. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4938. string shopname = GetPostString("shopname");
  4939. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4940. string buyernick = GetPostString("buyer_nick");
  4941. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4942. string customer = GetPostString("customer");
  4943. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4944. string design = GetPostString("design");
  4945. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4946. string sellermemo = GetPostString("seller_memo");
  4947. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4948. string supplier = GetPostString("supplier");
  4949. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4950. string date1 = GetPostString("date1");
  4951. string date2 = GetPostString("date2");
  4952. string pldate1 = GetPostString("placedate1");
  4953. string pldate2 = GetPostString("placedate2");
  4954. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4955. //if (dw.Length > 0) lw.Add(dw);
  4956. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4957. {
  4958. if (tid.Length > 0)
  4959. {
  4960. string select_tid = getTidByCtid(tid);
  4961. lw.Add(string.Format("tid='{0}'", select_tid));
  4962. }
  4963. if (buyernick.Length > 0)
  4964. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4965. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4966. if (dw.Length > 0) lw.Add(dw);
  4967. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4968. if (dw_place.Length > 0) lw.Add(dw_place);
  4969. }
  4970. else
  4971. {
  4972. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4973. {
  4974. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4975. }
  4976. }
  4977. string price1 = GetPostString("price1");
  4978. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4979. string price2 = GetPostString("price2");
  4980. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4981. string posTag = CurrentUser.UserPost.Post.Code;
  4982. if (posTag == "Supplier")
  4983. {
  4984. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4985. }
  4986. lw.Add(string.Format("OrderState >= 6"));
  4987. lw.Add(string.Format("IsSample != 2 "));
  4988. //lw.Add(string.Format("isDianziOrder = 0 "));
  4989. lw.Add(string.Format("SupplierId > 0 "));
  4990. //lw.Add(string.Format("IsRefund<={0}", 1));
  4991. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4992. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4993. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4994. foreach (DataRow dr in dt.Rows)
  4995. {
  4996. 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();
  4997. }
  4998. writeGridDataTableJson(dStruct.TotalCount, dt);
  4999. }
  5000. public void get_erp_financeallplacelist()
  5001. {
  5002. DataStruct dStruct = GetPostStruct();
  5003. List<string> lw = new List<string>();
  5004. string tid = GetPostString("ctid");
  5005. string shopname = GetPostString("shopname");
  5006. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5007. string buyernick = GetPostString("buyer_nick");
  5008. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5009. string customer = GetPostString("customer");
  5010. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5011. string design = GetPostString("design");
  5012. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5013. string sellermemo = GetPostString("seller_memo");
  5014. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5015. string supplier = GetPostString("supplier");
  5016. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5017. string date1 = GetPostString("date1");
  5018. string date2 = GetPostString("date2");
  5019. string pldate1 = GetPostString("placedate1");
  5020. string pldate2 = GetPostString("placedate2");
  5021. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5022. {
  5023. if (tid.Length > 0)
  5024. {
  5025. string select_tid = getTidByCtid(tid);
  5026. lw.Add(string.Format("tid='{0}'", select_tid));
  5027. }
  5028. if (buyernick.Length > 0)
  5029. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5030. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5031. if (dw.Length > 0) lw.Add(dw);
  5032. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5033. if (dw_place.Length > 0) lw.Add(dw_place);
  5034. }
  5035. else
  5036. {
  5037. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5038. {
  5039. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5040. }
  5041. }
  5042. string price1 = GetPostString("price1");
  5043. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5044. string price2 = GetPostString("price2");
  5045. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5046. string posTag = CurrentUser.UserPost.Post.Code;
  5047. if (posTag == "Supplier")
  5048. {
  5049. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5050. }
  5051. //lw.Add(string.Format("OrderState >= 6"));
  5052. lw.Add(string.Format("IsSample != 2 "));
  5053. lw.Add(string.Format("isDianziOrder = 0 "));
  5054. //lw.Add(string.Format("IsRefund<={0}", 1));
  5055. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5056. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5057. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5058. foreach (DataRow dr in dt.Rows)
  5059. {
  5060. 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();
  5061. }
  5062. writeGridDataTableJson(dStruct.TotalCount, dt);
  5063. }
  5064. public void get_erp_expresslist()
  5065. {
  5066. int listtype = GetInt("ltype");
  5067. DataStruct dStruct = GetPostStruct();
  5068. List<string> lw = new List<string>();
  5069. string tid = GetPostString("tid");
  5070. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5071. string outsid = GetPostString("out_sid");
  5072. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5073. string importer = GetPostString("ImportUserName");
  5074. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5075. string file = GetPostString("import_file");
  5076. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5077. string printman = GetPostString("printman");
  5078. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5079. string date1 = GetPostString("date1");
  5080. string date2 = GetPostString("date2");
  5081. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5082. if (dw.Length > 0) lw.Add(dw);
  5083. string fdate1 = GetPostString("finishdate1");
  5084. string fdate2 = GetPostString("finishdate2");
  5085. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5086. if (fdw.Length > 0) lw.Add(fdw);
  5087. string supplierId = GetPostString("supplierId");
  5088. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5089. if (listtype == 1)
  5090. {
  5091. lw.Add(string.Format("importUserId !=0"));
  5092. }
  5093. string posTag = CurrentUser.UserPost.Post.Code;
  5094. if (posTag == "Supplier")
  5095. {
  5096. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5097. }
  5098. if (dStruct.PageSize != 100000)
  5099. {
  5100. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5101. }
  5102. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5103. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5104. writeGridDataTableJson(dStruct.TotalCount, dt);
  5105. }
  5106. public void set_erp_buchaorderdelivery()
  5107. {
  5108. if (UrlPostParmsCheck("ctid"))
  5109. {
  5110. string eid = GetPostString("ctid");
  5111. CeErpTradeCell entity = null;
  5112. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5113. if (entity != null)
  5114. {
  5115. if (entity.IsSample != 2)
  5116. {
  5117. returnErrorMsg("补差价单才能标记为已发货");
  5118. return;
  5119. }
  5120. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5121. entity.OrderState = 7;
  5122. entity.Update();
  5123. returnSuccessMsg("操作成功!");
  5124. return;
  5125. }
  5126. returnErrorMsg("找不到记录");
  5127. }
  5128. }
  5129. public void get_stdtemplates()
  5130. {
  5131. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5132. //string res = taobaoHelper.test();
  5133. string res = apiHelper.API_PrintTemplate();
  5134. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5135. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5136. {
  5137. int sidx = res.IndexOf("error_code");
  5138. int eidx = res.IndexOf("success");
  5139. string msg = res.Substring(sidx, eidx - sidx);
  5140. returnErrorMsg(msg);
  5141. return;
  5142. }
  5143. if (res.Length <= 0)
  5144. {
  5145. returnErrorMsg("模板数据为空!");
  5146. return;
  5147. }
  5148. ReturnSuccess(res);
  5149. }
  5150. public void cancel_print_order()
  5151. {
  5152. if (UrlPostParmsCheck("ctid"))
  5153. {
  5154. string ctid = GetPostString("ctid");
  5155. CeErpTradeCell entity = null;
  5156. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5157. if (entity != null)
  5158. {
  5159. string res = "";
  5160. string code = entity.LastBillWaybillCode;
  5161. if (code == "")
  5162. {
  5163. code = entity.OutSid;
  5164. }
  5165. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5166. XLog.SaveLog(0, "取消面单" + res);
  5167. }
  5168. }
  5169. }
  5170. public void set_erp_printwaybill()
  5171. {
  5172. if (UrlPostParmsCheck("ctid"))
  5173. {
  5174. string ctid = GetPostString("ctid");
  5175. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5176. string cpName = GetPostString("cpname");
  5177. string isTogether = GetPostString("together");
  5178. //var res_obj = new
  5179. //{
  5180. // restype = 1,
  5181. // 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\"}"
  5182. //};
  5183. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5184. //ReturnSuccess(ro_json);
  5185. //return;
  5186. bool isUseLastWayBillCode = false;
  5187. CeErpTradeCell entity = null;
  5188. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5189. if (entity != null)
  5190. {
  5191. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5192. {
  5193. isUseLastWayBillCode = true;
  5194. }
  5195. if (entity.OrderState == 7 && "2".Equals(isTogether))
  5196. {
  5197. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5198. return;
  5199. }
  5200. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5201. {
  5202. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5203. return;
  5204. }
  5205. }
  5206. string res = "";
  5207. Api_waybill_code_response_Obj fullObj = null;
  5208. string pData_str = "";
  5209. string curUseWayBillCode = "";
  5210. if (isUseLastWayBillCode == false)
  5211. {
  5212. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5213. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5214. if (res.IndexOf("failure") != -1)
  5215. {
  5216. //int idx = res.IndexOf("sub_message");
  5217. //int idx2 = res.IndexOf("flag");
  5218. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5219. string errMsgNeed = commonHelper.KeepChinese(res);
  5220. var res_objd = new
  5221. {
  5222. restype = 0,
  5223. data = "获取面单失败" + errMsgNeed
  5224. };
  5225. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5226. returnSuccess(ro_jsond);
  5227. if (res.IndexOf("停发") != -1)
  5228. {
  5229. entity.UnusualCon = "物流停发";
  5230. entity.Update();
  5231. }
  5232. //returnErrorMsg("获取面单失败,"+emsg);
  5233. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5234. return;
  5235. }
  5236. else if (res.IndexOf("errorMsg") != -1)
  5237. {
  5238. //int idx = res.IndexOf("errorMsg");
  5239. //int idx2 = res.IndexOf("}]}");
  5240. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5241. string errMsgNeed = commonHelper.KeepChinese(res);
  5242. var res_objf = new
  5243. {
  5244. restype = 0,
  5245. data = "获取面单失败2" + errMsgNeed
  5246. };
  5247. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5248. if (res.IndexOf("停发") != -1)
  5249. {
  5250. entity.UnusualCon = "物流停发";
  5251. entity.Update();
  5252. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5253. if (trade != null)
  5254. {
  5255. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5256. }
  5257. }
  5258. returnSuccess(ro_jsonf);
  5259. //returnErrorMsg("获取面单失败," + emsg);
  5260. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5261. return;
  5262. }
  5263. try
  5264. {
  5265. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5266. //res = res.Replace(" ", "");
  5267. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5268. }
  5269. catch (Exception ex)
  5270. {
  5271. XLog.SaveLog(0, "生成fullObj" + res);
  5272. var res_objf = new
  5273. {
  5274. restype = 0,
  5275. data = "生成fullObj发生错误" + ex.Message
  5276. };
  5277. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5278. returnSuccess(ro_jsonf);
  5279. return;
  5280. }
  5281. if (fullObj.response.data.content.Count > 0)
  5282. {
  5283. ContentItem codeObj = fullObj.response.data.content[0];
  5284. if (cpCode.IndexOf("SFFQ-") != -1)
  5285. {
  5286. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5287. }
  5288. else
  5289. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5290. curUseWayBillCode = codeObj.waybillCode;
  5291. }
  5292. else
  5293. {
  5294. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5295. var res_objf = new
  5296. {
  5297. restype = 0,
  5298. data = "生成fullObj找不到快递单号waybillCode"
  5299. };
  5300. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5301. returnSuccess(ro_jsonf);
  5302. return;
  5303. }
  5304. }
  5305. else
  5306. {
  5307. //使用上次打印的快递单号
  5308. if (cpCode == "SFFQ-LY")
  5309. {
  5310. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5311. }
  5312. else
  5313. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5314. curUseWayBillCode = entity.LastBillWaybillCode;
  5315. }
  5316. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5317. {
  5318. var res_obje = new
  5319. {
  5320. restype = 0,
  5321. data = "获取加密打印数据失败"
  5322. };
  5323. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5324. returnSuccess(ro_jsone);
  5325. entity.LastBillCpCode = cpCode;
  5326. entity.LastBillWaybillCode = curUseWayBillCode;
  5327. entity.Update();
  5328. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5329. //returnErrorMsg("获取加密打印数据失败");
  5330. return;
  5331. }
  5332. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5333. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5334. string btnType = "";
  5335. if (entity != null)
  5336. {
  5337. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5338. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5339. //cpcode是 YTO-CAINIAO
  5340. //string comCode = cpCode.Split('-')[0].ToString();
  5341. string apires = "";
  5342. if (ctid.IndexOf("N") != -1)
  5343. {
  5344. apires = "发货成功";
  5345. }
  5346. else
  5347. {
  5348. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5349. }
  5350. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5351. //打单后发货
  5352. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5353. {
  5354. try
  5355. {
  5356. btnType = "待发货";
  5357. entity.OutSid = curUseWayBillCode;
  5358. entity.OrderState = 7;
  5359. entity.IsUrgency = false;
  5360. entity.LastBillCpCode = "";
  5361. entity.LastBillWaybillCode = "";
  5362. entity.FinishDeliveryTime = DateTime.Now;
  5363. entity.IsReturn = 0;
  5364. entity.MemoOpt = 0;
  5365. entity.UpdateTime = DateTime.Now;
  5366. entity.Update();
  5367. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5368. //还要插入快递信息到 快递信息表
  5369. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5370. exinfo.tid = entity.ctid;
  5371. exinfo.out_sid = curUseWayBillCode;
  5372. exinfo.company_code = cpCode;
  5373. exinfo.company_name = cpName;
  5374. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5375. exinfo.deliveryType = "发货成功";
  5376. exinfo.print_time = DateTime.Now;
  5377. exinfo.printUser = CurrentUser.UserName;
  5378. exinfo.postData = pData_str;
  5379. exinfo.Create();
  5380. commonHelper.UpdateRelationOrder(entity.ctid);
  5381. CeErpSukuraData.createInfo(ctid, 4);
  5382. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5383. if (entity.SupplierId == 64)
  5384. {
  5385. commonHelper.sendCytExpress(exinfo);
  5386. }
  5387. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5388. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5389. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5390. if (!string.IsNullOrEmpty(isTogether))
  5391. {
  5392. if (Convert.ToInt32(isTogether) > 0 && ceErpDeliverMark == null)
  5393. {
  5394. StringBuilder sqlsb = new StringBuilder();
  5395. 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);
  5396. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5397. }
  5398. }
  5399. if (ceErpDeliverMark != null)
  5400. {
  5401. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5402. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5403. {
  5404. List<string> list = new List<string>();
  5405. foreach (DataRow row in dt1.Rows)
  5406. {
  5407. list.Add("'" + row["ctid"] + "'");
  5408. }
  5409. 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));
  5410. }
  5411. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5412. }
  5413. }
  5414. catch (Exception ex)
  5415. {
  5416. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5417. }
  5418. }
  5419. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5420. {
  5421. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5422. if (entity.OrderState == 6)
  5423. {
  5424. entity.OrderState = 7;
  5425. }
  5426. entity.UpdateTime = DateTime.Now;
  5427. entity.FinishDeliveryTime = DateTime.Now;
  5428. btnType = "已发货";
  5429. entity.Update();
  5430. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5431. exinfo.tid = entity.ctid;
  5432. exinfo.out_sid = curUseWayBillCode;
  5433. exinfo.company_code = cpCode;
  5434. exinfo.company_name = cpName;
  5435. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5436. exinfo.deliveryType = "发货成功";
  5437. exinfo.print_time = DateTime.Now;
  5438. exinfo.printUser = CurrentUser.UserName;
  5439. exinfo.postData = pData_str;
  5440. exinfo.Create();
  5441. commonHelper.UpdateRelationOrder(entity.ctid);
  5442. CeErpSukuraData.createInfo(entity.ctid, 4);
  5443. if (entity.SupplierId == 64)
  5444. {
  5445. commonHelper.sendCytExpress(exinfo);
  5446. }
  5447. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5448. if (!string.IsNullOrEmpty(isTogether))
  5449. {
  5450. if (Convert.ToInt32(isTogether) > 0 && ceErpDeliverMark == null)
  5451. {
  5452. StringBuilder sqlsb = new StringBuilder();
  5453. 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);
  5454. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5455. }
  5456. }
  5457. if (ceErpDeliverMark != null)
  5458. {
  5459. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5460. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5461. {
  5462. List<string> list = new List<string>();
  5463. foreach (DataRow row in dt1.Rows)
  5464. {
  5465. list.Add("'" + row["ctid"] + "'");
  5466. }
  5467. 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));
  5468. }
  5469. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5470. }
  5471. //不处理
  5472. }
  5473. else
  5474. {
  5475. entity.UpdateTime = DateTime.Now;
  5476. entity.LastBillCpCode = cpCode;
  5477. entity.LastBillWaybillCode = curUseWayBillCode;
  5478. entity.Update();
  5479. string errmsg = commonHelper.KeepChinese(apires);
  5480. var res_objz = new
  5481. {
  5482. restype = 0,
  5483. data = "打单后发货失败"
  5484. };
  5485. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5486. returnSuccess(ro_jsonz);
  5487. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5488. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5489. return;
  5490. }
  5491. }
  5492. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5493. var res_obj = new
  5494. {
  5495. restype = 1,
  5496. data = pData_str
  5497. };
  5498. string ro_json = JsonConvert.SerializeObject(res_obj);
  5499. ReturnSuccess(ro_json);
  5500. return;
  5501. }
  5502. }
  5503. private string GetUTF8String(byte[] vs)
  5504. {
  5505. throw new NotImplementedException();
  5506. }
  5507. public void set_erp_printwaybill_cn()
  5508. {
  5509. if (UrlPostParmsCheck("ctid"))
  5510. {
  5511. string ctid = GetPostString("ctid");
  5512. string cpCode = GetPostString("cpcode");
  5513. string cpName = GetPostString("cpname");
  5514. string tempUrl = GetPostString("tempurl");
  5515. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5516. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5517. //string res = taobaoHelper.test();
  5518. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5519. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5520. {
  5521. int sidx = res.IndexOf("errorMsg");
  5522. int eidx = res.IndexOf("}");
  5523. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5524. var res_objzxx = new
  5525. {
  5526. restype = 0,
  5527. data = msg
  5528. };
  5529. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5530. returnSuccess(ro_jsonzxx);
  5531. //returnErrorMsg(msg);
  5532. return;
  5533. }
  5534. int idx = res.IndexOf("waybillCode");
  5535. int idx2 = res.IndexOf("printData");
  5536. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5537. string eid = GetPostString("ctid");
  5538. CeErpTradeCell entity = null;
  5539. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5540. if (entity != null)
  5541. {
  5542. string osid = entity.OutSid;
  5543. entity.OutSid = osid + "," + outsid;
  5544. entity.FinishDeliveryTime = DateTime.Now;
  5545. entity.OrderState = 7;
  5546. entity.UpdateTime = DateTime.Now;
  5547. entity.IsReturn = 0;
  5548. entity.Update();
  5549. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5550. exinfo.tid = entity.ctid;
  5551. exinfo.out_sid = outsid;
  5552. exinfo.company_code = cpCode;
  5553. exinfo.company_name = cpName;
  5554. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5555. exinfo.deliveryType = "发货成功";
  5556. exinfo.print_time = DateTime.Now;
  5557. exinfo.printUser = CurrentUser.UserName;
  5558. exinfo.Create();
  5559. if (entity.SupplierId == 64)
  5560. {
  5561. commonHelper.sendCytExpress(exinfo);
  5562. }
  5563. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5564. }
  5565. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5566. var res_objz = new
  5567. {
  5568. restype = 1,
  5569. data = res
  5570. };
  5571. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5572. returnSuccess(ro_jsonz);
  5573. //ReturnSuccess(res);
  5574. }
  5575. }
  5576. ////打单,打印面单 获取面单号
  5577. //public void set_erp_printwaybill()
  5578. //{
  5579. // if (UrlPostParmsCheck("ctid"))
  5580. // {
  5581. // string ctid = GetPostString("ctid");
  5582. // string cpCode = GetPostString("cpcode");
  5583. // string tempUrl = GetPostString("tempurl");
  5584. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5585. // //string res = taobaoHelper.test();
  5586. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5587. // if (res.IndexOf("error_response") != -1)
  5588. // {
  5589. // int sidx = res.IndexOf("sub_msg");
  5590. // int eidx = res.IndexOf("request_id");
  5591. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5592. // returnErrorMsg(msg);
  5593. // return;
  5594. // }
  5595. // int idx = res.IndexOf("waybill_code");
  5596. // int idx2 = res.IndexOf("}]}");
  5597. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5598. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5599. // ReturnSuccess(res);
  5600. // }
  5601. //}
  5602. public void cancel_erp_aftersale()
  5603. {
  5604. if (UrlPostParmsCheck("ctid"))
  5605. {
  5606. string eid = GetPostString("ctid");
  5607. CeErpTradeCell entity = null;
  5608. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5609. if (entity != null)
  5610. {
  5611. //有过处理的售后,取消也不能删除 售 字,保留
  5612. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5613. {
  5614. entity.AfterSaleState = 4;
  5615. }
  5616. else
  5617. entity.AfterSaleState = 0;
  5618. entity.UpdateTime = DateTime.Now;
  5619. entity.Update();
  5620. returnSuccessMsg("操作成功!");
  5621. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5622. return;
  5623. }
  5624. returnErrorMsg("找不到订单记录");
  5625. }
  5626. }
  5627. public void get_erp_aftersalelist()
  5628. {
  5629. DataStruct dStruct = GetPostStruct();
  5630. List<string> lw = new List<string>();
  5631. int st = GetInt("st");
  5632. string tid = GetPostString("ctid");
  5633. if (st == 3)
  5634. {
  5635. if (tid.Length > 0)
  5636. {
  5637. string select_tid = getTidByCtid(tid);
  5638. lw.Add(string.Format("tid='{0}'", select_tid));
  5639. }
  5640. }
  5641. else
  5642. {
  5643. if (tid.Length > 0)
  5644. {
  5645. string select_tid = getTidByCtid(tid);
  5646. lw.Add(string.Format("tid='{0}'", select_tid));
  5647. }
  5648. }
  5649. string shopname = GetPostString("shopname");
  5650. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5651. string buyernick = GetPostString("buyer_nick");
  5652. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5653. string sellermemo = GetPostString("seller_memo");
  5654. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5655. string orderState = GetPostString("orderState");
  5656. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5657. string afterState = GetPostString("afterstate");
  5658. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5659. string date1 = GetPostString("date1");
  5660. string date2 = GetPostString("date2");
  5661. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5662. if (dw.Length > 0) lw.Add(dw);
  5663. string price1 = GetPostString("price1");
  5664. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5665. string price2 = GetPostString("price2");
  5666. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5667. //lw.Add(string.Format("IsRefund!={0}", 1));
  5668. string reason = GetPostString("reason");
  5669. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5670. string method = GetPostString("method");
  5671. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5672. string handler = GetPostString("handler");
  5673. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5674. string handledate1 = GetPostString("handledate1");
  5675. string handledate2 = GetPostString("handledate2");
  5676. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5677. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5678. string finish1 = GetPostString("finishdate1");
  5679. string finish2 = GetPostString("finishdate2");
  5680. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5681. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5682. string afterdate1 = GetPostString("afterdate1");
  5683. string afterdate2 = GetPostString("afterdate2");
  5684. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5685. if (afterDate.Length > 0) lw.Add(afterDate);
  5686. string supplier = GetPostString("supplier");
  5687. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5688. string responsible = GetPostString("responsibleman");
  5689. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5690. string customer = GetPostString("customer");
  5691. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5692. string design = GetPostString("design");
  5693. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5694. string afterMemoType = GetPostString("aftermemotype");
  5695. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5696. string posCode = CurrentUser.UserPost.Post.Code;
  5697. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5698. //{
  5699. // string vstate = GetPostString("vstate");
  5700. // if (vstate.Length > 0)
  5701. // {
  5702. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5703. // }
  5704. // if (posCode == "Supplier")
  5705. // {
  5706. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5707. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5708. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5709. // }
  5710. // else
  5711. // {
  5712. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5713. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5714. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5715. // {
  5716. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5717. // }
  5718. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5719. // {
  5720. // int orgid = CurrentUser.UserPost.OrgID;
  5721. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5722. // }
  5723. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5724. // {
  5725. // string shopid = CurrentUser.User.pemShop;
  5726. // lw.Add(string.Format("shopId in ({0})", shopid));
  5727. // }
  5728. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5729. // //{
  5730. // // int org_id = CurrentUser.UserPost.OrgID;
  5731. // // lw.Add(string.Format("OrgID={0}", org_id));
  5732. // //}
  5733. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5734. // }
  5735. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5736. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5737. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5738. //}
  5739. if (st == 5)
  5740. {
  5741. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5742. {
  5743. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5744. {
  5745. string shopid = CurrentUser.User.pemShop;
  5746. lw.Add(string.Format("shopId in ({0})", shopid));
  5747. }
  5748. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5749. {
  5750. int mrOrgid = CurrentUser.UserPost.OrgID;
  5751. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5752. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5753. }
  5754. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5755. //{
  5756. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5757. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5758. //}
  5759. else
  5760. {
  5761. string userIdStr = "";
  5762. if (posCode == "CustomerService")
  5763. {
  5764. userIdStr = CurrentUser.UserID + "_k";
  5765. }
  5766. else if (posCode == "Designer" || posCode == "wxDesigner")
  5767. {
  5768. userIdStr = CurrentUser.UserID + "_s";
  5769. }
  5770. else if (posCode == "Place")
  5771. {
  5772. userIdStr = CurrentUser.UserID + "_x";
  5773. }
  5774. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5775. }
  5776. }
  5777. string placedate1 = GetPostString("placedate1");
  5778. string placedate2 = GetPostString("placedate2");
  5779. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5780. if (dwplace.Length > 0) lw.Add(dwplace);
  5781. string supState = GetPostString("supState");
  5782. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5783. string searchType = GetPostString("searchType");
  5784. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5785. {
  5786. lw.Add(string.Format("BackNum>1"));
  5787. }
  5788. lw.Add(string.Format("AfterSaleState>0"));
  5789. if (ex_psize > 0)
  5790. {
  5791. if (CurrentUser.UserPost.Post.Code == "Finance")
  5792. dStruct.Order = "pay_time desc";
  5793. else
  5794. dStruct.Order = "HandleTime desc";
  5795. }
  5796. else
  5797. dStruct.Order = "HandleTime desc";
  5798. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5799. DataTable dt = WebCache.GetData("view_test", dStruct);
  5800. writeGridDataTableJson(dStruct.TotalCount, dt);
  5801. }
  5802. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5803. //{
  5804. // lw.Add(string.Format("AfterSaleState=4"));
  5805. // string code = CurrentUser.UserPost.Post.Code;
  5806. // if (code == "CustomerService")
  5807. // {
  5808. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5809. // }
  5810. // else if (code == "Designer" || code == "DesignerMr")
  5811. // {
  5812. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5813. // }
  5814. // else if (code == "Place" || code == "PlaceMr")
  5815. // {
  5816. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5817. // }
  5818. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5819. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5820. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5821. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5822. //}
  5823. //else //处理中的售后,待处理和处理中合并
  5824. //{
  5825. // if (afterState.Length <= 0)
  5826. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5827. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5828. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5829. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5830. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5831. //}
  5832. }
  5833. public void get_erp_disagreeftersalelist()
  5834. {
  5835. DataStruct dStruct = GetPostStruct();
  5836. List<string> lw = new List<string>();
  5837. int st = 2;
  5838. string tid = GetPostString("ctid");
  5839. if (tid.Length > 0)
  5840. {
  5841. string select_tid = getTidByCtid(tid);
  5842. lw.Add(string.Format("tid='{0}'", select_tid));
  5843. }
  5844. string shopname = GetPostString("shopname");
  5845. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5846. string buyernick = GetPostString("buyer_nick");
  5847. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5848. string sellermemo = GetPostString("seller_memo");
  5849. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5850. string orderState = GetPostString("orderState");
  5851. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5852. string afterState = GetPostString("afterstate");
  5853. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5854. string date1 = GetPostString("date1");
  5855. string date2 = GetPostString("date2");
  5856. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5857. if (dw.Length > 0) lw.Add(dw);
  5858. string price1 = GetPostString("price1");
  5859. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5860. string price2 = GetPostString("price2");
  5861. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5862. //lw.Add(string.Format("IsRefund!={0}", 1));
  5863. string reason = GetPostString("reason");
  5864. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5865. string method = GetPostString("method");
  5866. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5867. string handler = GetPostString("handler");
  5868. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5869. string handledate1 = GetPostString("handledate1");
  5870. string handledate2 = GetPostString("handledate2");
  5871. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5872. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5873. string afterdate1 = GetPostString("afterdate1");
  5874. string afterdate2 = GetPostString("afterdate2");
  5875. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5876. if (afterDate.Length > 0) lw.Add(afterDate);
  5877. string backdate1 = GetPostString("backdate1");
  5878. string backdate2 = GetPostString("backdate2");
  5879. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5880. if (backDate.Length > 0) lw.Add(backDate);
  5881. string supplier = GetPostString("supplier");
  5882. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5883. string responsible = GetPostString("responsibleman");
  5884. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5885. string customer = GetPostString("customer");
  5886. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5887. string design = GetPostString("design");
  5888. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5889. string afterSaleMemo = GetPostString("afterSaleMemo");
  5890. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5891. string afterMemoType = GetPostString("aftermemotype");
  5892. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5893. string aftersakereason = GetPostString("aftersakereason");
  5894. if (aftersakereason.Length > 0)
  5895. {
  5896. if (aftersakereason == "1")
  5897. {
  5898. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5899. }
  5900. if (aftersakereason == "2")
  5901. {
  5902. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5903. }
  5904. }
  5905. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5906. string poscode = CurrentUser.UserPost.Post.Code;
  5907. if (poscode != "SysAdmin")
  5908. {
  5909. string shopid = CurrentUser.User.pemShop;
  5910. lw.Add(string.Format("shopId in ({0})", shopid));
  5911. }
  5912. string searchType = GetPostString("searchType");
  5913. if (searchType == "wait")
  5914. {
  5915. lw.Add(string.Format("HandleTime is null"));
  5916. }
  5917. if (searchType == "handling")
  5918. {
  5919. lw.Add(string.Format("HandleTime is not null "));
  5920. }
  5921. if (searchType == "back" || searchType == "puBack")
  5922. {
  5923. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5924. }
  5925. if (searchType == "reBack")
  5926. {
  5927. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5928. }
  5929. if (searchType == "moreBack")
  5930. {
  5931. lw.Add(string.Format("backNum > 1"));
  5932. }
  5933. lw.Add(string.Format("(AfterSaleState=5)"));
  5934. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5935. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5936. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5937. writeGridDataTableJson(dStruct.TotalCount, dt);
  5938. }
  5939. public void get_erp_handlingaftersalelist()
  5940. {
  5941. DataStruct dStruct = GetPostStruct();
  5942. List<string> lw = new List<string>();
  5943. int st = 2;
  5944. string tid = GetPostString("ctid");
  5945. if (tid.Length > 0)
  5946. {
  5947. string select_tid = getTidByCtid(tid);
  5948. lw.Add(string.Format("tid='{0}'", select_tid));
  5949. }
  5950. string shopname = GetPostString("shopname");
  5951. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5952. string buyernick = GetPostString("buyer_nick");
  5953. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5954. string sellermemo = GetPostString("seller_memo");
  5955. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5956. string orderState = GetPostString("orderState");
  5957. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5958. string afterState = GetPostString("afterstate");
  5959. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5960. string date1 = GetPostString("date1");
  5961. string date2 = GetPostString("date2");
  5962. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5963. if (dw.Length > 0) lw.Add(dw);
  5964. string price1 = GetPostString("price1");
  5965. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5966. string price2 = GetPostString("price2");
  5967. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5968. //lw.Add(string.Format("IsRefund!={0}", 1));
  5969. string reason = GetPostString("reason");
  5970. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5971. string method = GetPostString("method");
  5972. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5973. string handler = GetPostString("handler");
  5974. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5975. string handledate1 = GetPostString("handledate1");
  5976. string handledate2 = GetPostString("handledate2");
  5977. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5978. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5979. string afterdate1 = GetPostString("afterdate1");
  5980. string afterdate2 = GetPostString("afterdate2");
  5981. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5982. if (afterDate.Length > 0) lw.Add(afterDate);
  5983. string supplier = GetPostString("supplier");
  5984. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5985. string responsible = GetPostString("responsibleman");
  5986. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5987. string customer = GetPostString("customer");
  5988. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5989. string design = GetPostString("design");
  5990. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5991. string afterSaleMemo = GetPostString("afterSaleMemo");
  5992. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5993. string afterMemoType = GetPostString("aftermemotype");
  5994. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5995. string afterresult = GetPostString("afterresult");
  5996. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5997. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5998. string poscode = CurrentUser.UserPost.Post.Code;
  5999. if (poscode != "SysAdmin")
  6000. {
  6001. string shopid = CurrentUser.User.pemShop;
  6002. lw.Add(string.Format("shopId in ({0})", shopid));
  6003. }
  6004. string searchType = GetPostString("searchType");
  6005. if (searchType == "wait")
  6006. {
  6007. lw.Add(string.Format("HandleTime is null"));
  6008. }
  6009. if (searchType == "documentary")
  6010. {
  6011. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6012. }
  6013. if (searchType == "handling")
  6014. {
  6015. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6016. }
  6017. if (searchType == "back" || searchType == "puBack")
  6018. {
  6019. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6020. }
  6021. if (searchType == "reBack")
  6022. {
  6023. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6024. }
  6025. if (afterState.Length <= 0)
  6026. {
  6027. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6028. }
  6029. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6030. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6031. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6032. writeGridDataTableJson(dStruct.TotalCount, dt);
  6033. }
  6034. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6035. //public void get_erp_back_handlingaftersalelist()
  6036. //{
  6037. // DataStruct dStruct = GetPostStruct();
  6038. // List<string> lw = new List<string>();
  6039. // string tid = GetPostString("ctid");
  6040. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6041. // string shopname = GetPostString("shopname");
  6042. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6043. // string buyernick = GetPostString("buyer_nick");
  6044. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6045. // string sellermemo = GetPostString("seller_memo");
  6046. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6047. // string orderState = GetPostString("orderState");
  6048. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6049. // string afterState = GetPostString("afterstate");
  6050. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6051. // string date1 = GetPostString("date1");
  6052. // string date2 = GetPostString("date2");
  6053. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6054. // if (dw.Length > 0) lw.Add(dw);
  6055. // string price1 = GetPostString("price1");
  6056. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6057. // string price2 = GetPostString("price2");
  6058. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6059. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6060. // string reason = GetPostString("reason");
  6061. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6062. // string method = GetPostString("method");
  6063. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6064. // string handler = GetPostString("handler");
  6065. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6066. // string handledate1 = GetPostString("handledate1");
  6067. // string handledate2 = GetPostString("handledate2");
  6068. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6069. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6070. // string afterdate1 = GetPostString("afterdate1");
  6071. // string afterdate2 = GetPostString("afterdate2");
  6072. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6073. // if (afterDate.Length > 0) lw.Add(afterDate);
  6074. // string supplier = GetPostString("supplier");
  6075. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6076. // string responsible = GetPostString("responsibleman");
  6077. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6078. // string customer = GetPostString("customer");
  6079. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6080. // string design = GetPostString("design");
  6081. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6082. // string afterMemoType = GetPostString("aftermemotype");
  6083. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6084. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6085. // if (afterState.Length <= 0)
  6086. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6087. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6088. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6089. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6090. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6091. //}
  6092. public void get_erp_aftersaleverifylist()
  6093. {
  6094. DataStruct dStruct = GetPostStruct();
  6095. List<string> lw = new List<string>();
  6096. string tid = GetPostString("ctid");
  6097. if (tid.Length > 0)
  6098. {
  6099. string select_tid = getTidByCtid(tid);
  6100. lw.Add(string.Format("tid='{0}'", select_tid));
  6101. }
  6102. string shopname = GetPostString("shopname");
  6103. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6104. string buyernick = GetPostString("buyer_nick");
  6105. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6106. string sellermemo = GetPostString("seller_memo");
  6107. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6108. string orderState = GetPostString("orderState");
  6109. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6110. //lw.Add(string.Format("IsRefund!={0}", 1));
  6111. string reason = GetPostString("reason");
  6112. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6113. string method = GetPostString("method");
  6114. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6115. string handler = GetPostString("handler");
  6116. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6117. string handledate1 = GetPostString("handledate1");
  6118. string handledate2 = GetPostString("handledate2");
  6119. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6120. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6121. string finish1 = GetPostString("finishdate1");
  6122. string finish2 = GetPostString("finishdate2");
  6123. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6124. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6125. string supplier = GetPostString("supplier");
  6126. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6127. string responsible = GetPostString("responsibleman");
  6128. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6129. string posCode = CurrentUser.UserPost.Post.Code;
  6130. string vstate = GetPostString("vstate");
  6131. if (vstate.Length > 0)
  6132. {
  6133. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6134. }
  6135. if (posCode == "Supplier")
  6136. {
  6137. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6138. lw.Add(string.Format("VerifyState = 0"));
  6139. lw.Add("type = 1");
  6140. lw.Add(string.Format("AfterSaleState={0}", 3));
  6141. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6142. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6143. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6144. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6145. writeGridDataTableJson(dStruct.TotalCount, dt);
  6146. }
  6147. else if (posCode == "logistics")
  6148. {
  6149. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6150. lw.Add(string.Format("VerifyState = 0"));
  6151. lw.Add("type = 2");
  6152. lw.Add(string.Format("AfterSaleState={0}", 3));
  6153. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6154. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6155. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6156. writeGridDataTableJson(dStruct.TotalCount, dt);
  6157. }
  6158. else
  6159. {
  6160. lw.Add(string.Format("(AfterSaleState = 3)"));
  6161. string reasonState = GetPostString("reasonState");
  6162. lw.Add("type = 0");
  6163. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6164. || posCode == "Summarize" || posCode == "Finance")
  6165. {
  6166. if (reasonState == "2")
  6167. {
  6168. lw.Add("VerifyState = 3");
  6169. }
  6170. else if (reasonState == "1")
  6171. {
  6172. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6173. }
  6174. else
  6175. {
  6176. lw.Add("VerifyState in (0,3)");
  6177. }
  6178. //不加条件,可以看全部
  6179. }
  6180. 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")
  6181. {
  6182. int orgid = CurrentUser.UserPost.OrgID;
  6183. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6184. if (string.IsNullOrEmpty(manageOrgId))
  6185. {
  6186. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6187. }
  6188. else
  6189. {
  6190. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6191. }
  6192. if (reasonState == "1")
  6193. {
  6194. lw.Add("VerifyState = 3");
  6195. }
  6196. else if (reasonState == "2")
  6197. {
  6198. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6199. }
  6200. else
  6201. {
  6202. }
  6203. }
  6204. else
  6205. {
  6206. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6207. }
  6208. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6209. //{
  6210. // int org_id = CurrentUser.UserPost.OrgID;
  6211. // lw.Add(string.Format("OrgID={0}", org_id));
  6212. //}
  6213. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6214. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6215. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6216. writeGridDataTableJson(dStruct.TotalCount, dt);
  6217. }
  6218. }
  6219. public void get_erp_finishaftersalelist()
  6220. {
  6221. DataStruct dStruct = GetPostStruct();
  6222. List<string> lw = new List<string>();
  6223. int st = 4;
  6224. string tid = GetPostString("ctid");
  6225. if (tid.Length > 0)
  6226. {
  6227. string select_tid = getTidByCtid(tid);
  6228. lw.Add(string.Format("tid='{0}'", select_tid));
  6229. }
  6230. string shopname = GetPostString("shopname");
  6231. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6232. //lw.Add(string.Format("IsRefund!={0}", 1));
  6233. string reason = GetPostString("reason");
  6234. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6235. string method = GetPostString("method");
  6236. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6237. string buyernick = GetPostString("buyer_nick");
  6238. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6239. string handler = GetPostString("handler");
  6240. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6241. string handledate1 = GetPostString("handledate1");
  6242. string handledate2 = GetPostString("handledate2");
  6243. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6244. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6245. string finish1 = GetPostString("finishdate1");
  6246. string finish2 = GetPostString("finishdate2");
  6247. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6248. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6249. string supplier = GetPostString("supplier");
  6250. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6251. string responsible = GetPostString("responsibleman");
  6252. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6253. string vstate = GetPostString("vstate");
  6254. if (vstate.Length > 0)
  6255. {
  6256. if ("3".Equals(vstate))
  6257. {
  6258. lw.Add(string.Format("IsTem=1"));
  6259. }
  6260. else
  6261. {
  6262. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6263. }
  6264. }
  6265. lw.Add(string.Format("AfterSaleState=4"));
  6266. string code = CurrentUser.UserPost.Post.Code;
  6267. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6268. {
  6269. //不加条件,可以看全部
  6270. }
  6271. else if (code == "Supplier")
  6272. {
  6273. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6274. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6275. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6276. }
  6277. else if (code == "logistics")
  6278. {
  6279. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6280. lw.Add("type = 2");
  6281. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6282. }
  6283. 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")
  6284. {
  6285. int orgid = CurrentUser.UserPost.OrgID;
  6286. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6287. if (string.IsNullOrEmpty(manageOrgIds))
  6288. {
  6289. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6290. }
  6291. else
  6292. {
  6293. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6294. }
  6295. }
  6296. else
  6297. {
  6298. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6299. }
  6300. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6301. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6302. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6303. writeGridDataTableJson(dStruct.TotalCount, dt);
  6304. }
  6305. public void handle_erp_aftersale()
  6306. {
  6307. if (UrlPostParmsCheck("ctid"))
  6308. {
  6309. string eid = GetPostString("ctid");
  6310. string responStr = GetPostString("AfterSaleResponsible");
  6311. if (responStr.Length <= 0)
  6312. {
  6313. returnErrorMsg("售后责任人不能为空");
  6314. return;
  6315. }
  6316. bool isDesign = false;
  6317. double designFree = 0.00;
  6318. int responsibleId = 0;
  6319. CeErpTradeCell entity = null;
  6320. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6321. if (entity != null)
  6322. {
  6323. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6324. string afterMethod = GetPostString("AfterSaleMethod");
  6325. if (isNeedNewOrder == 1)
  6326. {
  6327. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6328. bool ishav = true;
  6329. if (newentity == null)
  6330. {
  6331. newentity = entity.Clone() as CeErpTradeCell;
  6332. ishav = false;
  6333. newentity.ctid = "S_" + entity.ctid;
  6334. newentity.OrderState = 0;
  6335. //唯一标识
  6336. newentity.OrderSn = newentity.ctid;
  6337. string orderSn = dataHelper.getSaleOrderSn();
  6338. if (orderSn != "")
  6339. {
  6340. newentity.OrderSn = orderSn;
  6341. }
  6342. }
  6343. newentity.UpdateTime = DateTime.Now;
  6344. newentity.AfterSaleState = 0;
  6345. newentity.AfterSaleMethod = afterMethod;
  6346. if (!ishav)
  6347. {
  6348. string memo_str = newentity.seller_memo;
  6349. memo_str = memo_str.Replace("(", "(");
  6350. memo_str = memo_str.Replace(")", ")");
  6351. int sIndex = memo_str.IndexOf("(");
  6352. int eIndex = memo_str.IndexOf(")");
  6353. if (sIndex == -1 || eIndex == -1)
  6354. {
  6355. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6356. return;
  6357. }
  6358. string first = memo_str.Substring(0, sIndex + 1);
  6359. string memoCtid = newentity.OrderSn;
  6360. //if (memoCtid.IndexOf("C") != -1)
  6361. //{
  6362. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6363. //if (CIdx.IndexOf("+") != -1)
  6364. //{
  6365. //CIdx = "C" + CIdx.Split('+')[1];
  6366. //}
  6367. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6368. //}
  6369. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6370. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6371. string newMemo = first + memoCtid + last;
  6372. newentity.seller_memo = newMemo;
  6373. newentity.FinishPlaceTime = null;
  6374. newentity.UnusualTag = 0;
  6375. newentity.UnusualCon = "";
  6376. newentity.UnusualTime = null;
  6377. newentity.AfterSaleMemo = "";
  6378. newentity.AfterSaleMethod = afterMethod;
  6379. newentity.AfterSalePreTime = null;
  6380. newentity.AfterSaleReason = "";
  6381. newentity.AfterSaleResponsible = "";
  6382. newentity.AfterSaleState = 0;
  6383. newentity.AfterSaleTime = null;
  6384. newentity.AfterSaleUserId = 0;
  6385. newentity.AfterSaleSupplierState = 0;
  6386. newentity.LastBillWaybillCode = "";
  6387. newentity.LastBillCpCode = "";
  6388. newentity.FinishAfterSaleTime = null;
  6389. newentity.HandleTime = null;
  6390. newentity.IsSF = 0;
  6391. newentity.IsOldCustomer = 0;
  6392. newentity.UrgencyTime = null;
  6393. newentity.ResponsibleUserId = "";
  6394. newentity.IsVerifyToSupplier = false;
  6395. newentity.payment = 0;
  6396. newentity.CheckMemo = "";
  6397. newentity.OutSid = "";
  6398. newentity.CheckOrderTime = null;
  6399. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6400. }
  6401. newentity.isAfterSaleOrder = 1;
  6402. newentity.IsRefund = 0;
  6403. string receiveMobile = GetPostString("receiver_mobile");
  6404. if (receiveMobile.Length > 0)
  6405. {
  6406. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6407. if (trade != null)
  6408. {
  6409. trade.receiver_name = GetPostString("receiver_name");
  6410. trade.receiver_mobile = receiveMobile;
  6411. trade.receiver_state = GetPostString("receiver_state");
  6412. trade.receiver_city = GetPostString("receiver_city");
  6413. trade.receiver_district = GetPostString("receiver_district");
  6414. trade.receiver_address = GetPostString("receiver_address");
  6415. newentity.IsOffLineOrder = 1;
  6416. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6417. }
  6418. }
  6419. string st = GetPostString("ToState");
  6420. if (st.Length > 0)
  6421. {
  6422. if (newentity.OrderState <= 3)
  6423. {
  6424. newentity.WaitDesignTime = DateTime.Now;
  6425. newentity.StartDesignTime = null;
  6426. newentity.FinishDesignTime = null;
  6427. newentity.OrderState = 3;
  6428. if (st == "下单员")
  6429. {
  6430. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6431. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6432. {
  6433. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6434. }
  6435. }
  6436. else
  6437. {
  6438. newentity.WaitDesignTime = DateTime.Now;
  6439. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6440. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6441. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6442. {
  6443. DataRow user = dt1.Rows[0];
  6444. //找主管
  6445. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6446. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6447. if (dt != null && dt.Rows.Count > 0)
  6448. {
  6449. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6450. newentity.DesignUserId = designMr;
  6451. string key = "aftersale_order_" + designMr;
  6452. if (RedisHelper.HasKey(key))
  6453. {
  6454. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6455. list.Add(newentity.ctid);
  6456. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6457. }
  6458. }
  6459. //账号正常
  6460. if (user["State"].ToString() == "0")
  6461. {
  6462. newentity.DesignUserId = entity.DesignUserId;
  6463. string key = "aftersale_order_" + entity.DesignUserId;
  6464. if (RedisHelper.HasKey(key))
  6465. {
  6466. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6467. list.Add(newentity.ctid);
  6468. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6469. }
  6470. }
  6471. }
  6472. }
  6473. }
  6474. if (entity.IsXianHuo == 1)
  6475. {
  6476. newentity.OrderState = 6;
  6477. entity.FinishPlaceTime = DateTime.Now;
  6478. }
  6479. }
  6480. if (ishav)
  6481. {
  6482. newentity.Update();
  6483. }
  6484. else
  6485. {
  6486. newentity.Create();
  6487. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6488. newCellExtend.ctid = newentity.ctid;
  6489. newCellExtend.orderFrom = 20;
  6490. newCellExtend.orderType = 30;
  6491. if (st == "下单员")
  6492. {
  6493. }
  6494. else
  6495. {
  6496. newCellExtend.ReprintTime = DateTime.Now;
  6497. }
  6498. newCellExtend.Create();
  6499. }
  6500. if (st != "下单员")
  6501. {
  6502. designHelper.API_GetPrintData_CreateOrder(newentity);
  6503. }
  6504. }
  6505. //处理售后扩展
  6506. string resIdStr = GetPostString("ResponsibleUserId");
  6507. string refundFees = GetPostString("refundFrees");
  6508. int IsComplain = GetPostInt("isComplain");
  6509. int IsBad = GetPostInt("isBad");
  6510. string IsOriginal = GetPostString("isOriginal");
  6511. double diffResultPrice = GetPostDouble("diffResultPrice");
  6512. string textResult = GetPostString("textResult");
  6513. string supplierResponsible = GetPostString("supplierResponsible");
  6514. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6515. if (ceErpTradeAfterSaleExtend == null)
  6516. {
  6517. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6518. ceErpTradeAfterSaleExtend.tid = eid;
  6519. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6520. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6521. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6522. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6523. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6524. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6525. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6526. ceErpTradeAfterSaleExtend.Create();
  6527. }
  6528. else
  6529. {
  6530. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6531. {
  6532. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6533. }
  6534. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6535. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6536. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6537. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6538. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6539. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6540. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6541. ceErpTradeAfterSaleExtend.Update();
  6542. }
  6543. int gysid = GetPostInt("ResponsibleSupId");
  6544. if (entity.AfterSaleUserId == 0)
  6545. {
  6546. entity.AfterSaleUserId = CurrentUser.UserID;
  6547. }
  6548. entity.ResponsibleUserId = resIdStr;
  6549. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6550. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6551. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6552. {
  6553. CeErpTradeResponsible.DelByTid(eid, -1);
  6554. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6555. int backNum = 0;
  6556. if (number != null)
  6557. {
  6558. backNum = number.BackNum;
  6559. }
  6560. char[] separator = { ',' };
  6561. string[] sArray = resIdStr.Split(separator);
  6562. string[] refundFreeList = { };
  6563. if (refundFees.Length > 0)
  6564. {
  6565. refundFreeList = refundFees.Split(separator);
  6566. }
  6567. int index = -1;
  6568. foreach (string i in sArray)
  6569. {
  6570. index++;
  6571. if (i.Length <= 0) continue;
  6572. char[] separator2 = { '_' };
  6573. string idstr = i.Split(separator2)[0];
  6574. string idtype = i.Split(separator2)[1];
  6575. double refudFree = 0;
  6576. if (refundFreeList.Length > 0)
  6577. {
  6578. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6579. }
  6580. if (idtype == "s")
  6581. {
  6582. isDesign = true;
  6583. designFree = refudFree;
  6584. }
  6585. int userId = Convert.ToInt32(idstr);
  6586. int type = 0;
  6587. if (idtype == "g")
  6588. {
  6589. type = 1;
  6590. }
  6591. if (idtype == "w")
  6592. {
  6593. type = 2;
  6594. }
  6595. if (idtype == "t")
  6596. {
  6597. type = 3;
  6598. }
  6599. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6600. if (ceErpTradeResponsible == null)
  6601. {
  6602. ceErpTradeResponsible = new CeErpTradeResponsible();
  6603. ceErpTradeResponsible.tid = eid;
  6604. ceErpTradeResponsible.UserId = userId;
  6605. ceErpTradeResponsible.createdTime = DateTime.Now;
  6606. ceErpTradeResponsible.type = type;
  6607. if (type == 1)
  6608. {
  6609. ceErpTradeResponsible.IsSup = 1;
  6610. }
  6611. if (type == 2)
  6612. {
  6613. ceErpTradeResponsible.IsFlow = 1;
  6614. }
  6615. }
  6616. ceErpTradeResponsible.RefundFee = refudFree;
  6617. ceErpTradeResponsible.VerifyState = 0;
  6618. if (userId == 2125 || idtype == "w")
  6619. {
  6620. ceErpTradeResponsible.VerifyState = 1;
  6621. }
  6622. if (idtype == "w" && userId == 101)
  6623. {
  6624. ceErpTradeResponsible.VerifyState = 0;
  6625. }
  6626. if (ceErpTradeResponsible.ID > 0)
  6627. {
  6628. ceErpTradeResponsible.Update();
  6629. }
  6630. else
  6631. {
  6632. ceErpTradeResponsible.Create();
  6633. }
  6634. if (isDesign)
  6635. {
  6636. responsibleId = ceErpTradeResponsible.ID;
  6637. }
  6638. }
  6639. CeErpTradeResponsible.NumByTid(backNum, eid);
  6640. }
  6641. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6642. if (ceErpTradeCellExtend != null)
  6643. {
  6644. ceErpTradeCellExtend.returnVisit = 0;
  6645. ceErpTradeCellExtend.Update();
  6646. }
  6647. if (entity.HandleTime != null)
  6648. {
  6649. if (entity.AfterSaleState == 1)
  6650. {
  6651. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6652. }
  6653. else
  6654. {
  6655. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6656. }
  6657. }
  6658. else
  6659. {
  6660. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6661. entity.HandleTime = DateTime.Now;
  6662. }
  6663. bool isCompale = false;
  6664. if (entity.AfterSaleState == 5)
  6665. {
  6666. isCompale = true;
  6667. entity.AfterSaleState = 3;
  6668. }
  6669. entity.AfterSaleSupplierState = 0;
  6670. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6671. {
  6672. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6673. }
  6674. string sImgs = GetPostString("img");
  6675. entity.AfterSaleSupplierImg = sImgs;
  6676. entity.supRefundType = GetPostString("supRefundType");
  6677. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6678. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6679. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6680. entity.AfterSaleMemoType = GetPostString("MemoType");
  6681. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6682. {
  6683. //entity.AfterSaleSupplierState = 2;
  6684. }
  6685. string df = GetPostString("DeductFee");
  6686. if (df == "")
  6687. {
  6688. df = "0";
  6689. }
  6690. string rf = GetPostString("RefundFee");
  6691. if (rf == "")
  6692. {
  6693. rf = "0";
  6694. }
  6695. string pm = GetPostString("AfterSalePayment");
  6696. if (pm == "")
  6697. {
  6698. pm = "0";
  6699. }
  6700. entity.AfterSalePayment = Convert.ToDouble(pm);
  6701. entity.DeductFee = Convert.ToDouble(df);
  6702. entity.RefundFee = Convert.ToDouble(rf);
  6703. entity.UpdateTime = DateTime.Now;
  6704. entity.Update();
  6705. string toState = GetPostString("ToState");
  6706. string original = GetPostString("isOriginal");
  6707. ApiVo apiVo = new ApiVo();
  6708. apiVo.orderNumber = entity.ctid;
  6709. apiVo.actionName = "afterDesign";
  6710. apiVo.orderRemarks = entity.AfterSaleMethod;
  6711. apiVo.reasonRemarks = entity.AfterSaleReason;
  6712. apiVo.isDesign = isDesign;
  6713. apiVo.designFree = designFree;
  6714. apiVo.responsibleId = responsibleId;
  6715. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6716. if (toState == "设计师")
  6717. {
  6718. apiVo.isOriginal = Convert.ToBoolean(original);
  6719. }
  6720. designHelper.API_WorkCore(apiVo);//afterDesign
  6721. CeErpMethod methodSql = new CeErpMethod();
  6722. methodSql.con = entity.AfterSaleMethod;
  6723. methodSql.addTime = DateTime.Now;
  6724. methodSql.Create();
  6725. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6726. CeErpMethod.ExecuteNonQuery(delsql);
  6727. if (isCompale)
  6728. {
  6729. aftersale_data_change(entity.ctid);
  6730. }
  6731. returnSuccessMsg("操作成功!");
  6732. return;
  6733. }
  6734. returnErrorMsg("找不到订单记录");
  6735. }
  6736. }
  6737. public void ins_erp_toresponsible()
  6738. {
  6739. if (UrlPostParmsCheck("ctid"))
  6740. {
  6741. string eid = GetPostString("ctid");
  6742. CeErpTradeCell entity = null;
  6743. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6744. if (entity != null)
  6745. {
  6746. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6747. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6748. {
  6749. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6750. return;
  6751. }
  6752. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6753. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6754. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6755. if (entity.AfterSalePreTime == null)
  6756. {
  6757. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6758. {
  6759. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6760. }
  6761. }
  6762. entity.AfterSalePreTime = DateTime.Now;
  6763. //预完成给售后主管审核客户问题直接完成
  6764. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6765. {
  6766. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6767. {
  6768. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6769. }
  6770. }
  6771. ceErpTradeAfterSaleExtend.Update();
  6772. entity.AfterSaleState = 2;
  6773. entity.UpdateTime = DateTime.Now;
  6774. entity.Update();
  6775. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6776. aftersale_data_change(entity.ctid);
  6777. returnSuccessMsg("操作成功!");
  6778. return;
  6779. }
  6780. returnErrorMsg("找不到订单记录");
  6781. }
  6782. }
  6783. public void cancel_erp_aftersaleanddelnew()
  6784. {
  6785. if (UrlPostParmsCheck("ctid"))
  6786. {
  6787. string eid = GetPostString("ctid");
  6788. CeErpTradeCell entity = null;
  6789. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6790. if (entity != null)
  6791. {
  6792. entity.AfterSaleState = 0;
  6793. entity.AfterSaleReason = "";
  6794. entity.AfterSaleMethod = "";
  6795. entity.AfterSaleMemo = "";
  6796. entity.AfterSaleResponsible = "";
  6797. entity.ResponsibleUserId = "";
  6798. entity.DeductFee = 0;
  6799. entity.RefundFee = 0;
  6800. entity.IsArbitrate = 0;
  6801. CeErpTradeResponsible.DelByTid(eid, -1);
  6802. entity.Update();
  6803. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6804. if (after != null)
  6805. {
  6806. if (after.OrderState < 5)
  6807. CeErpTradeCell.DelByCtid("S_" + eid);
  6808. }
  6809. returnSuccessMsg("操作成功!");
  6810. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6811. return;
  6812. }
  6813. returnErrorMsg("找不到订单记录");
  6814. }
  6815. }
  6816. public void get_erp_aftersale_pregather()
  6817. {
  6818. List<string> lw = new List<string>();
  6819. int st = GetInt("st");
  6820. string tid = GetPostString("ctid");
  6821. if (tid.Length > 0)
  6822. {
  6823. string select_tid = getTidByCtid(tid);
  6824. lw.Add(string.Format("tid='{0}'", select_tid));
  6825. }
  6826. string shopname = GetPostString("shopname");
  6827. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6828. string buyernick = GetPostString("buyer_nick");
  6829. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6830. string sellermemo = GetPostString("seller_memo");
  6831. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6832. string orderState = GetPostString("orderState");
  6833. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6834. string reason = GetPostString("reason");
  6835. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6836. string method = GetPostString("method");
  6837. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6838. string handler = GetPostString("handler");
  6839. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6840. string handledate1 = GetPostString("handledate1");
  6841. string handledate2 = GetPostString("handledate2");
  6842. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6843. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6844. string supplier = GetPostString("supplier");
  6845. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6846. string responsible = GetPostString("responsibleman");
  6847. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6848. string customer = GetPostString("customer");
  6849. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6850. string design = GetPostString("design");
  6851. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6852. string afterMemoType = GetPostString("aftermemotype");
  6853. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6854. string afterSaleMemo = GetPostString("afterSaleMemo");
  6855. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6856. string afterresult = GetPostString("afterresult");
  6857. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6858. string poscode = CurrentUser.UserPost.Post.Code;
  6859. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6860. {
  6861. string shopid = CurrentUser.User.pemShop;
  6862. lw.Add(string.Format("shopId in ({0})", shopid));
  6863. }
  6864. var mainwhere = string.Join(" and ", lw.ToArray());
  6865. string ro_json = "";
  6866. string type = GetPostString("gather_type");
  6867. int number = 0;
  6868. if (poscode == "AfterSale")
  6869. {
  6870. //处理中
  6871. if (type == "Handling")
  6872. {
  6873. 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) : ""));
  6874. DataTable dt = null;
  6875. try
  6876. {
  6877. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6878. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6879. }
  6880. catch (Exception e)
  6881. {
  6882. dt = new DataTable();
  6883. }
  6884. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6885. return;
  6886. }
  6887. if (type == "Wait")
  6888. {
  6889. //待处理
  6890. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6891. DataTable dt1 = null;
  6892. try
  6893. {
  6894. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6895. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6896. }
  6897. catch (Exception e)
  6898. {
  6899. dt1 = new DataTable();
  6900. }
  6901. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6902. return;
  6903. }
  6904. if (type == "back")
  6905. {
  6906. //打回
  6907. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6908. DataTable dt2 = null;
  6909. try
  6910. {
  6911. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6912. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6913. }
  6914. catch (Exception e)
  6915. {
  6916. dt2 = new DataTable();
  6917. }
  6918. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6919. return;
  6920. }
  6921. if (type == "preCompletion")
  6922. {
  6923. //预完成
  6924. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6925. DataTable dt3 = null;
  6926. try
  6927. {
  6928. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6929. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6930. }
  6931. catch (Exception e)
  6932. {
  6933. dt3 = new DataTable();
  6934. }
  6935. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6936. return;
  6937. }
  6938. if (type == "documentary")
  6939. {
  6940. //跟单中
  6941. 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) : ""));
  6942. DataTable dt4 = null;
  6943. try
  6944. {
  6945. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6946. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6947. }
  6948. catch (Exception e)
  6949. {
  6950. dt4 = new DataTable();
  6951. }
  6952. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6953. return;
  6954. }
  6955. if (type == "reBack")
  6956. {
  6957. //被打回
  6958. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6959. DataTable dt1 = null;
  6960. try
  6961. {
  6962. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6963. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6964. }
  6965. catch (Exception e)
  6966. {
  6967. dt1 = new DataTable();
  6968. }
  6969. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6970. return;
  6971. }
  6972. }
  6973. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6974. {
  6975. if (type == "puBack")
  6976. {
  6977. //退回
  6978. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6979. DataTable dt = null;
  6980. try
  6981. {
  6982. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6983. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6984. }
  6985. catch (Exception e)
  6986. {
  6987. dt = new DataTable();
  6988. }
  6989. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6990. return;
  6991. }
  6992. if (type == "reBack")
  6993. {
  6994. //打回
  6995. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6996. DataTable dt1 = null;
  6997. try
  6998. {
  6999. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7000. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7001. }
  7002. catch (Exception e)
  7003. {
  7004. dt1 = new DataTable();
  7005. }
  7006. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7007. return;
  7008. }
  7009. if (type == "examEd")
  7010. {
  7011. //已审核
  7012. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7013. DataTable dt2 = null;
  7014. try
  7015. {
  7016. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7017. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7018. }
  7019. catch (Exception e)
  7020. {
  7021. dt2 = new DataTable();
  7022. }
  7023. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7024. return;
  7025. }
  7026. if (type == "waitExam")
  7027. {
  7028. //待审核
  7029. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7030. DataTable dt3 = null;
  7031. try
  7032. {
  7033. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7034. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7035. }
  7036. catch (Exception e)
  7037. {
  7038. dt3 = new DataTable();
  7039. }
  7040. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7041. return;
  7042. }
  7043. if (type == "Handling")
  7044. {
  7045. //处理中
  7046. 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) : ""));
  7047. DataTable dt4 = null;
  7048. try
  7049. {
  7050. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7051. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7052. }
  7053. catch (Exception e)
  7054. {
  7055. dt4 = new DataTable();
  7056. }
  7057. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7058. return;
  7059. }
  7060. if (type == "Wait")
  7061. {
  7062. //待处理
  7063. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7064. DataTable dt5 = null;
  7065. try
  7066. {
  7067. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7068. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7069. }
  7070. catch (Exception e)
  7071. {
  7072. dt5 = new DataTable();
  7073. }
  7074. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7075. return;
  7076. }
  7077. if (type == "documentary")
  7078. {
  7079. //跟单中
  7080. 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) : ""));
  7081. DataTable dt6 = null;
  7082. try
  7083. {
  7084. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7085. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7086. }
  7087. catch (Exception e)
  7088. {
  7089. dt6 = new DataTable();
  7090. }
  7091. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7092. return;
  7093. }
  7094. }
  7095. returnSuccess(ro_json);
  7096. }
  7097. public void end_erp_aftersale()
  7098. {
  7099. if (UrlPostParmsCheck("ctid"))
  7100. {
  7101. string eid = GetPostString("ctid");
  7102. CeErpTradeCell entity = null;
  7103. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7104. if (entity != null)
  7105. {
  7106. string stype = GetPostString("stype");
  7107. string typeStr = stype;
  7108. entity.AfterSaleState = 4;
  7109. entity.FinishAfterSaleTime = DateTime.Now;
  7110. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7111. entity.Update();
  7112. ApiVo apiVo = new ApiVo();
  7113. apiVo.orderNumber = entity.ctid;
  7114. apiVo.actionName = "afterOver";
  7115. designHelper.API_WorkCore(apiVo); //afterOver
  7116. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7117. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7118. CeErpSukuraData.createInfo(entity.ctid, 8);
  7119. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7120. returnSuccessMsg("操作成功!");
  7121. return;
  7122. }
  7123. returnErrorMsg("找不到订单记录");
  7124. }
  7125. }
  7126. public void ins_erp_finishaftersale()
  7127. {
  7128. if (UrlPostParmsCheck("id"))
  7129. {
  7130. string eid = GetPostString("id");
  7131. CeErpTradeResponsible entity = null;
  7132. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7133. if (entity != null)
  7134. {
  7135. entity.VerifyState = 1;
  7136. entity.VerifyTime = DateTime.Now;
  7137. entity.Update();
  7138. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7139. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7140. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7141. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7142. if (dt.Rows.Count <= 0)
  7143. {
  7144. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7145. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7146. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7147. CeErpSukuraData.createInfo(entity.tid, 8);
  7148. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7149. {
  7150. CeErpDesignerBill.Del(entity.tid);
  7151. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7152. }
  7153. }
  7154. returnSuccessMsg("操作成功!");
  7155. return;
  7156. }
  7157. returnErrorMsg("找不到订单记录");
  7158. }
  7159. }
  7160. public void upd_erp_arbitrateaftersale()
  7161. {
  7162. if (UrlPostParmsCheck("id"))
  7163. {
  7164. string eid = GetPostString("id");
  7165. CeErpTradeResponsible entity = null;
  7166. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7167. if (entity != null)
  7168. {
  7169. entity.IsArbitrate = 1;
  7170. entity.ArbitradeMemo = GetPostString("reason");
  7171. entity.VerifyState = 2;
  7172. entity.Update();
  7173. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7174. if (tradecell != null)
  7175. {
  7176. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7177. tradecell.IsArbitrate = 1;
  7178. tradecell.Update();
  7179. }
  7180. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7181. returnSuccessMsg("操作成功!");
  7182. return;
  7183. }
  7184. returnErrorMsg("找不到订单记录");
  7185. }
  7186. }
  7187. public void upd_erp_backaftersale()
  7188. {
  7189. if (UrlPostParmsCheck("tid"))
  7190. {
  7191. string eid = GetPostString("tid");
  7192. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7193. int backNum = 0;
  7194. if (number != null)
  7195. {
  7196. backNum = number.BackNum;
  7197. }
  7198. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7199. CeErpTradeCell entity = null;
  7200. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7201. if (entity != null)
  7202. {
  7203. entity.AfterSaleBackReason = GetPostString("backreason");
  7204. entity.AfterSaleState = 1;
  7205. entity.AfterSaleSupplierState = 0;
  7206. entity.UpdateTime = DateTime.Now;
  7207. entity.Update();
  7208. returnSuccessMsg("操作成功!");
  7209. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7210. return;
  7211. }
  7212. returnErrorMsg("找不到订单记录");
  7213. }
  7214. }
  7215. public void get_erp_supplieraftersalelist()
  7216. {
  7217. DataStruct dStruct = GetPostStruct();
  7218. List<string> lw = new List<string>();
  7219. string tid = GetPostString("ctid");
  7220. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7221. string shopname = GetPostString("shopname");
  7222. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7223. string buyernick = GetPostString("buyer_nick");
  7224. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7225. string sellermemo = GetPostString("seller_memo");
  7226. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7227. string orderState = GetPostString("orderState");
  7228. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7229. string afterState = GetPostString("afterstate");
  7230. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7231. string date1 = GetPostString("date1");
  7232. string date2 = GetPostString("date2");
  7233. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7234. if (dw.Length > 0) lw.Add(dw);
  7235. string price1 = GetPostString("price1");
  7236. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7237. string price2 = GetPostString("price2");
  7238. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7239. string reason = GetPostString("reason");
  7240. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7241. string method = GetPostString("method");
  7242. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7243. string handledate1 = GetPostString("handledate1");
  7244. string handledate2 = GetPostString("handledate2");
  7245. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7246. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7247. string handler = GetPostString("handler");
  7248. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7249. string afterdate1 = GetPostString("afterdate1");
  7250. string afterdate2 = GetPostString("afterdate2");
  7251. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7252. if (afterDate.Length > 0) lw.Add(afterDate);
  7253. string customer = GetPostString("customer");
  7254. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7255. string design = GetPostString("design");
  7256. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7257. string afterMemoType = GetPostString("aftermemotype");
  7258. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7259. string vstate = GetPostString("vstate");
  7260. if (vstate.Length > 0)
  7261. {
  7262. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7263. }
  7264. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7265. string supplier = GetPostString("supplier");
  7266. int supid = commonHelper.getSupplierIDByName(supplier);
  7267. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7268. string posCode = CurrentUser.UserPost.Post.Code;
  7269. if (posCode == "Supplier")
  7270. {
  7271. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7272. }
  7273. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7274. {
  7275. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7276. }
  7277. else
  7278. {
  7279. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7280. }
  7281. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7282. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7283. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7284. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7285. writeGridDataTableJson(dStruct.TotalCount, dt);
  7286. }
  7287. public void upd_erp_supverifyaftersale()
  7288. {
  7289. if (UrlPostParmsCheck("id"))
  7290. {
  7291. string id = GetPostString("id");
  7292. int st = GetPostInt("afterstate");
  7293. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7294. CeErpTradeCell entity = null;
  7295. if (ceErpTradeResponsible != null)
  7296. {
  7297. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7298. }
  7299. string afmemo = GetPostString("supmemo");
  7300. string image = GetPostString("image");
  7301. if (entity != null)
  7302. {
  7303. entity.AfterSaleSupplierState = st;
  7304. entity.AfterSaleSupplierMemo = afmemo;
  7305. if (st == 1)
  7306. {
  7307. ceErpTradeResponsible.VerifyState = 1;
  7308. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7309. ceErpTradeResponsible.Update();
  7310. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7311. if (isAll)
  7312. {
  7313. entity.AfterSaleState = 4;
  7314. entity.FinishAfterSaleTime = DateTime.Now;
  7315. }
  7316. }
  7317. else
  7318. {
  7319. CeErpTradeResponsible.dateByTid(entity.ctid);
  7320. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7321. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7322. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7323. if (num <= 1)
  7324. {
  7325. entity.AfterSaleState = 1;
  7326. }
  7327. else
  7328. {
  7329. entity.AfterSaleState = 5;
  7330. }
  7331. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7332. if (ceErpTradeAfterSaleExtend != null)
  7333. {
  7334. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7335. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7336. ceErpTradeAfterSaleExtend.Update();
  7337. }
  7338. else
  7339. {
  7340. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7341. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7342. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7343. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7344. ceErpTradeAfterSaleExtend.Create();
  7345. }
  7346. }
  7347. if (entity.AfterSaleState == 4)
  7348. {
  7349. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7350. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7351. {
  7352. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7353. }
  7354. ApiVo apiVo = new ApiVo();
  7355. apiVo.orderNumber = entity.ctid;
  7356. apiVo.actionName = "afterOver";
  7357. designHelper.API_WorkCore(apiVo); //afterOver
  7358. }
  7359. entity.UpdateTime = DateTime.Now;
  7360. entity.Update();
  7361. returnSuccessMsg("操作成功!");
  7362. CeErpSukuraData.createInfo(entity.ctid, 8);
  7363. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7364. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7365. return;
  7366. }
  7367. returnErrorMsg("找不到订单记录");
  7368. }
  7369. }
  7370. public void upd_erp_masteraftersale()
  7371. {
  7372. if (UrlPostParmsCheck("id"))
  7373. {
  7374. string id = GetPostString("id");
  7375. int st = GetPostInt("afterstate");
  7376. string afmemo = GetPostString("supmemo");
  7377. string image = GetPostString("image");
  7378. string textResult = GetPostString("textResult");
  7379. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7380. if (ceErpTradeResponsible != null)
  7381. {
  7382. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7383. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7384. ceErpTradeResponsible.Update();
  7385. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7386. if (entity != null)
  7387. {
  7388. entity.AfterSaleSupplierState = st;
  7389. entity.AfterSaleSupplierMemo = afmemo;
  7390. if (st == 1)
  7391. {
  7392. }
  7393. else
  7394. {
  7395. CeErpTradeResponsible.dateByTid(entity.ctid);
  7396. //退回到售后
  7397. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7398. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7399. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7400. if (num <= 1)
  7401. {
  7402. entity.AfterSaleState = 1;
  7403. }
  7404. else
  7405. {
  7406. entity.AfterSaleState = 5;
  7407. }
  7408. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7409. if (ceErpTradeAfterSaleExtend != null)
  7410. {
  7411. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7412. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7413. ceErpTradeAfterSaleExtend.Update();
  7414. }
  7415. else
  7416. {
  7417. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7418. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7419. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7420. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7421. ceErpTradeAfterSaleExtend.Create();
  7422. }
  7423. }
  7424. entity.UpdateTime = DateTime.Now;
  7425. entity.Update();
  7426. returnSuccessMsg("操作成功!");
  7427. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7428. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7429. return;
  7430. }
  7431. }
  7432. returnErrorMsg("找不到订单记录");
  7433. }
  7434. }
  7435. public void upd_erp_personaftersale()
  7436. {
  7437. if (UrlPostParmsCheck("id"))
  7438. {
  7439. string id = GetPostString("id");
  7440. int st = GetPostInt("afterstate");
  7441. string afmemo = GetPostString("supmemo");
  7442. string image = GetPostString("image");
  7443. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7444. if (ceErpTradeResponsible != null)
  7445. {
  7446. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7447. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7448. ceErpTradeResponsible.Update();
  7449. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7450. if (entity != null)
  7451. {
  7452. entity.AfterSaleSupplierMemo = afmemo;
  7453. entity.AfterSaleSupplierState = st;
  7454. if (st == 1)
  7455. {
  7456. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7457. if (isAll)
  7458. {
  7459. entity.AfterSaleState = 4;
  7460. entity.FinishAfterSaleTime = DateTime.Now;
  7461. }
  7462. }
  7463. else
  7464. {
  7465. CeErpTradeResponsible.dateByTid(entity.ctid);
  7466. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7467. if (ceErpTradeAfterSaleExtend != null)
  7468. {
  7469. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7470. ceErpTradeAfterSaleExtend.Update();
  7471. }
  7472. else
  7473. {
  7474. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7475. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7476. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7477. ceErpTradeAfterSaleExtend.Create();
  7478. }
  7479. //退回到主管
  7480. //entity.AfterSaleState = 2;
  7481. }
  7482. if (entity.AfterSaleState == 4)
  7483. {
  7484. ApiVo apiVo = new ApiVo();
  7485. apiVo.orderNumber = entity.ctid;
  7486. apiVo.actionName = "afterOver";
  7487. designHelper.API_WorkCore(apiVo); //afterOver
  7488. }
  7489. entity.UpdateTime = DateTime.Now;
  7490. entity.Update();
  7491. returnSuccessMsg("操作成功!");
  7492. CeErpSukuraData.createInfo(entity.ctid, 8);
  7493. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7494. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7495. return;
  7496. }
  7497. }
  7498. returnErrorMsg("找不到订单记录");
  7499. }
  7500. }
  7501. public void set_erp_supplierrefundtag()
  7502. {
  7503. if (UrlPostParmsCheck("ctid"))
  7504. {
  7505. string eid = GetPostString("ctid");
  7506. CeErpTradeCell entity = null;
  7507. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7508. if (entity != null)
  7509. {
  7510. entity.IsSupplierRefund = GetPostInt("tag");
  7511. entity.Update();
  7512. returnSuccessMsg("操作成功!");
  7513. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7514. return;
  7515. }
  7516. returnErrorMsg("找不到订单记录");
  7517. }
  7518. }
  7519. public void get_erp_refundlist()
  7520. {
  7521. DataStruct dStruct = GetPostStruct();
  7522. List<string> lw = new List<string>();
  7523. string tid = GetPostString("tid");
  7524. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7525. //string rid = GetPostString("refund_id");
  7526. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7527. string shopname = GetPostString("shopname");
  7528. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7529. string buyernick = GetPostString("buyer_nick");
  7530. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7531. string customer = GetPostString("customer");
  7532. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7533. string design = GetPostString("design");
  7534. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7535. string sellermemo = GetPostString("seller_memo");
  7536. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7537. //string date1 = GetPostString("date1");
  7538. //string date2 = GetPostString("date2");
  7539. //string dateType = GetPostString("dateType");
  7540. //if (dateType.Length > 0)
  7541. //{
  7542. // if (dateType == "1001") dateType = "0";
  7543. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7544. // if (searchDT.Count == 2)
  7545. // {
  7546. // date1 = searchDT[0].ToString();
  7547. // date2 = searchDT[1].ToString();
  7548. // }
  7549. //}
  7550. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7551. //if (dw.Length > 0) lw.Add(dw);
  7552. string redate1 = GetPostString("refunddate1");
  7553. string redate2 = GetPostString("refunddate2");
  7554. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7555. if (dwdate.Length > 0) lw.Add(dwdate);
  7556. string price1 = GetPostString("price1");
  7557. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7558. string price2 = GetPostString("price2");
  7559. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7560. string ispartrefund = GetPostString("ispartrefund");
  7561. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7562. string refundState = GetPostString("refundvstate");
  7563. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7564. int st = GetInt("st");
  7565. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7566. {
  7567. string responsible = GetPostString("responsibleman");
  7568. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7569. lw.Add(string.Format("RefundState>={0}", st));
  7570. string code = CurrentUser.UserPost.Post.Code;
  7571. if (code == "CustomerService")
  7572. {
  7573. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7574. }
  7575. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7576. {
  7577. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7578. }
  7579. else if (code == "Place" || code == "PlaceMr")
  7580. {
  7581. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7582. }
  7583. dStruct.Order = "RefundState asc,created desc";
  7584. }
  7585. else if (st == 10)
  7586. {
  7587. string responsible = GetPostString("responsibleman");
  7588. if (responsible == "空白")
  7589. {
  7590. lw.Add(string.Format("ResponsibleUserName = ''"));
  7591. }
  7592. else if (responsible.Length > 0)
  7593. {
  7594. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7595. }
  7596. lw.Add(string.Format("RefundState>=0"));
  7597. dStruct.Order = "created desc";
  7598. }
  7599. else
  7600. {
  7601. string responsible = GetPostString("responsibleman");
  7602. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7603. lw.Add(string.Format("RefundState={0}", st));
  7604. dStruct.Order = "created desc";
  7605. }
  7606. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7607. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7608. dt.Columns.Add("refund_fees");
  7609. foreach (DataRow dr in dt.Rows)
  7610. {
  7611. String status = dr["status"].ToString();
  7612. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7613. {
  7614. dr["refund_fees"] = dr["refund_fee"];
  7615. }
  7616. else
  7617. {
  7618. dr["refund_fees"] = "0.0";
  7619. }
  7620. }
  7621. writeGridDataTableJson(dStruct.TotalCount, dt);
  7622. }
  7623. public void get_erp_refunddesignlist()
  7624. {
  7625. DataStruct dStruct = GetPostStruct();
  7626. List<string> lw = new List<string>();
  7627. string tid = GetPostString("tid");
  7628. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7629. string shopname = GetPostString("shopname");
  7630. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7631. string buyernick = GetPostString("buyer_nick");
  7632. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7633. string customer = GetPostString("customer");
  7634. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7635. string design = GetPostString("design");
  7636. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7637. string sellermemo = GetPostString("seller_memo");
  7638. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7639. string redate1 = GetPostString("refunddate1");
  7640. string redate2 = GetPostString("refunddate2");
  7641. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7642. if (dwdate.Length > 0) lw.Add(dwdate);
  7643. string price1 = GetPostString("price1");
  7644. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7645. string price2 = GetPostString("price2");
  7646. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7647. string ispartrefund = GetPostString("ispartrefund");
  7648. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7649. string designerorg = GetPostString("designerorg");
  7650. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7651. string refundState = GetPostString("refundState");
  7652. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7653. int myOrgid = CurrentUser.UserPost.OrgID;
  7654. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7655. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7656. {
  7657. if (CurrentUser.User.TeamIds.Length > 0)
  7658. {
  7659. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7660. }
  7661. else
  7662. {
  7663. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7664. }
  7665. }
  7666. else if ("SysAdmin".Equals(myOrgCode))
  7667. {
  7668. }
  7669. else
  7670. {
  7671. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7672. {
  7673. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7674. }
  7675. else
  7676. {
  7677. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7678. }
  7679. }
  7680. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7681. dStruct.Order = "created desc";
  7682. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7683. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7684. dt.Columns.Add("refund_fees");
  7685. foreach (DataRow dr in dt.Rows)
  7686. {
  7687. String status = dr["status"].ToString();
  7688. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7689. {
  7690. dr["refund_fees"] = dr["refund_fee"];
  7691. }
  7692. else
  7693. {
  7694. dr["refund_fees"] = "0.0";
  7695. }
  7696. }
  7697. writeGridDataTableJson(dStruct.TotalCount, dt);
  7698. }
  7699. public void handle_erp_refundtag()
  7700. {
  7701. if (UrlPostParmsCheck("refund_id"))
  7702. {
  7703. string eid = GetPostString("refund_id");
  7704. string respMan = GetPostString("ResponsibleName");
  7705. if (respMan.Length <= 0)
  7706. {
  7707. returnErrorMsg("责任人不能为空");
  7708. return;
  7709. }
  7710. CeErpTradeRefund entity = null;
  7711. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7712. if (entity != null)
  7713. {
  7714. entity.ResponsibleUserName = respMan;
  7715. string userid = GetPostString("ResponsibleUserId");
  7716. if (userid.Length > 0)
  7717. {
  7718. entity.ResponsibleUserId = userid;
  7719. }
  7720. entity.Memo = GetPostString("Memo");
  7721. if (respMan.IndexOf("客服") != -1 ||
  7722. respMan.IndexOf("设计师") != -1 ||
  7723. respMan.IndexOf("下单员") != -1)
  7724. {
  7725. entity.RefundState = 2;
  7726. }
  7727. else
  7728. {
  7729. entity.RefundState = 3;
  7730. }
  7731. entity.modified = DateTime.Now;
  7732. entity.Update();
  7733. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7734. returnSuccessMsg("操作成功!");
  7735. return;
  7736. }
  7737. returnErrorMsg("找不到订单记录");
  7738. }
  7739. }
  7740. public void handle_erp_designrefundtag()
  7741. {
  7742. if (UrlPostParmsCheck("refund_id"))
  7743. {
  7744. string eid = GetPostString("refund_id");
  7745. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7746. if (ceErpTradeCellExtend == null)
  7747. {
  7748. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7749. ceErpTradeCellExtend.ctid = eid;
  7750. }
  7751. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7752. if (ceErpTradeCellExtend.ID > 0)
  7753. {
  7754. ceErpTradeCellExtend.Update();
  7755. }
  7756. else
  7757. {
  7758. ceErpTradeCellExtend.Create();
  7759. }
  7760. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7761. returnSuccessMsg("操作成功!");
  7762. return;
  7763. }
  7764. returnErrorMsg("找不到订单记录");
  7765. }
  7766. public void upd_erp_refundverify()
  7767. {
  7768. if (UrlPostParmsCheck("refund_id"))
  7769. {
  7770. string eid = GetPostString("refund_id");
  7771. CeErpTradeRefund entity = null;
  7772. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7773. if (entity != null)
  7774. {
  7775. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7776. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7777. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7778. {
  7779. entity.RefundState = 2;
  7780. }
  7781. else
  7782. {
  7783. entity.RefundState = 3;
  7784. }
  7785. entity.Update();
  7786. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7787. returnSuccessMsg("操作成功!");
  7788. return;
  7789. }
  7790. returnErrorMsg("找不到订单记录");
  7791. }
  7792. }
  7793. public void upd_erp_refundapprove()
  7794. {
  7795. if (UrlPostParmsCheck("refund_id"))
  7796. {
  7797. string eid = GetPostString("refund_id");
  7798. CeErpTradeRefund entity = null;
  7799. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7800. if (entity != null)
  7801. {
  7802. int apr = GetPostInt("approve");
  7803. if (apr == 0)
  7804. {
  7805. entity.RefundState = 1;
  7806. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7807. }
  7808. else if (apr == 1)
  7809. {
  7810. entity.RefundState = 3;
  7811. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7812. }
  7813. entity.modified = DateTime.Now;
  7814. entity.Update();
  7815. returnSuccessMsg("操作成功!");
  7816. return;
  7817. }
  7818. returnErrorMsg("找不到订单记录");
  7819. }
  7820. }
  7821. public void get_erp_billlist()
  7822. {
  7823. DataStruct dStruct = GetPostStruct();
  7824. List<string> lw = new List<string>();
  7825. string title = GetPostString("title");
  7826. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7827. string tid = GetPostString("tid");
  7828. string tids = GetPostString("tids");
  7829. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7830. if (tids.Length > 0)
  7831. {
  7832. tids = "'" + tids + "'";
  7833. tids = tids.Replace(",", "','");
  7834. lw.Add(string.Format("tid in ({0})", tids));
  7835. }
  7836. string shopname = GetPostString("shopname");
  7837. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7838. string buyernick = GetPostString("buyer_nick");
  7839. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7840. string customer = GetPostString("customer");
  7841. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7842. string date1 = GetPostString("date1");
  7843. string date2 = GetPostString("date2");
  7844. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7845. if (dw.Length > 0) lw.Add(dw);
  7846. string price1 = GetPostString("price1");
  7847. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7848. string price2 = GetPostString("price2");
  7849. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7850. string returndate1 = GetPostString("returndate1");
  7851. string returndate2 = GetPostString("returndate2");
  7852. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7853. if (dw1.Length > 0) lw.Add(dw1);
  7854. string billtype = GetPostString("billtype");
  7855. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7856. string billstate = GetPostString("billstate");
  7857. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7858. string usershop = CurrentUser.User.pemShop;
  7859. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7860. dStruct.Order = "createTime desc";
  7861. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7862. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7863. //foreach (DataRow dr in dt.Rows)
  7864. //{
  7865. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7866. //}
  7867. writeGridDataTableJson(dStruct.TotalCount, dt);
  7868. }
  7869. public void modify_erp_billinfo()
  7870. {
  7871. if (UrlPostParmsCheck("ID"))
  7872. {
  7873. string eid = GetPostString("ID");
  7874. CeErpBill bill_entity = null;
  7875. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7876. if (bill_entity != null)
  7877. {
  7878. bill_entity.tid = GetPostString("tid");
  7879. bill_entity.title = GetPostString("title");
  7880. bill_entity.tax = GetPostString("tax");
  7881. bill_entity.bank = GetPostString("bank");
  7882. bill_entity.bankac = GetPostString("bankac");
  7883. bill_entity.address = GetPostString("address");
  7884. bill_entity.phone = GetPostString("phone");
  7885. bill_entity.price = GetPostString("price");
  7886. bill_entity.productId = GetPostInt("ProductName");
  7887. bill_entity.num = GetPostInt("num");
  7888. bill_entity.unit = GetPostString("unit");
  7889. bill_entity.type = GetPostString("type");
  7890. bill_entity.sendType = GetPostString("SendType");
  7891. bill_entity.email = GetPostString("email");
  7892. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7893. bill_entity.shopName = GetPostString("ShopName");
  7894. bill_entity.applymemo = GetPostString("applymemo");
  7895. bill_entity.modifyTime = DateTime.Now;
  7896. bill_entity.createTime = DateTime.Now;
  7897. bill_entity.state = 0;
  7898. bill_entity.Update();
  7899. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7900. returnSuccessMsg("发票修改成功!");
  7901. return;
  7902. }
  7903. returnErrorMsg("找不到对应记录");
  7904. }
  7905. }
  7906. public void set_erp_invoicing()
  7907. {
  7908. if (UrlPostParmsCheck("id"))
  7909. {
  7910. try
  7911. {
  7912. string eid = GetPostString("id");
  7913. CeErpBill bill_entity = null;
  7914. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7915. if (bill_entity != null)
  7916. {
  7917. int ComId = GetPostInt("ComId");
  7918. //string memo = GetPostString("Memo");
  7919. int allInfo = GetPostInt("allinfo");
  7920. string clert = CurrentUser.User.Name;
  7921. //string detailValue = GetPostString("detailvalue");
  7922. string billId = bill_entity.billOrderId;
  7923. string[] billIdList = billId.Split(',');
  7924. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7925. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7926. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7927. {
  7928. billCount += 1;
  7929. }
  7930. if (billId.Length <= 0 || billIdList.Length != billCount)
  7931. {
  7932. bill_entity.billOrderId = "";
  7933. string prebill = "ltb";
  7934. for (int idx = 1; idx <= billCount; idx++)
  7935. {
  7936. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7937. string billoid = prebill + idx + dtstr;
  7938. bill_entity.billOrderId += billoid;
  7939. if (idx < billCount)
  7940. {
  7941. bill_entity.billOrderId += ",";
  7942. }
  7943. }
  7944. }
  7945. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7946. if (bill_entity.state == 5)
  7947. {
  7948. string errMsg = bill_entity.failerror;
  7949. string[] errlist = errMsg.Split('|');
  7950. string[] errTags = new string[errlist.Length];
  7951. for (int itag = 0; itag < errlist.Length; itag++)
  7952. {
  7953. if (errlist[itag].Length <= 0) continue;
  7954. errTags[itag] = errlist[itag].Split('&')[0];
  7955. }
  7956. for (int iii = 0; iii < errTags.Length; iii++)
  7957. {
  7958. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7959. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7960. if (billOrderList.Length >= erroBillOrderTag)
  7961. {
  7962. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7963. if (needModifyBillId.Length <= 19)
  7964. {
  7965. needModifyBillId = needModifyBillId + "1";
  7966. }
  7967. else
  7968. {
  7969. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7970. last = last + 1;
  7971. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7972. }
  7973. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7974. }
  7975. }
  7976. }
  7977. bool isHaveBillSucces = false;
  7978. string totalRes = "";
  7979. bill_entity.failerror = "";
  7980. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7981. {
  7982. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7983. totalRes += res;
  7984. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7985. {
  7986. isHaveBillSucces = true;
  7987. bill_entity.comId = ComId;
  7988. bill_entity.state = 1;
  7989. bill_entity.executeTime = DateTime.Now;
  7990. bill_entity.executeUser = clert;
  7991. }
  7992. else
  7993. {
  7994. bill_entity.state = 5;
  7995. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7996. }
  7997. }
  7998. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7999. bill_entity.Update();
  8000. if (isHaveBillSucces)
  8001. {
  8002. StringBuilder sql = new StringBuilder();
  8003. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8004. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8005. }
  8006. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8007. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8008. {
  8009. returnErrorMsg("开票失败");
  8010. }
  8011. else
  8012. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8013. return;
  8014. }
  8015. returnErrorMsg("找不到对应记录");
  8016. }
  8017. catch (Exception ex)
  8018. {
  8019. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8020. returnErrorMsg("操作失败");
  8021. }
  8022. }
  8023. }
  8024. public void get_erp_invoicing_back()
  8025. {
  8026. if (UrlPostParmsCheck("id"))
  8027. {
  8028. try
  8029. {
  8030. string id = GetPostString("id");
  8031. CeErpBill entiy = CeErpBill.Get(id);
  8032. if (entiy != null)
  8033. {
  8034. if (entiy.state == 0)
  8035. {
  8036. returnErrorMsg("发票还未开具");
  8037. return;
  8038. }
  8039. string[] billOrderList = entiy.billOrderId.Split(',');
  8040. int iTag = 0;
  8041. entiy.fplsh = "";
  8042. entiy.fpdm = "";
  8043. entiy.fphm = "";
  8044. foreach (string billOrderId in billOrderList)
  8045. {
  8046. iTag++;
  8047. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8048. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8049. {
  8050. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8051. try
  8052. {
  8053. Invoicing_get_response_Obj iObj = null;
  8054. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8055. if (iObj != null)
  8056. {
  8057. entiy.state = 2;
  8058. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8059. entiy.fpdm += iObj.list[0].c_fpdm;
  8060. entiy.fphm += iObj.list[0].c_fphm;
  8061. if (iTag < billOrderList.Length)
  8062. {
  8063. entiy.fplsh += ",";
  8064. entiy.fpdm += ",";
  8065. entiy.fphm += ",";
  8066. }
  8067. entiy.Update();
  8068. }
  8069. StringBuilder sql = new StringBuilder();
  8070. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8071. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8072. returnSuccessMsg("开票成功");
  8073. }
  8074. catch (Exception ex)
  8075. {
  8076. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8077. }
  8078. return;
  8079. }
  8080. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8081. {
  8082. var res_obj = new
  8083. {
  8084. data = "开票中"
  8085. };
  8086. string ro_json = JsonConvert.SerializeObject(res_obj);
  8087. returnSuccess(ro_json);
  8088. return;
  8089. }
  8090. else
  8091. {
  8092. int eidx = res.IndexOf("c_resultmsg");
  8093. int lidx = res.IndexOf("c_status");
  8094. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8095. entiy.state = 5;
  8096. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8097. entiy.Update();
  8098. returnErrorMsg("开票失败");
  8099. return;
  8100. }
  8101. }
  8102. }
  8103. }
  8104. catch (Exception ex)
  8105. {
  8106. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8107. }
  8108. return;
  8109. }
  8110. }
  8111. public void get_erp_invoicing()
  8112. {
  8113. if (UrlPostParmsCheck("id"))
  8114. {
  8115. try
  8116. {
  8117. string id = GetPostString("id");
  8118. CeErpBill entiy = CeErpBill.Get(id);
  8119. if (entiy != null)
  8120. {
  8121. if (entiy.state == 0)
  8122. {
  8123. returnErrorMsg("发票还未开具");
  8124. return;
  8125. }
  8126. if (entiy.sendType == "纸质发票")
  8127. {
  8128. if (entiy.img.Length <= 0)
  8129. {
  8130. returnErrorMsg("查无纸质发票");
  8131. return;
  8132. }
  8133. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8134. returnSuccess(returnres);
  8135. return;
  8136. }
  8137. string[] billOrderList = entiy.billOrderId.Split(',');
  8138. int iTag = 0;
  8139. string fpUrl = "";
  8140. entiy.fplsh = "";
  8141. entiy.fpdm = "";
  8142. entiy.fphm = "";
  8143. foreach (string billOrderId in billOrderList)
  8144. {
  8145. iTag++;
  8146. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8147. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8148. {
  8149. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8150. Invoicing_get_response_Obj iObj = null;
  8151. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8152. if (iObj != null)
  8153. {
  8154. //entiy.state = 2;
  8155. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8156. entiy.fpdm += iObj.list[0].c_fpdm;
  8157. entiy.fphm += iObj.list[0].c_fphm;
  8158. if (iTag < billOrderList.Length)
  8159. {
  8160. entiy.fplsh += ",";
  8161. entiy.fpdm += ",";
  8162. entiy.fphm += ",";
  8163. }
  8164. entiy.Update();
  8165. fpUrl += iObj.list[0].c_url + ",";
  8166. }
  8167. //returnSuccess(res);
  8168. StringBuilder sql = new StringBuilder();
  8169. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8170. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8171. }
  8172. else
  8173. {
  8174. int eidx = res.IndexOf("c_resultmsg");
  8175. //int lidx = res.IndexOf("c_status");
  8176. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8177. //开票失败
  8178. entiy.state = 5;
  8179. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8180. entiy.Update();
  8181. returnErrorMsg("开票失败");
  8182. return;
  8183. }
  8184. }
  8185. var returnObj = new
  8186. {
  8187. data = fpUrl
  8188. };
  8189. string ro_json = JsonConvert.SerializeObject(returnObj);
  8190. returnSuccess(ro_json);
  8191. }
  8192. }
  8193. catch (Exception ex)
  8194. {
  8195. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8196. }
  8197. return;
  8198. }
  8199. }
  8200. public void save_erp_billimg()
  8201. {
  8202. if (UrlPostParmsCheck("id"))
  8203. {
  8204. string eid = GetPostString("id");
  8205. CeErpBill bill_entity = null;
  8206. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8207. if (bill_entity != null)
  8208. {
  8209. bill_entity.img = GetPostString("img");
  8210. bill_entity.executeTime = DateTime.Now;
  8211. bill_entity.state = 2;
  8212. bill_entity.Update();
  8213. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8214. returnSuccessMsg("保存成功");
  8215. }
  8216. return;
  8217. }
  8218. }
  8219. public void upd_erp_billreturnback()
  8220. {
  8221. if (UrlPostParmsCheck("id"))
  8222. {
  8223. int eid = GetPostInt("id");
  8224. CeErpBill bill_entity = null;
  8225. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8226. if (bill_entity != null)
  8227. {
  8228. bill_entity.state = 3;
  8229. bill_entity.returnReason = GetPostString("reason");
  8230. bill_entity.Update();
  8231. returnSuccessMsg("驳回成功!");
  8232. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8233. }
  8234. return;
  8235. }
  8236. }
  8237. public void cancel_erp_bill()
  8238. {
  8239. if (UrlPostParmsCheck("id"))
  8240. {
  8241. int eid = GetPostInt("id");
  8242. int detailValue = GetPostInt("detailvalue");
  8243. CeErpBill bill_entity = null;
  8244. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8245. string cres = "";
  8246. string gres = "";
  8247. if (bill_entity != null)
  8248. {
  8249. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8250. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8251. {
  8252. int iTag = 0;
  8253. bill_entity.fplsh = "";
  8254. bill_entity.fpdm = "";
  8255. bill_entity.fphm = "";
  8256. foreach (string billOrderId in billOrderList)
  8257. {
  8258. iTag++;
  8259. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8260. if (gres.IndexOf("success") != -1)
  8261. {
  8262. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8263. Invoicing_get_response_Obj iObj = null;
  8264. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8265. if (iObj != null)
  8266. {
  8267. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8268. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8269. bill_entity.fphm += iObj.list[0].c_fphm;
  8270. if (iTag < billOrderList.Length)
  8271. {
  8272. bill_entity.fplsh += ",";
  8273. bill_entity.fpdm += ",";
  8274. bill_entity.fphm += ",";
  8275. }
  8276. bill_entity.Update();
  8277. }
  8278. }
  8279. else
  8280. {
  8281. returnErrorMsg(gres);
  8282. return;
  8283. }
  8284. }
  8285. }
  8286. if (bill_entity.sendType == "纸质发票")
  8287. {
  8288. //作废
  8289. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8290. //if (DateTime.Now.Month == extime.Month)
  8291. //{
  8292. //cres = taobaoHelper.cancel_invoicing(eid);
  8293. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8294. //{
  8295. bill_entity.state = 4;//已作废
  8296. bill_entity.Update();
  8297. returnSuccessMsg("发票已作废");
  8298. return;
  8299. //}
  8300. //else
  8301. //{
  8302. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8303. // bill_entity.Update();
  8304. // returnErrorMsg(cres);
  8305. // return;
  8306. //}
  8307. //}
  8308. //else
  8309. //{
  8310. // returnErrorMsg("纸质发票只能作废本月的发票");
  8311. // return;
  8312. //}
  8313. }
  8314. //红冲
  8315. int redTag = 0;
  8316. string[] fpdmList = bill_entity.fpdm.Split(',');
  8317. string[] fphmList = bill_entity.fphm.Split(',');
  8318. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8319. {
  8320. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8321. return;
  8322. }
  8323. foreach (string billOrderId in billOrderList)
  8324. {
  8325. redTag++;
  8326. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8327. cres += onecres;
  8328. cres += ",";
  8329. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8330. {
  8331. bill_entity.state = 4;//已作废
  8332. //bill_entity.Update();
  8333. //returnSuccessMsg("发票已红冲");
  8334. }
  8335. else if (onecres.IndexOf("重复冲红") != -1)
  8336. {
  8337. bill_entity.state = 4;//已作废
  8338. //bill_entity.Update();
  8339. //returnSuccessMsg("发票已红冲");
  8340. }
  8341. else
  8342. {
  8343. string errmsg = commonHelper.KeepChinese(onecres);
  8344. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8345. }
  8346. }
  8347. bill_entity.Update();
  8348. if (cres.IndexOf("失败") != -1)
  8349. returnErrorMsg("红冲失败");
  8350. else
  8351. returnSuccessMsg("发票已红冲");
  8352. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8353. return;
  8354. }
  8355. return;
  8356. }
  8357. }
  8358. public void del_erp_billorder()
  8359. {
  8360. if (UrlPostParmsCheck("id"))
  8361. {
  8362. string eid = GetPostString("id");
  8363. CeErpBill.Del(eid);
  8364. CeErpBill bill = CeErpBill.Get(eid);
  8365. if (bill != null)
  8366. {
  8367. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8368. }
  8369. returnSuccessMsg("删除成功");
  8370. }
  8371. }
  8372. public void finish_erp_bill()
  8373. {
  8374. if (UrlPostParmsCheck("ids"))
  8375. {
  8376. string eids = GetPostString("ids");
  8377. string[] list = eids.Split(',');
  8378. foreach (string eid in list)
  8379. {
  8380. CeErpBill bill = CeErpBill.Get(eid);
  8381. if (bill != null)
  8382. {
  8383. bill.state = 2;
  8384. bill.Update();
  8385. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8386. }
  8387. }
  8388. returnSuccessMsg("操作成功");
  8389. }
  8390. }
  8391. public void get_erp_returncash()
  8392. {
  8393. DataStruct dStruct = GetPostStruct();
  8394. List<string> lw = new List<string>();
  8395. string tid = GetPostString("tid");
  8396. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8397. string shopname = GetPostString("shopname");
  8398. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8399. string buyernick = GetPostString("buyer_nick");
  8400. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8401. string customer = GetPostString("customer");
  8402. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8403. string returndate1 = GetPostString("returndate1");
  8404. string returndate2 = GetPostString("returndate2");
  8405. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8406. if (dw.Length > 0) lw.Add(dw);
  8407. string finishDate1 = GetPostString("finishdate1");
  8408. string finishDate2 = GetPostString("finishdate2");
  8409. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8410. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8411. string returntype = GetPostString("returntype");
  8412. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8413. string returnvstate = GetPostString("returnvstate");
  8414. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8415. dStruct.Order = "created desc";
  8416. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8417. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8418. writeGridDataTableJson(dStruct.TotalCount, dt);
  8419. }
  8420. public void get_erp_staygoods()
  8421. {
  8422. DataStruct dStruct = GetPostStruct();
  8423. List<string> lw = new List<string>();
  8424. string tid = GetPostString("tid");
  8425. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8426. string shopname = GetPostString("shopname");
  8427. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8428. string wangwang = GetPostString("wangwang");
  8429. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8430. string customer = GetPostString("customer");
  8431. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8432. string returndate1 = GetPostString("returndate1");
  8433. string returndate2 = GetPostString("returndate2");
  8434. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8435. if (dw.Length > 0) lw.Add(dw);
  8436. string finishDate1 = GetPostString("finishdate1");
  8437. string finishDate2 = GetPostString("finishdate2");
  8438. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8439. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8440. string returnvstate = GetPostString("returnvstate");
  8441. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8442. string persuadetype = GetPostString("persuadetype");
  8443. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8444. string customerOrg = GetPostString("customerOrg");
  8445. if (customerOrg.Length > 0)
  8446. {
  8447. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8448. }
  8449. dStruct.Order = "creata_time desc";
  8450. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8451. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8452. writeGridDataTableJson(dStruct.TotalCount, dt);
  8453. }
  8454. public void upd_erp_staygoods()
  8455. {
  8456. if (UrlPostParmsCheck("id"))
  8457. {
  8458. int eid = GetPostInt("id");
  8459. CeErpStayGoods entity = null;
  8460. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8461. if (entity != null)
  8462. {
  8463. entity.audit_type = 1;
  8464. entity.audit_time = DateTime.Now;
  8465. entity.audit_u_id = CurrentUser.UserID;
  8466. entity.audit_u_name = CurrentUser.UserName;
  8467. entity.Update();
  8468. returnSuccessMsg("审核成功!");
  8469. return;
  8470. }
  8471. returnErrorMsg("找不到订单记录");
  8472. }
  8473. }
  8474. public void upd_erp_stayGoodsback()
  8475. {
  8476. if (UrlPostParmsCheck("id"))
  8477. {
  8478. int eid = GetPostInt("id");
  8479. CeErpStayGoods entity = null;
  8480. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8481. if (entity != null)
  8482. {
  8483. entity.audit_text = GetPostString("reason");
  8484. entity.audit_type = 2;
  8485. entity.audit_time = DateTime.Now;
  8486. entity.audit_u_id = CurrentUser.UserID;
  8487. entity.audit_u_name = CurrentUser.UserName;
  8488. entity.Update();
  8489. returnSuccessMsg("退回成功!");
  8490. return;
  8491. }
  8492. returnErrorMsg("找不到订单记录");
  8493. }
  8494. }
  8495. public void upd_erp_returncashverify()
  8496. {
  8497. if (UrlPostParmsCheck("ID"))
  8498. {
  8499. int eid = GetPostInt("ID");
  8500. CeErpReturnCash entity = null;
  8501. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8502. if (entity != null)
  8503. {
  8504. entity.cashstate = 1;
  8505. entity.verifytime = DateTime.Now;
  8506. entity.verifyuserid = CurrentUser.UserID;
  8507. entity.Update();
  8508. returnSuccessMsg("审核成功!");
  8509. return;
  8510. }
  8511. returnErrorMsg("找不到订单记录");
  8512. }
  8513. }
  8514. public void upd_all_erp_returncashverify()
  8515. {
  8516. if (UrlPostParmsCheck("ID"))
  8517. {
  8518. String[] list = GetPostString("ID").Split(',');
  8519. CeErpReturnCash entity = null;
  8520. for (int i = 0; i < list.Length; i++)
  8521. {
  8522. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8523. if (entity != null)
  8524. {
  8525. if (entity.cashstate == 1)
  8526. {
  8527. returnErrorMsg("已审核过的订单不需要在审核!");
  8528. return;
  8529. }
  8530. entity.cashstate = 1;
  8531. entity.verifytime = DateTime.Now;
  8532. entity.verifyuserid = CurrentUser.UserID;
  8533. entity.Update();
  8534. }
  8535. }
  8536. returnSuccessMsg("审核成功!");
  8537. return;
  8538. }
  8539. }
  8540. public void upd_erp_returncashback()
  8541. {
  8542. if (UrlPostParmsCheck("ID"))
  8543. {
  8544. int eid = GetPostInt("ID");
  8545. CeErpReturnCash entity = null;
  8546. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8547. if (entity != null)
  8548. {
  8549. entity.backreason = GetPostString("reason");
  8550. entity.cashstate = 2;
  8551. entity.verifytime = DateTime.Now;
  8552. entity.verifyuserid = CurrentUser.UserID;
  8553. entity.Update();
  8554. returnSuccessMsg("退回成功!");
  8555. return;
  8556. }
  8557. returnErrorMsg("找不到订单记录");
  8558. }
  8559. }
  8560. public void upd_erp_returnprice()
  8561. {
  8562. if (UrlPostParmsCheck("ID"))
  8563. {
  8564. int eid = GetPostInt("ID");
  8565. CeErpReturnCash entity = null;
  8566. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8567. if (entity != null)
  8568. {
  8569. if (entity.cashstate == 1)
  8570. {
  8571. returnErrorMsg("审核通过了不能改");
  8572. return;
  8573. }
  8574. entity.returnprice = GetPostDouble("returnprice");
  8575. entity.Update();
  8576. returnSuccessMsg("修改成功!");
  8577. return;
  8578. }
  8579. returnErrorMsg("找不到订单记录");
  8580. }
  8581. }
  8582. public void del_erp_returncash()
  8583. {
  8584. if (UrlPostParmsCheck("ID"))
  8585. {
  8586. int eid = GetPostInt("ID");
  8587. CeErpReturnCash.Del(eid);
  8588. returnSuccessMsg("操作成功");
  8589. return;
  8590. }
  8591. }
  8592. public void test_for_do_sql()
  8593. {
  8594. string sql = GetPostString("sqlstr");
  8595. if (sql.Length > 0)
  8596. {
  8597. try
  8598. {
  8599. DbHelper.DbConn.ExecuteNonQuery(sql);
  8600. var res_obj = new
  8601. {
  8602. data = "成功",
  8603. };
  8604. string ro_json = JsonConvert.SerializeObject(res_obj);
  8605. returnSuccess(ro_json);
  8606. }
  8607. catch (Exception ex)
  8608. {
  8609. var res_obj = new
  8610. {
  8611. data = ex.Message,
  8612. };
  8613. string ro_json = JsonConvert.SerializeObject(res_obj);
  8614. returnSuccess(ro_json);
  8615. }
  8616. }
  8617. }
  8618. public void get_user_info()
  8619. {
  8620. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8621. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8622. }
  8623. public void get_total_data()
  8624. {
  8625. int userId = CurrentUser.UserID;
  8626. string sql = "";
  8627. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8628. {
  8629. 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);
  8630. }
  8631. else
  8632. {
  8633. 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 " +
  8634. "(select ID from CE_ErpUser where ID = {0}) d " +
  8635. "left join " +
  8636. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8637. ") a on d.ID = a.id left join " +
  8638. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8639. ") b on a.id = b.id1 left join" +
  8640. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8641. ") c on a.id = c.id2;", userId);
  8642. }
  8643. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8644. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8645. }
  8646. public void get_date_area_total_data2()
  8647. {
  8648. int userId = CurrentUser.UserID;
  8649. string date_type = GetPostString("timetype");
  8650. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8651. string sql = "";
  8652. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8653. {
  8654. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8655. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8656. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8657. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8658. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8659. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8660. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8661. ") a on e.ID = a.id left join " +
  8662. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8663. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8664. ") b on a.id = b.id1 " +
  8665. "left join " +
  8666. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8667. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8668. ") c on a.id = c.id2 " +
  8669. "left join " +
  8670. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8671. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8672. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8673. }
  8674. else
  8675. {
  8676. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8677. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8678. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8679. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8680. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8681. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8682. ") a on e.ID = a.id left join " +
  8683. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8684. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8685. ") c on a.id = c.id2 " +
  8686. "left join " +
  8687. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8688. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8689. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8690. }
  8691. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8692. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8693. }
  8694. public void get_date_area_total_data()
  8695. {
  8696. int userId = CurrentUser.UserID;
  8697. string date_type = GetPostString("timetype");
  8698. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8699. string date1 = searchDT[0].ToString();
  8700. string date2 = searchDT[1].ToString();
  8701. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8702. {
  8703. SqlParameter[] sqlParameter ={
  8704. new SqlParameter("@userId", SqlDbType.Int,4),
  8705. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8706. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8707. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8708. };
  8709. sqlParameter[0].Value = userId;
  8710. sqlParameter[1].Value = date1;
  8711. sqlParameter[2].Value = date2;
  8712. sqlParameter[3].Direction = ParameterDirection.Output;
  8713. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8714. string res = sqlParameter[3].Value.ToString();
  8715. var res_obj = new
  8716. {
  8717. data = res
  8718. };
  8719. string ro_json = JsonConvert.SerializeObject(res_obj);
  8720. returnSuccess(ro_json);
  8721. }
  8722. else
  8723. {
  8724. SqlParameter[] sqlParameter ={
  8725. new SqlParameter("@userId", SqlDbType.Int,4),
  8726. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8727. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8728. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8729. };
  8730. sqlParameter[0].Value = userId;
  8731. sqlParameter[1].Value = date1;
  8732. sqlParameter[2].Value = date2;
  8733. sqlParameter[3].Direction = ParameterDirection.Output;
  8734. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8735. string res = sqlParameter[3].Value.ToString();
  8736. var res_obj = new
  8737. {
  8738. data = res
  8739. };
  8740. string ro_json = JsonConvert.SerializeObject(res_obj);
  8741. returnSuccess(ro_json);
  8742. }
  8743. //writeGridDataViewJson(dt.Rows.Count, dv);
  8744. }
  8745. public void get_order_list()
  8746. {
  8747. string strFields = GetPostString("paraFields");
  8748. string strOrder = GetPostString("paraOrder");
  8749. string strWhere = GetPostString("paraWhere");
  8750. string strPageSize = GetPostString("paraPageSize");
  8751. DataStruct dStruct = GetPostStruct();
  8752. dStruct.PageSize = int.Parse(strPageSize);
  8753. dStruct.Fileds = strFields;
  8754. dStruct.Order = strOrder;
  8755. dStruct.MainWhere = strWhere;
  8756. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8757. writeGridDataTableJson(dStruct.TotalCount, dt);
  8758. }
  8759. ////获取待开始订单列表
  8760. //public void get_wait_design_order_list()
  8761. //{
  8762. // string date_type = GetPostString("date_type");
  8763. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8764. // DataStruct dStruct = GetPostStruct();
  8765. // dStruct.PageSize = 1000;
  8766. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8767. // List<string> lw = new List<string>();
  8768. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8769. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8770. // dStruct.Order = "WaitDesignTime asc";
  8771. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8772. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8773. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8774. //}
  8775. //获取完成单量排名
  8776. public void get_finish_order_count_ranking()
  8777. {
  8778. /* string date_type = GetPostString("date_type");
  8779. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8780. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8781. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8782. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8783. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8784. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8785. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8786. writeGridDataTableJson(0, new DataTable());
  8787. }
  8788. public void get_finish_order_amount_ranking()
  8789. {
  8790. /*string date_type = GetPostString("date_type");
  8791. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8792. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8793. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8794. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8795. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8796. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8797. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8798. writeGridDataTableJson(0, new DataTable());
  8799. }
  8800. public void get_finish_refund_count_ranking()
  8801. {
  8802. string date_type = GetPostString("date_type");
  8803. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8804. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8805. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8806. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8807. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8808. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8809. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8810. writeGridDataTableJson(dt.Rows.Count, dt);
  8811. }
  8812. public void get_finish_refund_amount_ranking()
  8813. {
  8814. string date_type = GetPostString("date_type");
  8815. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8816. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8817. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8818. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8819. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8820. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8821. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8822. writeGridDataTableJson(dt.Rows.Count, dt);
  8823. }
  8824. public void set_erp_finishorder_director()
  8825. {
  8826. if (UrlPostParmsCheck("ctid"))
  8827. {
  8828. string eid = GetPostString("ctid");
  8829. CeErpTradeCell entity = null;
  8830. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8831. if (entity != null)
  8832. {
  8833. entity.OrderState = 8;
  8834. entity.Update();
  8835. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8836. returnSuccessMsg("操作成功!");
  8837. return;
  8838. }
  8839. returnErrorMsg("找不到记录");
  8840. }
  8841. }
  8842. public void get_erp_placeregistlist()
  8843. {
  8844. DataStruct dStruct = GetPostStruct();
  8845. List<string> lw = new List<string>();
  8846. string outsid = GetPostString("outsid");
  8847. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8848. string memo = GetPostString("memo");
  8849. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8850. string filename = GetPostString("filename");
  8851. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8852. string islate = GetPostString("islate");
  8853. if (islate.Length > 0)
  8854. {
  8855. if (islate == "1")
  8856. lw.Add(string.Format("OutLate>0"));
  8857. else
  8858. lw.Add(string.Format("OutLate=0"));
  8859. }
  8860. string placedate1 = GetPostString("placedate1");
  8861. string placedate2 = GetPostString("placedate2");
  8862. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8863. if (dw.Length > 0) lw.Add(dw);
  8864. string deliveryDate1 = GetPostString("deliverydate1");
  8865. string deliveryDate2 = GetPostString("deliverydate2");
  8866. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8867. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8868. dStruct.Order = "ID desc";
  8869. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8870. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8871. writeGridDataTableJson(dStruct.TotalCount, dt);
  8872. }
  8873. public void ins_erp_placeregist()
  8874. {
  8875. if (UrlPostParmsCheck("id"))
  8876. {
  8877. string eid = GetPostString("id");
  8878. CeErpPlaceRegister entity = null;
  8879. if (eid == "0")//新增
  8880. {
  8881. entity = new CeErpPlaceRegister();
  8882. string xdTime = GetPostString("placeTime");
  8883. if (xdTime.Length > 0)
  8884. {
  8885. entity.PlactTime = Convert.ToDateTime(xdTime);
  8886. }
  8887. string fhTime = GetPostString("deliveryTime");
  8888. if (fhTime.Length > 0)
  8889. {
  8890. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8891. }
  8892. string preTime = GetPostString("preOutTime");
  8893. if (preTime.Length > 0)
  8894. {
  8895. entity.PreOutTime = Convert.ToDateTime(preTime);
  8896. }
  8897. entity.DeliveryCount = GetPostInt("deliveryCount");
  8898. entity.ReceiveCount = GetPostInt("receiveCount");
  8899. entity.OutSid = GetPostString("outSid");
  8900. entity.FileName = GetPostString("fileName");
  8901. entity.Memo = GetPostString("memo");
  8902. entity.AddUserId = CurrentUser.UserID;
  8903. entity.CreateTime = DateTime.Now;
  8904. entity.Img = GetPostString("img");
  8905. entity.Supplier = GetPostInt("supplier");
  8906. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8907. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8908. {
  8909. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8910. DateTime dt2 = (DateTime)entity.PreOutTime;
  8911. TimeSpan span = dt1.Subtract(dt2);
  8912. if (span.Days > 0)
  8913. {
  8914. entity.OutLate = span.Days;
  8915. }
  8916. }
  8917. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8918. entity.Create();
  8919. returnSuccessMsg("添加成功!");
  8920. return;
  8921. }
  8922. else //修改
  8923. {
  8924. entity = CeErpPlaceRegister.Get(eid);
  8925. if (entity != null)
  8926. {
  8927. string xdTime = GetPostString("placeTime");
  8928. if (xdTime.Length > 0)
  8929. {
  8930. entity.PlactTime = Convert.ToDateTime(xdTime);
  8931. }
  8932. string fhTime = GetPostString("deliveryTime");
  8933. if (fhTime.Length > 0)
  8934. {
  8935. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8936. }
  8937. string preTime = GetPostString("preOutTime");
  8938. if (preTime.Length > 0)
  8939. {
  8940. entity.PreOutTime = Convert.ToDateTime(preTime);
  8941. }
  8942. entity.DeliveryCount = GetPostInt("deliveryCount");
  8943. entity.ReceiveCount = GetPostInt("receiveCount");
  8944. if (entity.DeliveryCount == entity.ReceiveCount)
  8945. {
  8946. entity.CurState = "已完成";
  8947. }
  8948. else
  8949. {
  8950. entity.CurState = "未完成";
  8951. }
  8952. entity.OutSid = GetPostString("outSid");
  8953. entity.FileName = GetPostString("fileName");
  8954. entity.Memo = GetPostString("memo");
  8955. entity.Img = GetPostString("img");
  8956. entity.Supplier = GetPostInt("supplier");
  8957. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8958. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8959. {
  8960. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8961. DateTime dt2 = (DateTime)entity.PreOutTime;
  8962. TimeSpan span = dt1.Subtract(dt2);
  8963. if (span.Days > 0)
  8964. {
  8965. entity.OutLate = span.Days;
  8966. }
  8967. }
  8968. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8969. entity.Update();
  8970. returnSuccessMsg("修改成功");
  8971. return;
  8972. }
  8973. returnErrorMsg("找不到对应的记录");
  8974. return;
  8975. }
  8976. }
  8977. returnErrorMsg("缺少必要参数");
  8978. }
  8979. public void del_erp_placeregist()
  8980. {
  8981. string eid = GetPostString("id");
  8982. CeErpPlaceRegister.Del(eid);
  8983. returnSuccessMsg("删除成功!");
  8984. return;
  8985. }
  8986. public void ins_erp_placeregistbyorder()
  8987. {
  8988. string ctid = GetPostString("ctid");
  8989. if (ctid.Length > 0)
  8990. {
  8991. StringBuilder sql = new StringBuilder();
  8992. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8993. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8994. if (dt.Rows.Count > 0)
  8995. {
  8996. foreach (DataRow dr in dt.Rows)
  8997. {
  8998. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8999. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9000. entity.AddUserId = CurrentUser.UserID;
  9001. entity.tid = dr["tid"].ToString();
  9002. entity.Did = Convert.ToString(dr["ctid"]);
  9003. entity.splitTag = dr["SplitTag"].ToString();
  9004. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9005. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9006. if (pre_ctid.Length > 0)
  9007. {
  9008. sellmemo = sellmemo.Replace(pre_ctid, "");
  9009. }
  9010. sellmemo = sellmemo.Replace("[", "");
  9011. sellmemo = sellmemo.Replace("]", "");
  9012. entity.FileName = sellmemo;
  9013. string count = dr["ProductCount"].ToString();
  9014. int usecount = commonHelper.getIntCountFromString(count);
  9015. entity.DeliveryCount = usecount;
  9016. entity.CurState = "未完成";
  9017. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9018. {
  9019. entity.Supplier = 24;//dl手提袋定制
  9020. }
  9021. else
  9022. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9023. entity.CreateTime = DateTime.Now;
  9024. entity.Create();
  9025. }
  9026. returnSuccessMsg("操作成功");
  9027. return;
  9028. }
  9029. returnErrorMsg("没有找到对应订单");
  9030. return;
  9031. }
  9032. returnErrorMsg("缺少订单编号");
  9033. return;
  9034. }
  9035. public void get_erp_persuadelist()
  9036. {
  9037. DataStruct dStruct = GetPostStruct();
  9038. List<string> lw = new List<string>();
  9039. string ctid = GetPostString("ctid");
  9040. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9041. string shopname = GetPostString("shopname");
  9042. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9043. string buyernick = GetPostString("buyer_nick");
  9044. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9045. string customer = GetPostString("customer");
  9046. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9047. string returndate1 = GetPostString("returndate1");
  9048. string returndate2 = GetPostString("returndate2");
  9049. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9050. if (dw.Length > 0) lw.Add(dw);
  9051. string finishDate1 = GetPostString("finishdate1");
  9052. string finishDate2 = GetPostString("finishdate2");
  9053. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9054. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9055. string persuadetype = GetPostString("persuadetype");
  9056. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9057. string returnvstate = GetPostString("returnvstate");
  9058. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9059. dStruct.Order = "created desc";
  9060. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9061. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9062. writeGridDataTableJson(dStruct.TotalCount, dt);
  9063. }
  9064. public void upd_erp_returnpersuadeback()
  9065. {
  9066. if (UrlPostParmsCheck("ID"))
  9067. {
  9068. int eid = GetPostInt("ID");
  9069. CeErpPersuade entity = null;
  9070. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9071. if (entity != null)
  9072. {
  9073. entity.backreason = GetPostString("reason");
  9074. entity.pstate = 2;
  9075. entity.verifytime = DateTime.Now;
  9076. entity.verifyuserid = CurrentUser.UserID;
  9077. entity.Update();
  9078. returnSuccessMsg("退回成功!");
  9079. return;
  9080. }
  9081. returnErrorMsg("找不到订单记录");
  9082. }
  9083. }
  9084. public void upd_erp_returnpersuadeverify()
  9085. {
  9086. if (UrlPostParmsCheck("ID"))
  9087. {
  9088. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9089. {
  9090. returnErrorMsg("暂无权限审核");
  9091. return;
  9092. }
  9093. int eid = GetPostInt("ID");
  9094. CeErpPersuade entity = null;
  9095. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9096. if (entity != null)
  9097. {
  9098. entity.pstate = 1;
  9099. entity.verifytime = DateTime.Now;
  9100. entity.verifyuserid = CurrentUser.UserID;
  9101. entity.Update();
  9102. returnSuccessMsg("审核成功!");
  9103. return;
  9104. }
  9105. returnErrorMsg("找不到订单记录");
  9106. }
  9107. }
  9108. public void del_erp_persuade()
  9109. {
  9110. if (UrlPostParmsCheck("ID"))
  9111. {
  9112. int eid = GetPostInt("ID");
  9113. CeErpPersuade.Del(eid);
  9114. returnSuccessMsg("操作成功");
  9115. return;
  9116. }
  9117. }
  9118. public void get_erp_oldcustoupload()
  9119. {
  9120. DataStruct dStruct = GetPostStruct();
  9121. List<string> lw = new List<string>();
  9122. string buyernick = GetPostString("buyer_nick");
  9123. if (buyernick.Length > 0)
  9124. {
  9125. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9126. }
  9127. else
  9128. return;
  9129. dStruct.Order = "pay_time desc";
  9130. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9131. DataTable dt = null;
  9132. dt = WebCache.GetData("view_erptradecell", dStruct);
  9133. writeGridDataTableJson(dStruct.TotalCount, dt);
  9134. }
  9135. public void get_erp_checkorderlist()
  9136. {
  9137. DataStruct dStruct = GetPostStruct();
  9138. List<string> lw = new List<string>();
  9139. string tid = GetPostString("ctid");
  9140. if (tid.Length > 0)
  9141. {
  9142. string select_tid = getTidByCtid(tid);
  9143. lw.Add(string.Format("tid='{0}'", select_tid));
  9144. }
  9145. string shopname = GetPostString("shopname");
  9146. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9147. string buyernick = GetPostString("buyer_nick");
  9148. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9149. string customer = GetPostString("customer");
  9150. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9151. string design = GetPostString("design");
  9152. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9153. string orderState = GetPostString("orderState");
  9154. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9155. string address = GetPostString("address");
  9156. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9157. string sellermemo = GetPostString("seller_memo");
  9158. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9159. string supplier = GetPostString("supplier");
  9160. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9161. {
  9162. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9163. }
  9164. else
  9165. {
  9166. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9167. }
  9168. string date1 = GetPostString("date1");
  9169. string date2 = GetPostString("date2");
  9170. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9171. if (dw.Length > 0) lw.Add(dw);
  9172. string placedate1 = GetPostString("placedate1");
  9173. string placedate2 = GetPostString("placedate2");
  9174. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9175. if (fdw.Length > 0) lw.Add(fdw);
  9176. string price1 = GetPostString("price1");
  9177. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9178. string price2 = GetPostString("price2");
  9179. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9180. string checkst = GetPostString("checkstate");
  9181. if (checkst.Length > 0 && "10".Equals(checkst))
  9182. {
  9183. lw.Add(string.Format("CheckOut>0"));
  9184. }
  9185. else
  9186. {
  9187. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9188. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9189. }
  9190. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9191. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9192. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9193. writeGridDataTableJson(dStruct.TotalCount, dt);
  9194. }
  9195. public void ins_erp_startCheck()
  9196. {
  9197. if (UrlPostParmsCheck("ctid"))
  9198. {
  9199. string eid = GetPostString("ctid");
  9200. CeErpTradeCell entity = null;
  9201. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9202. if (entity != null)
  9203. {
  9204. entity.MemoOpt = 4;
  9205. entity.UpdateTime = DateTime.Now;
  9206. entity.Update();
  9207. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9208. CeErpSukuraData.createInfo(entity.ctid, 6);
  9209. returnSuccessMsg("操作成功!");
  9210. return;
  9211. }
  9212. returnErrorMsg("找不到记录");
  9213. }
  9214. }
  9215. public void upd_erp_sendXlw()
  9216. {
  9217. if (UrlPostParmsCheck("ctid"))
  9218. {
  9219. string eid = GetPostString("ctid");
  9220. CeErpTradeCell entity = null;
  9221. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9222. if (entity != null)
  9223. {
  9224. if (entity.IsSendGift == 1)
  9225. {
  9226. returnErrorMsg("请勿重复标记");
  9227. return;
  9228. }
  9229. entity.IsSendGift = 1;
  9230. entity.Update();
  9231. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9232. returnSuccessMsg("操作成功!");
  9233. return;
  9234. }
  9235. returnErrorMsg("找不到记录");
  9236. }
  9237. }
  9238. public void cancel_sendXlw()
  9239. {
  9240. if (UrlPostParmsCheck("ctid"))
  9241. {
  9242. string eid = GetPostString("ctid");
  9243. CeErpTradeCell entity = null;
  9244. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9245. if (entity != null)
  9246. {
  9247. if (entity.IsSendGift == 0)
  9248. {
  9249. returnErrorMsg("未标记小礼物");
  9250. return;
  9251. }
  9252. entity.IsSendGift = 0;
  9253. entity.Update();
  9254. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9255. returnSuccessMsg("操作成功!");
  9256. return;
  9257. }
  9258. returnErrorMsg("找不到记录");
  9259. }
  9260. }
  9261. public void get_erp_designbill()
  9262. {
  9263. DataStruct dStruct = GetPostStruct();
  9264. List<string> lw = new List<string>();
  9265. int isMy = GetInt("my");
  9266. if (isMy == 1)
  9267. {
  9268. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9269. }
  9270. string tid = GetPostString("tid");
  9271. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9272. string userName = GetPostString("design");
  9273. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9274. string price1 = GetPostString("price1");
  9275. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9276. string price2 = GetPostString("price2");
  9277. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9278. string rePrice1 = GetPostString("rePrice1");
  9279. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9280. string rePrice2 = GetPostString("rePrice2");
  9281. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9282. string designerType = GetPostString("designerType");
  9283. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9284. string orderState = GetPostString("orderState");
  9285. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9286. string endTime1 = GetPostString("endTime1");
  9287. string endTime2 = GetPostString("endTime2");
  9288. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9289. if (dw.Length > 0) lw.Add(dw);
  9290. string isDk = GetPostString("isDk");
  9291. if (isDk == "1")
  9292. {
  9293. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9294. }
  9295. else if (isDk == "0")
  9296. {
  9297. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9298. }
  9299. dStruct.Order = "oid, create_time desc";
  9300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9301. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9302. writeGridDataTableJson(dStruct.TotalCount, dt);
  9303. }
  9304. public void upd_erp_designerbill()
  9305. {
  9306. if (UrlPostParmsCheck("ID"))
  9307. {
  9308. string eid = GetPostString("ID");
  9309. CeErpDesignerBill entity = null;
  9310. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9311. if (entity != null)
  9312. {
  9313. if (GetPostDouble("designerpirce") > 0)
  9314. {
  9315. entity.realPrice = GetPostDouble("designerpirce");
  9316. entity.update_time = DateTime.Now;
  9317. entity.update_u_id = CurrentUser.UserID;
  9318. entity.update_u_name = CurrentUser.UserName;
  9319. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9320. entity.Update();
  9321. returnSuccessMsg("操作成功!");
  9322. return;
  9323. }
  9324. else
  9325. {
  9326. entity.price = GetPostDouble("price");
  9327. entity.update_time = DateTime.Now;
  9328. entity.update_u_id = CurrentUser.UserID;
  9329. entity.update_u_name = CurrentUser.UserName;
  9330. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9331. entity.Update();
  9332. returnSuccessMsg("操作成功!");
  9333. return;
  9334. }
  9335. }
  9336. returnErrorMsg("找不到记录");
  9337. }
  9338. }
  9339. public void audit_erp_designerbill()
  9340. {
  9341. if (UrlPostParmsCheck("ID"))
  9342. {
  9343. string eid = GetPostString("ID");
  9344. CeErpDesignerBill entity = null;
  9345. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9346. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9347. if (entity != null)
  9348. {
  9349. entity.realPrice = GetPostDouble("designerpirce");
  9350. entity.update_time = DateTime.Now;
  9351. entity.update_u_id = CurrentUser.UserID;
  9352. entity.update_u_name = CurrentUser.UserName;
  9353. entity.isAudit = 1;
  9354. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9355. entity.Update();
  9356. if (orderEntity != null)
  9357. {
  9358. orderEntity.IsReadTag = 3;
  9359. orderEntity.Update();
  9360. }
  9361. returnSuccessMsg("操作成功!");
  9362. return;
  9363. }
  9364. returnErrorMsg("找不到记录");
  9365. }
  9366. }
  9367. public void all_audit_erp_designerbill()
  9368. {
  9369. if (UrlPostParmsCheck("idList"))
  9370. {
  9371. string[] list = GetPostString("idList").Split(',');
  9372. CeErpDesignerBill entity = null;
  9373. for (int i = 0; i < list.Length; i++)
  9374. {
  9375. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9376. if (entity == null) return;
  9377. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9378. if (orderEntity == null) return;
  9379. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9380. entity.update_time = DateTime.Now;
  9381. entity.update_u_id = CurrentUser.UserID;
  9382. entity.update_u_name = CurrentUser.UserName;
  9383. entity.isAudit = 1;
  9384. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9385. entity.Update();
  9386. orderEntity.IsReadTag = 3;
  9387. orderEntity.Update();
  9388. }
  9389. returnSuccessMsg("操作成功!");
  9390. return;
  9391. }
  9392. }
  9393. public void get_erp_sameorders()
  9394. {
  9395. if (UrlPostParmsCheck("ctid"))
  9396. {
  9397. string eid = GetPostString("ctid");
  9398. CeErpTradeCell entity = null;
  9399. entity = CeErpTradeCell.GetByCtid(eid);
  9400. if (entity != null)
  9401. {
  9402. StringBuilder sql = new StringBuilder();
  9403. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9404. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9405. var res = new
  9406. {
  9407. data = dt.Rows.Count
  9408. };
  9409. string ro_jsond = JsonConvert.SerializeObject(res);
  9410. returnSuccess(ro_jsond);
  9411. return;
  9412. }
  9413. returnErrorMsg("未找到订单");
  9414. return;
  9415. }
  9416. returnErrorMsg("缺少必要的参数");
  9417. }
  9418. public void get_erp_islasthavesameorder()
  9419. {
  9420. if (UrlPostParmsCheck("ctid"))
  9421. {
  9422. string eid = GetPostString("ctid");
  9423. string[] ctidList = eid.Split(',');
  9424. StringBuilder sql = new StringBuilder();
  9425. string tisCtid = "";
  9426. foreach (string ctid in ctidList)
  9427. {
  9428. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9429. if (entity != null)
  9430. {
  9431. sql = new StringBuilder();
  9432. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9433. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9434. if (dth.Rows.Count > 0)
  9435. {
  9436. tisCtid += entity.ctid;
  9437. tisCtid += ",";
  9438. }
  9439. }
  9440. }
  9441. if (tisCtid.Length > 0)
  9442. {
  9443. var res = new
  9444. {
  9445. data = tisCtid
  9446. };
  9447. string ro_jsond = JsonConvert.SerializeObject(res);
  9448. returnSuccess(ro_jsond);
  9449. }
  9450. else
  9451. {
  9452. var res = new
  9453. {
  9454. data = ""
  9455. };
  9456. string ro_jsond = JsonConvert.SerializeObject(res);
  9457. returnSuccess(ro_jsond);
  9458. }
  9459. return;
  9460. }
  9461. returnErrorMsg("缺少必要的参数");
  9462. }
  9463. public void file_client_down_url()
  9464. {
  9465. if (!UrlPostParmsCheck("userId"))
  9466. {
  9467. returnErrorMsg("缺少必要的参数");
  9468. }
  9469. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9470. }
  9471. public void checkout_form_data()
  9472. {
  9473. if (!UrlPostParmsCheck("tid"))
  9474. {
  9475. returnErrorMsg("缺少必要的参数");
  9476. }
  9477. string tid = GetPostString("tid");
  9478. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9479. if (ceErpOrderFormData != null)
  9480. {
  9481. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9482. returnSuccess(ro_jsond);
  9483. return;
  9484. }
  9485. returnErrorMsg("尚未有文件!");
  9486. }
  9487. public void back_supplier_audit()
  9488. {
  9489. int userId = CurrentUser.UserID;
  9490. StringBuilder sql = new StringBuilder();
  9491. 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);
  9492. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9493. if (dt.Rows.Count > 0)
  9494. {
  9495. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9496. }
  9497. else
  9498. {
  9499. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9500. }
  9501. }
  9502. public void back_supplier_query()
  9503. {
  9504. string eid = GetPostString("ctid");
  9505. if (eid != "")
  9506. {
  9507. StringBuilder sql = new StringBuilder();
  9508. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9509. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9510. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9511. }
  9512. else
  9513. {
  9514. returnErrorMsg("找不到订单记录");
  9515. return;
  9516. }
  9517. }
  9518. public void verified_to_order()
  9519. {
  9520. int userId = CurrentUser.UserID;
  9521. StringBuilder sql = new StringBuilder();
  9522. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9523. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9524. if (dt.Rows.Count > 0)
  9525. {
  9526. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9527. }
  9528. else
  9529. {
  9530. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9531. }
  9532. }
  9533. public void upd_supplier_audit()
  9534. {
  9535. if (UrlPostParmsCheck("ctid"))
  9536. {
  9537. string eid = GetPostString("ctid");
  9538. string reason = GetPostString("returnreason");
  9539. CeErpTradeCell entity = null;
  9540. CeWithdraw withdraw = null;
  9541. withdraw = CeWithdraw.GetByTid(eid);
  9542. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9543. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9544. {
  9545. if (withdraw != null)
  9546. {
  9547. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9548. {
  9549. returnSuccessMsg("您没有权限操作!");
  9550. return;
  9551. }
  9552. else
  9553. {
  9554. if (reason.Equals("1"))
  9555. {
  9556. if (entity.OrderState == -1)
  9557. {
  9558. if (entity.FinishPlaceTime == null)
  9559. {
  9560. entity.OrderState = 2;
  9561. }
  9562. else
  9563. {
  9564. entity.OrderState = 6;
  9565. }
  9566. }
  9567. entity.Update();
  9568. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9569. if (withdraw != null)
  9570. {
  9571. withdraw.status = int.Parse(reason);
  9572. withdraw.Update();
  9573. }
  9574. returnSuccessMsg("操作成功!");
  9575. return;
  9576. }
  9577. else
  9578. {
  9579. withdraw.status = int.Parse(reason);
  9580. withdraw.acknowledgingtime = DateTime.Now;
  9581. withdraw.Update();
  9582. returnSuccessMsg("查看详细请点击线下订单查询");
  9583. return;
  9584. }
  9585. }
  9586. }
  9587. // 第一个字符是 'N'
  9588. }
  9589. if (eid[0] != 'N')
  9590. {
  9591. }
  9592. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9593. {
  9594. entity.IsVerifyToSupplier = false;
  9595. entity.IsReturn = 1;
  9596. entity.ReturnTime = DateTime.Now;
  9597. entity.ReturnReason = reason;
  9598. if (entity.OrderState == 6)
  9599. {
  9600. entity.OrderState = 5;
  9601. }
  9602. entity.Update();
  9603. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9604. if (withdraw != null)
  9605. {
  9606. withdraw.status = int.Parse(reason);
  9607. withdraw.Update();
  9608. }
  9609. returnSuccessMsg("操作成功!");
  9610. return;
  9611. }
  9612. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9613. {
  9614. ;
  9615. if (withdraw != null)
  9616. {
  9617. withdraw.status = int.Parse(reason);
  9618. withdraw.acknowledgingtime = DateTime.Now;
  9619. withdraw.Update();
  9620. returnSuccessMsg("供应商取消撤回!");
  9621. return;
  9622. }
  9623. }
  9624. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9625. {
  9626. if (entity.OrderState == -1)
  9627. {
  9628. if (entity.FinishPlaceTime == null)
  9629. {
  9630. entity.OrderState = 2;
  9631. }
  9632. else
  9633. {
  9634. entity.OrderState = 3;
  9635. }
  9636. commonHelper.getCytPrice(entity);
  9637. }
  9638. entity.Update();
  9639. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9640. if (withdraw != null)
  9641. {
  9642. withdraw.status = int.Parse(reason);
  9643. withdraw.Update();
  9644. }
  9645. returnSuccessMsg("操作成功!");
  9646. return;
  9647. }
  9648. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9649. {
  9650. if (withdraw == null)
  9651. {
  9652. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9653. return;
  9654. }
  9655. }
  9656. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9657. {
  9658. if (withdraw != null)
  9659. {
  9660. withdraw.status = int.Parse(reason);
  9661. withdraw.acknowledgingtime = DateTime.Now;
  9662. withdraw.Update();
  9663. returnSuccessMsg("查看详细请点击线下订单查询");
  9664. return;
  9665. }
  9666. }
  9667. return;
  9668. }
  9669. }
  9670. //校验报价
  9671. public void refund_order_tip()
  9672. {
  9673. int userid = CurrentUser.UserID;
  9674. int sectionId = CurrentUser.UserPost.OrgID;
  9675. StringBuilder sql = new StringBuilder();
  9676. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9677. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9678. List<string> ids = new List<string>();
  9679. if (dth.Rows.Count > 0)
  9680. {
  9681. foreach (DataRow dr in dth.Rows)
  9682. {
  9683. ids.Add(dr["ID"].ToString());
  9684. }
  9685. try
  9686. {
  9687. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9688. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9689. }
  9690. catch (Exception ex)
  9691. {
  9692. }
  9693. }
  9694. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9695. }
  9696. public void refund_order_Design()
  9697. {
  9698. int userid = CurrentUser.UserID;
  9699. int sectionId = CurrentUser.UserPost.OrgID;
  9700. StringBuilder sql = new StringBuilder();
  9701. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9702. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9703. List<string> ids = new List<string>();
  9704. if (dth.Rows.Count > 0)
  9705. {
  9706. foreach (DataRow dr in dth.Rows)
  9707. {
  9708. ids.Add(dr["ID"].ToString());
  9709. }
  9710. try
  9711. {
  9712. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9713. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9714. }
  9715. catch (Exception ex)
  9716. {
  9717. }
  9718. }
  9719. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9720. }
  9721. public void change_order_info()
  9722. {
  9723. int userid = CurrentUser.UserID;
  9724. StringBuilder sql = new StringBuilder();
  9725. 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);
  9726. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9727. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9728. }
  9729. public void change_win_mome()
  9730. {
  9731. if (UrlPostParmsCheck("id,ctid"))
  9732. {
  9733. string id = GetPostString("id");
  9734. string ctid = GetPostString("ctid");
  9735. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9736. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9737. if (ce == null || ceErpMessageTip == null)
  9738. {
  9739. returnSuccessMsg("未找到对应的订单!");
  9740. return;
  9741. }
  9742. if (ce.OrderState >= 5)
  9743. {
  9744. returnSuccessMsg("已上传文件无法修改!");
  9745. return;
  9746. }
  9747. int type = GetPostInt("type");
  9748. string content = GetPostString("content");
  9749. if (type == 0)
  9750. {
  9751. content = content.Replace("(", "(");
  9752. content = content.Replace(")", ")");
  9753. string check = MidStrEx(content, "(", ")").Trim();
  9754. if (string.IsNullOrEmpty(check))
  9755. {
  9756. returnSuccessMsg("文件名格式不正确");
  9757. return;
  9758. }
  9759. }
  9760. ce.seller_memo = content;
  9761. ce.Update();
  9762. ceErpMessageTip.isVisit = true;
  9763. ceErpMessageTip.Update();
  9764. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9765. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9766. ApiVo apiVo = new ApiVo();
  9767. apiVo.orderNumber = ce.ctid;
  9768. apiVo.actionName = "demandDesign";
  9769. apiVo.orderRemarks = content;
  9770. apiVo.demandExamine = type + 1;
  9771. designHelper.API_WorkCore(apiVo);//demandDesign
  9772. returnSuccessMsg("修改成功!");
  9773. }
  9774. }
  9775. public static string MidStrEx(string sourse, string startstr, string endstr)
  9776. {
  9777. string result = string.Empty;
  9778. int startindex, endindex;
  9779. try
  9780. {
  9781. startindex = sourse.IndexOf(startstr);
  9782. if (startindex == -1)
  9783. return result;
  9784. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9785. endindex = tmpstr.IndexOf(endstr);
  9786. if (endindex == -1)
  9787. return result;
  9788. result = tmpstr.Remove(endindex);
  9789. }
  9790. catch (Exception ex)
  9791. {
  9792. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9793. }
  9794. return result;
  9795. }
  9796. public void refund_order_list()
  9797. {
  9798. int userid = CurrentUser.UserID;
  9799. int sectionId = CurrentUser.UserPost.OrgID;
  9800. StringBuilder sql = new StringBuilder();
  9801. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9802. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9803. DataStruct dStruct = GetPostStruct();
  9804. DataTable dt = null;
  9805. List<string> ids = new List<string>();
  9806. List<string> tids = new List<string>();
  9807. if (dth.Rows.Count > 0)
  9808. {
  9809. foreach (DataRow dr in dth.Rows)
  9810. {
  9811. tids.Add("'" + dr["tid"].ToString() + "'");
  9812. ids.Add(dr["id"].ToString());
  9813. }
  9814. try
  9815. {
  9816. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9817. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9818. List<string> lw = new List<string>();
  9819. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9820. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9821. dt = WebCache.GetData("view_orderlist", dStruct);
  9822. }
  9823. catch (Exception ex)
  9824. {
  9825. }
  9826. }
  9827. writeGridDataTableJson(dStruct.TotalCount, dt);
  9828. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9829. }
  9830. //新增
  9831. public void order_batch_downloads()
  9832. {
  9833. string ceid = GetPostString("tid");
  9834. String[] tid = ceid.Split(',');
  9835. order_batch_caiyingtong(tid);
  9836. /* (string success, string errors) = UploadFiles(tid);
  9837. returnSuccessMsg(success + errors);*/
  9838. return;
  9839. }
  9840. //报价接口
  9841. public void Get_To_Quote()
  9842. {
  9843. string ceid = GetPostString("ctid");
  9844. if (ceid != null)
  9845. {
  9846. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9847. if (entity != null)
  9848. {
  9849. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9850. {
  9851. return;
  9852. }
  9853. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9854. double price = 0;
  9855. if (cp == null)
  9856. {
  9857. JObject jsonObject12 = new JObject
  9858. {
  9859. { "UserId", "77886" },
  9860. { "Pwd", "lt666888" },
  9861. { "Filename", entity.seller_memo }
  9862. };
  9863. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9864. JObject jsonObjects1 = JObject.Parse(response1);
  9865. string ms1g = (string)jsonObjects1["msg"];
  9866. if (ms1g == "报价成功")
  9867. {
  9868. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9869. string data = (string)jsonObject1["price"];
  9870. 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 + "');";
  9871. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9872. returnSuccessMsg("获取报价成功:" + data);
  9873. price = Convert.ToDouble(data);
  9874. }
  9875. else
  9876. {
  9877. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9878. return;
  9879. }
  9880. }
  9881. String[] beizhu = entity.seller_memo.Split('-');
  9882. String chanp = "";
  9883. if (beizhu.Length > 0)
  9884. {
  9885. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9886. }
  9887. else
  9888. {
  9889. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9890. }
  9891. JObject jsonObject = new JObject
  9892. {
  9893. { "UserId", "77886" },
  9894. { "Pwd", "lt666888" },
  9895. { "Filename", chanp }
  9896. };
  9897. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9898. JObject jsonObjects = JObject.Parse(response);
  9899. string msg = (string)jsonObjects["msg"];
  9900. if (msg == "报价成功")
  9901. {
  9902. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9903. string data = (string)jsonObject1["price"];
  9904. 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 + "');";
  9905. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9906. returnSuccessMsg("获取报价成功:" + data);
  9907. price = Convert.ToDouble(data);
  9908. }
  9909. else
  9910. {
  9911. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9912. return;
  9913. }
  9914. if (price > 0)
  9915. {
  9916. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9917. if (ceErpTradeCellExtend == null)
  9918. {
  9919. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9920. ceErpTradeCellExtend.ctid = entity.ctid;
  9921. ceErpTradeCellExtend.payment_cyt = price;
  9922. ceErpTradeCellExtend.Create();
  9923. }
  9924. else
  9925. {
  9926. ceErpTradeCellExtend.payment_cyt = price;
  9927. ceErpTradeCellExtend.Update();
  9928. }
  9929. }
  9930. return;
  9931. }
  9932. }
  9933. else
  9934. {
  9935. returnErrorMsg("请至少选择一条数据");
  9936. return;
  9937. }
  9938. }
  9939. //新增
  9940. public void order_To_Supplier()
  9941. {
  9942. string ceid = GetPostString("tid");
  9943. String[] tid = ceid.Split(',');
  9944. if (tid.Length > 0)
  9945. {
  9946. try
  9947. {
  9948. for (int i = 0; i < tid.Length; i++)
  9949. {
  9950. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9951. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9952. entity.SupplierId = suid;
  9953. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9954. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9955. entity.Update();
  9956. }
  9957. }
  9958. catch (Exception ex)
  9959. {
  9960. returnErrorMsg("自动匹配供应商失败");
  9961. return;
  9962. }
  9963. }
  9964. else
  9965. {
  9966. returnErrorMsg("请至少选择一条数据");
  9967. return;
  9968. }
  9969. returnSuccessMsg("自动匹配供应商成功");
  9970. return;
  9971. }
  9972. public (string, string) UploadFiles(string[] urls)
  9973. {
  9974. string success = "";
  9975. string errors = "";
  9976. int userid = CurrentUser.UserID;
  9977. foreach (string url in urls)
  9978. {
  9979. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9980. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9981. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9982. {
  9983. JObject jsonObject = new JObject
  9984. {
  9985. { "Userid", "77886" },
  9986. { "pwd", "cyt86435015" },
  9987. { "content", base64FileContent },
  9988. { "ext", Path.GetExtension(fileName) }
  9989. };
  9990. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9991. JObject jsonObjects = JObject.Parse(response);
  9992. string msg = (string)jsonObjects["msg"];
  9993. if (msg.Equals("上传成功"))
  9994. {
  9995. success += url + " 上传成功";
  9996. }
  9997. else
  9998. {
  9999. errors += url + " 上传失败";
  10000. }
  10001. }
  10002. else
  10003. {
  10004. errors += url + " 格式出现问题";
  10005. }
  10006. }
  10007. if (urls.Length == 0)
  10008. {
  10009. return (success, errors);
  10010. }
  10011. return (success, errors);
  10012. }
  10013. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10014. {
  10015. return true; //总是接受
  10016. }
  10017. public static string HttpPost(string url, string param = null)
  10018. {
  10019. HttpWebRequest request;
  10020. //如果是发送HTTPS请求
  10021. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10022. {
  10023. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10024. request = WebRequest.Create(url) as HttpWebRequest;
  10025. request.ProtocolVersion = HttpVersion.Version10;
  10026. }
  10027. else
  10028. {
  10029. request = WebRequest.Create(url) as HttpWebRequest;
  10030. }
  10031. request.Method = "POST";
  10032. request.ContentType = "application/json";
  10033. request.Accept = "*/*";
  10034. request.Timeout = 120000;
  10035. request.AllowAutoRedirect = false;
  10036. StreamWriter requestStream = null;
  10037. WebResponse response = null;
  10038. string responseStr = null;
  10039. try
  10040. {
  10041. requestStream = new StreamWriter(request.GetRequestStream());
  10042. requestStream.Write(param);
  10043. requestStream.Close();
  10044. response = request.GetResponse();
  10045. if (response != null)
  10046. {
  10047. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10048. responseStr = reader.ReadToEnd();
  10049. reader.Close();
  10050. }
  10051. }
  10052. catch (Exception ex)
  10053. {
  10054. return ex.Message;
  10055. }
  10056. finally
  10057. {
  10058. request = null;
  10059. requestStream = null;
  10060. response = null;
  10061. }
  10062. return responseStr;
  10063. }
  10064. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10065. {
  10066. string base64FileContent;
  10067. string fileName;
  10068. using (WebClient webClient = new WebClient())
  10069. {
  10070. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10071. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10072. {
  10073. using (Stream stream = response.GetResponseStream())
  10074. {
  10075. using (MemoryStream memoryStream = new MemoryStream())
  10076. {
  10077. stream.CopyTo(memoryStream);
  10078. byte[] fileBytes = memoryStream.ToArray();
  10079. base64FileContent = Convert.ToBase64String(fileBytes);
  10080. fileName = response.Headers["Content-Disposition"];
  10081. if (!string.IsNullOrEmpty(fileName))
  10082. {
  10083. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10084. if (index >= 0)
  10085. {
  10086. fileName = fileName.Substring(index + 9).Trim('\"');
  10087. }
  10088. }
  10089. else
  10090. {
  10091. fileName = Path.GetFileName(downloadUrl);
  10092. }
  10093. }
  10094. }
  10095. }
  10096. }
  10097. return (fileName, base64FileContent);
  10098. }
  10099. //新增
  10100. public void order_batch_caiyingtong(string[] downloadUrls)
  10101. {
  10102. try
  10103. {
  10104. //遍历文件
  10105. DataStruct dStruct = GetPostStruct();
  10106. DataTable dt = null;
  10107. int userid = CurrentUser.UserID;
  10108. List<string> ids = new List<string>();//失败组
  10109. List<string> tids = new List<string>();
  10110. using (WebClient webClient = new WebClient())
  10111. {
  10112. foreach (var url in downloadUrls)
  10113. {
  10114. try
  10115. {
  10116. tids.Add("'" + url + "'");
  10117. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10118. if (entity != null)
  10119. {
  10120. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10121. if (cp == null)
  10122. {
  10123. JObject jsonObject = new JObject
  10124. {
  10125. { "Userid", "77886" },
  10126. { "pwd", "lt666888" },
  10127. { "Filename",entity.seller_memo }
  10128. };
  10129. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10130. JObject jsonObjects = JObject.Parse(response);
  10131. string msg = (string)jsonObjects["msg"];
  10132. if (msg == "报价成功")
  10133. {
  10134. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10135. DownloadAndConvertToBase64(url1);
  10136. }
  10137. else
  10138. {
  10139. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10140. }
  10141. }
  10142. else
  10143. {
  10144. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10145. JObject jsonObject = new JObject
  10146. {
  10147. { "Userid", "77886" },
  10148. { "pwd", "lt666888" },
  10149. { "Filename",chanp }
  10150. };
  10151. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10152. JObject jsonObjects = JObject.Parse(response);
  10153. string msg = (string)jsonObjects["msg"];
  10154. if (msg == "报价成功")
  10155. {
  10156. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10157. DownloadAndConvertToBase64(url1);
  10158. }
  10159. else
  10160. {
  10161. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10162. }
  10163. }
  10164. }
  10165. // 上传文件到FTP
  10166. }
  10167. catch (Exception ex)
  10168. {
  10169. Console.WriteLine($"An error occurred: {ex.Message}");
  10170. }
  10171. }
  10172. List<string> lw = new List<string>();
  10173. lw.Add(string.Format("( OrderState < 6 )"));
  10174. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10175. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10176. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10177. if (dt.Rows.Count > 0)
  10178. {
  10179. foreach (DataRow dr in dt.Rows)
  10180. {
  10181. ids.Add(dr["ctid"].ToString());
  10182. }
  10183. }
  10184. String ErrorMsgs = "";
  10185. foreach (String id in ids)
  10186. {
  10187. ErrorMsgs += id + ",";
  10188. }
  10189. if (ErrorMsgs.Length > 1)
  10190. {
  10191. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10192. }
  10193. if (ErrorMsgs.Length < 1)
  10194. {
  10195. ErrorMsgs = "上传成功";
  10196. returnSuccessMsg(ErrorMsgs);
  10197. }
  10198. else
  10199. {
  10200. returnErrorMsg("以下订单" + ErrorMsgs);
  10201. }
  10202. }
  10203. // 删除文件夹及其内容
  10204. /* Directory.Delete(localDirectory, true);*/
  10205. }
  10206. catch { }
  10207. }
  10208. public void get_center_data()
  10209. {
  10210. int userId = CurrentUser.UserID;
  10211. string postCode = CurrentUser.UserPost.Post.Code;
  10212. List<string> lw = new List<string>();
  10213. List<string> ww = new List<string>();
  10214. DateTime currentTime = DateTime.Now;
  10215. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10216. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10217. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10218. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10219. string sql = " SELECT ";
  10220. string startTime = "2023-10-01 11:22:31";
  10221. //设计
  10222. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10223. {
  10224. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10225. 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));
  10226. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10227. 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));
  10228. }
  10229. //客服
  10230. else if (postCode == "CustomerService" || postCode == "Director")
  10231. {
  10232. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10233. 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));
  10234. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10235. 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));
  10236. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10237. 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));
  10238. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10239. 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));
  10240. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10241. 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));
  10242. }
  10243. //售后
  10244. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10245. {
  10246. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10247. 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));
  10248. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10249. 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));
  10250. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10251. 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));
  10252. }
  10253. //下单部
  10254. else if (postCode == "Place" || postCode == "PlaceMr")
  10255. {
  10256. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10257. 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));
  10258. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10259. 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));
  10260. }
  10261. //车间
  10262. else if (postCode == "Supplier")
  10263. {
  10264. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10265. 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));
  10266. }
  10267. DataTable dt = new DataTable();
  10268. if (lw.Count > 0)
  10269. {
  10270. sql += string.Join(" , ", lw);
  10271. sql += " FROM ";
  10272. sql += string.Join(" , ", ww);
  10273. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10274. }
  10275. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10276. }
  10277. public void get_center_data_list()
  10278. {
  10279. int userId = CurrentUser.UserID;
  10280. string postCode = CurrentUser.UserPost.Post.Code;
  10281. string shopIds = CurrentUser.User.pemShop;
  10282. DataStruct dStruct = GetPostStruct();
  10283. List<string> lw = new List<string>();
  10284. DateTime currentTime = DateTime.Now;
  10285. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10286. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10287. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10288. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10289. string startTime = "2023-10-01 11:22:31";
  10290. int order_type = GetPostInt("order_type");
  10291. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10292. {
  10293. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10294. if (order_type == 0)
  10295. {
  10296. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10297. }
  10298. else if (order_type == 3)
  10299. {
  10300. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10301. }
  10302. else
  10303. {
  10304. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10305. }
  10306. }
  10307. //客服
  10308. if (postCode == "CustomerService" || postCode == "Director")
  10309. {
  10310. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10311. if (order_type == 0)
  10312. {
  10313. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10314. }
  10315. else if (order_type == 1)
  10316. {
  10317. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10318. }
  10319. else if (order_type == 2)
  10320. {
  10321. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10322. }
  10323. else if (order_type == 3)
  10324. {
  10325. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10326. }
  10327. else if (order_type == 4)
  10328. {
  10329. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10330. }
  10331. else
  10332. {
  10333. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10334. }
  10335. }
  10336. //售后
  10337. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10338. {
  10339. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10340. if (shopIds != "")
  10341. {
  10342. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10343. }
  10344. if (order_type == 2)
  10345. {
  10346. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10347. }
  10348. else if (order_type == 4)
  10349. {
  10350. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10351. }
  10352. else if (order_type == 5)
  10353. {
  10354. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10355. }
  10356. else
  10357. {
  10358. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10359. }
  10360. }
  10361. //下单部
  10362. if (postCode == "Place" || postCode == "PlaceMr")
  10363. {
  10364. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10365. if (shopIds != "")
  10366. {
  10367. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10368. }
  10369. else if (order_type == 1)
  10370. {
  10371. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10372. }
  10373. else if (order_type == 2)
  10374. {
  10375. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10376. }
  10377. else
  10378. {
  10379. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10380. }
  10381. }
  10382. //车间
  10383. if (postCode == "Supplier")
  10384. {
  10385. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10386. if (order_type == 5)
  10387. {
  10388. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10389. }
  10390. else
  10391. {
  10392. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10393. }
  10394. }
  10395. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10396. dStruct.Fileds = "tid,ctid";
  10397. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10398. writeGridDataTableJson(dStruct.TotalCount, dt);
  10399. }
  10400. public void aftersale_audit_master()
  10401. {
  10402. if (UrlPostParmsCheck("ctid"))
  10403. {
  10404. string ctid = GetPostString("ctid");
  10405. if (ctid.Length > 0)
  10406. {
  10407. bool result = aftersale_data_change(ctid);
  10408. if (result)
  10409. {
  10410. returnSuccessMsg("修改成功!");
  10411. return;
  10412. }
  10413. }
  10414. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10415. }
  10416. }
  10417. public void aftersale_batch_audit_master()
  10418. {
  10419. if (UrlPostParmsCheck("ctids"))
  10420. {
  10421. string ctids = GetPostString("ctids");
  10422. if (ctids.Length > 0)
  10423. {
  10424. List<string> list = new List<string>();
  10425. string[] ctid_list = ctids.Split(',');
  10426. foreach (var item in ctid_list)
  10427. {
  10428. bool result = aftersale_data_change(item);
  10429. if (!result)
  10430. {
  10431. list.Add(item);
  10432. }
  10433. }
  10434. if (list.Count > 0)
  10435. {
  10436. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10437. return;
  10438. }
  10439. returnSuccessMsg("修改成功!");
  10440. return;
  10441. }
  10442. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10443. }
  10444. }
  10445. public bool aftersale_data_change(string ctid)
  10446. {
  10447. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10448. if (ceErpTradeCell != null)
  10449. {
  10450. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10451. ceErpTradeCell.AfterSaleSupplierState = 0;
  10452. StringBuilder sql = new StringBuilder();
  10453. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10454. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10455. CeErpTradeResponsible.DelByTid(ctid, 0);
  10456. 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 == "不理赔")
  10457. {
  10458. CeErpTradeResponsible.DelByTid(ctid, 1);
  10459. ceErpTradeCell.AfterSaleSupplierState = 1;
  10460. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10461. ceErpTradeCell.AfterSaleState = 4;
  10462. }
  10463. else
  10464. {
  10465. ceErpTradeCell.AfterSaleState = 3;
  10466. }
  10467. bool needCyt = false;
  10468. if (dt != null)
  10469. {
  10470. if (dt.Rows.Count == 1)
  10471. {
  10472. bool isEnd = false;
  10473. foreach (DataRow dr in dt.Rows)
  10474. {
  10475. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10476. {
  10477. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10478. isEnd = true;
  10479. }
  10480. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10481. {
  10482. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10483. isEnd = true;
  10484. }
  10485. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10486. {
  10487. needCyt = true;
  10488. }
  10489. }
  10490. if (isEnd)
  10491. {
  10492. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10493. ceErpTradeCell.AfterSaleState = 4;
  10494. ceErpTradeCell.AfterSaleSupplierState = 1;
  10495. }
  10496. }
  10497. else
  10498. {
  10499. bool isAll = true;
  10500. foreach (DataRow dr in dt.Rows)
  10501. {
  10502. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10503. {
  10504. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10505. continue;
  10506. }
  10507. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10508. {
  10509. string path = "";
  10510. int OrgID = 0;
  10511. if (!Convert.IsDBNull(dr["OrgPath"]))
  10512. {
  10513. path = dr["OrgPath"].ToString();
  10514. }
  10515. if (!Convert.IsDBNull(dr["OrgID"]))
  10516. {
  10517. OrgID = Convert.ToInt32(dr["OrgID"]);
  10518. }
  10519. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10520. {
  10521. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10522. continue;
  10523. }
  10524. }
  10525. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10526. {
  10527. needCyt = true;
  10528. }
  10529. isAll = false;
  10530. }
  10531. if (isAll)
  10532. {
  10533. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10534. ceErpTradeCell.AfterSaleState = 4;
  10535. ceErpTradeCell.AfterSaleSupplierState = 1;
  10536. }
  10537. }
  10538. }
  10539. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10540. {
  10541. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10542. }
  10543. if (ceErpTradeCell.AfterSaleState == 4)
  10544. {
  10545. ApiVo apiVo = new ApiVo();
  10546. apiVo.orderNumber = ceErpTradeCell.ctid;
  10547. apiVo.actionName = "afterOver";
  10548. designHelper.API_WorkCore(apiVo); //afterOver
  10549. }
  10550. ceErpTradeCell.Update();
  10551. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10552. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10553. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10554. return true;
  10555. }
  10556. return false;
  10557. }
  10558. public void get_erp_wechatorder()
  10559. {
  10560. DataStruct dStruct = GetPostStruct();
  10561. List<string> lw = new List<string>();
  10562. string tid = GetPostString("tid");
  10563. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10564. string shopname = GetPostString("shopname");
  10565. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10566. string buyernick = GetPostString("buyer_nick");
  10567. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10568. string customer = GetPostString("customer");
  10569. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10570. string returndate1 = GetPostString("returndate1");
  10571. string returndate2 = GetPostString("returndate2");
  10572. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10573. if (dw.Length > 0) lw.Add(dw);
  10574. string finishDate1 = GetPostString("finishdate1");
  10575. string finishDate2 = GetPostString("finishdate2");
  10576. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10577. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10578. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10579. dStruct.Order = "created desc";
  10580. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10581. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10582. writeGridDataTableJson(dStruct.TotalCount, dt);
  10583. }
  10584. public void get_erp_wechatlist_sumprice()
  10585. {
  10586. DataStruct dStruct = GetPostStruct();
  10587. List<string> lw = new List<string>();
  10588. string tid = GetPostString("tid");
  10589. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10590. string shopname = GetPostString("shopname");
  10591. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10592. string buyernick = GetPostString("buyer_nick");
  10593. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10594. string customer = GetPostString("customer");
  10595. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10596. string returndate1 = GetPostString("returndate1");
  10597. string returndate2 = GetPostString("returndate2");
  10598. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10599. if (dw.Length > 0) lw.Add(dw);
  10600. string finishDate1 = GetPostString("finishdate1");
  10601. string finishDate2 = GetPostString("finishdate2");
  10602. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10603. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10604. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10605. string mainWhere = string.Join(" and ", lw.ToArray());
  10606. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10607. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10608. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10609. decimal total = 0;
  10610. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10611. {
  10612. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10613. }
  10614. var res = new
  10615. {
  10616. data = total
  10617. };
  10618. string ro_jsond = JsonConvert.SerializeObject(res);
  10619. returnSuccess(ro_jsond);
  10620. return;
  10621. }
  10622. public void get_erp_qr_waitdeliverylist()
  10623. {
  10624. DataStruct dStruct = GetPostStruct();
  10625. List<string> lw = new List<string>();
  10626. string tid = GetPostString("ctid");
  10627. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10628. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10629. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10630. var res_objz = new
  10631. {
  10632. restype = 1,
  10633. data = dt
  10634. };
  10635. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10636. returnSuccess(ro_jsonz);
  10637. }
  10638. public void get_erp_yield_list()
  10639. {
  10640. DataStruct dStruct = GetPostStruct();
  10641. List<string> lw = new List<string>();
  10642. string tid = GetPostString("ctid");
  10643. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10644. string shopname = GetPostString("shopname");
  10645. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10646. string buyernick = GetPostString("buyer_nick");
  10647. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10648. //if (tid.Length == 0 && buyernick.Length == 0)
  10649. //{
  10650. // lw.Add(string.Format("IsRefund<={0}", 1));
  10651. //}
  10652. string customer = GetPostString("customer");
  10653. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10654. string design = GetPostString("design");
  10655. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10656. string orderState = GetPostString("orderState");
  10657. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10658. string address = GetPostString("address");
  10659. 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));
  10660. string sellermemo = GetPostString("seller_memo");
  10661. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10662. string supplier = GetPostString("supplier");
  10663. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10664. string OrderArea = GetPostString("order_area");
  10665. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10666. string placedate1 = GetPostString("placedate1");
  10667. string placedate2 = GetPostString("placedate2");
  10668. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10669. if (fdw.Length > 0) lw.Add(fdw);
  10670. string price1 = GetPostString("price1");
  10671. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10672. string price2 = GetPostString("price2");
  10673. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10674. string unusualCon = GetPostString("unusualcon");
  10675. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10676. string posTag = CurrentUser.UserPost.Post.Code;
  10677. if (posTag == "Supplier")
  10678. {
  10679. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10680. }
  10681. lw.Add(string.Format("OrderState = 6 "));
  10682. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10683. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10684. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10685. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10686. writeGridDataTableJson(dStruct.TotalCount, dt);
  10687. }
  10688. public void change_erp_sup_state()
  10689. {
  10690. if (UrlPostParmsCheck("ctid"))
  10691. {
  10692. string ctid = GetPostString("ctid");
  10693. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10694. if (ceErpTradeCell != null)
  10695. {
  10696. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10697. if (ceErpTradeCellExtend == null)
  10698. {
  10699. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10700. ceErpTradeCellExtend.ctid = ctid;
  10701. ceErpTradeCellExtend.SupState = 1;
  10702. ceErpTradeCellExtend.Create();
  10703. }
  10704. else
  10705. {
  10706. ceErpTradeCellExtend.SupState = 1;
  10707. ceErpTradeCellExtend.Update();
  10708. }
  10709. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10710. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10711. return;
  10712. }
  10713. returnErrorMsg("找不到订单");
  10714. }
  10715. }
  10716. public void supplier_all_downs()
  10717. {
  10718. if (UrlPostParmsCheck("tids"))
  10719. {
  10720. string tids = GetPostString("tids");
  10721. if (tids != null && tids.Length > 0)
  10722. {
  10723. StringBuilder sql = new StringBuilder();
  10724. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10725. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10726. sql = new StringBuilder();
  10727. 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, "下载设计文件");
  10728. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10729. string[] list = tids.Split(',');
  10730. foreach (string ctid in list)
  10731. {
  10732. CeErpSukuraData.createInfo(ctid, 3);
  10733. }
  10734. designHelper.api_approveDesign(tids); //approveDesign
  10735. returnSuccessMsg("下载成功!");
  10736. return;
  10737. }
  10738. returnErrorMsg("下载订单更新失败");
  10739. }
  10740. }
  10741. public void uploaderFileSuccess()
  10742. {
  10743. if (UrlPostParmsCheck("fileName"))
  10744. {
  10745. string fileName = GetPostString("fileName");
  10746. ApiVo apiVo = new ApiVo();
  10747. apiVo.orderNumber = fileName;
  10748. apiVo.actionName = "finishDesign";
  10749. designHelper.API_WorkCore(apiVo);//finishDesign
  10750. returnSuccessMsg("");
  10751. }
  10752. }
  10753. public void get_sample2_order()
  10754. {
  10755. if (UrlPostParmsCheck("ctid"))
  10756. {
  10757. string ctid = GetPostString("ctid");
  10758. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10759. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10760. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10761. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10762. double total = 0.0;
  10763. double order_price = 0.0;
  10764. if (dt_bu.Rows.Count > 0)
  10765. {
  10766. foreach (DataRow dr in dt_bu.Rows)
  10767. {
  10768. total += Convert.ToDouble(dr["payment"]);
  10769. }
  10770. }
  10771. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10772. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10773. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10774. string tid = ctid.Replace("S_", "");
  10775. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10776. double paymant = 0.0;
  10777. if (entity != null)
  10778. {
  10779. paymant = entity.payment;
  10780. }
  10781. string return_reason = "";
  10782. if (dt_after != null && dt_after.Rows.Count > 0)
  10783. {
  10784. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10785. }
  10786. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10787. }
  10788. }
  10789. public void get_erp_design_status()
  10790. {
  10791. string designName = GetPostString("designName");
  10792. DataStruct dStruct = GetPostStruct();
  10793. if (designName.Length > 0)
  10794. {
  10795. 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";
  10796. sql_user += " and Name like '%" + designName + "%'";
  10797. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10798. List<string> ids_list = new List<string>();
  10799. if (user_table.Rows.Count > 0)
  10800. {
  10801. foreach (DataRow item in user_table.Rows)
  10802. {
  10803. ids_list.Add(item["id"].ToString());
  10804. string ids_s = item["TeamIds"].ToString();
  10805. if (ids_s.Length > 0)
  10806. {
  10807. ids_list.AddRange(ids_s.Split(','));
  10808. }
  10809. }
  10810. }
  10811. HashSet<string> set = new HashSet<string>(ids_list);
  10812. ids_list = set.ToList();
  10813. if (ids_list.Count > 0)
  10814. {
  10815. 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));
  10816. dStruct.MainWhere = sql;
  10817. DataTable dt = null;
  10818. dt = WebCache.GetData("view_ErpUser", dStruct);
  10819. writeGridDataTableJson(dStruct.TotalCount, dt);
  10820. }
  10821. }
  10822. }
  10823. public void change_erp_order_price()
  10824. {
  10825. string ctid = GetPostString("ctid");
  10826. double price = GetPostDouble("price");
  10827. if (ctid.Length > 0)
  10828. {
  10829. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10830. if (ceErpTradeCellExtend == null)
  10831. {
  10832. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10833. ceErpTradeCellExtend.ctid = ctid;
  10834. ceErpTradeCellExtend.payment_cyt = price;
  10835. ceErpTradeCellExtend.Create();
  10836. }
  10837. else
  10838. {
  10839. ceErpTradeCellExtend.payment_cyt = price;
  10840. ceErpTradeCellExtend.Update();
  10841. }
  10842. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10843. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10844. {
  10845. ceErpDataSendOrderInfo.isSync = false;
  10846. ceErpDataSendOrderInfo.Update();
  10847. }
  10848. if (ceErpDataSendOrderInfo == null)
  10849. {
  10850. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10851. ceErpDataSendOrderInfo.isSync = false;
  10852. ceErpDataSendOrderInfo.ctid = ctid;
  10853. ceErpDataSendOrderInfo.Create();
  10854. }
  10855. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10856. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10857. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10858. if (dth != null && dth.Rows.Count > 0)
  10859. {
  10860. dataSendOrderBean dataSendOrderBean = null;
  10861. foreach (DataRow item in dth.Rows)
  10862. {
  10863. try
  10864. {
  10865. dataSendOrderBean = new dataSendOrderBean();
  10866. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10867. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10868. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10869. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10870. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10871. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10872. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10873. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10874. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10875. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10876. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10877. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10878. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10879. if (result != null)
  10880. {
  10881. if ("0".Equals(result.errcode))
  10882. {
  10883. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10884. }
  10885. else
  10886. {
  10887. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10888. }
  10889. }
  10890. }
  10891. catch (Exception ex)
  10892. {
  10893. }
  10894. }
  10895. }
  10896. returnSuccessMsg("修改成功!");
  10897. return;
  10898. }
  10899. returnErrorMsg("找不到订单");
  10900. }
  10901. public void find_he_together()
  10902. {
  10903. string ctid = GetPostString("ctid");
  10904. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10905. List<string> list = new List<string>();
  10906. if (ceErpTradeCell != null)
  10907. {
  10908. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10909. {
  10910. 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);
  10911. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10912. if (table != null && table.Rows.Count > 0)
  10913. {
  10914. foreach (TableRow row in table.Rows)
  10915. {
  10916. }
  10917. }
  10918. }
  10919. }
  10920. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10921. }
  10922. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10923. {
  10924. //chy----19
  10925. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10926. //GD-CYT-----64
  10927. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10928. //ZHX----3
  10929. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10930. //JK----97
  10931. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10932. //ZT----70
  10933. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10934. //LHCY-----98
  10935. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10936. //XD-----90
  10937. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10938. //CYCY-----14
  10939. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10940. };
  10941. //其他改名
  10942. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10943. {
  10944. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10945. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10946. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10947. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10948. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10949. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10950. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10951. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10952. };
  10953. //不统计
  10954. List<int> no_suppliers = new List<int>()
  10955. {
  10956. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10957. };
  10958. //配件单
  10959. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10960. {
  10961. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10962. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10963. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10964. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10965. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10966. {"旗杆",new List<string>(){ "班旗" } },
  10967. {"牙签",new List<string>(){ "不干胶" } }
  10968. };
  10969. public void get_place_order_data()
  10970. {
  10971. string date1 = GetPostString("date1");
  10972. string date2 = GetPostString("date2");
  10973. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10974. DateTime start = DateTime.Parse(starttime);
  10975. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10976. DateTime end = DateTime.Parse(endtime);
  10977. if (date1 != null && date1.Length > 0)
  10978. {
  10979. DateTime dateTime = DateTime.Parse(date1);
  10980. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10981. start = DateTime.Parse(starttime);
  10982. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10983. end = DateTime.Parse(endtime);
  10984. }
  10985. if (date2 != null && date2.Length > 0)
  10986. {
  10987. DateTime dateTime = DateTime.Parse(date2);
  10988. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10989. end = DateTime.Parse(endtime);
  10990. }
  10991. 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);
  10992. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10993. //不干胶-----1,卡片-----29
  10994. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10995. foreach (DataRow row in data.Rows)
  10996. {
  10997. int productId = Convert.ToInt32(row["ProductId"]);
  10998. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10999. if (no_suppliers.Contains(supplierId))
  11000. {
  11001. continue;
  11002. }
  11003. string seller_memo = row["seller_memo"].ToString();
  11004. bool ispj = false;//是否配件单
  11005. bool isfirst = true;//第一个配
  11006. maps.Keys.ForEach(key =>
  11007. {
  11008. //备注包含配件
  11009. if (seller_memo.Contains(key) && isfirst)
  11010. {
  11011. List<string> list = maps[key];
  11012. ispj = true;
  11013. isfirst = false;
  11014. for (int i = 0; i < list.Count; i++)
  11015. {
  11016. if (seller_memo.Contains(list[i]))
  11017. {
  11018. ispj = false;
  11019. break;
  11020. }
  11021. }
  11022. }
  11023. });
  11024. if (ispj)
  11025. {
  11026. continue;
  11027. }
  11028. seller_memo = seller_memo.Replace("UV", "uv");
  11029. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11030. //吊牌归到卡片
  11031. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11032. seller_memo = seller_memo.Replace("卡套", "卡片");
  11033. seller_memo = seller_memo.Replace("封套", "卡片");
  11034. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11035. seller_memo = seller_memo.Replace("腰封", "卡片");
  11036. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11037. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11038. seller_memo = seller_memo.Replace("横幅", "条幅");
  11039. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11040. string map_key = "";
  11041. string type = "";
  11042. if (supplierMap.ContainsKey(supplierId))
  11043. {
  11044. foreach (var kvp in supplierMap[supplierId])
  11045. {
  11046. if (seller_memo.Contains(kvp.Key))
  11047. {
  11048. map_key = kvp.Value;
  11049. type = kvp.Value;
  11050. break;
  11051. }
  11052. }
  11053. }
  11054. if (map_key == "")
  11055. {
  11056. type = "其他";
  11057. map_key = "其他";
  11058. }
  11059. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11060. {
  11061. map_key = suppliers[supplierId];
  11062. }
  11063. if (supplierId == 70)
  11064. {
  11065. supplierId = 70;
  11066. }
  11067. map_key += "_" + row["SupplierName"].ToString();
  11068. Dictionary<string, int> map = null;
  11069. if (other_map.ContainsKey(map_key))
  11070. {
  11071. other_map.TryGetValue(map_key, out map);
  11072. }
  11073. else
  11074. {
  11075. map = new Dictionary<string, int>();
  11076. map.Add("dayDev", 0);//当天出货
  11077. map.Add("dayTotal", 0);//下单总数
  11078. map.Add("payTotal", 0);//500以上
  11079. map.Add("today", 0);//当天出货数量
  11080. map.Add("unusua", 0);//异常数
  11081. other_map.Add(map_key, map);
  11082. other_map.TryGetValue(map_key, out map);
  11083. }
  11084. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11085. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11086. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11087. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11088. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11089. {
  11090. map["dayTotal"]++;
  11091. if (supplierId == 97)
  11092. {
  11093. supplierId = 97;
  11094. }
  11095. }
  11096. if (Convert.ToDecimal(row["payment"]) >= 500)
  11097. {
  11098. map["payTotal"]++;
  11099. }
  11100. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11101. {
  11102. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11103. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11104. {
  11105. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11106. {
  11107. map["today"]++;
  11108. }
  11109. }
  11110. else
  11111. {
  11112. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11113. {
  11114. map["today"]++;
  11115. }
  11116. else
  11117. {
  11118. if (supplierId == 119)
  11119. {
  11120. Debug.WriteLine(row["seller_memo"].ToString());
  11121. }
  11122. }
  11123. }
  11124. }
  11125. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11126. {
  11127. map["unusua"]++;
  11128. }
  11129. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11130. //GD-CYT-----64
  11131. DateTime two = palceTimeStart.AddHours(14);
  11132. DateTime three = palceTimeStart.AddHours(15);
  11133. DateTime four = palceTimeStart.AddHours(16);
  11134. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11135. {
  11136. //下午四点前 500-1000
  11137. string count = row["ProductCount"].ToString();
  11138. if (count != null && count.Length > 0)
  11139. {
  11140. int productCount = commonHelper.getPlaceProductCount(count);
  11141. if (productCount >= 500 && productCount <= 1000)
  11142. {
  11143. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11144. {
  11145. map["dayDev"]++;
  11146. }
  11147. }
  11148. }
  11149. }
  11150. //UV
  11151. else if ("uv".Equals(type))
  11152. {
  11153. //ZT----70
  11154. //ZHX----3
  11155. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11156. {
  11157. map["dayDev"]++;
  11158. }
  11159. //JK----97
  11160. //HZX----105
  11161. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11162. {
  11163. map["dayDev"]++;
  11164. if (supplierId == 97)
  11165. {
  11166. supplierId = 97;
  11167. }
  11168. }
  11169. }
  11170. //帆布---52|条幅---27
  11171. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11172. {
  11173. //LHCY-----98
  11174. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11175. {
  11176. map["dayDev"]++;
  11177. }
  11178. }
  11179. //条幅
  11180. else if ("条幅".Equals(type))
  11181. {
  11182. //XD-----90
  11183. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11184. {
  11185. map["dayDev"]++;
  11186. }
  11187. }
  11188. //桌布
  11189. else if ("桌布".Equals(type))
  11190. {
  11191. //XD-----90
  11192. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11193. {
  11194. map["dayDev"]++;
  11195. }
  11196. }
  11197. //DL---10
  11198. //AYTW---119
  11199. //FS-CYT-DY ----80
  11200. //JK----97
  11201. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11202. {
  11203. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11204. {
  11205. map["dayDev"]++;
  11206. }
  11207. }
  11208. }
  11209. DataTable dt = new DataTable();
  11210. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11211. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11212. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11213. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11214. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11215. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11216. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11217. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11218. other_map.Keys.ForEach(key =>
  11219. {
  11220. DataRow dr = dt.NewRow();
  11221. Dictionary<string, int> map = other_map[key];
  11222. string[] key_list = key.Split('_');
  11223. dr[0] = key_list[0];
  11224. dr[1] = key_list[1];
  11225. if (key_list.Length > 2)
  11226. {
  11227. dr[1] += "(" + key_list[2] + ")";
  11228. }
  11229. dr[2] = map["dayTotal"];
  11230. dr[3] = map["payTotal"];
  11231. dr[4] = map["today"];
  11232. dr[5] = map["unusua"];
  11233. dr[6] = map["dayDev"];
  11234. double rate = 0.00;
  11235. if (map["dayDev"] > 0)
  11236. {
  11237. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11238. }
  11239. dr[7] = rate.ToString();
  11240. dt.Rows.Add(dr);
  11241. });
  11242. DataView dv = new DataView(dt);
  11243. dv.Sort = "SupplierName";
  11244. //dv.Sort = "AllOrder desc";
  11245. DataTable dtNew = dv.ToTable();
  11246. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11247. }
  11248. public void check_order_desing_info()
  11249. {
  11250. string ctid = GetPostString("ctid");
  11251. if (!string.IsNullOrEmpty(ctid))
  11252. {
  11253. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11254. if (ceErpTradeCell != null)
  11255. {
  11256. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11257. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11258. return;
  11259. }
  11260. returnErrorMsg("找不到订单");
  11261. return;
  11262. }
  11263. returnErrorMsg("找不到订单");
  11264. }
  11265. public void get_timeout_detail()
  11266. {
  11267. string poscode = CurrentUser.UserPost.Post.Code;
  11268. DataStruct dStruct = GetPostStruct();
  11269. List<string> lw = new List<string>();
  11270. string id = GetPostString("id");
  11271. string pay_date1 = GetPostString("pay_date1");
  11272. string pay_date2 = GetPostString("pay_date2");
  11273. int type = GetPostInt("type");
  11274. if (type == 0)
  11275. {
  11276. if (pay_date1.Length > 0)
  11277. {
  11278. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11279. }
  11280. if (pay_date2.Length > 0)
  11281. {
  11282. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11283. }
  11284. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11285. }
  11286. if (type == 1)
  11287. {
  11288. if (pay_date1.Length > 0)
  11289. {
  11290. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11291. }
  11292. if (pay_date2.Length > 0)
  11293. {
  11294. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11295. }
  11296. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11297. }
  11298. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11299. DataTable dt = null;
  11300. dt = WebCache.GetData("view_orderlist", dStruct);
  11301. writeGridDataTableJson(dStruct.TotalCount, dt);
  11302. }
  11303. public void saveUrgentChargePrice()
  11304. {
  11305. string ctid = GetPostString("ctid");
  11306. if (!string.IsNullOrEmpty(ctid))
  11307. {
  11308. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11309. if (ceErpTradeCell != null)
  11310. {
  11311. double price = GetPostDouble("price");
  11312. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11313. if (ceErpTradeCellExtend == null)
  11314. {
  11315. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11316. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11317. }
  11318. ceErpTradeCellExtend.urgentCharge = price;
  11319. if (ceErpTradeCellExtend.ID > 0)
  11320. {
  11321. ceErpTradeCellExtend.Update();
  11322. }
  11323. else
  11324. {
  11325. ceErpTradeCellExtend.Save();
  11326. }
  11327. returnSuccessMsg("修改成功!");
  11328. return;
  11329. }
  11330. returnErrorMsg("找不到订单");
  11331. return;
  11332. }
  11333. returnErrorMsg("找不到订单");
  11334. }
  11335. public void finish_erp_order()
  11336. {
  11337. string ctid = GetPostString("ctid");
  11338. if (!string.IsNullOrEmpty(ctid))
  11339. {
  11340. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11341. {
  11342. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11343. if (ceErpTradeCell != null)
  11344. {
  11345. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11346. ceErpTradeCell.Update();
  11347. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11348. returnSuccessMsg("修改成功!");
  11349. return;
  11350. }
  11351. }
  11352. }
  11353. returnErrorMsg("找不到订单");
  11354. }
  11355. public void get_trade_order_list()
  11356. {
  11357. string tid = GetPostString("tid");
  11358. if (!string.IsNullOrEmpty(tid))
  11359. {
  11360. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11361. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11362. writeGridDataTableJson(data.Rows.Count, data);
  11363. return;
  11364. }
  11365. returnErrorMsg("找不到订单");
  11366. }
  11367. public void save_cell_spu()
  11368. {
  11369. string ctid = GetPostString("ctid");
  11370. string spu_id = GetPostString("spu_id");
  11371. if (!string.IsNullOrEmpty(ctid))
  11372. {
  11373. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11374. if (ceErpTradeCellExtend == null)
  11375. {
  11376. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11377. ceErpTradeCellExtend.ctid = ctid;
  11378. }
  11379. ceErpTradeCellExtend.spu_id = spu_id;
  11380. if (ceErpTradeCellExtend.ID == 0)
  11381. {
  11382. ceErpTradeCellExtend.Create();
  11383. }
  11384. else
  11385. {
  11386. ceErpTradeCellExtend.Update();
  11387. }
  11388. returnSuccessMsg("修改成功!");
  11389. return;
  11390. }
  11391. returnErrorMsg("找不到订单");
  11392. }
  11393. public void change_express_info()
  11394. {
  11395. string ctid = GetPostString("ctid");
  11396. string transNo = GetPostString("transNo");
  11397. string transCom = GetPostString("transCom");
  11398. if (!string.IsNullOrEmpty(ctid))
  11399. {
  11400. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11401. if (ceErpTradeCellExtend == null)
  11402. {
  11403. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11404. ceErpTradeCellExtend.ctid = ctid;
  11405. }
  11406. ceErpTradeCellExtend.modExpressNo = transNo;
  11407. ceErpTradeCellExtend.modExpressCom = transCom;
  11408. ceErpTradeCellExtend.readMod = 2;
  11409. if (ceErpTradeCellExtend.ID == 0)
  11410. {
  11411. ceErpTradeCellExtend.Create();
  11412. }
  11413. else
  11414. {
  11415. ceErpTradeCellExtend.Update();
  11416. }
  11417. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11418. returnSuccessMsg("修改成功!");
  11419. return;
  11420. }
  11421. returnErrorMsg("找不到订单");
  11422. }
  11423. public void get_change_express_list()
  11424. {
  11425. DataStruct dStruct = GetPostStruct();
  11426. List<string> lw = new List<string>();
  11427. int st = 2;
  11428. string tid = GetPostString("ctid");
  11429. if (tid.Length > 0)
  11430. {
  11431. string select_tid = getTidByCtid(tid);
  11432. lw.Add(string.Format("tid='{0}'", select_tid));
  11433. }
  11434. string shopname = GetPostString("shopname");
  11435. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11436. string buyernick = GetPostString("buyer_nick");
  11437. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11438. string sellermemo = GetPostString("seller_memo");
  11439. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11440. string supplier = GetPostString("supplier");
  11441. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11442. string customer = GetPostString("customer");
  11443. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11444. string design = GetPostString("design");
  11445. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11446. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11447. string poscode = CurrentUser.UserPost.Post.Code;
  11448. if (poscode != "SysAdmin")
  11449. {
  11450. string shopid = CurrentUser.User.pemShop;
  11451. lw.Add(string.Format("shopId in ({0})", shopid));
  11452. }
  11453. lw.Add("readMod = 2");
  11454. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11455. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11456. writeGridDataTableJson(dStruct.TotalCount, dt);
  11457. }
  11458. public void deal_express_complete()
  11459. {
  11460. string ctid = GetPostString("ctid");
  11461. if (!string.IsNullOrEmpty(ctid))
  11462. {
  11463. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11464. if (ceErpTradeCellExtend == null)
  11465. {
  11466. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11467. ceErpTradeCellExtend.ctid = ctid;
  11468. }
  11469. ceErpTradeCellExtend.readMod = 1;
  11470. if (ceErpTradeCellExtend.ID == 0)
  11471. {
  11472. ceErpTradeCellExtend.Create();
  11473. }
  11474. else
  11475. {
  11476. ceErpTradeCellExtend.Update();
  11477. }
  11478. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11479. returnSuccessMsg("修改成功!");
  11480. return;
  11481. }
  11482. returnErrorMsg("找不到订单");
  11483. }
  11484. public void aftersale_return_visit()
  11485. {
  11486. string ctid = GetPostString("ctid");
  11487. if (!string.IsNullOrEmpty(ctid))
  11488. {
  11489. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11490. if (ceErpTradeCellExtend == null)
  11491. {
  11492. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11493. ceErpTradeCellExtend.ctid = ctid;
  11494. }
  11495. ceErpTradeCellExtend.returnVisit = 1;
  11496. if (ceErpTradeCellExtend.ID == 0)
  11497. {
  11498. ceErpTradeCellExtend.Create();
  11499. }
  11500. else
  11501. {
  11502. ceErpTradeCellExtend.Update();
  11503. }
  11504. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11505. if (ceErpTradeAfterSaleExtend != null)
  11506. {
  11507. ceErpTradeAfterSaleExtend.TextResult = "";
  11508. ceErpTradeAfterSaleExtend.Update();
  11509. }
  11510. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11511. returnSuccessMsg("修改成功!");
  11512. return;
  11513. }
  11514. returnErrorMsg("找不到订单");
  11515. }
  11516. public void orderPlaceInfo()
  11517. {
  11518. string ctids = GetPostString("ctids");
  11519. string[] list = ctids.Split(',');
  11520. foreach (string ctid in list)
  11521. {
  11522. CeErpSukuraData.createInfo(ctid, 3);
  11523. }
  11524. StringBuilder sql = new StringBuilder();
  11525. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11526. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11527. designHelper.api_approveDesign(ctids); //approveDesign
  11528. returnSuccessMsg("");
  11529. }
  11530. public void get_issue_list()
  11531. {
  11532. DataStruct dStruct = GetPostStruct();
  11533. List<string> lw = new List<string>();
  11534. int st = 2;
  11535. string tid = GetPostString("ctid");
  11536. if (tid.Length > 0)
  11537. {
  11538. string select_tid = getTidByCtid(tid);
  11539. lw.Add(string.Format("tid='{0}'", select_tid));
  11540. }
  11541. string shopname = GetPostString("shopname");
  11542. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11543. string buyernick = GetPostString("buyer_nick");
  11544. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11545. string sellermemo = GetPostString("seller_memo");
  11546. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11547. string supplier = GetPostString("supplier");
  11548. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11549. string customer = GetPostString("customer");
  11550. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11551. string design = GetPostString("design");
  11552. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11553. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11554. string poscode = CurrentUser.UserPost.Post.Code;
  11555. if (poscode != "SysAdmin")
  11556. {
  11557. string shopid = CurrentUser.User.pemShop;
  11558. lw.Add(string.Format("shopId in ({0})", shopid));
  11559. }
  11560. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11561. {
  11562. lw.Add("IssueState = 1");
  11563. }
  11564. lw.Add("IssueState > 0");
  11565. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11566. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11567. writeGridDataTableJson(dStruct.TotalCount, dt);
  11568. }
  11569. public void saveIssueContent()
  11570. {
  11571. string ctid = GetPostString("ctid");
  11572. if (!string.IsNullOrEmpty(ctid))
  11573. {
  11574. string content = GetPostString("content");
  11575. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11576. if (ceErpTradeAfterSaleExtend == null)
  11577. {
  11578. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11579. ceErpTradeAfterSaleExtend.tid = ctid;
  11580. }
  11581. ceErpTradeAfterSaleExtend.IssueContent = content;
  11582. ceErpTradeAfterSaleExtend.IssueState = 1;
  11583. if (ceErpTradeAfterSaleExtend.ID > 0)
  11584. {
  11585. ceErpTradeAfterSaleExtend.Update();
  11586. }
  11587. else
  11588. {
  11589. ceErpTradeAfterSaleExtend.Create();
  11590. }
  11591. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11592. returnSuccessMsg("添加成功!");
  11593. return;
  11594. }
  11595. returnErrorMsg("找不到订单");
  11596. }
  11597. public void dealIssueContent()
  11598. {
  11599. string ctid = GetPostString("ctid");
  11600. if (!string.IsNullOrEmpty(ctid))
  11601. {
  11602. string content = GetPostString("content");
  11603. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11604. if (ceErpTradeAfterSaleExtend != null)
  11605. {
  11606. ceErpTradeAfterSaleExtend.IssueState = 2;
  11607. ceErpTradeAfterSaleExtend.Update();
  11608. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11609. returnSuccessMsg("修改完成!");
  11610. return;
  11611. }
  11612. }
  11613. returnErrorMsg("找不到订单");
  11614. }
  11615. public void set_tid_attachments()
  11616. {
  11617. string tid = GetPostString("tid");
  11618. string atta = GetPostString("atta");
  11619. if (!string.IsNullOrEmpty(tid))
  11620. {
  11621. if (string.IsNullOrEmpty(atta))
  11622. {
  11623. returnErrorMsg("文件地址为空");
  11624. return;
  11625. }
  11626. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11627. if (ceErpTradeCell != null)
  11628. {
  11629. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11630. if (ceErpTrade == null)
  11631. {
  11632. returnErrorMsg("找不到订单");
  11633. return;
  11634. }
  11635. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11636. bool isSend = false;
  11637. if (dt != null && dt.Rows.Count > 0)
  11638. {
  11639. foreach (DataRow row in dt.Rows)
  11640. {
  11641. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11642. {
  11643. isSend = true;
  11644. }
  11645. }
  11646. if (isSend)
  11647. {
  11648. returnErrorMsg("已发货无法修改");
  11649. return;
  11650. }
  11651. ceErpTrade.Attachments = atta;
  11652. ceErpTrade.Update();
  11653. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11654. returnSuccessMsg("上传成功!");
  11655. return;
  11656. }
  11657. }
  11658. }
  11659. returnErrorMsg("找不到订单");
  11660. }
  11661. public void get_tid_attachments()
  11662. {
  11663. string tid = GetPostString("tid");
  11664. if (!string.IsNullOrEmpty(tid))
  11665. {
  11666. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11667. if (ceErpTradeCell != null)
  11668. {
  11669. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11670. if (ceErpTrade == null)
  11671. {
  11672. returnErrorMsg("找不到订单");
  11673. return;
  11674. }
  11675. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11676. return;
  11677. }
  11678. }
  11679. returnErrorMsg("找不到订单");
  11680. }
  11681. public void check_erp_sameorders()
  11682. {
  11683. if (UrlPostParmsCheck("ctid"))
  11684. {
  11685. string eid = GetPostString("ctid");
  11686. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11687. if (entity != null)
  11688. {
  11689. if (entity.OrderState > 6)
  11690. {
  11691. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11692. return;
  11693. }
  11694. StringBuilder sql = new StringBuilder();
  11695. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11696. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11697. List<string> ids = new List<string>();
  11698. if (dt != null && dt.Rows.Count > 1)
  11699. {
  11700. bool needhe = true;
  11701. foreach (DataRow dr in dt.Rows)
  11702. {
  11703. ids.Add("'" + dr["ctid"] + "'");
  11704. /* //备注有合包
  11705. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11706. {
  11707. needhe = true;
  11708. }
  11709. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11710. {
  11711. needhe = true;
  11712. }
  11713. //顺丰快递
  11714. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11715. {
  11716. needhe = true;
  11717. }*/
  11718. }
  11719. if (!needhe)
  11720. {
  11721. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11722. return;
  11723. }
  11724. sql = new StringBuilder();
  11725. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11726. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11727. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11728. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11729. foreach (DataRow dr in dt.Rows)
  11730. {
  11731. dr["dstate"] = 0;
  11732. dr["dnumber"] = 0;
  11733. foreach (DataRow row in dt1.Rows)
  11734. {
  11735. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11736. {
  11737. dr["dstate"] = 2;
  11738. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11739. }
  11740. }
  11741. if (eid.Equals(dr["ctid"].ToString()))
  11742. {
  11743. dr["dstate"] = 1;
  11744. }
  11745. }
  11746. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11747. return;
  11748. }
  11749. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11750. return;
  11751. }
  11752. returnErrorMsg("未找到订单");
  11753. return;
  11754. }
  11755. returnErrorMsg("缺少必要的参数");
  11756. }
  11757. public void get_mark_number()
  11758. {
  11759. string eid = GetPostString("ctid");
  11760. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11761. if (entity != null)
  11762. {
  11763. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  11764. int current = 1;
  11765. if (ceErpDeliverMark == null)
  11766. {
  11767. StringBuilder sql = new StringBuilder();
  11768. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11769. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11770. List<string> ids = new List<string>();
  11771. if (dt != null && dt.Rows.Count > 1)
  11772. {
  11773. foreach (DataRow dr in dt.Rows)
  11774. {
  11775. ids.Add("'" + dr["ctid"] + "'");
  11776. }
  11777. //查询已有的编号
  11778. sql = new StringBuilder();
  11779. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11780. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11781. if (dt1 == null || dt1.Rows.Count == 0)
  11782. {
  11783. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  11784. List<int> list_number = new List<int>();
  11785. foreach (DataRow row in numbers.Rows)
  11786. {
  11787. list_number.Add(Convert.ToInt32(row["markNumber"]));
  11788. }
  11789. //查询空余编号
  11790. for (int i = 0; i < list_number.Count + 2; i++)
  11791. {
  11792. if (!list_number.Contains(current))
  11793. {
  11794. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  11795. //防止查询过程中有新数据生成
  11796. if (ceErpDeliverMark1 == null)
  11797. {
  11798. break;
  11799. }
  11800. }
  11801. current++;
  11802. }
  11803. }
  11804. else
  11805. {
  11806. foreach (DataRow row in dt1.Rows)
  11807. {
  11808. current = Convert.ToInt32(row["markNumber"]);
  11809. }
  11810. }
  11811. ceErpDeliverMark = new CeErpDeliverMark();
  11812. ceErpDeliverMark.ctid = eid;
  11813. ceErpDeliverMark.createtime = DateTime.Now;
  11814. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11815. if (ceErpTrade != null)
  11816. {
  11817. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  11818. }
  11819. ceErpDeliverMark.markNumber = current;
  11820. ceErpDeliverMark.Create();
  11821. }
  11822. }
  11823. else
  11824. {
  11825. current = ceErpDeliverMark.markNumber;
  11826. }
  11827. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  11828. return;
  11829. }
  11830. }
  11831. }
  11832. }