| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621 |
- using BizCom;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using NHibernate.Linq;
- using NHibernate.Mapping;
- using NPOI.OpenXmlFormats.Dml.Diagram;
- using NPOI.OpenXmlFormats.Shared;
- using NPOI.SS.Formula.Eval;
- using NPOI.SS.Formula.Functions;
- using NPOI.SS.Formula.Udf;
- using SiteCore.Redis;
- using SiteCore.taobao;
- using SiteCore.taoObj;
- using SQLData;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.ComponentModel.Design;
- using System.Data;
- using System.Data.SqlClient;
- using System.Data.SqlTypes;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Security;
- using System.Reflection.Emit;
- using System.Security.Cryptography;
- using System.Security.Cryptography.X509Certificates;
- using System.Security.Policy;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- using System.Web.UI.WebControls;
- using Utils;
- using Utils.Serialization;
- using static NHibernate.Linq.Visitors.LeftJoinDetector;
- using static SiteCore.taoObj.Api_trade_info;
- using static SiteCore.taoObj.Api_waybill_code_response_Obj;
- using static SiteCore.taoObj.work_core_vo;
- using static System.Net.Mime.MediaTypeNames;
- namespace SiteCore.Handler
- {
- public partial class sync
- {
- public void get_erp_orderlist()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- DataStruct dStruct = GetPostStruct();
- //apiHelper.Api_SyncOrderByTime("598825");
- //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
- //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
- //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
- //banniuApiHelper.sendLogisticsInfo(null);
- //commonHelper.setOrderDummyDelivery("4055992920657411904");
- //commonHelper.checkOrderListDesignInfo("4042031616863358615");
- //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
- //int sid = commonHelper.autoDistributeToSupplier(entity);
- // string a = apiHelper.API_GetPrintData("YT8951457355085");
- //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1740972223000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1741145016000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2208932202028/O1CN01SQkhPk1QqsBIMPegn_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":10.0,\"refOlId\":\"2484480075794418199\",\"refSkuId\":\"0\",\"refSpuId\":\"787248116865\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"饰品售后卡片定制珠宝项链购后感谢卡硬卡设计金银保养留言卡纸制作电商包裹贺卡高级明信片首饰好平小卡印刷\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1740995566000,\"openBuyerId\":\"AAFoRHraABkUZRPgSx0XdWH-\",\"openBuyerNick\":\"t**\",\"openSellerNick\":\"麦郁旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1740972209000,\"payTime\":1740972216000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"maiyu\",\"posId\":598808,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"湖州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴兴区\",\"receiverId\":\"82b7afe37a7abf32c5a68285642bc6c7$\",\"receiverState\":\"浙江省\",\"receiverTown\":\"织里镇\",\"refOid\":\"2484480075794418199\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-卡片-300克铜版纸-tb90589912-小元-2,寄样-卡片-300克雅柔纸-tb90589912-小元-2,寄样-卡片-300克蛋壳纸-tb90589912-小元-2,寄样-卡片-300克刚古水纹纸-tb90589912-小元-2,寄样-卡片-300克荷兰白卡纸-tb90589912-小元-2\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
- //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}}");
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- //12-1 修改
- string urgent = GetPostString("urgent");
- string back = GetPostString("back");
- string offlineSearch = GetPostString("offlineSearch");
- int paramsCount = 0;
- if (!string.IsNullOrWhiteSpace(urgent))
- {
- if (urgent.Equals("true"))
- {
- lw.Add(string.Format("(IsUrgency='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(back))
- {
- if (back.Equals("true"))
- {
- lw.Add(string.Format("(IsReturn='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(offlineSearch))
- {
- if (offlineSearch.Equals("true"))
- {
- lw.Add(string.Format("(ctid like '{0}%')", "N"));
- }
- }
- //end
- string date2 = GetPostString("date2");
- string buyernick = GetPostString("buyer_nick");
- if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
- {
- if (tid.Length <= 0 && buyernick.Length <= 0)
- {
- return;
- }
- }
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- {
- lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
- }
- if (buyernick.Length > 0)
- {
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- }
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0)
- {
- lw.Add(dw);
- }
- if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
- {
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("ShopId in ({0})", usershop));
- }
- }
- else
- {
- if (ex_psize == 0)
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- if (PKey != "admin")
- {
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("ShopId in ({0})", usershop));
- paramsCount++;
- }
- }
- string uploaddate1 = GetPostString("uploaddate1");
- string uploaddate2 = GetPostString("uploaddate2");
- string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
- if (update.Length > 0) lw.Add(update);
- string deliverydate1 = GetPostString("deliverydate1");
- string deliverydate2 = GetPostString("deliverydate2");
- string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
- if (deliverydate.Length > 0)
- {
- lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
- };
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string addwechat = GetPostString("addwechat");
- if (addwechat.Length > 0)
- {
- int addWt = Convert.ToInt32(addwechat);
- if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
- else lw.Add(string.Format("IsAddWechat={0}", addWt));
- }
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string backReason = GetPostString("backReason");
- if (backReason.Length > 0)
- {
- lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
- }
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string isoldcustomer = GetPostString("isoldcus");
- string finishdate1 = GetPostString("finishdate1");
- string finishdate2 = GetPostString("finishdate2");
- string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
- bool isFinish = false;
- if (finishdate.Length > 0)
- {
- lw.Add(finishdate);
- isFinish = true;
- paramsCount++;
- }
- if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
- if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- if (ex_psize > 0)
- {
- int UserID = CurrentUser.UserID;
- if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
- UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
- }
- dStruct.Order = "pay_time desc";
- }
- string isNew = GetPostString("isNew");
- if (isNew == "true")
- {
- lw.Add(string.Format("IsNew = {0}", 1));
- }
- string overtime = GetPostString("overtime");
- if (overtime == "1")
- {
- lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
- }
- String usePost = CurrentUser.UserPost.Post.Code;
- if (usePost.Equals("Operation") == true)
- {
- dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
- }
- else
- {
- dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
- }
- //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";
- if (dStruct.PageSize == 100000)
- {
- dStruct.Order = "";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- string tablename = "view_orderlist";
- if (isFinish)
- {
- tablename = "view_orderlist_end";
- }
- dt = WebCache.GetData(tablename, dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- if (dr["refund_fees"] != null)
- {
- decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
- decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
- decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
- if (payment == refund_fees)
- {
- dr["refund_fees"] = Math.Round(refund_fees, 2);
- }
- else if (refund_fees == total_fee)
- {
- dr["refund_fees"] = payment;
- }
- else
- {
- decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
- decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
- dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
- }
- }
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- // 处理空引用异常
- dr["refund_fees"] = "0.00";
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_orderlist_sumprice()
- {
- returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
- return;
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- if (tid.Length > 0 || date1.Length > 0)
- {
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string isoldcustomer = GetPostString("isoldcus");
- if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
- if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- if (PKey != "admin")
- {
- string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", usershop));
- }
- //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";
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
- DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
- DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
- decimal total = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
- }
- var res = new
- {
- data = total
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_CustomerServiceGather()
- {
- string userWhere = "", orderWhere = "";
- List<string> lw = new List<string>();
- string customer = GetPostString("customer");
- if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- orderWhere = string.Join(" and ", lw.ToArray());
- 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 " +
- "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
- "left join " +
- "( " +
- " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
- ") as b on a.ID = b.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
- ") as d on a.ID = d.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
- ") as e on a.ID = e.CustomerUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, RefundCount, RefundSum from " +
- " ( " +
- " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
- " from CE_ErpTradeRefund a " +
- " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
- " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
- " group by CustomerUserId " +
- " ) as a " +
- ") as f on a.ID = f.CustomerUserId " +
- "where a.PostCode = 'CustomerService'",
- userWhere, orderWhere);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- //writeGridDataTableJson(dt.Rows.Count, dt);
- }
- //设计汇总
- public void get_erp_DesignerGather()
- {
- string userWhere = "", orderWhere = "";
- List<string> lw = new List<string>();
- string Designer = GetPostString("designer");
- int org = GetPostInt("org");
- if (Designer.Length > 0)
- {
- userWhere = string.Format(" where Name like '%{0}%'", Designer);
- if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
- }
- else if (org > 0)
- {
- userWhere = string.Format(" where OrgID ={0}", org);
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string state = GetPostString("state");
- if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string UpDate1 = GetPostString("UpDate1");
- string UpDate2 = GetPostString("UpDate2");
- dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
- if (dw.Length > 0) lw.Add(dw);
- orderWhere = string.Join(" and ", lw.ToArray());
- 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 (" +
- "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 " +
- "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
- "left join " +
- "( " +
- " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
- ") as b on a.ID = b.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as d on a.ID = d.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as e on a.ID = e.DesignUserId " +
- "left join " +
- "( " +
- " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
- ") as g on a.ID = g.DesignUserId " +
- "left join " +
- "( " +
- " select CustomerUserId, RefundCount, RefundSum from " +
- " ( " +
- " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
- " from CE_ErpTradeRefund a " +
- " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
- " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
- " group by CustomerUserId " +
- " ) as a " +
- ") as f on a.ID = f.CustomerUserId " +
- "where a.PostCode = 'Designer') as z",
- userWhere, orderWhere);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- //删除tradecell的订单
- public void del_erp_cellorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell.DelByCtid(eid);
- LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
- returnSuccessMsg("删除成功");
- }
- }
- public void clear_erp_refundstate()
- {
- if (UrlPostParmsCheck("ids"))
- {
- string eids = GetPostString("ids");
- string[] ctidList = eids.Split(',');
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.IsRefund = 0;
- entity.Update();
- LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
- }
- else
- continue;
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("缺少必要参数");
- }
- public void set_erp_urgency()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string utime = GetPostString("urgencytime");
- if (utime.Length > 0)
- {
- entity.UrgencyTime = Convert.ToDateTime(utime);
- }
- else
- {
- returnErrorMsg("请选择加急时间");
- return;
- }
- if (entity.OrderState <= 4)
- {
- //entity.seller_memo = entity.seller_memo + "-加急";
- string smemo = entity.seller_memo;
- int kindex = smemo.IndexOf(")");
- string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
- if (lastoneStr != "-")
- {
- smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
- }
- string prememo = smemo.Substring(0, kindex + 2);
- string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
- int lastkindex = lastmemo.IndexOf("(");
- DateTime urgtime = Convert.ToDateTime(utime);
- string newlastmemo = "";
- if (lastkindex == 0)
- {
- string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
- newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
- }
- else
- {
- newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
- }
- entity.seller_memo = prememo + newlastmemo;
- }
- entity.IsUrgency = true;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "changeDesign";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.remarkSign = 3;
- designHelper.API_WorkCore(apiVo); //changeDesign
- CeErpSukuraData.createInfo(entity.ctid, 7);
- LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
- returnSuccessMsg("设置成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void set_erp_reset()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
- {
- if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
- {
- returnErrorMsg("财务要求已下单已发货无法重置");
- return;
- }
- }
- entity.IsUrgency = false;
- entity.seller_memo = "";
- entity.OtherMemo = "";
- entity.OrderState = 0;
- entity.IsReturn = 0;
- //entity.IsRefund = 0;
- entity.MemoOpt = 0;
- entity.AfterSaleState = 0;
- entity.AfterSaleResponsible = "";
- entity.AfterSaleUserId = 0;
- entity.IsNeedBill = 0;
- entity.CustomerUserId = 0;
- entity.DesignUserId = 0;
- entity.SupplierId = 0;
- entity.PlaceUserId = 0;
- entity.ptid = "";
- entity.IsSample = 0;
- entity.IsXianHuo = 0;
- entity.isDianziOrder = 0;
- entity.DispatchSort = 0;
- entity.FinishPlaceTime = null;
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- trade.seller_memo = "";
- trade.Update();
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
- returnSuccessMsg("重置成功!");
- CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
- if (desginBill != null)
- {
- desginBill.isDel = 1;
- desginBill.Update();
- LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "resetDesign";
- designHelper.API_WorkCore(apiVo);//resetDesign
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_sellermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- string memo = GetPostString("seller_memo");
- memo = memo.Replace(" ", "");
- if (memo.Contains("补差"))
- {
- returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
- return;
- }
- if (entity.seller_memo != memo)
- {
- if (entity.IsSample == 2)
- {
- returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
- return;
- }
- if (CurrentUser.UserPost.Post.Code != "SysAdmin")
- {
- if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
- {
- returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
- return;
- }
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
- }
- commonHelper.getCytPrice(entity);
- int memoopt = GetPostInt("MemoOpt");
- Boolean ismemoopt = false;
- if (memoopt > 0)
- {
- string stropt = "";
- if (memoopt == 1)
- {
- stropt = "“改稿”";
- ismemoopt = true;
- }
- else if (memoopt == 2)
- {
- stropt = "“定稿”";
- }
- else if (memoopt == 3)
- {
- stropt = "“查货”";
- CeErpSukuraData.createInfo(entity.ctid, 6);
- }
- entity.MemoOpt = Convert.ToInt32(memoopt);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
- }
- if (entity.OrderState < 5)
- {
- memo = memo.Replace("(", "(");
- memo = memo.Replace(")", ")");
- }
- entity.seller_memo = memo;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
- apiVo.orderRemarks = memo;
- apiVo.remarkSign = memoopt;
- designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_checkorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if (entity.OrderState < 6)
- {
- returnErrorMsg("下单完成后才可查货");
- return;
- }
- /*if (entity.OrderState > 6)
- {
- returnErrorMsg("订单已发货");
- return;
- }*/
- if (entity.FinishPlaceTime != null)
- {
- if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
- {
- returnErrorMsg("下单时间不足,无法查货");
- return;
- }
- }
- entity.MemoOpt = 3;
- entity.CheckOrderTime = DateTime.Now;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 6);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_othermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.OtherMemo = GetPostString("otherMemo");
- if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
- {
- //品类一直
- entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
- CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
- if (ceErpSampleCustomer == null)
- {
- ceErpSampleCustomer = new CeErpSampleCustomer();
- ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
- ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
- ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
- ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
- ceErpSampleCustomer.shopId = entity.ShopId;
- }
- ceErpSampleCustomer.lastbuy_time = entity.pay_time;
- ceErpSampleCustomer.lastTid = entity.tid;
- if (ceErpSampleCustomer.ID > 0)
- {
- ceErpSampleCustomer.Update();
- }
- else
- {
- ceErpSampleCustomer.Create();
- }
- }
- }
- }
- }
- //if (entity.IsOldCustomer == 1)
- //{
- //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
- //{
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
- //}
- //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
- //{
- // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
- // {
- // if (entity.OtherMemo.IndexOf("改稿") > -1)
- // {
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
- // }
- // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
- // {
- // entity.OrderState = 2;
- // entity.DesignUserId = 0;
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
- // }
- // else
- // {
- // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
- // }
- // }
- //}
- //}
- entity.Update();
- returnSuccessMsg("保存成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void save_erp_customermemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.CustomerMemo = GetPostString("CustomerMemo");
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "followRemarks";
- apiVo.orderRemarks = entity.CustomerMemo;
- designHelper.API_WorkCore(apiVo);//followRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_addmemotag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- string sfTagstr = GetPostString("memotag");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState == 0)
- {
- returnErrorMsg("请先领单");
- return;
- }
- //撤销顺丰
- if (sfTagstr == "撤销顺丰")
- {
- entity.IsSF = 0;
- string reMsg = "";
- string oldmemo = entity.seller_memo;
- if (entity.OrderState < 5)
- {
- oldmemo = oldmemo.Replace("顺丰到付", "");
- oldmemo = oldmemo.Replace("顺丰寄付", "");
- entity.seller_memo = oldmemo;
- }
- else
- {
- if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
- {
- reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
- }
- }
- entity.Update();
- work_core_vo.ApiVo api = new work_core_vo.ApiVo();
- api.orderNumber = entity.ctid;
- api.actionName = "followRemarks";
- api.orderRemarks = entity.seller_memo;
- api.isSf = entity.IsSF.ToString();
- designHelper.API_WorkCore(api);//followRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
- returnSuccessMsg("撤销成功!" + reMsg);
- return;
- }
- if (entity.OrderState < 5 || entity.IsXianHuo == 1)
- {
- //string oldmemo = entity.seller_memo;
- //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
- string sfStr = GetPostString("memotag");
- string smemo = entity.seller_memo;
- int kindex = smemo.IndexOf(")");
- string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
- if (lastoneStr != "-")
- {
- smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
- }
- string prememo = smemo.Substring(0, kindex + 2);
- string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
- int lastkindex = lastmemo.IndexOf("(");
- string newlastmemo = "";
- if (lastkindex == 0)
- {
- string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
- newlastmemo = "(" + sfStr + "." + useLastmemo;
- }
- else
- {
- newlastmemo = "(" + sfStr + ")-" + lastmemo;
- }
- entity.seller_memo = prememo + newlastmemo;
- }
- string sfTagMSg = "";
- if (sfTagstr == "顺丰寄付")
- {
- entity.IsSF = 1;
- sfTagMSg = "顺丰寄付";
- }
- else if (sfTagstr == "顺丰到付")
- {
- entity.IsSF = 2;
- sfTagMSg = "顺丰到付";
- }
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "orderRemarks";
- apiVo.orderRemarks = entity.seller_memo;
- apiVo.isSf = entity.IsSF.ToString();
- designHelper.API_WorkCore(apiVo);//orderRemarks
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_ordertag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- int tag = GetPostInt("wechattag");
- //if(tag==4 && entity.IsSample == 2)
- //{
- // returnErrorMsg("补差价单不能标记微信单");
- // return;
- //}
- entity.wechatTag = tag;
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (tag == 1)
- {
- CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
- if (cash == null)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- cash = new CeErpReturnCash();
- cash.tid = entity.tid;
- cash.seller_nick = main.seller_nick;
- cash.payment = trade.payment;
- cash.buyer_nick = main.buyer_nick;
- cash.cashstate = 0;
- cash.rtype = "微信返现";
- cash.returnprice = 0;
- cash.created = DateTime.Now;
- cash.con = "订单标记微信单";
- cash.img = "";
- cash.applyuserid = CurrentUser.UserID;
- cash.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
- }
- else
- {
- cash.cashstate = 0;
- cash.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 9);
- }
- else if (tag == 2)
- {
- CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
- if (cash == null)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- cash = new CeErpReturnCash();
- cash.tid = entity.tid;
- cash.seller_nick = main.seller_nick;
- cash.payment = trade.payment;
- cash.buyer_nick = main.buyer_nick;
- cash.cashstate = 0;
- cash.rtype = "推购返现";
- cash.returnprice = 5;
- cash.created = DateTime.Now;
- cash.con = "订单标记推购单";
- cash.img = "";
- cash.applyuserid = CurrentUser.UserID;
- cash.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
- }
- else
- {
- cash.cashstate = 0;
- cash.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 9);
- }
- else if (tag == 3)
- {
- CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
- if (pers == null)
- {
- pers = new CeErpPersuade();
- pers.ctid = entity.ctid;
- pers.pstate = 0;
- pers.created = DateTime.Now;
- pers.applyuserid = CurrentUser.UserID;
- pers.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
- }
- else
- {
- pers.pstate = 0;
- pers.Update();
- }
- }
- else if (tag == 4 || tag == 5)
- {
- CeErpTrade main = CeErpTrade.Get(entity.tid);
- CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
- if (pers == null)
- {
- pers = new CeErpStayGoods();
- pers.t_id = entity.tid;
- pers.status = "待审核";
- pers.audit_type = 0;
- if (tag == 4)
- {
- pers.stay_type = "微信推购";
- }
- else
- {
- pers.stay_type = "旺旺推购";
- }
- if (entity.IsXianHuo == 0)
- {
- pers.product_id = entity.ProductId;
- }
- pers.wangwang = main.buyer_nick;
- pers.shop_name = main.seller_nick;
- pers.creata_time = DateTime.Now;
- pers.create_u_id = CurrentUser.UserID;
- pers.create_u_name = CurrentUser.UserName;
- pers.Create();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
- }
- else
- {
- pers.audit_type = 0;
- pers.Update();
- }
- CeErpSukuraData.createInfo(entity.ctid, 10);
- }
- //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_ordertag_cancel()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.wechatTag = 0;
- entity.Update();
- CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
- if (pers != null)
- {
- pers.status = "取消推购";
- pers.audit_type = 3;
- pers.Update();
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_addweichattag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsAddWechat > 0)
- {
- returnErrorMsg("此单已经标记过了");
- return;
- }
- 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);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- entity.IsAddWechat = 2;
- }
- else
- {
- entity.IsAddWechat = 1;
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
- returnSuccessMsg("标记成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_getmyorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.ctid.IndexOf("C") != -1)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- decimal total = 0;
- foreach (DataRow dr in dt.Rows)
- {
- total += Convert.ToDecimal(dr["payment"]);
- }
- decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
- if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
- {
- returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
- return;
- }
- }
- }
- entity.CustomerUserId = CurrentUser.UserID;
- if (entity.OrderState < 2)
- {
- entity.OrderState = 2;
- if (entity.ShopId != 0)
- {
- entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
- returnSuccessMsg("领单成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void getmyorder_from_init()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string sellerMemo = GetPostString("sellerMemo");
- if (sellerMemo.Length > 0)
- {
- entity.seller_memo = sellerMemo;
- }
- string oterhMemo = GetPostString("otherMemo");
- if (oterhMemo.Length > 0)
- {
- entity.OtherMemo = oterhMemo;
- }
- int urg = GetPostInt("urgency");
- entity.IsUrgency = (urg == 1 ? true : false);
- int wechat = GetPostInt("wechat");
- int command = GetPostInt("command");
- if (wechat == 1)
- {
- entity.wechatTag = 1;
- }
- if (command == 1)
- {
- entity.wechatTag = 2;
- }
- string pPro = GetPostString("pprofession");
- if (pPro.Length > 0)
- {
- entity.ParentProfessionId = Convert.ToInt32(pPro);
- string spro = GetPostString("profession");
- if (spro.Length > 0)
- {
- entity.ProfessionId = Convert.ToInt32(spro);
- }
- }
- string proId = GetPostString("productId");
- if (proId.Length > 0)
- {
- entity.ProductId = Convert.ToInt32(proId);
- }
- entity.Material = GetPostString("material");
- entity.Craft = GetPostString("craft");
- entity.CustomerUserId = CurrentUser.UserID;
- if (entity.OrderState < 2)
- {
- entity.OrderState = 2;
- if (entity.ShopId != 0)
- {
- entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
- returnSuccessMsg("领单成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_setrelationorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- ;
- string eid = GetPostString("ctid");
- string ftid = GetPostString("ftid");
- CeErpTradeCell entity = null;
- CeErpTradeCell fentity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
- if (fentity == null)
- {
- returnErrorMsg("找不到关联的主订单");
- return;
- }
- if (entity != null)
- {
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("本单已经设计完成无法关联");
- return;
- }
- if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
- {
- returnErrorMsg("线下单续审核后才能关联!");
- return;
- }
- entity.ptid = ftid;
- entity.OrderState = fentity.OrderState;
- //entity.status = fentity.status;
- entity.CustomerUserId = fentity.CustomerUserId;
- entity.DesignUserId = fentity.DesignUserId;
- entity.seller_memo = "补差价单:" + ftid;
- entity.IsSample = 2;
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ftid;
- apiVo.payment = entity.payment;
- apiVo.actionName = "repairDesign";
- designHelper.API_WorkCore(apiVo);//repairDesign
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
- returnSuccessMsg("关联成功!");
- return;
- }
- else
- returnErrorMsg("找不到记录");
- }
- }
- public void download_erp_neworder()
- {
- string seller = GetPostString("seller_nick");
- string tid = GetPostString("tid");
- if (seller.Length <= 0 || tid.Length <= 0)
- {
- returnErrorMsg("数据错误");
- }
- //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
- //{
- // returnErrorMsg("找不到店铺Sessionkey");
- //}
- //string sessionkey = taobaoHelper.ShopKeyDics[seller];
- //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
- string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
- if (res.IndexOf("refOid") == -1)
- {
- returnErrorMsg("下载订单数据失败");
- return;
- }
- tmcHelper.Api_Tmc_CreateNewOrder(res);
- returnSuccessMsg("下载完成");
- //tmcHelper.createNewOrder(res);
- //CeErpTrade entr = null;
- //entr = CeErpTrade.Get(tid);
- //if (entr != null)
- //{
- // returnSuccess("下载成功");
- // //下载成功之后,Cell表生成对应的订单;
- // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
- //}
- //else
- //{
- // returnErrorMsg("下载失败或者创建订单失败");
- //}
- }
- public void set_erp_atersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("AfterSaleReason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
- {
- returnErrorMsg("此订单已经在售后");
- return;
- }
- entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
- //entity.AfterSaleReason = reason;
- entity.AfterSaleTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
- returnSuccessMsg("转售后成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void set_erp_withdraw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- try
- {
- string eid = GetPostString("ctid");//商品id
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
- CeWithdraw ceWithdrawSelect = null;
- ceWithdrawSelect = CeWithdraw.GetByTid(eid);
- if (ceWithdrawSelect != null)
- {
- if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
- {
- ceWithdrawSelect.status = -1;
- ceWithdrawSelect.Update();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
- returnSuccessMsg("重新发起审核成功");
- return;
- }
- else
- {
- returnSuccessMsg("请勿重复申请!");
- return;
- }
- }
- else
- {
- string CustomerUserId = GetPostString("CustomerUserId");//供应商id
- if (string.IsNullOrEmpty(CustomerUserId))
- {
- CustomerUserId = "-1";
- }
- int Userid = CurrentUser.UserID;//用户id
- CeWithdraw ceWithdraw = new CeWithdraw();
- ceWithdraw.tid = eid;
- ceWithdraw.userid = Userid;
- ceWithdraw.providerid = CustomerUserId;
- ceWithdraw.status = 3;
- ceWithdraw.creationtime = DateTime.Now;
- ceWithdraw.Create();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
- returnSuccessMsg("申请撤回订单成功,待车间确认");
- return;
- }
- }
- catch
- {
- returnErrorMsg("申请撤回订单失败");
- return;
- }
- }
- }
- public void ins_erp_billinfo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpBill bill = CeErpBill.GetByTid(eid);
- bool isHave = false;
- if (bill != null)
- {
- isHave = true;
- if (bill.state != 4)
- {
- returnErrorMsg("此单已经申请过发票了");
- return;
- }
- }
- if (entity.IsNeedBill == 0)
- {
- entity.IsNeedBill = 1;
- }
- entity.Update();
- string errjson = "";
- try
- {
- CeErpBill bill_entity = new CeErpBill();
- bill_entity.tid = entity.tid;
- bill_entity.title = GetPostString("title");
- string taxstr = GetPostString("tax");
- taxstr = taxstr.Replace(" ", "");
- bill_entity.tax = taxstr;
- bill_entity.bank = GetPostString("bank");
- string bankacstr = GetPostString("bankac");
- bankacstr = bankacstr.Replace(" ", "");
- bill_entity.bankac = bankacstr;
- bill_entity.address = GetPostString("address");
- bill_entity.phone = GetPostString("phone");
- bill_entity.price = GetPostString("price");
- int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
- if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
- {
- billCount += 1;
- }
- string prebill = "ltb";
- for (int idx = 1; idx <= billCount; idx++)
- {
- string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
- string billoid = prebill + idx + dtstr;
- bill_entity.billOrderId += billoid;
- if (idx < billCount)
- {
- bill_entity.billOrderId += ",";
- }
- }
- bill_entity.productId = GetPostInt("ProductName");
- bill_entity.num = GetPostInt("num");
- bill_entity.unit = GetPostString("unit");
- bill_entity.type = GetPostString("type");
- bill_entity.sendType = GetPostString("SendType");
- bill_entity.email = GetPostString("email");
- bill_entity.buyer_nick = GetPostString("buyer_nick");
- bill_entity.shopName = GetPostString("ShopName");
- bill_entity.applymemo = GetPostString("applyMemo");
- bill_entity.createTime = DateTime.Now;
- bill_entity.state = 0;
- bill_entity.userId = CurrentUser.UserID;
- errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
- bill_entity.Create();
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
- returnErrorMsg("创建发票出错!");
- return;
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
- returnSuccessMsg("发票申请成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_neworder()
- {
- if (UrlPostParmsCheck("receiver_name"))
- {
- CeErpTrade entity = new CeErpTrade();
- string plat_form = GetPostString("platform");
- string preStr = "N_";
- if (plat_form == "拼多多")
- {
- preStr = "P_";
- }
- else if (plat_form == "阿里巴巴")
- {
- preStr = "A_";
- }
- entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
- entity.seller_nick = GetPostString("seller_nick");
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.payment = Convert.ToDouble(GetPostString("payment"));
- entity.total_fee = entity.payment;
- entity.pay_time = DateTime.Now;
- entity.status = "NOT_SHIPPED";
- entity.receiver_name = GetPostString("receiver_name");
- entity.receiver_mobile = GetPostString("receiver_mobile");
- entity.receiver_state = GetPostString("receiver_state");
- entity.receiver_city = GetPostString("receiver_city");
- entity.receiver_district = GetPostString("receiver_district");
- entity.receiver_address = GetPostString("receiver_address");
- if (entity.receiver_state == "" || entity.receiver_city == "")
- {
- returnErrorMsg("收件地址不能为空");
- return;
- }
- int shopId = 0;
- CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
- if (nShop != null)
- {
- shopId = nShop.ID;
- }
- if (shopId != 34 && entity.payment == 0)
- {
- returnErrorMsg("公司自用的单金额才能为0");
- return;
- }
- entity.Create();
- CeErpTradeCell entitycell = new CeErpTradeCell();
- entitycell.ctid = entity.tid;
- entitycell.tid = entity.tid;
- entitycell.ShopId = shopId;
- entitycell.payment = Convert.ToDouble(GetPostString("payment"));
- entitycell.OrderState = 0;
- entitycell.pay_time = entity.pay_time;
- entitycell.IsOffLineOrder = 1;
- entitycell.Create();
- returnSuccessMsg("订单已生成!单号:" + entity.tid);
- LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
- return;
- }
- }
- public void ins_erp_neworder2()
- {
- if (UrlPostParmsCheck("receiver_name"))
- {
- //string plat_form = GetPostString("platform");
- string preStr = "X_";
- string memo = GetPostString("memo");
- string productId = GetPostString("productId");
- string primg = GetPostString("proofimg");
- string sellerNick = GetPostString("seller_nick");
- string addFrom = GetPostString("addfrom");
- if (addFrom == "1")
- {
- preStr = "N_";
- }
- int shopId = 0;
- CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
- if (nShop != null)
- {
- shopId = nShop.ID;
- }
- else
- {
- returnErrorMsg("找不到对应店铺");
- return;
- }
- if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
- {
- returnErrorMsg("必须上传付款凭证");
- return;
- }
- CeErpTrade entity = new CeErpTrade();
- entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
- entity.seller_nick = sellerNick;
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.payment = Convert.ToDouble(GetPostString("payment"));
- entity.total_fee = entity.payment;
- entity.pay_time = DateTime.Now;
- entity.status = "NOT_SHIPPED";
- entity.receiver_name = GetPostString("receiver_name");
- entity.receiver_mobile = GetPostString("receiver_mobile");
- entity.receiver_state = GetPostString("receiver_state");
- entity.receiver_city = GetPostString("receiver_city");
- entity.receiver_district = GetPostString("receiver_district");
- entity.receiver_address = GetPostString("receiver_address");
- entity.seller_memo = memo;
- entity.orderFrom = 20;
- entity.orderType = 15;
- if (entity.receiver_state == "" || entity.receiver_city == "")
- {
- returnErrorMsg("收件地址不能为空");
- return;
- }
- if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
- {
- returnErrorMsg("公司自用的单金额才能为0");
- return;
- }
- entity.Create();
- string toWhere = GetPostString("towhere");
- CeErpTradeCell entitycell = new CeErpTradeCell();
- entitycell.ctid = entity.tid;
- //唯一标识
- entitycell.OrderSn = entity.tid;
- //string orderSn = dataHelper.getSaleOrderSn();
- //if (orderSn != "")
- // {
- // entitycell.OrderSn = orderSn;
- // }
- entitycell.tid = entity.tid;
- //if (preStr == "X_")
- //{
- entitycell.IsOffLineOrder = 1;
- //}
- entitycell.CustomerUserId = CurrentUser.UserID;
- entitycell.PayProofImg = primg;
- entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
- entitycell.ProductId = Convert.ToInt32(productId);
- entitycell.ShopId = shopId;
- entitycell.payment = Convert.ToDouble(GetPostString("payment"));
- if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
- {
- entitycell.IsXianHuo = 1;
- }
- entitycell.pay_time = entity.pay_time;
- if (toWhere == "1")
- {
- entitycell.OrderState = 2;
- }
- else
- {
- entitycell.OrderState = 6;
- entitycell.FinishPlaceTime = entitycell.pay_time;
- }
- if (shopId == 94)
- {
- entitycell.OrderState = 4;
- entitycell.WaitDesignTime = entitycell.pay_time;
- entitycell.StartDesignTime = entitycell.pay_time;
- entitycell.DesignUserId = 218;
- }
- if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
- {
- entitycell.OrderState = -1;//修改12-5
- CeWithdraw ceWithdraw = new CeWithdraw();
- ceWithdraw.tid = entity.tid;
- ceWithdraw.providerid = "-1";
- ceWithdraw.status = -1;
- ceWithdraw.creationtime = DateTime.Now;
- ceWithdraw.userid = 1337;
- ceWithdraw.Create();
- }
- entitycell.Create();
- CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
- if (shopId == 34 && entity.buyer_nick == "现货手提袋")
- {
- addPlaceRegist(entitycell, CurrentUser.UserID);
- }
- returnSuccessMsg("订单已生成!单号:" + entity.tid);
- LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
- return;
- }
- }
- public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
- {
- CeErpPlaceRegister entity = new CeErpPlaceRegister();
- entity.PlactTime = tradecell.pay_time;
- entity.AddUserId = userid;
- entity.FileName = tradecell.seller_memo;
- entity.Supplier = 24;
- entity.CreateTime = DateTime.Now;
- entity.Did = tradecell.ctid;
- entity.tid = tradecell.tid;
- entity.splitTag = tradecell.SplitTag;
- entity.CurState = "未完成";
- entity.Create();
- }
- public void get_erp_offlinelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- if (tid.Length > 0 || date1.Length > 0)
- {
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0)
- {
- lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //if (PKey != "admin")
- //{
- // string usershop = CurrentUser.User.pemShop;
- // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
- //}
- //if (ex_psize > 0)
- //{
- dStruct.Order = "pay_time desc";
- //}
- //else
- // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
- lw.Add(string.Format("IsOffLineOrder=1"));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_returncashrecord()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("tid like '%{0}%'", tid));
- dStruct.Order = "id desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
- //writeGridDataTableJson(dStruct.TotalCount, dt);
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- return;
- }
- returnErrorMsg("id数据错误!");
- }
- public void ins_erp_returncashrecord()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string tid = GetPostString("tid");
- string retype = GetPostString("type");
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnErrorMsg("相同返现类型记录已存在");
- return;
- }
- CeErpReturnCash entity = new CeErpReturnCash();
- entity.tid = tid;
- entity.seller_nick = GetPostString("seller_nick");
- string pment = GetPostString("payment");
- if (pment.Length > 0)
- {
- entity.payment = Convert.ToDouble(pment);
- }
- entity.buyer_nick = GetPostString("buyer_nick");
- entity.cashstate = 0;
- entity.rtype = retype;
- string rPrice = GetPostString("returnprice");
- if (rPrice.Length > 0)
- {
- entity.returnprice = Convert.ToDouble(rPrice);
- }
- entity.created = DateTime.Now;
- entity.con = GetPostString("con");
- entity.img = GetPostString("img");
- entity.applyuserid = CurrentUser.UserID;
- entity.Create();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void set_erp_predelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
- //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
- //{
- // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
- // return;
- //}
- entity.IsPreDelivery = 1;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
- returnSuccessMsg("预发货成功!");
- return;
- //string shop = GetPostString("seller_nick");
- ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
- //string comName = GetPostString("comName");
- //string comCode = GetPostString("comCode");
- //string outSid = GetPostString("outSid");//运单号
- //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
- //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
- ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
- //string apires = "";
- //if (deliveryType == "虚拟发货")
- //{
- // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
- //}
- //else
- //{
- // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
- //}
- ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
- ////{
- //if (apires.IndexOf("发货成功") != -1)
- //{
- // if (deliveryType != "虚拟发货")
- // {
- // //还要插入快递信息到 快递信息表
- // CeErpExpressInfo exinfo = new CeErpExpressInfo();
- // exinfo.tid = eid;
- // exinfo.out_sid = outSid;
- // exinfo.company_code = comCode;
- // exinfo.company_name = comName;
- // exinfo.delivery_memo = deliveryMemo;
- // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- // exinfo.deliveryType = deliveryType;
- // exinfo.Create();
- // }
- // returnSuccessMsg("发货成功!");
- // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
- //}
- //else
- //{
- // returnErrorMsg("淘宝发货失败!!");
- //}
- //return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_unusuallist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string ResponsibleMan = GetPostString("responsible");
- if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("UnusualTag > 0"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_unusualtonomal()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.UnusualTag = -1;
- entity.Update();
- returnSuccessMsg("忽略成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_unusualreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.MemoOpt = 4;
- entity.UnusualCon = GetPostString("con");
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
- }
- //查货是否超时
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = entity.ctid;
- }
- if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
- {
- ceErpTradeCellExtend.CheckOut += 1;
- }
- ceErpTradeCellExtend.CheckTime = DateTime.Now;
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Create();
- }
- CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_sampleorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string[] eArr = eid.Split(',');
- if (eArr.Length > 1)
- {
- List<string> eLst = new List<string>();
- for (int i = 0; i < eArr.Length; i++)
- {
- eLst.Add("'" + eArr[i] + "'");
- }
- eid = string.Join(",", eLst.ToArray());
- }
- else
- {
- eid = "'" + eid + "'";
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
- if (dt.Rows.Count > 0)
- {
- string errmsg = "";
- foreach (DataRow dr in dt.Rows)
- {
- StringBuilder sqlsb = new StringBuilder();
- sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
- sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
- string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
- if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
- {
- continue;
- }
- else
- {
- string emsg = commonHelper.KeepChinese(apires);
- errmsg += emsg;
- }
- }
- if (errmsg.Length > 0)
- {
- returnErrorMsg(errmsg);
- return;
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_transcustomer()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int userid = GetPostInt("CustomerUserId");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //string[] mlist = entity.seller_memo.Split('-');
- //string sql = "select * from view_erpuser where id=" + userid;
- //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //if (dt != null && dt.Rows.Count > 0)
- //{
- // string nmemo = "";
- // for(int i = 0; i < mlist.Length - 1; i++)
- // {
- // nmemo += mlist[i];
- // nmemo += "-";
- // }
- // nmemo+= dt.Rows[0]["Tb"].ToString();
- // entity.seller_memo = nmemo;
- //}
- entity.CustomerUserId = userid;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_transdesigner()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string[] ctidList = eids.Split(',');
- int userid = GetPostInt("DesignUserId");
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- entitys = CeErpDesignerBill.GetByTid(ctid);
- if (entity != null)
- {
- if (entity.OrderState > 4)
- {
- continue;
- }
- //存在退款不能流转
- if (entity.IsRefund > 0)
- {
- continue;
- }
- entity.DesignUserId = userid;
- entity.WaitDesignTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- }
- }
- public void upd_erp_distributedesigner()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int userid = GetPostInt("DesignUserId");
- string[] idlist = eid.Split(',');
- if (idlist.Length <= 0)
- {
- returnErrorMsg("订单不能为空");
- return;
- }
- foreach (string ctid in idlist)
- {
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- else continue;
- if (entity != null)
- {
- if (userid == 2125 || userid == 3542)
- { }
- if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
- {
- returnErrorMsg("金额错误的订单无法指派");
- return;
- }
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("已经设计完成无法指派");
- return;
- }
- if (entity.OrderState == -1)
- {
- returnErrorMsg("审核中的订单无法指派");
- return;
- }
- if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
- {
- returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
- return;
- }
- //157赖橙帆 159林晨
- 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)
- {
- returnErrorMsg("指派设计共创无法再次指派!");
- return;
- }
- entity.OrderState = 3;
- CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
- if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
- {
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- if (userid == 2125 && entity.seller_memo != "")
- {
- apiDesign.API_GetPrintData_CreateOrder(entity);
- }
- if (userid == 3542 && entity.seller_memo != "")
- {
- designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
- LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
- if (response.msg != "设计共创:成功")
- {
- returnErrorMsg(response.msg);
- return;
- }
- entity.DispatchSort = 2;
- }
- else
- {
- if (entity.DispatchSort == 2)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.actionName = "closeDesign";
- apiVo.orderNumber = entity.ctid;
- designHelper.API_WorkCore(apiVo);//closeDesign
- }
- entity.DispatchSort = 0;
- }
- entity.DesignUserId = userid;
- entity.WaitDesignTime = DateTime.Now;
- entity.Update();
- string name = commonHelper.getUserNameById(userid);
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_myorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
- }
- //12-1 修改
- string urgent = GetPostString("urgent");
- string back = GetPostString("back");
- string offlineSearch = GetPostString("offlineSearch");
- if (!string.IsNullOrWhiteSpace(urgent))
- {
- if (urgent.Equals("true"))
- {
- lw.Add(string.Format("(IsUrgency='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(back))
- {
- if (back.Equals("true"))
- {
- lw.Add(string.Format("(IsReturn='{0}' )", 1));
- }
- }
- if (!string.IsNullOrWhiteSpace(offlineSearch))
- {
- if (offlineSearch.Equals("true"))
- {
- lw.Add(string.Format("(ctid like '{0}%')", "N"));
- }
- }
- //end
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string urgency = GetPostString("urgency");
- if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
- string after = GetPostString("after");
- if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
- lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- if (dr["DispatchSort"].ToString() == "2")
- {
- dr["gongchuang"] = 200;
- }
- else
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_myreturnorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0)
- {
- lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
- {
- lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
- }
- else
- {
- lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
- }
- lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- if (dStruct.PageSize != 100000)
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- catch (NullReferenceException ex)
- {
- // 处理空引用异常
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_myorderlist_pregather()
- {
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- int userId = CurrentUser.UserID; //客服id
- string orderWhere = "";
- List<string> lw = new List<string>();
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- lw.Add(string.Format("CustomerUserId={0}", userId));
- lw.Add(string.Format("OrderState<9"));
- orderWhere = string.Join(" and ", lw.ToArray());
- string orderWhere2 = "";
- List<string> lw2 = new List<string>();
- string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw2.Length > 0) lw2.Add(dw2);
- lw2.Add(string.Format("CustomerUserId={0}", userId));
- orderWhere2 = string.Join(" and ", lw2.ToArray());
- string sql = string.Format("select *" +
- "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
- "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 " +
- "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 " +
- "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");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //writeGridDataTableJson(dt.Rows.Count, dt);
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void upd_erp_publishorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 0; //发布后,变为待抢单
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
- returnSuccessMsg("发布成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_my_tiporder()
- {
- StringBuilder sql = new StringBuilder();
- int userId = 0;
- if (CurrentUser != null) userId = CurrentUser.UserID;
- string posCode = CurrentUser.UserPost.Post.Code;
- string isTipedAfterSaleVerify = GetPostString("af");
- DataTable dt = new DataTable();
- if (posCode != "Supplier")
- {
- if (posCode == "CustomerService" || posCode == "Director")
- {
- sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
- }
- else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
- {
- sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
- }
- else
- {
- string teamIds = CurrentUser.User.TeamIds;
- if (teamIds == "")
- {
- teamIds = "0";
- }
- 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);
- }
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- if (dt.Rows.Count <= 0)
- {
- string key = "aftersale_order_" + userId;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- dt.Columns.Add("ctid", typeof(string));
- dt.Columns.Add("IsReadTag", typeof(int));
- foreach (var i in list)
- {
- DataRow data = dt.NewRow();
- data["ctid"] = i;
- data["IsReadTag"] = 4;
- dt.Rows.Add(data);
- }
- RedisHelper.StringDelete(key);
- }
- }
- if (dt.Rows.Count <= 0)
- {
- sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- if (posCode == "Supplier")
- {
- string ids = CurrentUser.User.pemVend;
- if (ids != null && ids.Length > 0)
- {
- string[] ids_list = ids.Split(',');
- foreach (var item in ids_list)
- {
- string key = "return_order_" + item;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- dt.Columns.Add("ctid", typeof(string));
- dt.Columns.Add("IsReadTag", typeof(int));
- foreach (var i in list)
- {
- DataRow data = dt.NewRow();
- data["ctid"] = i;
- data["IsReadTag"] = 1;
- dt.Rows.Add(data);
- }
- RedisHelper.StringDelete(key);
- }
- }
- }
- if (dt.Rows.Count <= 0)
- {
- sql = new StringBuilder();
- 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);
- dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void reset_erp_tiporder()
- {
- string ids = GetPostString("ids");
- string[] ctidList = ids.Split(',');
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
- if (enty != null)
- {
- enty.IsReadTag = 0;
- enty.Update();
- }
- }
- returnSuccessMsg("成功!");
- return;
- }
- public void get_erp_designlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
- lw.Add(string.Format("OrderState<6"));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string designTime = GetPostString("designtime");
- if (designTime.Length > 0)
- {
- lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
- }
- string usershop = CurrentUser.User.pemShop;
- if (usershop.Length > 0)
- {
- lw.Add(string.Format("shopId in ({0})", usershop));
- }
- int myOrgid = CurrentUser.UserPost.OrgID;
- string myOrgCode = CurrentUser.UserPost.Post.Code;
- if (myOrgCode.IndexOf("Designer") != -1)
- {
- if (CurrentUser.User.ManageOrgIds.Length > 0)
- {
- lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
- }
- else
- {
- lw.Add(string.Format("DesOrgID = {0}", myOrgid));
- }
- }
- else
- {
- string orgId = GetPostString("designerhd");
- if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
- }
- if (tid.Length > 0 || buyernick.Length > 0)
- {
- lw.Add(string.Format("OrderState >= 3"));
- }
- else
- lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
- if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_mydesignlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
- //lw.Add(string.Format("OrderState<6"));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string apdate1 = GetPostString("apdate1");
- string apdate2 = GetPostString("apdate2");
- string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
- if (dwap.Length > 0) lw.Add(dwap);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string olddownload = GetPostString("olddown");
- if (olddownload == "1")
- {
- lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
- }
- else if (olddownload == "2")
- {
- lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
- }
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
- if (CurrentUser.User.TeamIds.Length > 0)
- {
- if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
- lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
- else
- lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
- }
- else
- {
- lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
- }
- if (tid.Length <= 0)
- {
- lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
- }
- lw.Add(string.Format("IsReturn!=3"));
- dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- string teamids = CurrentUser.User.TeamIds.ToString();
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- try
- {
- // 对象操作
- CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
- ceErpTradeCell.ctid = dr["ctid"].ToString();
- ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
- ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
- ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
- if (dStruct.PageSize != 100000)
- {
- designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
- dr["gongchuang"] = response.code;
- }
- }
- catch (NullReferenceException ex)
- {
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_startdesign()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState != 3)
- {
- returnErrorMsg("请刷新,订单已经设计了");
- return;
- }
- entity.StartDesignTime = DateTime.Now;
- entity.OrderState = 4;
- if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
- {
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- //entity.MakeSupplier = suname;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
- commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
- commonHelper.getCytPrice(entity);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_designselfmemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string con = GetPostString("con");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.DesignSelfMemo = con;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void ins_erp_designprice()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- int uid = CurrentUser.UserID;
- string userName = CurrentUser.UserName;
- CeErpTradeCell entity = null;
- CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entitys == null)
- {
- entitys = new CeErpDesignerBill();
- }
- if (entity != null)
- {
- entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
- //entity.Number = Convert.ToInt32(GetPostString("number"));
- entity.StartDesignTime = DateTime.Now;
- entity.OrderState = 4;
- string suname = "";
- if (entity.SupplierId == 0)
- {
- int sid = commonHelper.autoDistributeToSupplier(entity);
- entity.SupplierId = sid;
- suname = commonHelper.getSupplierNameById(entity.SupplierId);
- }
- entity.Update();
- CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
- if (ceErpUserPost != null)
- {
- CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
- if (ceErpPost != null)
- {
- if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
- {
- entitys.tid = entity.ctid;
- entitys.oid = entity.tid;
- entitys.uid = uid;
- entitys.userName = userName;
- entitys.designerType = 1;
- entitys.designerTypeText = "内部设计师";
- entitys.price = Convert.ToDouble(GetPostString("price"));
- entitys.designNum = GetPostInt("designNum");
- entitys.modifyNum = GetPostInt("modifyNum");
- entitys.designSize = GetPostString("designSize");
- entitys.modifySize = GetPostString("modifySize");
- if (CeErpDesignerBill.GetByTid("ctid") == null)
- {
- entitys.create_time = DateTime.Now;
- entitys.create_u_id = uid;
- entitys.create_u_name = userName;
- entitys.Save();
- }
- else
- {
- entitys.update_time = DateTime.Now;
- entitys.update_u_id = uid;
- entitys.update_u_name = userName;
- entitys.Update();
- }
- }
- }
- }
- commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
- LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
- if (suname != "")
- {
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- }
- commonHelper.getCytPrice(entity);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upload_erp_filecomplete()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 5; //设计完成
- entity.Update();
- returnSuccessMsg(eid + "上传成功,设计完成!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_designovertimelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string ResponsibleMan = GetPostString("responsible");
- if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- lw.Add(string.Format("UnusualTag=3"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "WaitDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //设计管理 获取抢单大厅列表
- public void get_erp_grabinglist()
- {
- int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
- DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
- bool oldOrder = false;
- if (org != null)
- {
- oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
- }
- string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
- sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
- //先处理订单数据
- if (dt.Rows.Count > 0)
- {
- Dictionary<string, int> design = null;
- int count = 0;
- foreach (DataRow row in dt.Rows)
- {
- if (map.ContainsKey(row["ShopId"].ToString()))
- {
- map.TryGetValue(row["ShopId"].ToString(), out design);
- }
- else
- {
- design = new Dictionary<string, int>();
- }
- if (design.ContainsKey(row["ProductId"].ToString()))
- {
- design.TryGetValue(row["ProductId"].ToString(), out count);
- }
- count++;
- design[row["ProductId"].ToString()] = count;
- map[row["ShopId"].ToString()] = design;
- }
- }
- sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
- DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //把店铺排序和技能排序分类
- Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
- Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
- if (design_dt.Rows.Count > 0)
- {
- Dictionary<string, string> design = null;
- List<string> shopIds = null;
- foreach (DataRow row in design_dt.Rows)
- {
- if ("0".Equals(row["designId"].ToString()))
- {
- if (shop_orders.ContainsKey(row["orders"].ToString()))
- {
- shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
- }
- else
- {
- shopIds = new List<string>();
- }
- shopIds.Add(row["shopId"].ToString());
- shop_orders[row["orders"].ToString()] = shopIds;
- }
- else
- {
- if (design_orders.ContainsKey(row["shopId"].ToString()))
- {
- design_orders.TryGetValue(row["shopId"].ToString(), out design);
- }
- else
- {
- design = new Dictionary<string, string>();
- }
- design[row["orders"].ToString()] = row["designId"].ToString();
- design_orders[row["shopId"].ToString()] = design;
- }
- }
- //处理成key value后根据key排序
- shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- foreach (List<string> val in shop_orders.Values)
- {
- if (val != null)
- {
- foreach (string key in val)
- {
- if (design_orders.ContainsKey(key.ToString()))
- {
- design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
- }
- }
- }
- }
- }
- //校验哪个优先级有订单
- Dictionary<string, string> designIds = new Dictionary<string, string>();
- foreach (string key in shop_orders.Keys)
- {
- List<string> ids = null;
- shop_orders.TryGetValue(key, out ids);
- //id为shopid
- foreach (string id in ids)
- {
- Dictionary<string, int> list = null;
- Dictionary<string, string> desing = null;
- map.TryGetValue(id, out list);
- design_orders.TryGetValue(id, out desing);
- if (list != null && desing != null)
- {
- foreach (var item in desing)
- {
- int count = 0;
- if (list.ContainsKey(item.Value))
- {
- list.TryGetValue(item.Value, out count);
- if (count > 0)
- {
- designIds[id] = item.Value;
- break;
- }
- }
- }
- }
- }
- if (designIds.Count > 0)
- {
- break;
- }
- }
- DataTable table = new DataTable();
- table.Columns.Add("tid", typeof(string));
- table.Columns.Add("ctid", typeof(string));
- table.Columns.Add("seller_nick", typeof(string));
- table.Columns.Add("productName", typeof(string));
- table.Columns.Add("pay_time", typeof(string));
- table.Columns.Add("seller_memo", typeof(string));
- if (designIds.Count > 0)
- {
- string shopId = "";
- string productId = "";
- foreach (var designInfo in designIds)
- {
- shopId = designInfo.Key;
- productId = designInfo.Value;
- CeErpShop ceErpShop = CeErpShop.Get(shopId);
- CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow row in dt.Rows)
- {
- if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
- {
- DataRow data = table.NewRow();
- data["ctid"] = row["ctid"].ToString();
- data["tid"] = row["tid"].ToString();
- data["seller_nick"] = ceErpShop.ShopName;
- data["pay_time"] = row["pay_time"].ToString();
- data["seller_memo"] = row["seller_memo"].ToString();
- data["productName"] = ceErpProduct.PType;
- table.Rows.Add(data);
- }
- }
- }
- }
- }
- writeGridDataTableJson(table.Rows.Count, table);
- }
- private object rushLockObject = new object();
- public void set_erp_grabingorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- int total = CurrentUser.User.Person.Total;
- int userId = CurrentUser.User.ID;
- int noFinish = CurrentUser.User.Person.NoFinish;
- int finalization = CurrentUser.User.Person.Finalization;
- string eids = GetPostString("ctid");
- string key = "RushKey_" + userId;
- int count = 0;
- if (erpRedis.RedisHelper.KeyExists(key))
- {
- string redisCount = erpRedis.RedisHelper.StringGet(key);
- if (redisCount != null)
- {
- count = Convert.ToInt32(redisCount);
- }
- }
- if (count >= total)
- {
- returnErrorMsg("半小时内已经抢" + total + "单");
- return;
- }
- string[] ctidlist = eids.Split(',');
- if (count + ctidlist.Length > total)
- {
- returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
- return;
- }
- int itag = 0;
- lock (rushLockObject)
- {
- if (ctidlist.Length > 0)
- {
- string[] dtList = new string[ctidlist.Length];
- for (int i = 0; i < ctidlist.Length; i++)
- {
- dtList[i] = "'" + ctidlist[i] + "'";
- }
- 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"));
- DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
- if (dt_user.Rows.Count > 0)
- {
- int doing = 0;//未定稿
- int finish = 0;//已完成
- foreach (DataRow dr in dt_user.Rows)
- {
- if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
- {
- doing++;
- }
- else
- {
- finish++;
- }
- }
- if (doing >= noFinish)
- {
- returnErrorMsg(doing + "未定稿数量,无法继续抢单");
- return;
- }
- if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
- {
- returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
- return;
- }
- }
- //校验选择单子状态
- string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt.Rows.Count > 0)
- {
- List<string> list = new List<string>();
- foreach (DataRow dr in dt.Rows)
- {
- if (Convert.ToInt32(dr["OrderState"]) != 2)
- {
- list.Add(dr["ctid"].ToString());
- }
- }
- if (list.Count > 0)
- {
- returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
- return;
- }
- }
- foreach (string ctid in ctidlist)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.OrderState = 3;
- entity.DesignUserId = CurrentUser.UserID;
- entity.WaitDesignTime = DateTime.Now;
- entity.StartDesignTime = DateTime.Now;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
- itag++;
- }
- }
- }
- }
- count += ctidlist.Length;
- erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
- if (itag == 0)
- returnErrorMsg("没有找到相关订单");
- else
- returnSuccessMsg("抢单成功!");
- return;
- }
- }
- public void get_erp_waitorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string address = GetPostString("address");
- 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));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("OrderState = 5 "));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- string pagesize = GetPostString("pagesize");
- if (pagesize != null)
- {
- dStruct.PageSize = 200;
- }
- DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- entity.Update();
- }
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_supplierwaitorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- lw.Add(string.Format("OrderState = 5 "));
- lw.Add(string.Format("IsVerifyToSupplier=1"));
- if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- string supplier = GetPostString("supplier");
- if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
- {
- lw.Add(string.Format("SupplierName = '{0}'", supplier));
- }
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_verifytosupplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- CeErpTradeCell entity = null;
- string[] eidsList = eids.Split(',');
- if (eidsList.Length <= 0)
- {
- returnErrorMsg("订单号不能空");
- return;
- }
- List<string> tLst = new List<string>();
- foreach (string ctidstr in eidsList)
- {
- tLst.Add("'" + ctidstr + "'");
- CeErpDataSendOrderInfo.createObject(ctidstr);
- }
- string needtids = string.Join(",", tLst.ToArray());
- StringBuilder sql = new StringBuilder();
- //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
- sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
- sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("操作成功!");
- return;
- /**foreach (string ctidstr in eidsList)
- {
- entity = CeErpTradeCell.GetByCtid(ctidstr);
- if (entity != null)
- {
- if (entity.SupplierId == 0)
- {
- continue;
- }
- entity.IsVerifyToSupplier = true;
- if (entity.IsReturn == 1) //1是供应商打回
- {
- entity.IsReturn = 0;
- }
- entity.FinishPlaceTime = DateTime.Now;
- entity.PlaceUserId = CurrentUser.UserID;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;**/
- }
- }
- public void upd_erp_supplierback()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
- {
- string key = "return_order_" + entity.SupplierId;
- List<string> list = new List<string>();
- if (RedisHelper.HasKey(key))
- {
- object data = RedisHelper.StringGet(key);
- list = Convert.ToString(data).Split(',').ToList();
- }
- list.Add(eid);
- RedisHelper.StringSet(key, string.Join(",", list));
- }
- entity.IsVerifyToSupplier = false;
- entity.IsReturn = 1;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- if (entity.OrderState == 6)
- {
- entity.OrderState = 5;
- }
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_toaftersaleorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.isAfterSaleOrder != 1)
- {
- returnErrorMsg("带S的售后单才能打回给售后");
- return;
- }
- if (entity.OrderState >= 5)
- {
- returnErrorMsg("已经设计完成了不能打回给售后");
- return;
- }
- entity.OrderState = 0;
- entity.IsReturn = 3;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_aftersaletodesign()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 3;
- entity.IsReturn = 0;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void assign_erp_supplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- int sid = GetPostInt("SupplierName");
- string fromTag = GetPostString("tag");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("指派不能为空");
- return;
- }
- string errMsg = "";
- string suname = commonHelper.getSupplierNameById(sid);
- foreach (string ctid in eidList)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if (fromTag == "waitingorder" && entity.OrderState >= 6)
- {
- errMsg += (ctid + "指派失败!!!");
- continue;
- }
- entity.SupplierId = sid;
- entity.Update();
- commonHelper.UpdateRelationOrder(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
- if (entity.OrderState >= 6)
- {
- //if (entity.MakeSupplier.IndexOf(",") != -1)
- //{
- // string msl = entity.MakeSupplier;
- // string[] mslist = msl.Split(',');
- // 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);
- // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- //}
- //else
- //{
- StringBuilder sql = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- //}
- }
- }
- else
- {
- continue;
- }
- }
- if (errMsg.Length > 0)
- {
- returnErrorMsg(errMsg);
- return;
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void assign_erp_makesupplier()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string sname = GetPostString("SupplierName");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("指派不能为空");
- return;
- }
- List<string> tLst = new List<string>();
- foreach (string ctid in eidList)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.MakeSupplier = sname;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
- tLst.Add("'" + ctid + "'");
- }
- else
- {
- continue;
- }
- }
- string ctids = string.Join(",", tLst.ToArray());
- StringBuilder sql2 = new StringBuilder();
- sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void ins_erp_returnreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- string userpost = CurrentUser.UserPost.Post.Code;
- if (entity != null)
- {
- bool isPlace = false;
- if (entity.OrderState > 6)
- {
- returnErrorMsg("已发货无法打回!");
- return;
- }
- if (entity.OrderState == 6)
- {
- isPlace = true;
- }
- bool isNeedUpdateCell2 = false;
- if (entity.OrderState >= 6)
- {
- isNeedUpdateCell2 = true;
- }
- int returnTag = 2;
- if (userpost == "Supplier")
- {
- returnTag = 1;
- }
- int toType = GetPostInt("totype");
- string fromType = "3";
- if (entity.OrderState < 5)
- {
- fromType = "3";
- }
- else
- {
- fromType = "4";
- }
- if (entity.IsXianHuo == 0)
- {
- if (returnTag == 2)
- {
- if (toType == 1)
- {
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- string clearman = GetPostString("clearman");
- if (!string.IsNullOrEmpty(clearman))
- {
- entity.DesignUserId = 0;
- }
- }
- else
- {
- entity.OrderState = 3;
- entity.ReturnUserType = 2;
- }
- entity.IsReadTag = 1;
- }
- else if (returnTag == 1)
- {
- entity.OrderState = 5;
- }
- entity.IsVerifyToSupplier = false;
- }
- if (entity.IsXianHuo == 1)
- {
- entity.OrderState = 5;
- }
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = returnTag;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = GetPostString("returnreason");
- entity.Update();
- if (entity.OrderState == 3)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "rebutDesign";
- apiVo.orderRemarks = entity.ReturnReason;
- designHelper.API_WorkCore(apiVo);//rebutDesign
- }
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
- {
- dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
- }
- CeErpSukuraData.createInfo(entity.ctid, 5);
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
- if (isPlace)
- {
- string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dth != null && dth.Rows.Count > 0)
- {
- dataSendOrderBean dataSendOrderBean = null;
- foreach (DataRow item in dth.Rows)
- {
- try
- {
- dataSendOrderBean = new dataSendOrderBean();
- dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
- dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
- dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
- dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
- dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
- dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
- dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
- dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
- dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
- dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
- dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
- dataSendOrderBean.Radio1723534706288 = "打回";
- dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
- if (result != null)
- {
- if ("0".Equals(result.errcode))
- {
- CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
- }
- else
- {
- CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
- if (isNeedUpdateCell2)
- {
- if (entity.MakeSupplier.IndexOf(",") != -1)
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- else
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void cyt_erp_returnreason()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- string userpost = CurrentUser.UserPost.Post.Code;
- if (entity != null)
- {
- if (entity.OrderState > 6)
- {
- returnErrorMsg("已发货无法打回!");
- return;
- }
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "Pwd", "lt666888" },
- { "LTOrderId",eid }
- };
- string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg != "取消成功")
- {
- returnErrorMsg(msg);
- return;
- }
- bool isNeedUpdateCell2 = false;
- if (entity.OrderState >= 6)
- {
- isNeedUpdateCell2 = true;
- }
- int returnTag = 2;
- if (userpost == "Supplier")
- {
- returnTag = 1;
- }
- if (entity.IsXianHuo == 0)
- {
- if (returnTag == 2)
- {
- int toType = GetPostInt("totype");
- if (toType == 1)
- {
- entity.OrderState = 0;
- entity.ReturnUserType = 1;
- }
- else
- {
- entity.OrderState = 4;
- entity.ReturnUserType = 2;
- }
- entity.IsReadTag = 1;
- }
- else if (returnTag == 1)
- {
- entity.OrderState = 5;
- }
- entity.IsVerifyToSupplier = false;
- }
- entity.UnusualTag = 0;
- entity.UnusualTime = null;
- entity.UnusualCon = "";
- entity.IsReturn = returnTag;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = GetPostString("returnreason");
- entity.Update();
- if (entity.OrderState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "rebutDesign";
- apiVo.orderRemarks = entity.ReturnReason;
- designHelper.API_WorkCore(apiVo);//rebutDesign
- }
- CeErpSukuraData.createInfo(entity.ctid, 5);
- apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
- if (isNeedUpdateCell2)
- {
- if (entity.MakeSupplier.IndexOf(",") != -1)
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- else
- {
- StringBuilder sql2 = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_xianhuoreturntag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eids = GetPostString("ctid");
- string[] ctids = eids.Split(',');
- foreach (string ctid in ctids)
- {
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.IsReturn = 0;
- entity.Update();
- CeErpSukuraData.createInfo(entity.ctid, 5);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_waitdeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
- lw.Add(string.Format("type != 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.RemoveAt(0);
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_changedeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string otherMemo = GetPostString("otherMemo");
- if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
- lw.Add(string.Format("type != 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.RemoveAt(0);
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_pddderiving()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
- lw.Add(string.Format("type = 'PDD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.RemoveAt(0);
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_jdderiving()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("type = 'JD' "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_demoorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- //lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("IsSample={0}", 3));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void save_erp_checkmemo()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- entity.CheckMemo = GetPostString("CheckMemo");
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
- returnSuccessMsg("保存成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_returnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsReturn>0"));
- lw.Add(string.Format("IsXianHuo=0"));
- lw.Add(string.Format("IsReturn!=3"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_today_sumreturn()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string bdate1 = GetPostString("returnTimeS");
- string bdate2 = GetPostString("returnTimeE");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- lw.Add(string.Format("IsReturn=0"));
- lw.Add(string.Format("IsXianHuo=0"));
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "";
- if (dw_back.Length > 0)
- {
- sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
- }
- else
- {
- 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 + "'";
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- decimal total = 0, today_finish = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["total"]);
- }
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
- {
- today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
- }
- var res = new
- {
- data = total,
- data1 = today_finish,
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_allreturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string backreason = GetPostString("backreason");
- if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
- lw.Add(string.Format("IsXianHuo=0"));
- lw.Add(string.Format("ReturnTime != ''"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- dStruct.Order = "FinishDesignTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_aftersalereturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string bdate1 = GetPostString("backdate1");
- string bdate2 = GetPostString("backdate2");
- string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
- if (dw_back.Length > 0) lw.Add(dw_back);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- lw.Add(string.Format("IsReturn=3"));
- string backtype = GetPostString("backtype");
- if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
- string backreason = GetPostString("backreason");
- if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
- dStruct.Order = "ReturnTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_xianhuoreturnlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState=6 "));
- lw.Add(string.Format("IsXianHuo=1 "));
- lw.Add(string.Format("IsReturn>0 "));
- lw.Add(string.Format("IsReturn!=3"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_orderdelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.OrderState >= 7)
- {
- returnErrorMsg("此单已发货,无需重复发货");
- return;
- }
- if (entity.OrderState != 6)
- {
- returnErrorMsg("此单状态为非【下单完成】,无法发货");
- return;
- }
- string shop = GetPostString("seller_nick");
- //string sessionkey = taobaoHelper.ShopKeyDics[shop];
- string comName = GetPostString("comName");
- string comCode = GetPostString("comCode");
- string outSid = GetPostString("outSid");
- string deliveryType = GetPostString("deliveryType");
- string deliveryMemo = GetPostString("deliveryMemo");
- outSid = outSid.Trim();
- CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
- if (mainEn == null)
- {
- returnErrorMsg("找不到原始订单记录");
- return;
- }
- bool isInitOrderDeliv = false;
- if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
- {
- isInitOrderDeliv = true;
- }
- string apires = "";
- string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
- 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)
- {
- apires = "发货成功true";
- }
- else
- {
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
- apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
- }
- if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
- {
- entity.OrderState = 7;//发货后订单已发货
- entity.OutSid = outSid;
- entity.MemoOpt = 0;
- entity.FinishDeliveryTime = DateTime.Now;
- entity.Update();
- commonHelper.aftersaleSend(entity.ctid, comName, outSid);
- commonHelper.UpdateRelationOrder(entity.ctid);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = eid;
- exinfo.out_sid = outSid;
- exinfo.company_code = comCode;
- exinfo.company_name = comName;
- exinfo.delivery_memo = deliveryMemo;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = deliveryType;
- exinfo.Create();
- returnSuccessMsg("发货操作成功!");
- commonHelper.UpdateRelationOrder(entity.ctid);
- commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
- CeErpSukuraData.createInfo(entity.ctid, 4);
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
- }
- else
- {
- string errmsg = commonHelper.KeepChinese(apires);
- returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
- XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
- }
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void set_erp_multidelivery()
- {
- string eids = GetPostString("tids");
- string[] eidList = eids.Split(',');
- if (eidList.Length <= 0)
- {
- returnErrorMsg("发货不能为空");
- return;
- }
- foreach (string ctid in eidList)
- {
- if (ctid.Length <= 0) continue;
- CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
- if (expInfo != null)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
- {
- expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
- expInfo.state = "异常";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- continue;
- }
- if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
- {
- expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
- expInfo.state = "异常";
- expInfo.Update();
- continue;
- }
- //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
- bool isInitOrderDeliv = false;
- if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
- {
- isInitOrderDeliv = true;
- expInfo.isMultiDelivery = 1;
- }
- if (ctid.IndexOf("N") != -1)
- {
- StringBuilder sqlbucha = new StringBuilder();
- sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
- CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
- LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
- commonHelper.UpdateRelationOrder(ctid);
- expInfo.delivery_memo = "发货成功";
- expInfo.state = "发货成功";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- }
- else
- {
- string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
- string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
- if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
- {
- expInfo.delivery_memo = "发货成功";
- expInfo.state = "发货成功";
- expInfo.isMultiDelivery = 1;
- expInfo.Update();
- commonHelper.UpdateRelationOrder(ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
- LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
- }
- else
- {
- expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
- expInfo.state = "异常";
- expInfo.Update();
- }
- }
- }
- }
- }
- returnSuccessMsg("操作完成");
- }
- public void reset_erp_memoopt()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string stropt = "";
- if (entity.MemoOpt == 1)
- {
- stropt = "“改稿”";
- }
- else if (entity.MemoOpt == 2)
- {
- stropt = "“定稿”";
- }
- else if (entity.MemoOpt == 3)
- {
- stropt = "“完成查货”";
- CeErpSukuraData.createInfo(entity.ctid, 6);
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
- entity.MemoOpt = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_deliveryunusual()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6"));
- lw.Add(string.Format("UnusualTag = 5"));
- lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_deliveryedlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string logistics = GetPostString("logistics");
- if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /*if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- if (dt != null)
- {
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_pdddeliveryed()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string logistics = GetPostString("logistics");
- if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("type = 'PDD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- /* if (tid.Length > 0)
- {
- List<string> tids = new List<string>();
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow item in dt.Rows)
- {
- tids.Add("'" + item["tid"] + "'");
- }
- }
- if (tids.Count > 0)
- {
- lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
- lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_erptradecell", dStruct);
- }
- }*/
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_jddeliveryed()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string devdate1 = GetPostString("deliverydate1");
- string devdate2 = GetPostString("deliverydate2");
- string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
- if (dw_dev.Length > 0) lw.Add(dw_dev);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("ctid like '%{0}%'", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- }
- else
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
- lw.Add(string.Format("type = 'JD' "));
- lw.Add(string.Format("IsRefund!={0}", 2));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_allplacelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string pldate1 = GetPostString("placedate1");
- string pldate2 = GetPostString("placedate2");
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
- {
- if (tid.Length > 0)
- lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- if (buyernick.Length > 0)
- lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- }
- else
- {
- if (ex_psize <= 0) //非导出的时候 显示3个月数据
- {
- lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
- }
- }
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState >= 6"));
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("isDianziOrder = 0 "));
- //lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_financeallplacelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string pldate1 = GetPostString("placedate1");
- string pldate2 = GetPostString("placedate2");
- string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
- if (dw_place.Length > 0) lw.Add(dw_place);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- //lw.Add(string.Format("OrderState >= 6"));
- lw.Add(string.Format("IsSample != 2 "));
- lw.Add(string.Format("isDianziOrder = 0 "));
- //lw.Add(string.Format("IsRefund<={0}", 1));
- dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
- foreach (DataRow dr in dt.Rows)
- {
- 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();
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_expresslist()
- {
- int listtype = GetInt("ltype");
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string outsid = GetPostString("out_sid");
- if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
- string importer = GetPostString("ImportUserName");
- if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
- string file = GetPostString("import_file");
- if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
- string printman = GetPostString("printman");
- if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string fdate1 = GetPostString("finishdate1");
- string fdate2 = GetPostString("finishdate2");
- string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string supplierId = GetPostString("supplierId");
- if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
- if (listtype == 1)
- {
- lw.Add(string.Format("importUserId !=0"));
- }
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- if (dStruct.PageSize != 100000)
- {
- dStruct.Order = "isMultiDelivery asc, import_time desc";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void set_erp_buchaorderdelivery()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSample != 2)
- {
- returnErrorMsg("补差价单才能标记为已发货");
- return;
- }
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
- entity.OrderState = 7;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_stdtemplates()
- {
- //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
- //string res = taobaoHelper.test();
- string res = apiHelper.API_PrintTemplate();
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
- {
- int sidx = res.IndexOf("error_code");
- int eidx = res.IndexOf("success");
- string msg = res.Substring(sidx, eidx - sidx);
- returnErrorMsg(msg);
- return;
- }
- if (res.Length <= 0)
- {
- returnErrorMsg("模板数据为空!");
- return;
- }
- ReturnSuccess(res);
- }
- public void cancel_print_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- string res = "";
- string code = entity.LastBillWaybillCode;
- if (code == "")
- {
- code = entity.OutSid;
- }
- res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
- XLog.SaveLog(0, "取消面单" + res);
- }
- }
- }
- public void set_erp_printwaybill()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
- string cpName = GetPostString("cpname");
- string isTogether = GetPostString("together");
- //var res_obj = new
- //{
- // restype = 1,
- // 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\"}"
- //};
- //string ro_json = JsonConvert.SerializeObject(res_obj);
- //ReturnSuccess(ro_json);
- //return;
- bool isUseLastWayBillCode = false;
- CeErpTradeCell entity = null;
- if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
- {
- isUseLastWayBillCode = true;
- }
- if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
- {
- returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
- return;
- }
- }
- string res = "";
- Api_waybill_code_response_Obj fullObj = null;
- string pData_str = "";
- string curUseWayBillCode = "";
- if (isUseLastWayBillCode == false)
- {
- res = apiHelper.API_GetWaybill(cpCode, ctid);
- //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
- if (res.IndexOf("failure") != -1)
- {
- //int idx = res.IndexOf("sub_message");
- //int idx2 = res.IndexOf("flag");
- //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
- string errMsgNeed = commonHelper.KeepChinese(res);
- var res_objd = new
- {
- restype = 0,
- data = "获取面单失败" + errMsgNeed
- };
- string ro_jsond = JsonConvert.SerializeObject(res_objd);
- returnSuccess(ro_jsond);
- if (res.IndexOf("停发") != -1)
- {
- entity.UnusualCon = "物流停发";
- entity.Update();
- }
- //returnErrorMsg("获取面单失败,"+emsg);
- XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
- return;
- }
- else if (res.IndexOf("errorMsg") != -1)
- {
- //int idx = res.IndexOf("errorMsg");
- //int idx2 = res.IndexOf("}]}");
- //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
- string errMsgNeed = commonHelper.KeepChinese(res);
- var res_objf = new
- {
- restype = 0,
- data = "获取面单失败2" + errMsgNeed
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- if (res.IndexOf("停发") != -1)
- {
- entity.UnusualCon = "物流停发";
- entity.Update();
- CeErpTrade trade = CeErpTrade.Get(entity.tid);
- if (trade != null)
- {
- string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
- }
- }
- returnSuccess(ro_jsonf);
- //returnErrorMsg("获取面单失败," + emsg);
- XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
- return;
- }
- try
- {
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- //res = res.Replace(" ", "");
- fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "生成fullObj" + res);
- var res_objf = new
- {
- restype = 0,
- data = "生成fullObj发生错误" + ex.Message
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- returnSuccess(ro_jsonf);
- return;
- }
- if (fullObj.response.data.content.Count > 0)
- {
- ContentItem codeObj = fullObj.response.data.content[0];
- if (cpCode.IndexOf("SFFQ-") != -1)
- {
- pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
- }
- else
- pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
- curUseWayBillCode = codeObj.waybillCode;
- }
- else
- {
- XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
- var res_objf = new
- {
- restype = 0,
- data = "生成fullObj找不到快递单号waybillCode"
- };
- string ro_jsonf = JsonConvert.SerializeObject(res_objf);
- returnSuccess(ro_jsonf);
- return;
- }
- }
- else
- {
- //使用上次打印的快递单号
- if (cpCode == "SFFQ-LY")
- {
- pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
- }
- else
- pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
- curUseWayBillCode = entity.LastBillWaybillCode;
- }
- if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
- {
- var res_obje = new
- {
- restype = 0,
- data = "获取加密打印数据失败"
- };
- string ro_jsone = JsonConvert.SerializeObject(res_obje);
- returnSuccess(ro_jsone);
- entity.LastBillCpCode = cpCode;
- entity.LastBillWaybillCode = curUseWayBillCode;
- entity.Update();
- XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
- //returnErrorMsg("获取加密打印数据失败");
- return;
- }
- //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
- //string msg = "{\"data\":\""+pageUrl+"\"}";
- string btnType = "";
- if (entity != null)
- {
- CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
- //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
- //cpcode是 YTO-CAINIAO
- //string comCode = cpCode.Split('-')[0].ToString();
- string apires = "";
- if (ctid.IndexOf("N") != -1)
- {
- apires = "发货成功";
- }
- else
- {
- apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
- }
- //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
- //打单后发货
- if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
- {
- try
- {
- btnType = "待发货";
- entity.OutSid = curUseWayBillCode;
- entity.OrderState = 7;
- entity.IsUrgency = false;
- entity.LastBillCpCode = "";
- entity.LastBillWaybillCode = "";
- entity.FinishDeliveryTime = DateTime.Now;
- entity.IsReturn = 0;
- entity.MemoOpt = 0;
- entity.Update();
- commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
- //还要插入快递信息到 快递信息表
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = entity.OutSid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(entity.ctid);
- CeErpSukuraData.createInfo(ctid, 4);
- commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- if (isTogether == "1")
- {
- StringBuilder sqlsb = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
- }
- }
- else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
- {
- entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
- if (entity.OrderState == 6)
- {
- entity.OrderState = 7;
- }
- entity.FinishDeliveryTime = DateTime.Now;
- btnType = "已发货";
- entity.Update();
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = entity.OutSid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- commonHelper.UpdateRelationOrder(entity.ctid);
- CeErpSukuraData.createInfo(entity.ctid, 4);
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- if (isTogether == "1")
- {
- StringBuilder sqlsb = new StringBuilder();
- 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);
- DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
- }
- //不处理
- }
- else
- {
- entity.LastBillCpCode = cpCode;
- entity.LastBillWaybillCode = curUseWayBillCode;
- entity.Update();
- string errmsg = commonHelper.KeepChinese(apires);
- var res_objz = new
- {
- restype = 0,
- data = "打单后发货失败"
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
- XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
- return;
- }
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
- var res_obj = new
- {
- restype = 1,
- data = pData_str
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- ReturnSuccess(ro_json);
- return;
- }
- }
- private string GetUTF8String(byte[] vs)
- {
- throw new NotImplementedException();
- }
- public void set_erp_printwaybill_cn()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- string cpCode = GetPostString("cpcode");
- string cpName = GetPostString("cpname");
- string tempUrl = GetPostString("tempurl");
- //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
- string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
- //string res = taobaoHelper.test();
- res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
- {
- int sidx = res.IndexOf("errorMsg");
- int eidx = res.IndexOf("}");
- string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
- var res_objzxx = new
- {
- restype = 0,
- data = msg
- };
- string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
- returnSuccess(ro_jsonzxx);
- //returnErrorMsg(msg);
- return;
- }
- int idx = res.IndexOf("waybillCode");
- int idx2 = res.IndexOf("printData");
- string outsid = res.Substring(idx + 14, idx2 - idx - 17);
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string osid = entity.OutSid;
- entity.OutSid = osid + "," + outsid;
- entity.FinishDeliveryTime = DateTime.Now;
- entity.OrderState = 7;
- entity.IsReturn = 0;
- entity.Update();
- CeErpExpressInfo exinfo = new CeErpExpressInfo();
- exinfo.tid = entity.ctid;
- exinfo.out_sid = outsid;
- exinfo.company_code = cpCode;
- exinfo.company_name = cpName;
- exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
- exinfo.deliveryType = "发货成功";
- exinfo.print_time = DateTime.Now;
- exinfo.printUser = CurrentUser.UserName;
- exinfo.Create();
- if (entity.SupplierId == 64)
- {
- commonHelper.sendCytExpress(exinfo);
- }
- //CeErpDataSendOrderInfo.createObject(entity.ctid);
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
- var res_objz = new
- {
- restype = 1,
- data = res
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- //ReturnSuccess(res);
- }
- }
- ////打单,打印面单 获取面单号
- //public void set_erp_printwaybill()
- //{
- // if (UrlPostParmsCheck("ctid"))
- // {
- // string ctid = GetPostString("ctid");
- // string cpCode = GetPostString("cpcode");
- // string tempUrl = GetPostString("tempurl");
- // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
- // //string res = taobaoHelper.test();
- // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
- // if (res.IndexOf("error_response") != -1)
- // {
- // int sidx = res.IndexOf("sub_msg");
- // int eidx = res.IndexOf("request_id");
- // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
- // returnErrorMsg(msg);
- // return;
- // }
- // int idx = res.IndexOf("waybill_code");
- // int idx2 = res.IndexOf("}]}");
- // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
- // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
- // ReturnSuccess(res);
- // }
- //}
- public void cancel_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- //有过处理的售后,取消也不能删除 售 字,保留
- if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
- {
- entity.AfterSaleState = 4;
- }
- else
- entity.AfterSaleState = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_aftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = GetInt("st");
- string tid = GetPostString("ctid");
- if (st == 3)
- {
- if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
- }
- else
- {
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string posCode = CurrentUser.UserPost.Post.Code;
- //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
- //{
- // string vstate = GetPostString("vstate");
- // if (vstate.Length > 0)
- // {
- // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- // }
- // if (posCode == "Supplier")
- // {
- // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- // }
- // else
- // {
- // lw.Add(string.Format("AfterSaleState = {0}", st));
- // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
- // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
- // {
- // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
- // }
- // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
- // {
- // int orgid = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
- // }
- // else if (CurrentUser.UserPost.Post.Code == "Director")
- // {
- // string shopid = CurrentUser.User.pemShop;
- // lw.Add(string.Format("shopId in ({0})", shopid));
- // }
- // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
- // //{
- // // int org_id = CurrentUser.UserPost.OrgID;
- // // lw.Add(string.Format("OrgID={0}", org_id));
- // //}
- // dStruct.Order = "IsArbitrate desc, createdTime desc";
- // }
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- if (st == 5)
- {
- if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
- {
- if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
- {
- int mrOrgid = CurrentUser.UserPost.OrgID;
- lw.Add(string.Format("DesOrgID={0}", mrOrgid));
- lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
- }
- //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
- //{
- // int mrOrgid = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
- //}
- else
- {
- string userIdStr = "";
- if (posCode == "CustomerService")
- {
- userIdStr = CurrentUser.UserID + "_k";
- }
- else if (posCode == "Designer" || posCode == "wxDesigner")
- {
- userIdStr = CurrentUser.UserID + "_s";
- }
- else if (posCode == "Place")
- {
- userIdStr = CurrentUser.UserID + "_x";
- }
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
- }
- }
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (dwplace.Length > 0) lw.Add(dwplace);
- string supState = GetPostString("supState");
- if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
- string searchType = GetPostString("searchType");
- if (searchType.Length > 0 && "moreBack".Equals(searchType))
- {
- lw.Add(string.Format("BackNum>1"));
- }
- lw.Add(string.Format("AfterSaleState>0"));
- if (ex_psize > 0)
- {
- if (CurrentUser.UserPost.Post.Code == "Finance")
- dStruct.Order = "pay_time desc";
- else
- dStruct.Order = "HandleTime desc";
- }
- else
- dStruct.Order = "HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_test", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
- //{
- // lw.Add(string.Format("AfterSaleState=4"));
- // string code = CurrentUser.UserPost.Post.Code;
- // if (code == "CustomerService")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
- // }
- // else if (code == "Designer" || code == "DesignerMr")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
- // }
- // else if (code == "Place" || code == "PlaceMr")
- // {
- // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
- // }
- // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- //else //处理中的售后,待处理和处理中合并
- //{
- // if (afterState.Length <= 0)
- // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- }
- public void get_erp_disagreeftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string backdate1 = GetPostString("backdate1");
- string backdate2 = GetPostString("backdate2");
- string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
- if (backDate.Length > 0) lw.Add(backDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string aftersakereason = GetPostString("aftersakereason");
- if (aftersakereason.Length > 0)
- {
- if (aftersakereason == "1")
- {
- lw.Add(string.Format("AfterSaleResSupId > 0"));
- }
- if (aftersakereason == "2")
- {
- lw.Add(string.Format("AfterSaleResSupId = 0"));
- }
- }
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- string searchType = GetPostString("searchType");
- if (searchType == "wait")
- {
- lw.Add(string.Format("HandleTime is null"));
- }
- if (searchType == "handling")
- {
- lw.Add(string.Format("HandleTime is not null "));
- }
- if (searchType == "back" || searchType == "puBack")
- {
- lw.Add(string.Format("AfterSaleBackReason != ''"));
- }
- if (searchType == "reBack")
- {
- lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
- }
- if (searchType == "moreBack")
- {
- lw.Add(string.Format("backNum > 1"));
- }
- lw.Add(string.Format("(AfterSaleState=5)"));
- dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_handlingaftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string afterresult = GetPostString("afterresult");
- if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- string searchType = GetPostString("searchType");
- if (searchType == "wait")
- {
- lw.Add(string.Format("HandleTime is null"));
- }
- if (searchType == "documentary")
- {
- lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
- }
- if (searchType == "handling")
- {
- lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
- }
- if (searchType == "back" || searchType == "puBack")
- {
- lw.Add(string.Format("AfterSaleBackReason != ''"));
- }
- if (searchType == "reBack")
- {
- lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
- }
- if (afterState.Length <= 0)
- {
- lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- }
- dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
- //public void get_erp_back_handlingaftersalelist()
- //{
- // DataStruct dStruct = GetPostStruct();
- // List<string> lw = new List<string>();
- // string tid = GetPostString("ctid");
- // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- // string shopname = GetPostString("shopname");
- // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- // string buyernick = GetPostString("buyer_nick");
- // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- // string sellermemo = GetPostString("seller_memo");
- // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- // string orderState = GetPostString("orderState");
- // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- // string afterState = GetPostString("afterstate");
- // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- // string date1 = GetPostString("date1");
- // string date2 = GetPostString("date2");
- // string dw = GetDateMinuteWhere("pay_time", date1, date2);
- // if (dw.Length > 0) lw.Add(dw);
- // string price1 = GetPostString("price1");
- // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- // string price2 = GetPostString("price2");
- // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- // //lw.Add(string.Format("IsRefund!={0}", 1));
- // string reason = GetPostString("reason");
- // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- // string method = GetPostString("method");
- // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- // string handler = GetPostString("handler");
- // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- // string handledate1 = GetPostString("handledate1");
- // string handledate2 = GetPostString("handledate2");
- // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- // string afterdate1 = GetPostString("afterdate1");
- // string afterdate2 = GetPostString("afterdate2");
- // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- // if (afterDate.Length > 0) lw.Add(afterDate);
- // string supplier = GetPostString("supplier");
- // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- // string responsible = GetPostString("responsibleman");
- // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- // string customer = GetPostString("customer");
- // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- // string design = GetPostString("design");
- // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- // string afterMemoType = GetPostString("aftermemotype");
- // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
- // if (afterState.Length <= 0)
- // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
- // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- public void get_erp_aftersaleverifylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string posCode = CurrentUser.UserPost.Post.Code;
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- if (posCode == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- lw.Add(string.Format("VerifyState = 0"));
- lw.Add("type = 1");
- lw.Add(string.Format("AfterSaleState={0}", 3));
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- else if (posCode == "logistics")
- {
- lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
- lw.Add(string.Format("VerifyState = 0"));
- lw.Add("type = 2");
- lw.Add(string.Format("AfterSaleState={0}", 3));
- dStruct.Order = "AfterSaleState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- else
- {
- lw.Add(string.Format("(AfterSaleState = 3)"));
- string reasonState = GetPostString("reasonState");
- lw.Add("type = 0");
- if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
- || posCode == "Summarize" || posCode == "Finance")
- {
- if (reasonState == "2")
- {
- lw.Add("VerifyState = 3");
- }
- else if (reasonState == "1")
- {
- lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
- }
- else
- {
- lw.Add("VerifyState in (0,3)");
- }
- //不加条件,可以看全部
- }
- 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")
- {
- int orgid = CurrentUser.UserPost.OrgID;
- string manageOrgId = CurrentUser.User.ManageOrgIds;
- if (string.IsNullOrEmpty(manageOrgId))
- {
- lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
- }
- if (reasonState == "1")
- {
- lw.Add("VerifyState = 3");
- }
- else if (reasonState == "2")
- {
- lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
- }
- else
- {
- }
- }
- else
- {
- lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
- }
- //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
- //{
- // int org_id = CurrentUser.UserPost.OrgID;
- // lw.Add(string.Format("OrgID={0}", org_id));
- //}
- dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- }
- public void get_erp_finishaftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 4;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- //lw.Add(string.Format("IsRefund!={0}", 1));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string finish1 = GetPostString("finishdate1");
- string finish2 = GetPostString("finishdate2");
- string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
- if (dwfinish.Length > 0) lw.Add(dwfinish);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- if ("3".Equals(vstate))
- {
- lw.Add(string.Format("IsTem=1"));
- }
- else
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- }
- lw.Add(string.Format("AfterSaleState=4"));
- string code = CurrentUser.UserPost.Post.Code;
- if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
- {
- //不加条件,可以看全部
- }
- else if (code == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- }
- else if (code == "logistics")
- {
- lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
- lw.Add("type = 2");
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- }
- 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")
- {
- int orgid = CurrentUser.UserPost.OrgID;
- string manageOrgIds = CurrentUser.User.ManageOrgIds;
- if (string.IsNullOrEmpty(manageOrgIds))
- {
- lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
- }
- }
- else
- {
- lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
- }
- dStruct.Order = "HandleTime desc,AfterSaleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void handle_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string responStr = GetPostString("AfterSaleResponsible");
- if (responStr.Length <= 0)
- {
- returnErrorMsg("售后责任人不能为空");
- return;
- }
- bool isDesign = false;
- double designFree = 0.00;
- int responsibleId = 0;
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- int isNeedNewOrder = GetPostInt("IsNewOrder");
- string afterMethod = GetPostString("AfterSaleMethod");
- if (isNeedNewOrder == 1)
- {
- CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
- bool ishav = true;
- if (newentity == null)
- {
- newentity = entity.Clone() as CeErpTradeCell;
- ishav = false;
- newentity.ctid = "S_" + entity.ctid;
- newentity.OrderState = 0;
- }
- //唯一标识
- newentity.OrderSn = newentity.ctid;
- /* string orderSn = dataHelper.getSaleOrderSn();
- if (orderSn != "")
- {
- newentity.OrderSn = orderSn;
- }*/
- newentity.AfterSaleState = 0;
- newentity.AfterSaleMethod = afterMethod;
- if (!ishav)
- {
- string memo_str = newentity.seller_memo;
- memo_str = memo_str.Replace("(", "(");
- memo_str = memo_str.Replace(")", ")");
- int sIndex = memo_str.IndexOf("(");
- int eIndex = memo_str.IndexOf(")");
- if (sIndex == -1 || eIndex == -1)
- {
- returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
- return;
- }
- string first = memo_str.Substring(0, sIndex + 1);
- string memoCtid = newentity.OrderSn;
- //if (memoCtid.IndexOf("C") != -1)
- //{
- //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
- //if (CIdx.IndexOf("+") != -1)
- //{
- //CIdx = "C" + CIdx.Split('+')[1];
- //}
- //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
- //}
- string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
- //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
- string newMemo = first + memoCtid + last;
- newentity.seller_memo = newMemo;
- newentity.FinishPlaceTime = null;
- newentity.UnusualTag = 0;
- newentity.UnusualCon = "";
- newentity.UnusualTime = null;
- newentity.AfterSaleMemo = "";
- newentity.AfterSaleMethod = afterMethod;
- newentity.AfterSalePreTime = null;
- newentity.AfterSaleReason = "";
- newentity.AfterSaleResponsible = "";
- newentity.AfterSaleState = 0;
- newentity.AfterSaleTime = null;
- newentity.AfterSaleUserId = 0;
- newentity.AfterSaleSupplierState = 0;
- newentity.LastBillWaybillCode = "";
- newentity.LastBillCpCode = "";
- newentity.FinishAfterSaleTime = null;
- newentity.HandleTime = null;
- newentity.IsSF = 0;
- newentity.IsOldCustomer = 0;
- newentity.UrgencyTime = null;
- newentity.ResponsibleUserId = "";
- newentity.IsVerifyToSupplier = false;
- newentity.payment = 0;
- newentity.CheckMemo = "";
- newentity.OutSid = "";
- newentity.CheckOrderTime = null;
- LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
- }
- newentity.isAfterSaleOrder = 1;
- newentity.IsRefund = 0;
- string receiveMobile = GetPostString("receiver_mobile");
- if (receiveMobile.Length > 0)
- {
- CeErpTrade trade = CeErpTrade.Get(newentity.tid);
- if (trade != null)
- {
- trade.receiver_name = GetPostString("receiver_name");
- trade.receiver_mobile = receiveMobile;
- trade.receiver_state = GetPostString("receiver_state");
- trade.receiver_city = GetPostString("receiver_city");
- trade.receiver_district = GetPostString("receiver_district");
- trade.receiver_address = GetPostString("receiver_address");
- newentity.IsOffLineOrder = 1;
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
- }
- }
- string st = GetPostString("ToState");
- if (st.Length > 0)
- {
- if (newentity.OrderState <= 3)
- {
- newentity.WaitDesignTime = DateTime.Now;
- newentity.StartDesignTime = null;
- newentity.FinishDesignTime = null;
- newentity.OrderState = 3;
- if (st == "下单员")
- {
- newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
- if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
- {
- newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
- }
- }
- else
- {
- newentity.WaitDesignTime = DateTime.Now;
- string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
- DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
- {
- DataRow user = dt1.Rows[0];
- //找主管
- string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dt != null && dt.Rows.Count > 0)
- {
- int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
- newentity.DesignUserId = designMr;
- string key = "aftersale_order_" + designMr;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- list.Add(newentity.ctid);
- RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
- }
- }
- //账号正常
- if (user["State"].ToString() == "0")
- {
- newentity.DesignUserId = entity.DesignUserId;
- string key = "aftersale_order_" + entity.DesignUserId;
- if (RedisHelper.HasKey(key))
- {
- List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
- list.Add(newentity.ctid);
- RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
- }
- }
- }
- }
- }
- if (entity.IsXianHuo == 1)
- {
- newentity.OrderState = 6;
- entity.FinishPlaceTime = DateTime.Now;
- }
- }
- if (ishav)
- {
- newentity.Update();
- }
- else
- {
- newentity.Create();
- CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
- newCellExtend.ctid = newentity.ctid;
- newCellExtend.orderFrom = 20;
- newCellExtend.orderType = 30;
- if (st == "下单员")
- {
- }
- else
- {
- newCellExtend.ReprintTime = DateTime.Now;
- }
- newCellExtend.Create();
- }
- if (st != "下单员")
- {
- designHelper.API_GetPrintData_CreateOrder(newentity);
- }
- }
- //处理售后扩展
- string resIdStr = GetPostString("ResponsibleUserId");
- string refundFees = GetPostString("refundFrees");
- int IsComplain = GetPostInt("isComplain");
- int IsBad = GetPostInt("isBad");
- string IsOriginal = GetPostString("isOriginal");
- double diffResultPrice = GetPostDouble("diffResultPrice");
- string textResult = GetPostString("textResult");
- string supplierResponsible = GetPostString("supplierResponsible");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
- if (ceErpTradeAfterSaleExtend == null)
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = eid;
- ceErpTradeAfterSaleExtend.RefundFees = refundFees;
- ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
- ceErpTradeAfterSaleExtend.IsBad = IsBad;
- ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
- ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
- ceErpTradeAfterSaleExtend.TextResult = textResult;
- ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
- ceErpTradeAfterSaleExtend.Create();
- }
- else
- {
- if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
- {
- ceErpTradeAfterSaleExtend.ChangeNum += 1;
- }
- ceErpTradeAfterSaleExtend.RefundFees = refundFees;
- ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
- ceErpTradeAfterSaleExtend.TextResult = textResult;
- ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
- ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
- ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
- ceErpTradeAfterSaleExtend.IsBad = IsBad;
- ceErpTradeAfterSaleExtend.Update();
- }
- int gysid = GetPostInt("ResponsibleSupId");
- if (entity.AfterSaleUserId == 0)
- {
- entity.AfterSaleUserId = CurrentUser.UserID;
- }
- entity.ResponsibleUserId = resIdStr;
- entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
- entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
- if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
- {
- CeErpTradeResponsible.DelByTid(eid, -1);
- CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
- int backNum = 0;
- if (number != null)
- {
- backNum = number.BackNum;
- }
- char[] separator = { ',' };
- string[] sArray = resIdStr.Split(separator);
- string[] refundFreeList = { };
- if (refundFees.Length > 0)
- {
- refundFreeList = refundFees.Split(separator);
- }
- int index = -1;
- foreach (string i in sArray)
- {
- index++;
- if (i.Length <= 0) continue;
- char[] separator2 = { '_' };
- string idstr = i.Split(separator2)[0];
- string idtype = i.Split(separator2)[1];
- double refudFree = 0;
- if (refundFreeList.Length > 0)
- {
- refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
- }
- if (idtype == "s")
- {
- isDesign = true;
- designFree = refudFree;
- }
- int userId = Convert.ToInt32(idstr);
- int type = 0;
- if (idtype == "g")
- {
- type = 1;
- }
- if (idtype == "w")
- {
- type = 2;
- }
- if (idtype == "t")
- {
- type = 3;
- }
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
- if (ceErpTradeResponsible == null)
- {
- ceErpTradeResponsible = new CeErpTradeResponsible();
- ceErpTradeResponsible.tid = eid;
- ceErpTradeResponsible.UserId = userId;
- ceErpTradeResponsible.createdTime = DateTime.Now;
- ceErpTradeResponsible.type = type;
- if (type == 1)
- {
- ceErpTradeResponsible.IsSup = 1;
- }
- if (type == 2)
- {
- ceErpTradeResponsible.IsFlow = 1;
- }
- }
- ceErpTradeResponsible.RefundFee = refudFree;
- ceErpTradeResponsible.VerifyState = 0;
- if (userId == 2125 || idtype == "w")
- {
- ceErpTradeResponsible.VerifyState = 1;
- }
- if (idtype == "w" && userId == 101)
- {
- ceErpTradeResponsible.VerifyState = 0;
- }
- if (ceErpTradeResponsible.ID > 0)
- {
- ceErpTradeResponsible.Update();
- }
- else
- {
- ceErpTradeResponsible.Create();
- }
- if (isDesign)
- {
- responsibleId = ceErpTradeResponsible.ID;
- }
- }
- CeErpTradeResponsible.NumByTid(backNum, eid);
- }
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend != null)
- {
- ceErpTradeCellExtend.returnVisit = 0;
- ceErpTradeCellExtend.Update();
- }
- if (entity.HandleTime != null)
- {
- if (entity.AfterSaleState == 1)
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
- }
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
- entity.HandleTime = DateTime.Now;
- }
- bool isCompale = false;
- if (entity.AfterSaleState == 5)
- {
- isCompale = true;
- entity.AfterSaleState = 3;
- }
- entity.AfterSaleSupplierState = 0;
- if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
- }
- string sImgs = GetPostString("img");
- entity.AfterSaleSupplierImg = sImgs;
- entity.supRefundType = GetPostString("supRefundType");
- entity.AfterSaleReason = GetPostString("AfterSaleReason");
- entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
- entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
- entity.AfterSaleMemoType = GetPostString("MemoType");
- if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
- {
- //entity.AfterSaleSupplierState = 2;
- }
- string df = GetPostString("DeductFee");
- if (df == "")
- {
- df = "0";
- }
- string rf = GetPostString("RefundFee");
- if (rf == "")
- {
- rf = "0";
- }
- string pm = GetPostString("AfterSalePayment");
- if (pm == "")
- {
- pm = "0";
- }
- entity.AfterSalePayment = Convert.ToDouble(pm);
- entity.DeductFee = Convert.ToDouble(df);
- entity.RefundFee = Convert.ToDouble(rf);
- entity.Update();
- string toState = GetPostString("ToState");
- string original = GetPostString("isOriginal");
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterDesign";
- apiVo.orderRemarks = entity.AfterSaleMethod;
- apiVo.reasonRemarks = entity.AfterSaleReason;
- apiVo.isDesign = isDesign;
- apiVo.designFree = designFree;
- apiVo.responsibleId = responsibleId;
- apiVo.afterFiles = entity.AfterSaleSupplierImg;
- if (toState == "设计师")
- {
- apiVo.isOriginal = Convert.ToBoolean(original);
- }
- designHelper.API_WorkCore(apiVo);//afterDesign
- CeErpMethod methodSql = new CeErpMethod();
- methodSql.con = entity.AfterSaleMethod;
- methodSql.addTime = DateTime.Now;
- methodSql.Create();
- string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
- CeErpMethod.ExecuteNonQuery(delsql);
- if (isCompale)
- {
- aftersale_data_change(entity.ctid);
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void ins_erp_toresponsible()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
- {
- returnErrorMsg("客户售后结果不能为空或不能为待处理!");
- return;
- }
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (entity.AfterSalePreTime == null)
- {
- if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
- {
- ceErpTradeAfterSaleExtend.PreTimeOut += 1;
- }
- }
- entity.AfterSalePreTime = DateTime.Now;
- //预完成给售后主管审核客户问题直接完成
- if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
- {
- if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
- {
- ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
- }
- }
- ceErpTradeAfterSaleExtend.Update();
- entity.AfterSaleState = 2;
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
- aftersale_data_change(entity.ctid);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void cancel_erp_aftersaleanddelnew()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.AfterSaleState = 0;
- entity.AfterSaleReason = "";
- entity.AfterSaleMethod = "";
- entity.AfterSaleMemo = "";
- entity.AfterSaleResponsible = "";
- entity.ResponsibleUserId = "";
- entity.DeductFee = 0;
- entity.RefundFee = 0;
- entity.IsArbitrate = 0;
- CeErpTradeResponsible.DelByTid(eid, -1);
- entity.Update();
- CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
- if (after != null)
- {
- if (after.OrderState < 5)
- CeErpTradeCell.DelByCtid("S_" + eid);
- }
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_aftersale_pregather()
- {
- List<string> lw = new List<string>();
- int st = GetInt("st");
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(tid = '{0}' or ctid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string afterSaleMemo = GetPostString("afterSaleMemo");
- if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
- string afterresult = GetPostString("afterresult");
- if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- var mainwhere = string.Join(" and ", lw.ToArray());
- string ro_json = "";
- string type = GetPostString("gather_type");
- if (poscode == "AfterSale")
- {
- //处理中
- if (type == "Handling")
- {
- 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) : ""));
- DataTable dt = null;
- try
- {
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- catch (Exception e)
- {
- dt = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
- return;
- }
- if (type == "Wait")
- {
- //待处理
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
- return;
- }
- if (type == "back")
- {
- //打回
- string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt2 = null;
- try
- {
- dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
- }
- catch (Exception e)
- {
- dt2 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
- return;
- }
- if (type == "preCompletion")
- {
- //预完成
- string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt3 = null;
- try
- {
- dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
- }
- catch (Exception e)
- {
- dt3 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
- return;
- }
- if (type == "documentary")
- {
- //跟单中
- 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) : ""));
- DataTable dt4 = null;
- try
- {
- dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
- }
- catch (Exception e)
- {
- dt4 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
- return;
- }
- if (type == "reBack")
- {
- //被打回
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
- return;
- }
- }
- if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
- {
- if (type == "puBack")
- {
- //退回
- string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt = null;
- try
- {
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- catch (Exception e)
- {
- dt = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
- return;
- }
- if (type == "reBack")
- {
- //打回
- string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt1 = null;
- try
- {
- dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
- }
- catch (Exception e)
- {
- dt1 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
- return;
- }
- if (type == "examEd")
- {
- //已审核
- string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt2 = null;
- try
- {
- dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
- }
- catch (Exception e)
- {
- dt2 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
- return;
- }
- if (type == "waitExam")
- {
- //待审核
- string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt3 = null;
- try
- {
- dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
- }
- catch (Exception e)
- {
- dt3 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
- return;
- }
- if (type == "Handling")
- {
- //处理中
- 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) : ""));
- DataTable dt4 = null;
- try
- {
- dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
- }
- catch (Exception e)
- {
- dt4 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
- return;
- }
- if (type == "Wait")
- {
- //待处理
- string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
- DataTable dt5 = null;
- try
- {
- dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
- }
- catch (Exception e)
- {
- dt5 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
- return;
- }
- if (type == "documentary")
- {
- //跟单中
- 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) : ""));
- DataTable dt6 = null;
- try
- {
- dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
- }
- catch (Exception e)
- {
- dt6 = new DataTable();
- }
- returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
- return;
- }
- }
- returnSuccess(ro_json);
- }
- public void end_erp_aftersale()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- string stype = GetPostString("stype");
- string typeStr = stype;
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
- entity.Update();
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
- DbHelper.DbConn.ExecuteNonQuery(sqlupd);
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void ins_erp_finishaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpTradeResponsible entity = null;
- if (eid != "") entity = CeErpTradeResponsible.Get(eid);
- if (entity != null)
- {
- entity.VerifyState = 1;
- entity.VerifyTime = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
- string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
- if (dt.Rows.Count <= 0)
- {
- string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
- DbHelper.DbConn.ExecuteNonQuery(sqlupd);
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
- CeErpSukuraData.createInfo(entity.tid, 8);
- if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
- {
- CeErpDesignerBill.Del(entity.tid);
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
- }
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_arbitrateaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpTradeResponsible entity = null;
- if (eid != "") entity = CeErpTradeResponsible.Get(eid);
- if (entity != null)
- {
- entity.IsArbitrate = 1;
- entity.ArbitradeMemo = GetPostString("reason");
- entity.VerifyState = 2;
- entity.Update();
- CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
- if (tradecell != null)
- {
- tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
- tradecell.IsArbitrate = 1;
- tradecell.Update();
- }
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_backaftersale()
- {
- if (UrlPostParmsCheck("tid"))
- {
- string eid = GetPostString("tid");
- CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
- int backNum = 0;
- if (number != null)
- {
- backNum = number.BackNum;
- }
- CeErpTradeResponsible.NumByTid(backNum + 1, eid);
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.AfterSaleBackReason = GetPostString("backreason");
- entity.AfterSaleState = 1;
- entity.AfterSaleSupplierState = 0;
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_supplieraftersalelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string afterState = GetPostString("afterstate");
- if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string reason = GetPostString("reason");
- if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
- string method = GetPostString("method");
- if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
- string handledate1 = GetPostString("handledate1");
- string handledate2 = GetPostString("handledate2");
- string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
- if (dwhandledate.Length > 0) lw.Add(dwhandledate);
- string handler = GetPostString("handler");
- if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
- string afterdate1 = GetPostString("afterdate1");
- string afterdate2 = GetPostString("afterdate2");
- string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
- if (afterDate.Length > 0) lw.Add(afterDate);
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string afterMemoType = GetPostString("aftermemotype");
- if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
- string vstate = GetPostString("vstate");
- if (vstate.Length > 0)
- {
- lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
- }
- lw.Add(string.Format("AfterSaleState>={0}", 2));
- string supplier = GetPostString("supplier");
- int supid = commonHelper.getSupplierIDByName(supplier);
- if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
- string posCode = CurrentUser.UserPost.Post.Code;
- if (posCode == "Supplier")
- {
- lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
- }
- else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
- }
- else
- {
- lw.Add(string.Format("AfterSaleResSupId != 0"));
- }
- lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
- dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_supverifyaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- CeErpTradeCell entity = null;
- if (ceErpTradeResponsible != null)
- {
- entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- }
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- if (entity != null)
- {
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- ceErpTradeResponsible.VerifyState = 1;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (num <= 1)
- {
- entity.AfterSaleState = 1;
- }
- else
- {
- entity.AfterSaleState = 5;
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Create();
- }
- }
- if (entity.AfterSaleState == 4)
- {
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
- if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
- {
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
- }
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_masteraftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- string textResult = GetPostString("textResult");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- if (ceErpTradeResponsible != null)
- {
- ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (entity != null)
- {
- entity.AfterSaleSupplierState = st;
- entity.AfterSaleSupplierMemo = afmemo;
- if (st == 1)
- {
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- //退回到售后
- string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
- int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
- if (num <= 1)
- {
- entity.AfterSaleState = 1;
- }
- else
- {
- entity.AfterSaleState = 5;
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
- ceErpTradeAfterSaleExtend.Create();
- }
- }
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_personaftersale()
- {
- if (UrlPostParmsCheck("id"))
- {
- string id = GetPostString("id");
- int st = GetPostInt("afterstate");
- string afmemo = GetPostString("supmemo");
- string image = GetPostString("image");
- CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
- if (ceErpTradeResponsible != null)
- {
- ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
- ceErpTradeResponsible.VerifyTime = DateTime.Now;
- ceErpTradeResponsible.Update();
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
- if (entity != null)
- {
- entity.AfterSaleSupplierMemo = afmemo;
- entity.AfterSaleSupplierState = st;
- if (st == 1)
- {
- bool isAll = commonHelper.tradeResponsibleAll(entity);
- if (isAll)
- {
- entity.AfterSaleState = 4;
- entity.FinishAfterSaleTime = DateTime.Now;
- }
- }
- else
- {
- CeErpTradeResponsible.dateByTid(entity.ctid);
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = entity.ctid;
- ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
- ceErpTradeAfterSaleExtend.Create();
- }
- //退回到主管
- //entity.AfterSaleState = 2;
- }
- if (entity.AfterSaleState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = entity.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- entity.Update();
- returnSuccessMsg("操作成功!");
- CeErpSukuraData.createInfo(entity.ctid, 8);
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
- LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
- return;
- }
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void set_erp_supplierrefundtag()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.IsSupplierRefund = GetPostInt("tag");
- entity.Update();
- returnSuccessMsg("操作成功!");
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_refundlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- //string rid = GetPostString("refund_id");
- //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- //string date1 = GetPostString("date1");
- //string date2 = GetPostString("date2");
- //string dateType = GetPostString("dateType");
- //if (dateType.Length > 0)
- //{
- // if (dateType == "1001") dateType = "0";
- // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
- // if (searchDT.Count == 2)
- // {
- // date1 = searchDT[0].ToString();
- // date2 = searchDT[1].ToString();
- // }
- //}
- //string dw = GetDateMinuteWhere("pay_time", date1, date2);
- //if (dw.Length > 0) lw.Add(dw);
- string redate1 = GetPostString("refunddate1");
- string redate2 = GetPostString("refunddate2");
- string dwdate = GetDateMinuteWhere("created", redate1, redate2);
- if (dwdate.Length > 0) lw.Add(dwdate);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string ispartrefund = GetPostString("ispartrefund");
- if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
- string refundState = GetPostString("refundvstate");
- if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
- int st = GetInt("st");
- if (st == 2) //待确认列表中,把state=3已确认的也显示
- {
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- lw.Add(string.Format("RefundState>={0}", st));
- string code = CurrentUser.UserPost.Post.Code;
- if (code == "CustomerService")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
- }
- else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
- }
- else if (code == "Place" || code == "PlaceMr")
- {
- lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
- }
- dStruct.Order = "RefundState asc,created desc";
- }
- else if (st == 10)
- {
- string responsible = GetPostString("responsibleman");
- if (responsible == "空白")
- {
- lw.Add(string.Format("ResponsibleUserName = ''"));
- }
- else if (responsible.Length > 0)
- {
- lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- }
- lw.Add(string.Format("RefundState>=0"));
- dStruct.Order = "created desc";
- }
- else
- {
- string responsible = GetPostString("responsibleman");
- if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
- lw.Add(string.Format("RefundState={0}", st));
- dStruct.Order = "created desc";
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
- dt.Columns.Add("refund_fees");
- foreach (DataRow dr in dt.Rows)
- {
- String status = dr["status"].ToString();
- if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
- {
- dr["refund_fees"] = dr["refund_fee"];
- }
- else
- {
- dr["refund_fees"] = "0.0";
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_refunddesignlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string redate1 = GetPostString("refunddate1");
- string redate2 = GetPostString("refunddate2");
- string dwdate = GetDateMinuteWhere("created", redate1, redate2);
- if (dwdate.Length > 0) lw.Add(dwdate);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string ispartrefund = GetPostString("ispartrefund");
- if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
- string designerorg = GetPostString("designerorg");
- if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
- string refundState = GetPostString("refundState");
- if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
- int myOrgid = CurrentUser.UserPost.OrgID;
- string myOrgCode = CurrentUser.UserPost.Post.Code;
- if ("Designer".Equals(myOrgCode))//设计师能看到的
- {
- if (CurrentUser.User.TeamIds.Length > 0)
- {
- lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
- }
- else
- {
- lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
- }
- }
- else if ("SysAdmin".Equals(myOrgCode))
- {
- }
- else
- {
- if (CurrentUser.User.ManageOrgIds.Length > 0)
- {
- lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
- }
- else
- {
- lw.Add(string.Format("DesOrgID = {0}", myOrgid));
- }
- }
- lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
- dt.Columns.Add("refund_fees");
- foreach (DataRow dr in dt.Rows)
- {
- String status = dr["status"].ToString();
- if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
- {
- dr["refund_fees"] = dr["refund_fee"];
- }
- else
- {
- dr["refund_fees"] = "0.0";
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void handle_erp_refundtag()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- string respMan = GetPostString("ResponsibleName");
- if (respMan.Length <= 0)
- {
- returnErrorMsg("责任人不能为空");
- return;
- }
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- entity.ResponsibleUserName = respMan;
- string userid = GetPostString("ResponsibleUserId");
- if (userid.Length > 0)
- {
- entity.ResponsibleUserId = userid;
- }
- entity.Memo = GetPostString("Memo");
- if (respMan.IndexOf("客服") != -1 ||
- respMan.IndexOf("设计师") != -1 ||
- respMan.IndexOf("下单员") != -1)
- {
- entity.RefundState = 2;
- }
- else
- {
- entity.RefundState = 3;
- }
- entity.modified = DateTime.Now;
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void handle_erp_designrefundtag()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = eid;
- }
- ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Create();
- }
- LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- public void upd_erp_refundverify()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
- entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
- entity.ResponsibleUserName.IndexOf("下单员") != -1)
- {
- entity.RefundState = 2;
- }
- else
- {
- entity.RefundState = 3;
- }
- entity.Update();
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_refundapprove()
- {
- if (UrlPostParmsCheck("refund_id"))
- {
- string eid = GetPostString("refund_id");
- CeErpTradeRefund entity = null;
- if (eid != "") entity = CeErpTradeRefund.Get(eid);
- if (entity != null)
- {
- int apr = GetPostInt("approve");
- if (apr == 0)
- {
- entity.RefundState = 1;
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
- }
- else if (apr == 1)
- {
- entity.RefundState = 3;
- LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
- }
- entity.modified = DateTime.Now;
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void get_erp_billlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string title = GetPostString("title");
- if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
- string tid = GetPostString("tid");
- string tids = GetPostString("tids");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- if (tids.Length > 0)
- {
- tids = "'" + tids + "'";
- tids = tids.Replace(",", "','");
- lw.Add(string.Format("tid in ({0})", tids));
- }
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
- if (dw1.Length > 0) lw.Add(dw1);
- string billtype = GetPostString("billtype");
- if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
- string billstate = GetPostString("billstate");
- if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
- string usershop = CurrentUser.User.pemShop;
- lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
- dStruct.Order = "createTime desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
- //foreach (DataRow dr in dt.Rows)
- //{
- // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
- //}
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void modify_erp_billinfo()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpBill bill_entity = null;
- if (eid != "") bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.tid = GetPostString("tid");
- bill_entity.title = GetPostString("title");
- bill_entity.tax = GetPostString("tax");
- bill_entity.bank = GetPostString("bank");
- bill_entity.bankac = GetPostString("bankac");
- bill_entity.address = GetPostString("address");
- bill_entity.phone = GetPostString("phone");
- bill_entity.price = GetPostString("price");
- bill_entity.productId = GetPostInt("ProductName");
- bill_entity.num = GetPostInt("num");
- bill_entity.unit = GetPostString("unit");
- bill_entity.type = GetPostString("type");
- bill_entity.sendType = GetPostString("SendType");
- bill_entity.email = GetPostString("email");
- bill_entity.buyer_nick = GetPostString("buyer_nick");
- bill_entity.shopName = GetPostString("ShopName");
- bill_entity.applymemo = GetPostString("applymemo");
- bill_entity.modifyTime = DateTime.Now;
- bill_entity.createTime = DateTime.Now;
- bill_entity.state = 0;
- bill_entity.Update();
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
- returnSuccessMsg("发票修改成功!");
- return;
- }
- returnErrorMsg("找不到对应记录");
- }
- }
- public void set_erp_invoicing()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string eid = GetPostString("id");
- CeErpBill bill_entity = null;
- if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- int ComId = GetPostInt("ComId");
- //string memo = GetPostString("Memo");
- int allInfo = GetPostInt("allinfo");
- string clert = CurrentUser.User.Name;
- //string detailValue = GetPostString("detailvalue");
- string billId = bill_entity.billOrderId;
- string[] billIdList = billId.Split(',');
- CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
- int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
- if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
- {
- billCount += 1;
- }
- if (billId.Length <= 0 || billIdList.Length != billCount)
- {
- bill_entity.billOrderId = "";
- string prebill = "ltb";
- for (int idx = 1; idx <= billCount; idx++)
- {
- string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
- string billoid = prebill + idx + dtstr;
- bill_entity.billOrderId += billoid;
- if (idx < billCount)
- {
- bill_entity.billOrderId += ",";
- }
- }
- }
- string[] billOrderList = bill_entity.billOrderId.Split(',');
- if (bill_entity.state == 5)
- {
- string errMsg = bill_entity.failerror;
- string[] errlist = errMsg.Split('|');
- string[] errTags = new string[errlist.Length];
- for (int itag = 0; itag < errlist.Length; itag++)
- {
- if (errlist[itag].Length <= 0) continue;
- errTags[itag] = errlist[itag].Split('&')[0];
- }
- for (int iii = 0; iii < errTags.Length; iii++)
- {
- if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
- int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
- if (billOrderList.Length >= erroBillOrderTag)
- {
- string needModifyBillId = billOrderList[erroBillOrderTag - 1];
- if (needModifyBillId.Length <= 19)
- {
- needModifyBillId = needModifyBillId + "1";
- }
- else
- {
- int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
- last = last + 1;
- needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
- }
- billOrderList[erroBillOrderTag - 1] = needModifyBillId;
- }
- }
- }
- bool isHaveBillSucces = false;
- string totalRes = "";
- bill_entity.failerror = "";
- for (int ii = 1; ii <= billOrderList.Length; ii++)
- {
- string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
- totalRes += res;
- if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
- {
- isHaveBillSucces = true;
- bill_entity.comId = ComId;
- bill_entity.state = 1;
- bill_entity.executeTime = DateTime.Now;
- bill_entity.executeUser = clert;
- }
- else
- {
- bill_entity.state = 5;
- bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
- }
- }
- bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
- bill_entity.Update();
- if (isHaveBillSucces)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
- if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
- {
- returnErrorMsg("开票失败");
- }
- else
- returnSuccessMsg("发票开具中,稍后刷新查看!");
- return;
- }
- returnErrorMsg("找不到对应记录");
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
- returnErrorMsg("操作失败");
- }
- }
- }
- public void get_erp_invoicing_back()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string id = GetPostString("id");
- CeErpBill entiy = CeErpBill.Get(id);
- if (entiy != null)
- {
- if (entiy.state == 0)
- {
- returnErrorMsg("发票还未开具");
- return;
- }
- string[] billOrderList = entiy.billOrderId.Split(',');
- int iTag = 0;
- entiy.fplsh = "";
- entiy.fpdm = "";
- entiy.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- string res = taobaoHelper.get_invoicing(id, billOrderId);
- if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
- {
- //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
- try
- {
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
- if (iObj != null)
- {
- entiy.state = 2;
- entiy.fplsh += iObj.list[0].c_fpqqlsh;
- entiy.fpdm += iObj.list[0].c_fpdm;
- entiy.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- entiy.fplsh += ",";
- entiy.fpdm += ",";
- entiy.fphm += ",";
- }
- entiy.Update();
- }
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- returnSuccessMsg("开票成功");
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
- }
- return;
- }
- else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
- {
- var res_obj = new
- {
- data = "开票中"
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- return;
- }
- else
- {
- int eidx = res.IndexOf("c_resultmsg");
- int lidx = res.IndexOf("c_status");
- string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
- entiy.state = 5;
- entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
- entiy.Update();
- returnErrorMsg("开票失败");
- return;
- }
- }
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
- }
- return;
- }
- }
- public void get_erp_invoicing()
- {
- if (UrlPostParmsCheck("id"))
- {
- try
- {
- string id = GetPostString("id");
- CeErpBill entiy = CeErpBill.Get(id);
- if (entiy != null)
- {
- if (entiy.state == 0)
- {
- returnErrorMsg("发票还未开具");
- return;
- }
- if (entiy.sendType == "纸质发票")
- {
- if (entiy.img.Length <= 0)
- {
- returnErrorMsg("查无纸质发票");
- return;
- }
- string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
- returnSuccess(returnres);
- return;
- }
- string[] billOrderList = entiy.billOrderId.Split(',');
- int iTag = 0;
- string fpUrl = "";
- entiy.fplsh = "";
- entiy.fpdm = "";
- entiy.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- string res = taobaoHelper.get_invoicing(id, billOrderId);
- if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
- {
- //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
- if (iObj != null)
- {
- //entiy.state = 2;
- entiy.fplsh += iObj.list[0].c_fpqqlsh;
- entiy.fpdm += iObj.list[0].c_fpdm;
- entiy.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- entiy.fplsh += ",";
- entiy.fpdm += ",";
- entiy.fphm += ",";
- }
- entiy.Update();
- fpUrl += iObj.list[0].c_url + ",";
- }
- //returnSuccess(res);
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
- DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
- }
- else
- {
- int eidx = res.IndexOf("c_resultmsg");
- //int lidx = res.IndexOf("c_status");
- string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
- //开票失败
- entiy.state = 5;
- entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
- entiy.Update();
- returnErrorMsg("开票失败");
- return;
- }
- }
- var returnObj = new
- {
- data = fpUrl
- };
- string ro_json = JsonConvert.SerializeObject(returnObj);
- returnSuccess(ro_json);
- }
- }
- catch (Exception ex)
- {
- XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
- }
- return;
- }
- }
- public void save_erp_billimg()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpBill bill_entity = null;
- if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.img = GetPostString("img");
- bill_entity.executeTime = DateTime.Now;
- bill_entity.state = 2;
- bill_entity.Update();
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
- returnSuccessMsg("保存成功");
- }
- return;
- }
- }
- public void upd_erp_billreturnback()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpBill bill_entity = null;
- if (eid != 0) bill_entity = CeErpBill.Get(eid);
- if (bill_entity != null)
- {
- bill_entity.state = 3;
- bill_entity.returnReason = GetPostString("reason");
- bill_entity.Update();
- returnSuccessMsg("驳回成功!");
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
- }
- return;
- }
- }
- public void cancel_erp_bill()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- int detailValue = GetPostInt("detailvalue");
- CeErpBill bill_entity = null;
- if (eid != 0) bill_entity = CeErpBill.Get(eid);
- string cres = "";
- string gres = "";
- if (bill_entity != null)
- {
- string[] billOrderList = bill_entity.billOrderId.Split(',');
- if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
- {
- int iTag = 0;
- bill_entity.fplsh = "";
- bill_entity.fpdm = "";
- bill_entity.fphm = "";
- foreach (string billOrderId in billOrderList)
- {
- iTag++;
- gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
- if (gres.IndexOf("success") != -1)
- {
- //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
- Invoicing_get_response_Obj iObj = null;
- iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
- if (iObj != null)
- {
- bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
- bill_entity.fpdm += iObj.list[0].c_fpdm;
- bill_entity.fphm += iObj.list[0].c_fphm;
- if (iTag < billOrderList.Length)
- {
- bill_entity.fplsh += ",";
- bill_entity.fpdm += ",";
- bill_entity.fphm += ",";
- }
- bill_entity.Update();
- }
- }
- else
- {
- returnErrorMsg(gres);
- return;
- }
- }
- }
- if (bill_entity.sendType == "纸质发票")
- {
- //作废
- //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
- //if (DateTime.Now.Month == extime.Month)
- //{
- //cres = taobaoHelper.cancel_invoicing(eid);
- //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
- //{
- bill_entity.state = 4;//已作废
- bill_entity.Update();
- returnSuccessMsg("发票已作废");
- return;
- //}
- //else
- //{
- // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
- // bill_entity.Update();
- // returnErrorMsg(cres);
- // return;
- //}
- //}
- //else
- //{
- // returnErrorMsg("纸质发票只能作废本月的发票");
- // return;
- //}
- }
- //红冲
- int redTag = 0;
- string[] fpdmList = bill_entity.fpdm.Split(',');
- string[] fphmList = bill_entity.fphm.Split(',');
- if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
- {
- returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
- return;
- }
- foreach (string billOrderId in billOrderList)
- {
- redTag++;
- string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
- cres += onecres;
- cres += ",";
- if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
- {
- bill_entity.state = 4;//已作废
- //bill_entity.Update();
- //returnSuccessMsg("发票已红冲");
- }
- else if (onecres.IndexOf("重复冲红") != -1)
- {
- bill_entity.state = 4;//已作废
- //bill_entity.Update();
- //returnSuccessMsg("发票已红冲");
- }
- else
- {
- string errmsg = commonHelper.KeepChinese(onecres);
- bill_entity.failerror += redTag + "&" + errmsg + "|";
- }
- }
- bill_entity.Update();
- if (cres.IndexOf("失败") != -1)
- returnErrorMsg("红冲失败");
- else
- returnSuccessMsg("发票已红冲");
- LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
- return;
- }
- return;
- }
- }
- public void del_erp_billorder()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpBill.Del(eid);
- CeErpBill bill = CeErpBill.Get(eid);
- if (bill != null)
- {
- LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
- }
- returnSuccessMsg("删除成功");
- }
- }
- public void finish_erp_bill()
- {
- if (UrlPostParmsCheck("ids"))
- {
- string eids = GetPostString("ids");
- string[] list = eids.Split(',');
- foreach (string eid in list)
- {
- CeErpBill bill = CeErpBill.Get(eid);
- if (bill != null)
- {
- bill.state = 2;
- bill.Update();
- LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
- }
- }
- returnSuccessMsg("操作成功");
- }
- }
- public void get_erp_returncash()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string returntype = GetPostString("returntype");
- if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_staygoods()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
- string wangwang = GetPostString("wangwang");
- if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
- string persuadetype = GetPostString("persuadetype");
- if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
- string customerOrg = GetPostString("customerOrg");
- if (customerOrg.Length > 0)
- {
- lw.Add(string.Format("OrgID = {0}", customerOrg));
- }
- dStruct.Order = "creata_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_staygoods()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpStayGoods entity = null;
- if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
- if (entity != null)
- {
- entity.audit_type = 1;
- entity.audit_time = DateTime.Now;
- entity.audit_u_id = CurrentUser.UserID;
- entity.audit_u_name = CurrentUser.UserName;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_stayGoodsback()
- {
- if (UrlPostParmsCheck("id"))
- {
- int eid = GetPostInt("id");
- CeErpStayGoods entity = null;
- if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
- if (entity != null)
- {
- entity.audit_text = GetPostString("reason");
- entity.audit_type = 2;
- entity.audit_time = DateTime.Now;
- entity.audit_u_id = CurrentUser.UserID;
- entity.audit_u_name = CurrentUser.UserName;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returncashverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- entity.cashstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_all_erp_returncashverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- String[] list = GetPostString("ID").Split(',');
- CeErpReturnCash entity = null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
- if (entity != null)
- {
- if (entity.cashstate == 1)
- {
- returnErrorMsg("已审核过的订单不需要在审核!");
- return;
- }
- entity.cashstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- }
- }
- returnSuccessMsg("审核成功!");
- return;
- }
- }
- public void upd_erp_returncashback()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- entity.backreason = GetPostString("reason");
- entity.cashstate = 2;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returnprice()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash entity = null;
- if (eid != 0) entity = CeErpReturnCash.Get(eid);
- if (entity != null)
- {
- if (entity.cashstate == 1)
- {
- returnErrorMsg("审核通过了不能改");
- return;
- }
- entity.returnprice = GetPostDouble("returnprice");
- entity.Update();
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void del_erp_returncash()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpReturnCash.Del(eid);
- returnSuccessMsg("操作成功");
- return;
- }
- }
- public void test_for_do_sql()
- {
- string sql = GetPostString("sqlstr");
- if (sql.Length > 0)
- {
- try
- {
- DbHelper.DbConn.ExecuteNonQuery(sql);
- var res_obj = new
- {
- data = "成功",
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- catch (Exception ex)
- {
- var res_obj = new
- {
- data = ex.Message,
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- }
- }
- public void get_user_info()
- {
- DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
- }
- public void get_total_data()
- {
- int userId = CurrentUser.UserID;
- string sql = "";
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- 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);
- }
- else
- {
- 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 " +
- "(select ID from CE_ErpUser where ID = {0}) d " +
- "left join " +
- "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
- ") a on d.ID = a.id left join " +
- "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
- ") b on a.id = b.id1 left join" +
- "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
- ") c on a.id = c.id2;", userId);
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_date_area_total_data2()
- {
- int userId = CurrentUser.UserID;
- string date_type = GetPostString("timetype");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = "";
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
- "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
- "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
- "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
- "(select ID from CE_ErpUser where ID = {0}) e left join " +
- "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
- " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") a on e.ID = a.id left join " +
- "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
- " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") b on a.id = b.id1 " +
- "left join " +
- "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
- " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
- ") c on a.id = c.id2 " +
- "left join " +
- "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
- " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
- ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
- }
- else
- {
- sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
- "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
- "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
- "(select ID from CE_ErpUser where ID = {0}) e left join " +
- "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
- " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
- ") a on e.ID = a.id left join " +
- "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
- " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
- ") c on a.id = c.id2 " +
- "left join " +
- "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
- " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
- ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_date_area_total_data()
- {
- int userId = CurrentUser.UserID;
- string date_type = GetPostString("timetype");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string date1 = searchDT[0].ToString();
- string date2 = searchDT[1].ToString();
- if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
- {
- SqlParameter[] sqlParameter ={
- new SqlParameter("@userId", SqlDbType.Int,4),
- new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@res", SqlDbType.VarChar, 4000)
- };
- sqlParameter[0].Value = userId;
- sqlParameter[1].Value = date1;
- sqlParameter[2].Value = date2;
- sqlParameter[3].Direction = ParameterDirection.Output;
- DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
- string res = sqlParameter[3].Value.ToString();
- var res_obj = new
- {
- data = res
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- else
- {
- SqlParameter[] sqlParameter ={
- new SqlParameter("@userId", SqlDbType.Int,4),
- new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
- new SqlParameter("@res", SqlDbType.VarChar, 4000)
- };
- sqlParameter[0].Value = userId;
- sqlParameter[1].Value = date1;
- sqlParameter[2].Value = date2;
- sqlParameter[3].Direction = ParameterDirection.Output;
- DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
- string res = sqlParameter[3].Value.ToString();
- var res_obj = new
- {
- data = res
- };
- string ro_json = JsonConvert.SerializeObject(res_obj);
- returnSuccess(ro_json);
- }
- //writeGridDataViewJson(dt.Rows.Count, dv);
- }
- public void get_order_list()
- {
- string strFields = GetPostString("paraFields");
- string strOrder = GetPostString("paraOrder");
- string strWhere = GetPostString("paraWhere");
- string strPageSize = GetPostString("paraPageSize");
- DataStruct dStruct = GetPostStruct();
- dStruct.PageSize = int.Parse(strPageSize);
- dStruct.Fileds = strFields;
- dStruct.Order = strOrder;
- dStruct.MainWhere = strWhere;
- DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- ////获取待开始订单列表
- //public void get_wait_design_order_list()
- //{
- // string date_type = GetPostString("date_type");
- // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- // DataStruct dStruct = GetPostStruct();
- // dStruct.PageSize = 1000;
- // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
- // List<string> lw = new List<string>();
- // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
- // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
- // dStruct.Order = "WaitDesignTime asc";
- // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- // writeGridDataTableJson(dStruct.TotalCount, dt);
- //}
- //获取完成单量排名
- public void get_finish_order_count_ranking()
- {
- /* string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
- "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
- "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
- writeGridDataTableJson(0, new DataTable());
- }
- public void get_finish_order_amount_ranking()
- {
- /*string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
- "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
- "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
- writeGridDataTableJson(0, new DataTable());
- }
- public void get_finish_refund_count_ranking()
- {
- string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
- "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
- "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- public void get_finish_refund_amount_ranking()
- {
- string date_type = GetPostString("date_type");
- List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
- string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
- "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
- "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
- "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
- "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(dt.Rows.Count, dt);
- }
- public void set_erp_finishorder_director()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.OrderState = 8;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_placeregistlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string outsid = GetPostString("outsid");
- if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
- string memo = GetPostString("memo");
- if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
- string filename = GetPostString("filename");
- if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
- string islate = GetPostString("islate");
- if (islate.Length > 0)
- {
- if (islate == "1")
- lw.Add(string.Format("OutLate>0"));
- else
- lw.Add(string.Format("OutLate=0"));
- }
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
- if (dw.Length > 0) lw.Add(dw);
- string deliveryDate1 = GetPostString("deliverydate1");
- string deliveryDate2 = GetPostString("deliverydate2");
- string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
- if (dw_deli.Length > 0) lw.Add(dw_deli);
- dStruct.Order = "ID desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void ins_erp_placeregist()
- {
- if (UrlPostParmsCheck("id"))
- {
- string eid = GetPostString("id");
- CeErpPlaceRegister entity = null;
- if (eid == "0")//新增
- {
- entity = new CeErpPlaceRegister();
- string xdTime = GetPostString("placeTime");
- if (xdTime.Length > 0)
- {
- entity.PlactTime = Convert.ToDateTime(xdTime);
- }
- string fhTime = GetPostString("deliveryTime");
- if (fhTime.Length > 0)
- {
- entity.DeliveryTime = Convert.ToDateTime(fhTime);
- }
- string preTime = GetPostString("preOutTime");
- if (preTime.Length > 0)
- {
- entity.PreOutTime = Convert.ToDateTime(preTime);
- }
- entity.DeliveryCount = GetPostInt("deliveryCount");
- entity.ReceiveCount = GetPostInt("receiveCount");
- entity.OutSid = GetPostString("outSid");
- entity.FileName = GetPostString("fileName");
- entity.Memo = GetPostString("memo");
- entity.AddUserId = CurrentUser.UserID;
- entity.CreateTime = DateTime.Now;
- entity.Img = GetPostString("img");
- entity.Supplier = GetPostInt("supplier");
- entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
- if (entity.PreOutTime != null && entity.DeliveryTime != null)
- {
- DateTime dt1 = (DateTime)entity.DeliveryTime;
- DateTime dt2 = (DateTime)entity.PreOutTime;
- TimeSpan span = dt1.Subtract(dt2);
- if (span.Days > 0)
- {
- entity.OutLate = span.Days;
- }
- }
- entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
- entity.Create();
- returnSuccessMsg("添加成功!");
- return;
- }
- else //修改
- {
- entity = CeErpPlaceRegister.Get(eid);
- if (entity != null)
- {
- string xdTime = GetPostString("placeTime");
- if (xdTime.Length > 0)
- {
- entity.PlactTime = Convert.ToDateTime(xdTime);
- }
- string fhTime = GetPostString("deliveryTime");
- if (fhTime.Length > 0)
- {
- entity.DeliveryTime = Convert.ToDateTime(fhTime);
- }
- string preTime = GetPostString("preOutTime");
- if (preTime.Length > 0)
- {
- entity.PreOutTime = Convert.ToDateTime(preTime);
- }
- entity.DeliveryCount = GetPostInt("deliveryCount");
- entity.ReceiveCount = GetPostInt("receiveCount");
- if (entity.DeliveryCount == entity.ReceiveCount)
- {
- entity.CurState = "已完成";
- }
- else
- {
- entity.CurState = "未完成";
- }
- entity.OutSid = GetPostString("outSid");
- entity.FileName = GetPostString("fileName");
- entity.Memo = GetPostString("memo");
- entity.Img = GetPostString("img");
- entity.Supplier = GetPostInt("supplier");
- //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
- if (entity.PreOutTime != null && entity.DeliveryTime != null)
- {
- DateTime dt1 = (DateTime)entity.DeliveryTime;
- DateTime dt2 = (DateTime)entity.PreOutTime;
- TimeSpan span = dt1.Subtract(dt2);
- if (span.Days > 0)
- {
- entity.OutLate = span.Days;
- }
- }
- entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
- entity.Update();
- returnSuccessMsg("修改成功");
- return;
- }
- returnErrorMsg("找不到对应的记录");
- return;
- }
- }
- returnErrorMsg("缺少必要参数");
- }
- public void del_erp_placeregist()
- {
- string eid = GetPostString("id");
- CeErpPlaceRegister.Del(eid);
- returnSuccessMsg("删除成功!");
- return;
- }
- public void ins_erp_placeregistbyorder()
- {
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- CeErpPlaceRegister entity = new CeErpPlaceRegister();
- entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
- entity.AddUserId = CurrentUser.UserID;
- entity.tid = dr["tid"].ToString();
- entity.Did = Convert.ToString(dr["ctid"]);
- entity.splitTag = dr["SplitTag"].ToString();
- string sellmemo = Convert.ToString(dr["seller_memo"]);
- string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
- if (pre_ctid.Length > 0)
- {
- sellmemo = sellmemo.Replace(pre_ctid, "");
- }
- sellmemo = sellmemo.Replace("[", "");
- sellmemo = sellmemo.Replace("]", "");
- entity.FileName = sellmemo;
- string count = dr["ProductCount"].ToString();
- int usecount = commonHelper.getIntCountFromString(count);
- entity.DeliveryCount = usecount;
- entity.CurState = "未完成";
- if (Convert.ToInt32(dr["SupplierId"]) == 0)
- {
- entity.Supplier = 24;//dl手提袋定制
- }
- else
- entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
- entity.CreateTime = DateTime.Now;
- entity.Create();
- }
- returnSuccessMsg("操作成功");
- return;
- }
- returnErrorMsg("没有找到对应订单");
- return;
- }
- returnErrorMsg("缺少订单编号");
- return;
- }
- public void get_erp_persuadelist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- string persuadetype = GetPostString("persuadetype");
- if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
- string returnvstate = GetPostString("returnvstate");
- if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_returnpersuadeback()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpPersuade entity = null;
- if (eid != 0) entity = CeErpPersuade.Get(eid);
- if (entity != null)
- {
- entity.backreason = GetPostString("reason");
- entity.pstate = 2;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("退回成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void upd_erp_returnpersuadeverify()
- {
- if (UrlPostParmsCheck("ID"))
- {
- if (CurrentUser.UserPost.Post.Code != "Summarize")
- {
- returnErrorMsg("暂无权限审核");
- return;
- }
- int eid = GetPostInt("ID");
- CeErpPersuade entity = null;
- if (eid != 0) entity = CeErpPersuade.Get(eid);
- if (entity != null)
- {
- entity.pstate = 1;
- entity.verifytime = DateTime.Now;
- entity.verifyuserid = CurrentUser.UserID;
- entity.Update();
- returnSuccessMsg("审核成功!");
- return;
- }
- returnErrorMsg("找不到订单记录");
- }
- }
- public void del_erp_persuade()
- {
- if (UrlPostParmsCheck("ID"))
- {
- int eid = GetPostInt("ID");
- CeErpPersuade.Del(eid);
- returnSuccessMsg("操作成功");
- return;
- }
- }
- public void get_erp_oldcustoupload()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0)
- {
- lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- }
- else
- return;
- dStruct.Order = "pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_erptradecell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_checkorderlist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (CurrentUser.UserPost.Post.Code == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- else
- {
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- }
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string dw = GetDateMinuteWhere("pay_time", date1, date2);
- if (dw.Length > 0) lw.Add(dw);
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string checkst = GetPostString("checkstate");
- if (checkst.Length > 0 && "10".Equals(checkst))
- {
- lw.Add(string.Format("CheckOut>0"));
- }
- else
- {
- if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
- lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
- }
- dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void ins_erp_startCheck()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.MemoOpt = 4;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
- CeErpSukuraData.createInfo(entity.ctid, 6);
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void upd_erp_sendXlw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSendGift == 1)
- {
- returnErrorMsg("请勿重复标记");
- return;
- }
- entity.IsSendGift = 1;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void cancel_sendXlw()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- if (entity.IsSendGift == 0)
- {
- returnErrorMsg("未标记小礼物");
- return;
- }
- entity.IsSendGift = 0;
- entity.Update();
- LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void get_erp_designbill()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int isMy = GetInt("my");
- if (isMy == 1)
- {
- lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
- }
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string userName = GetPostString("design");
- if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
- string rePrice1 = GetPostString("rePrice1");
- if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
- string rePrice2 = GetPostString("rePrice2");
- if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
- string designerType = GetPostString("designerType");
- if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
- string endTime1 = GetPostString("endTime1");
- string endTime2 = GetPostString("endTime2");
- string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
- if (dw.Length > 0) lw.Add(dw);
- string isDk = GetPostString("isDk");
- if (isDk == "1")
- {
- lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
- }
- else if (isDk == "0")
- {
- lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
- }
- dStruct.Order = "oid, create_time desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void upd_erp_designerbill()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpDesignerBill entity = null;
- if (eid != "") entity = CeErpDesignerBill.Get(eid);
- if (entity != null)
- {
- if (GetPostDouble("designerpirce") > 0)
- {
- entity.realPrice = GetPostDouble("designerpirce");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- else
- {
- entity.price = GetPostDouble("price");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
- entity.Update();
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void audit_erp_designerbill()
- {
- if (UrlPostParmsCheck("ID"))
- {
- string eid = GetPostString("ID");
- CeErpDesignerBill entity = null;
- if (eid != "") entity = CeErpDesignerBill.Get(eid);
- CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- entity.realPrice = GetPostDouble("designerpirce");
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- entity.isAudit = 1;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
- entity.Update();
- if (orderEntity != null)
- {
- orderEntity.IsReadTag = 3;
- orderEntity.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- returnErrorMsg("找不到记录");
- }
- }
- public void all_audit_erp_designerbill()
- {
- if (UrlPostParmsCheck("idList"))
- {
- string[] list = GetPostString("idList").Split(',');
- CeErpDesignerBill entity = null;
- for (int i = 0; i < list.Length; i++)
- {
- if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
- if (entity == null) return;
- CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
- if (orderEntity == null) return;
- if (entity.realPrice == 0) entity.realPrice = entity.price;
- entity.update_time = DateTime.Now;
- entity.update_u_id = CurrentUser.UserID;
- entity.update_u_name = CurrentUser.UserName;
- entity.isAudit = 1;
- LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
- entity.Update();
- orderEntity.IsReadTag = 3;
- orderEntity.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- }
- public void get_erp_sameorders()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- CeErpTradeCell entity = null;
- entity = CeErpTradeCell.GetByCtid(eid);
- if (entity != null)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- var res = new
- {
- data = dt.Rows.Count
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- returnErrorMsg("未找到订单");
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void get_erp_islasthavesameorder()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string[] ctidList = eid.Split(',');
- StringBuilder sql = new StringBuilder();
- string tisCtid = "";
- foreach (string ctid in ctidList)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
- if (entity != null)
- {
- sql = new StringBuilder();
- sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dth.Rows.Count > 0)
- {
- tisCtid += entity.ctid;
- tisCtid += ",";
- }
- }
- }
- if (tisCtid.Length > 0)
- {
- var res = new
- {
- data = tisCtid
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- }
- else
- {
- var res = new
- {
- data = ""
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- }
- return;
- }
- returnErrorMsg("缺少必要的参数");
- }
- public void file_client_down_url()
- {
- if (!UrlPostParmsCheck("userId"))
- {
- returnErrorMsg("缺少必要的参数");
- }
- returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
- }
- public void checkout_form_data()
- {
- if (!UrlPostParmsCheck("tid"))
- {
- returnErrorMsg("缺少必要的参数");
- }
- string tid = GetPostString("tid");
- CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
- if (ceErpOrderFormData != null)
- {
- string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
- returnSuccess(ro_jsond);
- return;
- }
- returnErrorMsg("尚未有文件!");
- }
- public void back_supplier_audit()
- {
- int userId = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- 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);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- }
- public void back_supplier_query()
- {
- string eid = GetPostString("ctid");
- if (eid != "")
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnErrorMsg("找不到订单记录");
- return;
- }
- }
- public void verified_to_order()
- {
- int userId = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- if (dt.Rows.Count > 0)
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- else
- {
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- }
- public void upd_supplier_audit()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string eid = GetPostString("ctid");
- string reason = GetPostString("returnreason");
- CeErpTradeCell entity = null;
- CeWithdraw withdraw = null;
- withdraw = CeWithdraw.GetByTid(eid);
- if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
- if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
- {
- if (withdraw != null)
- {
- if (!withdraw.userid.Equals(CurrentUser.UserID))
- {
- returnSuccessMsg("您没有权限操作!");
- return;
- }
- else
- {
- if (reason.Equals("1"))
- {
- if (entity.OrderState == -1)
- {
- if (entity.FinishPlaceTime == null)
- {
- entity.OrderState = 2;
- }
- else
- {
- entity.OrderState = 6;
- }
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("查看详细请点击线下订单查询");
- return;
- }
- }
- }
- // 第一个字符是 'N'
- }
- if (eid[0] != 'N')
- {
- }
- if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
- {
- entity.IsVerifyToSupplier = false;
- entity.IsReturn = 1;
- entity.ReturnTime = DateTime.Now;
- entity.ReturnReason = reason;
- if (entity.OrderState == 6)
- {
- entity.OrderState = 5;
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else if (int.Parse(reason) == 2 && entity.OrderState > 2)
- {
- ;
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("供应商取消撤回!");
- return;
- }
- }
- else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
- {
- if (entity.OrderState == -1)
- {
- if (entity.FinishPlaceTime == null)
- {
- entity.OrderState = 2;
- }
- else
- {
- entity.OrderState = 3;
- }
- commonHelper.getCytPrice(entity);
- }
- entity.Update();
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.Update();
- }
- returnSuccessMsg("操作成功!");
- return;
- }
- else if (int.Parse(reason) == 2 && entity.OrderState < 0)
- {
- if (withdraw == null)
- {
- returnSuccessMsg("驳回操作成功!可重新发起审核!");
- return;
- }
- }
- else if (int.Parse(reason) == 4 && entity.OrderState < 0)
- {
- if (withdraw != null)
- {
- withdraw.status = int.Parse(reason);
- withdraw.acknowledgingtime = DateTime.Now;
- withdraw.Update();
- returnSuccessMsg("查看详细请点击线下订单查询");
- return;
- }
- }
- return;
- }
- }
- //校验报价
- public void refund_order_tip()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- List<string> ids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- ids.Add(dr["ID"].ToString());
- }
- try
- {
- /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
- }
- catch (Exception ex)
- {
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void refund_order_Design()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- List<string> ids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- ids.Add(dr["ID"].ToString());
- }
- try
- {
- string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- }
- catch (Exception ex)
- {
- }
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void change_order_info()
- {
- int userid = CurrentUser.UserID;
- StringBuilder sql = new StringBuilder();
- 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);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
- }
- public void change_win_mome()
- {
- if (UrlPostParmsCheck("id,ctid"))
- {
- string id = GetPostString("id");
- string ctid = GetPostString("ctid");
- CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
- CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
- if (ce == null || ceErpMessageTip == null)
- {
- returnSuccessMsg("未找到对应的订单!");
- return;
- }
- int type = GetPostInt("type");
- string content = GetPostString("content");
- if (type == 0)
- {
- content = content.Replace("(", "(");
- content = content.Replace(")", ")");
- string check = MidStrEx(content, "(", ")").Trim();
- if (string.IsNullOrEmpty(check))
- {
- returnSuccessMsg("文件名格式不正确");
- return;
- }
- }
- ce.seller_memo = content;
- ce.Update();
- ceErpMessageTip.isVisit = true;
- ceErpMessageTip.Update();
- string text = type == 0 ? "同意修改:" + content : "不同意修改";
- LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ce.ctid;
- apiVo.actionName = "demandDesign";
- apiVo.orderRemarks = content;
- apiVo.demandExamine = type + 1;
- designHelper.API_WorkCore(apiVo);//demandDesign
- returnSuccessMsg("修改成功!");
- }
- }
- public static string MidStrEx(string sourse, string startstr, string endstr)
- {
- string result = string.Empty;
- int startindex, endindex;
- try
- {
- startindex = sourse.IndexOf(startstr);
- if (startindex == -1)
- return result;
- string tmpstr = sourse.Substring(startindex + startstr.Length);
- endindex = tmpstr.IndexOf(endstr);
- if (endindex == -1)
- return result;
- result = tmpstr.Remove(endindex);
- }
- catch (Exception ex)
- {
- Console.WriteLine("MidStrEx Err:" + ex.Message);
- }
- return result;
- }
- public void refund_order_list()
- {
- int userid = CurrentUser.UserID;
- int sectionId = CurrentUser.UserPost.OrgID;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- DataStruct dStruct = GetPostStruct();
- DataTable dt = null;
- List<string> ids = new List<string>();
- List<string> tids = new List<string>();
- if (dth.Rows.Count > 0)
- {
- foreach (DataRow dr in dth.Rows)
- {
- tids.Add("'" + dr["tid"].ToString() + "'");
- ids.Add(dr["id"].ToString());
- }
- try
- {
- string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- List<string> lw = new List<string>();
- lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_orderlist", dStruct);
- }
- catch (Exception ex)
- {
- }
- }
- writeGridDataTableJson(dStruct.TotalCount, dt);
- /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
- }
- //新增
- public void order_batch_downloads()
- {
- string ceid = GetPostString("tid");
- String[] tid = ceid.Split(',');
- order_batch_caiyingtong(tid);
- /* (string success, string errors) = UploadFiles(tid);
- returnSuccessMsg(success + errors);*/
- return;
- }
- //报价接口
- public void Get_To_Quote()
- {
- string ceid = GetPostString("ctid");
- if (ceid != null)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
- if (entity != null)
- {
- if (entity.seller_memo.IndexOf("种子纸") > -1)
- {
- return;
- }
- CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
- double price = 0;
- if (cp == null)
- {
- JObject jsonObject12 = new JObject
- {
- { "UserId", "77886" },
- { "Pwd", "lt666888" },
- { "Filename", entity.seller_memo }
- };
- string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
- JObject jsonObjects1 = JObject.Parse(response1);
- string ms1g = (string)jsonObjects1["msg"];
- if (ms1g == "报价成功")
- {
- JObject jsonObject1 = (JObject)jsonObjects1["data"];
- string data = (string)jsonObject1["price"];
- 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 + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- returnSuccessMsg("获取报价成功:" + data);
- price = Convert.ToDouble(data);
- }
- else
- {
- returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
- return;
- }
- }
- String[] beizhu = entity.seller_memo.Split('-');
- String chanp = "";
- if (beizhu.Length > 0)
- {
- chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
- }
- else
- {
- chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
- }
- JObject jsonObject = new JObject
- {
- { "UserId", "77886" },
- { "Pwd", "lt666888" },
- { "Filename", chanp }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- JObject jsonObject1 = (JObject)jsonObjects["data"];
- string data = (string)jsonObject1["price"];
- 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 + "');";
- CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
- returnSuccessMsg("获取报价成功:" + data);
- price = Convert.ToDouble(data);
- }
- else
- {
- returnErrorMsg("获取报价失败,检查备注格式" + msg);
- return;
- }
- if (price > 0)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = entity.ctid;
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Update();
- }
- }
- return;
- }
- }
- else
- {
- returnErrorMsg("请至少选择一条数据");
- return;
- }
- }
- //新增
- public void order_To_Supplier()
- {
- string ceid = GetPostString("tid");
- String[] tid = ceid.Split(',');
- if (tid.Length > 0)
- {
- try
- {
- for (int i = 0; i < tid.Length; i++)
- {
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
- int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
- entity.SupplierId = suid;
- string suname = commonHelper.getSupplierNameById(entity.SupplierId);
- LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
- entity.Update();
- }
- }
- catch (Exception ex)
- {
- returnErrorMsg("自动匹配供应商失败");
- return;
- }
- }
- else
- {
- returnErrorMsg("请至少选择一条数据");
- return;
- }
- returnSuccessMsg("自动匹配供应商成功");
- return;
- }
- public (string, string) UploadFiles(string[] urls)
- {
- string success = "";
- string errors = "";
- int userid = CurrentUser.UserID;
- foreach (string url in urls)
- {
- String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
- (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
- if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
- {
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "cyt86435015" },
- { "content", base64FileContent },
- { "ext", Path.GetExtension(fileName) }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg.Equals("上传成功"))
- {
- success += url + " 上传成功";
- }
- else
- {
- errors += url + " 上传失败";
- }
- }
- else
- {
- errors += url + " 格式出现问题";
- }
- }
- if (urls.Length == 0)
- {
- return (success, errors);
- }
- return (success, errors);
- }
- private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
- {
- return true; //总是接受
- }
- public static string HttpPost(string url, string param = null)
- {
- HttpWebRequest request;
- //如果是发送HTTPS请求
- if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
- {
- ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
- request = WebRequest.Create(url) as HttpWebRequest;
- request.ProtocolVersion = HttpVersion.Version10;
- }
- else
- {
- request = WebRequest.Create(url) as HttpWebRequest;
- }
- request.Method = "POST";
- request.ContentType = "application/json";
- request.Accept = "*/*";
- request.Timeout = 120000;
- request.AllowAutoRedirect = false;
- StreamWriter requestStream = null;
- WebResponse response = null;
- string responseStr = null;
- try
- {
- requestStream = new StreamWriter(request.GetRequestStream());
- requestStream.Write(param);
- requestStream.Close();
- response = request.GetResponse();
- if (response != null)
- {
- StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
- responseStr = reader.ReadToEnd();
- reader.Close();
- }
- }
- catch (Exception ex)
- {
- return ex.Message;
- }
- finally
- {
- request = null;
- requestStream = null;
- response = null;
- }
- return responseStr;
- }
- public (string, string) DownloadAndConvertToBase64(string downloadUrl)
- {
- string base64FileContent;
- string fileName;
- using (WebClient webClient = new WebClient())
- {
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
- using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
- {
- using (Stream stream = response.GetResponseStream())
- {
- using (MemoryStream memoryStream = new MemoryStream())
- {
- stream.CopyTo(memoryStream);
- byte[] fileBytes = memoryStream.ToArray();
- base64FileContent = Convert.ToBase64String(fileBytes);
- fileName = response.Headers["Content-Disposition"];
- if (!string.IsNullOrEmpty(fileName))
- {
- int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
- if (index >= 0)
- {
- fileName = fileName.Substring(index + 9).Trim('\"');
- }
- }
- else
- {
- fileName = Path.GetFileName(downloadUrl);
- }
- }
- }
- }
- }
- return (fileName, base64FileContent);
- }
- //新增
- public void order_batch_caiyingtong(string[] downloadUrls)
- {
- try
- {
- //遍历文件
- DataStruct dStruct = GetPostStruct();
- DataTable dt = null;
- int userid = CurrentUser.UserID;
- List<string> ids = new List<string>();//失败组
- List<string> tids = new List<string>();
- using (WebClient webClient = new WebClient())
- {
- foreach (var url in downloadUrls)
- {
- try
- {
- tids.Add("'" + url + "'");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
- if (entity != null)
- {
- CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
- if (cp == null)
- {
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "lt666888" },
- { "Filename",entity.seller_memo }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
- DownloadAndConvertToBase64(url1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
- }
- }
- else
- {
- String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
- JObject jsonObject = new JObject
- {
- { "Userid", "77886" },
- { "pwd", "lt666888" },
- { "Filename",chanp }
- };
- string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
- JObject jsonObjects = JObject.Parse(response);
- string msg = (string)jsonObjects["msg"];
- if (msg == "报价成功")
- {
- String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
- DownloadAndConvertToBase64(url1);
- }
- else
- {
- LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
- }
- }
- }
- // 上传文件到FTP
- }
- catch (Exception ex)
- {
- Console.WriteLine($"An error occurred: {ex.Message}");
- }
- }
- List<string> lw = new List<string>();
- lw.Add(string.Format("( OrderState < 6 )"));
- lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- if (dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- ids.Add(dr["ctid"].ToString());
- }
- }
- String ErrorMsgs = "";
- foreach (String id in ids)
- {
- ErrorMsgs += id + ",";
- }
- if (ErrorMsgs.Length > 1)
- {
- ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
- }
- if (ErrorMsgs.Length < 1)
- {
- ErrorMsgs = "上传成功";
- returnSuccessMsg(ErrorMsgs);
- }
- else
- {
- returnErrorMsg("以下订单" + ErrorMsgs);
- }
- }
- // 删除文件夹及其内容
- /* Directory.Delete(localDirectory, true);*/
- }
- catch { }
- }
- public void get_center_data()
- {
- int userId = CurrentUser.UserID;
- string postCode = CurrentUser.UserPost.Post.Code;
- List<string> lw = new List<string>();
- List<string> ww = new List<string>();
- DateTime currentTime = DateTime.Now;
- string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
- string sql = " SELECT ";
- string startTime = "2023-10-01 11:22:31";
- //设计
- if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
- {
- lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
- 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));
- lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
- 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));
- }
- //客服
- else if (postCode == "CustomerService" || postCode == "Director")
- {
- lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
- 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));
- lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
- 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));
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
- 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));
- lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
- 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));
- }
- //售后
- else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
- 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));
- lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
- 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));
- }
- //下单部
- else if (postCode == "Place" || postCode == "PlaceMr")
- {
- lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
- 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));
- lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
- 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));
- }
- //车间
- else if (postCode == "Supplier")
- {
- lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
- 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));
- }
- DataTable dt = new DataTable();
- if (lw.Count > 0)
- {
- sql += string.Join(" , ", lw);
- sql += " FROM ";
- sql += string.Join(" , ", ww);
- dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- }
- returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
- }
- public void get_center_data_list()
- {
- int userId = CurrentUser.UserID;
- string postCode = CurrentUser.UserPost.Post.Code;
- string shopIds = CurrentUser.User.pemShop;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- DateTime currentTime = DateTime.Now;
- string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
- string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
- string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
- string startTime = "2023-10-01 11:22:31";
- int order_type = GetPostInt("order_type");
- if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
- {
- lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
- if (order_type == 0)
- {
- lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
- }
- else if (order_type == 3)
- {
- lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //客服
- if (postCode == "CustomerService" || postCode == "Director")
- {
- lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
- if (order_type == 0)
- {
- lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
- }
- else if (order_type == 1)
- {
- lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
- }
- else if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else if (order_type == 3)
- {
- lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
- }
- else if (order_type == 4)
- {
- lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //售后
- if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (shopIds != "")
- {
- lw.Add(string.Format("ShopId in ({0})", shopIds));
- }
- if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else if (order_type == 4)
- {
- lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
- }
- else if (order_type == 5)
- {
- lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //下单部
- if (postCode == "Place" || postCode == "PlaceMr")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (shopIds != "")
- {
- lw.Add(string.Format("ShopId in ({0})", shopIds));
- }
- else if (order_type == 1)
- {
- lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
- }
- else if (order_type == 2)
- {
- lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- //车间
- if (postCode == "Supplier")
- {
- lw.Add(string.Format("pay_time > '{0}' ", startTime));
- if (order_type == 5)
- {
- lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
- }
- else
- {
- writeGridDataTableJson(dStruct.TotalCount, new DataTable());
- }
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- dStruct.Fileds = "tid,ctid";
- DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void aftersale_audit_master()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- if (ctid.Length > 0)
- {
- bool result = aftersale_data_change(ctid);
- if (result)
- {
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- returnErrorMsg("找不到指定售后单对应的原始订单!");
- }
- }
- public void aftersale_batch_audit_master()
- {
- if (UrlPostParmsCheck("ctids"))
- {
- string ctids = GetPostString("ctids");
- if (ctids.Length > 0)
- {
- List<string> list = new List<string>();
- string[] ctid_list = ctids.Split(',');
- foreach (var item in ctid_list)
- {
- bool result = aftersale_data_change(item);
- if (!result)
- {
- list.Add(item);
- }
- }
- if (list.Count > 0)
- {
- returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
- return;
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到指定售后单对应的原始订单!");
- }
- }
- public bool aftersale_data_change(string ctid)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
- ceErpTradeCell.AfterSaleSupplierState = 0;
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
- DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
- CeErpTradeResponsible.DelByTid(ctid, 0);
- 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 == "不理赔")
- {
- CeErpTradeResponsible.DelByTid(ctid, 1);
- ceErpTradeCell.AfterSaleSupplierState = 1;
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- }
- else
- {
- ceErpTradeCell.AfterSaleState = 3;
- }
- bool needCyt = false;
- if (dt != null)
- {
- if (dt.Rows.Count == 1)
- {
- bool isEnd = false;
- foreach (DataRow dr in dt.Rows)
- {
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- isEnd = true;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- isEnd = true;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
- {
- needCyt = true;
- }
- }
- if (isEnd)
- {
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- ceErpTradeCell.AfterSaleSupplierState = 1;
- }
- }
- else
- {
- bool isAll = true;
- foreach (DataRow dr in dt.Rows)
- {
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- continue;
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
- {
- string path = "";
- int OrgID = 0;
- if (!Convert.IsDBNull(dr["OrgPath"]))
- {
- path = dr["OrgPath"].ToString();
- }
- if (!Convert.IsDBNull(dr["OrgID"]))
- {
- OrgID = Convert.ToInt32(dr["OrgID"]);
- }
- if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
- {
- CeErpTradeResponsible.DelById(dr["ID"], 1);
- continue;
- }
- }
- if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
- {
- needCyt = true;
- }
- isAll = false;
- }
- if (isAll)
- {
- ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
- ceErpTradeCell.AfterSaleState = 4;
- ceErpTradeCell.AfterSaleSupplierState = 1;
- }
- }
- }
- if (needCyt && ceErpTradeCell.AfterSaleState != 4)
- {
- commonHelper.sendCytAfterSale(ceErpTradeCell);
- }
- if (ceErpTradeCell.AfterSaleState == 4)
- {
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = ceErpTradeCell.ctid;
- apiVo.actionName = "afterOver";
- designHelper.API_WorkCore(apiVo); //afterOver
- }
- ceErpTradeCell.Update();
- CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
- CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
- return true;
- }
- return false;
- }
- public void get_erp_wechatorder()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- lw.Add(string.Format("rtype = '{0}'", "微信返现"));
- dStruct.Order = "created desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void get_erp_wechatlist_sumprice()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("tid");
- if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
- string returndate1 = GetPostString("returndate1");
- string returndate2 = GetPostString("returndate2");
- string dw = GetDateMinuteWhere("created", returndate1, returndate2);
- if (dw.Length > 0) lw.Add(dw);
- string finishDate1 = GetPostString("finishdate1");
- string finishDate2 = GetPostString("finishdate2");
- string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
- if (dw_finish.Length > 0) lw.Add(dw_finish);
- lw.Add(string.Format("rtype = '{0}'", "微信返现"));
- string mainWhere = string.Join(" and ", lw.ToArray());
- string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
- DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
- DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
- decimal total = 0;
- if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
- {
- total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
- }
- var res = new
- {
- data = total
- };
- string ro_jsond = JsonConvert.SerializeObject(res);
- returnSuccess(ro_jsond);
- return;
- }
- public void get_erp_qr_waitdeliverylist()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
- var res_objz = new
- {
- restype = 1,
- data = dt
- };
- string ro_jsonz = JsonConvert.SerializeObject(res_objz);
- returnSuccess(ro_jsonz);
- }
- public void get_erp_yield_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
- //if (tid.Length == 0 && buyernick.Length == 0)
- //{
- // lw.Add(string.Format("IsRefund<={0}", 1));
- //}
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- string orderState = GetPostString("orderState");
- if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
- string address = GetPostString("address");
- 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));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string OrderArea = GetPostString("order_area");
- if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
- string placedate1 = GetPostString("placedate1");
- string placedate2 = GetPostString("placedate2");
- string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
- if (fdw.Length > 0) lw.Add(fdw);
- string price1 = GetPostString("price1");
- if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
- string price2 = GetPostString("price2");
- if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
- string unusualCon = GetPostString("unusualcon");
- if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
- string posTag = CurrentUser.UserPost.Post.Code;
- if (posTag == "Supplier")
- {
- lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
- }
- lw.Add(string.Format("OrderState = 6 "));
- lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
- dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_supYield", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void change_erp_sup_state()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- ceErpTradeCellExtend.SupState = 1;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.SupState = 1;
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
- returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
- return;
- }
- returnErrorMsg("找不到订单");
- }
- }
- public void supplier_all_downs()
- {
- if (UrlPostParmsCheck("tids"))
- {
- string tids = GetPostString("tids");
- if (tids != null && tids.Length > 0)
- {
- StringBuilder sql = new StringBuilder();
- sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- sql = new StringBuilder();
- 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, "下载设计文件");
- CeErpTradeCell.ExecuteNonQuery(sql.ToString());
- string[] list = tids.Split(',');
- foreach (string ctid in list)
- {
- CeErpSukuraData.createInfo(ctid, 3);
- }
- designHelper.api_approveDesign(tids); //approveDesign
- returnSuccessMsg("下载成功!");
- return;
- }
- returnErrorMsg("下载订单更新失败");
- }
- }
- public void uploaderFileSuccess()
- {
- if (UrlPostParmsCheck("fileName"))
- {
- string fileName = GetPostString("fileName");
- ApiVo apiVo = new ApiVo();
- apiVo.orderNumber = fileName;
- apiVo.actionName = "finishDesign";
- designHelper.API_WorkCore(apiVo);//finishDesign
- returnSuccessMsg("");
- }
- }
- public void get_sample2_order()
- {
- if (UrlPostParmsCheck("ctid"))
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
- string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
- DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
- double total = 0.0;
- double order_price = 0.0;
- if (dt_bu.Rows.Count > 0)
- {
- foreach (DataRow dr in dt_bu.Rows)
- {
- total += Convert.ToDouble(dr["payment"]);
- }
- }
- order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
- string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
- DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
- string tid = ctid.Replace("S_", "");
- CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
- double paymant = 0.0;
- if (entity != null)
- {
- paymant = entity.payment;
- }
- string return_reason = "";
- if (dt_after != null && dt_after.Rows.Count > 0)
- {
- return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
- }
- returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
- }
- }
- public void get_erp_design_status()
- {
- string designName = GetPostString("designName");
- DataStruct dStruct = GetPostStruct();
- if (designName.Length > 0)
- {
- 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";
- sql_user += " and Name like '%" + designName + "%'";
- DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
- List<string> ids_list = new List<string>();
- if (user_table.Rows.Count > 0)
- {
- foreach (DataRow item in user_table.Rows)
- {
- ids_list.Add(item["id"].ToString());
- string ids_s = item["TeamIds"].ToString();
- if (ids_s.Length > 0)
- {
- ids_list.AddRange(ids_s.Split(','));
- }
- }
- }
- HashSet<string> set = new HashSet<string>(ids_list);
- ids_list = set.ToList();
- if (ids_list.Count > 0)
- {
- 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));
- dStruct.MainWhere = sql;
- DataTable dt = null;
- dt = WebCache.GetData("view_ErpUser", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- }
- }
- public void change_erp_order_price()
- {
- string ctid = GetPostString("ctid");
- double price = GetPostDouble("price");
- if (ctid.Length > 0)
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.payment_cyt = price;
- ceErpTradeCellExtend.Update();
- }
- CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
- if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
- {
- ceErpDataSendOrderInfo.isSync = false;
- ceErpDataSendOrderInfo.Update();
- }
- if (ceErpDataSendOrderInfo == null)
- {
- ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
- ceErpDataSendOrderInfo.isSync = false;
- ceErpDataSendOrderInfo.ctid = ctid;
- ceErpDataSendOrderInfo.Create();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
- string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
- DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (dth != null && dth.Rows.Count > 0)
- {
- dataSendOrderBean dataSendOrderBean = null;
- foreach (DataRow item in dth.Rows)
- {
- try
- {
- dataSendOrderBean = new dataSendOrderBean();
- dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
- dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
- dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
- dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
- dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
- dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
- dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
- dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
- dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
- dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
- dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
- dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
- dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
- if (result != null)
- {
- if ("0".Equals(result.errcode))
- {
- CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
- }
- else
- {
- CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
- }
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void find_he_together()
- {
- string ctid = GetPostString("ctid");
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- List<string> list = new List<string>();
- if (ceErpTradeCell != null)
- {
- if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
- {
- 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);
- DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- if (table != null && table.Rows.Count > 0)
- {
- foreach (TableRow row in table.Rows)
- {
- }
- }
- }
- }
- returnSuccess(JsonConvert.SerializeObject(new { list }));
- }
- Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
- {
- //chy----19
- {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
- //GD-CYT-----64
- {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
- //ZHX----3
- {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
- //JK----97
- {97, new Dictionary<string, string> {{"uv", "uv"}}},
- //ZT----70
- {70, new Dictionary<string, string> {{"uv", "uv"}}},
- //LHCY-----98
- {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
- //XD-----90
- {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
- //CYCY-----14
- {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
- };
- //其他改名
- Dictionary<int, string> suppliers = new Dictionary<int, string>()
- {
- {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
- {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
- {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
- {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
- {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
- {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
- {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
- {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
- };
- //不统计
- List<int> no_suppliers = new List<int>()
- {
- 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
- };
- //配件单
- Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
- {
- {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
- {"棉绳",new List<string>(){ "卡片", "吊牌" } },
- {"别针",new List<string>(){ "卡片", "吊牌" } },
- {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
- {"流苏",new List<string>(){ "卡片", "吊牌" } },
- {"旗杆",new List<string>(){ "班旗" } },
- {"牙签",new List<string>(){ "不干胶" } }
- };
- public void get_place_order_data()
- {
- string date1 = GetPostString("date1");
- string date2 = GetPostString("date2");
- string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
- DateTime start = DateTime.Parse(starttime);
- string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
- DateTime end = DateTime.Parse(endtime);
- if (date1 != null && date1.Length > 0)
- {
- DateTime dateTime = DateTime.Parse(date1);
- starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
- start = DateTime.Parse(starttime);
- endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
- end = DateTime.Parse(endtime);
- }
- if (date2 != null && date2.Length > 0)
- {
- DateTime dateTime = DateTime.Parse(date2);
- endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
- end = DateTime.Parse(endtime);
- }
- 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);
- DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- //不干胶-----1,卡片-----29
- Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
- foreach (DataRow row in data.Rows)
- {
- int productId = Convert.ToInt32(row["ProductId"]);
- int supplierId = Convert.ToInt32(row["SupplierId"]);
- if (no_suppliers.Contains(supplierId))
- {
- continue;
- }
- string seller_memo = row["seller_memo"].ToString();
- bool ispj = false;//是否配件单
- bool isfirst = true;//第一个配
- maps.Keys.ForEach(key =>
- {
- //备注包含配件
- if (seller_memo.Contains(key) && isfirst)
- {
- List<string> list = maps[key];
- ispj = true;
- isfirst = false;
- for (int i = 0; i < list.Count; i++)
- {
- if (seller_memo.Contains(list[i]))
- {
- ispj = false;
- break;
- }
- }
- }
- });
- if (ispj)
- {
- continue;
- }
- seller_memo = seller_memo.Replace("UV", "uv");
- seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
- //吊牌归到卡片
- seller_memo = seller_memo.Replace("吊牌", "卡片");
- seller_memo = seller_memo.Replace("卡套", "卡片");
- seller_memo = seller_memo.Replace("封套", "卡片");
- seller_memo = seller_memo.Replace("吸管套", "卡片");
- seller_memo = seller_memo.Replace("腰封", "卡片");
- seller_memo = seller_memo.Replace("旗帜布", "条幅");
- seller_memo = seller_memo.Replace("手拉旗", "条幅");
- seller_memo = seller_memo.Replace("横幅", "条幅");
- seller_memo = seller_memo.Replace("锦旗", "条幅");
- string map_key = "";
- string type = "";
- if (supplierMap.ContainsKey(supplierId))
- {
- foreach (var kvp in supplierMap[supplierId])
- {
- if (seller_memo.Contains(kvp.Key))
- {
- map_key = kvp.Value;
- type = kvp.Value;
- break;
- }
- }
- }
- if (map_key == "")
- {
- type = "其他";
- map_key = "其他";
- }
- if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
- {
- map_key = suppliers[supplierId];
- }
- if (supplierId == 70)
- {
- supplierId = 70;
- }
- map_key += "_" + row["SupplierName"].ToString();
- Dictionary<string, int> map = null;
- if (other_map.ContainsKey(map_key))
- {
- other_map.TryGetValue(map_key, out map);
- }
- else
- {
- map = new Dictionary<string, int>();
- map.Add("dayDev", 0);//当天出货
- map.Add("dayTotal", 0);//下单总数
- map.Add("payTotal", 0);//500以上
- map.Add("today", 0);//当天出货数量
- map.Add("unusua", 0);//异常数
- other_map.Add(map_key, map);
- other_map.TryGetValue(map_key, out map);
- }
- DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
- DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
- DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
- DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
- if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
- {
- map["dayTotal"]++;
- if (supplierId == 97)
- {
- supplierId = 97;
- }
- }
- if (Convert.ToDecimal(row["payment"]) >= 500)
- {
- map["payTotal"]++;
- }
- if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
- {
- DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
- if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
- {
- if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
- {
- map["today"]++;
- }
- }
- else
- {
- if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
- {
- map["today"]++;
- }
- }
- }
- if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
- {
- map["unusua"]++;
- }
- DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
- //GD-CYT-----64
- DateTime two = palceTimeStart.AddHours(14);
- DateTime three = palceTimeStart.AddHours(15);
- DateTime four = palceTimeStart.AddHours(16);
- if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
- {
- //下午四点前 500-1000
- string count = row["ProductCount"].ToString();
- if (count != null && count.Length > 0)
- {
- int productCount = commonHelper.getPlaceProductCount(count);
- if (productCount >= 500 && productCount <= 1000)
- {
- if (DateTime.Compare(FinishPlaceTime, four) < 0)
- {
- map["dayDev"]++;
- }
- }
- }
- }
- //UV
- else if ("uv".Equals(type))
- {
- //ZT----70
- //ZHX----3
- if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
- {
- map["dayDev"]++;
- }
- //JK----97
- //HZX----105
- if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
- {
- map["dayDev"]++;
- if (supplierId == 97)
- {
- supplierId = 97;
- }
- }
- }
- //帆布---52|条幅---27
- else if ("帆布".Equals(type) || "条幅".Equals(type))
- {
- //LHCY-----98
- if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
- {
- map["dayDev"]++;
- }
- }
- //条幅
- else if ("条幅".Equals(type))
- {
- //XD-----90
- if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
- {
- map["dayDev"]++;
- }
- }
- //桌布
- else if ("桌布".Equals(type))
- {
- //XD-----90
- if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
- {
- map["dayDev"]++;
- }
- }
- //DL---10
- //AYTW---119
- //FS-CYT-DY ----80
- //JK----97
- else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
- {
- if (DateTime.Compare(FinishPlaceTime, three) < 0)
- {
- map["dayDev"]++;
- }
- }
- }
- DataTable dt = new DataTable();
- dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
- dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
- dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
- dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
- dt.Columns.Add(new DataColumn("today", typeof(string)));
- dt.Columns.Add(new DataColumn("unusua", typeof(string)));
- dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
- dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
- other_map.Keys.ForEach(key =>
- {
- DataRow dr = dt.NewRow();
- Dictionary<string, int> map = other_map[key];
- string[] key_list = key.Split('_');
- dr[0] = key_list[0];
- dr[1] = key_list[1];
- if (key_list.Length > 2)
- {
- dr[1] += "(" + key_list[2] + ")";
- }
- dr[2] = map["dayTotal"];
- dr[3] = map["payTotal"];
- dr[4] = map["today"];
- dr[5] = map["unusua"];
- dr[6] = map["dayDev"];
- double rate = 0.00;
- if (map["dayDev"] > 0)
- {
- rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
- }
- dr[7] = rate.ToString();
- dt.Rows.Add(dr);
- });
- DataView dv = new DataView(dt);
- dv.Sort = "SupplierName";
- //dv.Sort = "AllOrder desc";
- DataTable dtNew = dv.ToTable();
- writeGridDataTableJson(dtNew.Rows.Count, dtNew);
- }
- public void check_order_desing_info()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
- returnSuccess(JsonConvert.SerializeObject(new { response }));
- return;
- }
- returnErrorMsg("找不到订单");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void get_timeout_detail()
- {
- string poscode = CurrentUser.UserPost.Post.Code;
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- string id = GetPostString("id");
- string pay_date1 = GetPostString("pay_date1");
- string pay_date2 = GetPostString("pay_date2");
- int type = GetPostInt("type");
- if (type == 0)
- {
- if (pay_date1.Length > 0)
- {
- lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
- }
- if (pay_date2.Length > 0)
- {
- lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
- }
- lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
- }
- if (type == 1)
- {
- if (pay_date1.Length > 0)
- {
- lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
- }
- if (pay_date2.Length > 0)
- {
- lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
- }
- lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
- }
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = null;
- dt = WebCache.GetData("view_orderlist", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void saveUrgentChargePrice()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- double price = GetPostDouble("price");
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
- }
- ceErpTradeCellExtend.urgentCharge = price;
- if (ceErpTradeCellExtend.ID > 0)
- {
- ceErpTradeCellExtend.Update();
- }
- else
- {
- ceErpTradeCellExtend.Save();
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void finish_erp_order()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
- {
- CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
- if (ceErpTradeCell != null)
- {
- ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
- ceErpTradeCell.Update();
- LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
- returnSuccessMsg("修改成功!");
- return;
- }
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void get_trade_order_list()
- {
- string tid = GetPostString("tid");
- if (!string.IsNullOrEmpty(tid))
- {
- string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
- DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
- writeGridDataTableJson(data.Rows.Count, data);
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void save_cell_spu()
- {
- string ctid = GetPostString("ctid");
- string spu_id = GetPostString("spu_id");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.spu_id = spu_id;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void change_express_info()
- {
- string ctid = GetPostString("ctid");
- string transNo = GetPostString("transNo");
- string transCom = GetPostString("transCom");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.modExpressNo = transNo;
- ceErpTradeCellExtend.modExpressCom = transCom;
- ceErpTradeCellExtend.readMod = 2;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void get_change_express_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- lw.Add("readMod = 2");
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void deal_express_complete()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.readMod = 1;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void aftersale_return_visit()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
- if (ceErpTradeCellExtend == null)
- {
- ceErpTradeCellExtend = new CeErpTradeCellExtend();
- ceErpTradeCellExtend.ctid = ctid;
- }
- ceErpTradeCellExtend.returnVisit = 1;
- if (ceErpTradeCellExtend.ID == 0)
- {
- ceErpTradeCellExtend.Create();
- }
- else
- {
- ceErpTradeCellExtend.Update();
- }
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.TextResult = "";
- ceErpTradeAfterSaleExtend.Update();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
- returnSuccessMsg("修改成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void orderPlaceInfo()
- {
- string ctids = GetPostString("ctids");
- string[] list = ctids.Split(',');
- foreach (string ctid in list)
- {
- CeErpSukuraData.createInfo(ctid, 3);
- }
- designHelper.api_approveDesign(ctids); //approveDesign
- returnSuccessMsg("");
- }
- public void get_issue_list()
- {
- DataStruct dStruct = GetPostStruct();
- List<string> lw = new List<string>();
- int st = 2;
- string tid = GetPostString("ctid");
- if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
- string shopname = GetPostString("shopname");
- if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
- string buyernick = GetPostString("buyer_nick");
- if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
- string sellermemo = GetPostString("seller_memo");
- if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
- string supplier = GetPostString("supplier");
- if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
- string customer = GetPostString("customer");
- if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
- string design = GetPostString("design");
- if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
- //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
- string poscode = CurrentUser.UserPost.Post.Code;
- if (poscode != "SysAdmin")
- {
- string shopid = CurrentUser.User.pemShop;
- lw.Add(string.Format("shopId in ({0})", shopid));
- }
- if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
- {
- lw.Add("IssueState = 1");
- }
- lw.Add("IssueState > 0");
- dStruct.MainWhere = string.Join(" and ", lw.ToArray());
- DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
- writeGridDataTableJson(dStruct.TotalCount, dt);
- }
- public void saveIssueContent()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- string content = GetPostString("content");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend == null)
- {
- ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
- ceErpTradeAfterSaleExtend.tid = ctid;
- }
- ceErpTradeAfterSaleExtend.IssueContent = content;
- ceErpTradeAfterSaleExtend.IssueState = 1;
- if (ceErpTradeAfterSaleExtend.ID > 0)
- {
- ceErpTradeAfterSaleExtend.Update();
- }
- else
- {
- ceErpTradeAfterSaleExtend.Create();
- }
- LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
- returnSuccessMsg("添加成功!");
- return;
- }
- returnErrorMsg("找不到订单");
- }
- public void dealIssueContent()
- {
- string ctid = GetPostString("ctid");
- if (!string.IsNullOrEmpty(ctid))
- {
- string content = GetPostString("content");
- CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
- if (ceErpTradeAfterSaleExtend != null)
- {
- ceErpTradeAfterSaleExtend.IssueState = 2;
- ceErpTradeAfterSaleExtend.Update();
- LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
- returnSuccessMsg("修改完成!");
- return;
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void set_tid_attachments()
- {
- string tid = GetPostString("tid");
- string atta = GetPostString("atta");
- if (!string.IsNullOrEmpty(tid))
- {
- if (string.IsNullOrEmpty(atta))
- {
- returnErrorMsg("文件地址为空");
- return;
- }
- CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
- if (ceErpTrade == null)
- {
- returnErrorMsg("找不到订单");
- return;
- }
- DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", tid)).Tables[0];
- bool isSend = false;
- if (dt != null && dt.Rows.Count > 0)
- {
- foreach (DataRow row in dt.Rows)
- {
- if (Convert.ToInt16(row["OrderState"]) > 6)
- {
- isSend = true;
- }
- }
- if (isSend)
- {
- returnErrorMsg("已发货无法修改");
- return;
- }
- ceErpTrade.Attachments = atta;
- ceErpTrade.Update();
- LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
- returnSuccessMsg("上传成功!");
- return;
- }
- }
- returnErrorMsg("找不到订单");
- }
- public void get_tid_attachments()
- {
- string tid = GetPostString("tid");
- if (!string.IsNullOrEmpty(tid))
- {
- CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
- if (ceErpTrade == null)
- {
- returnErrorMsg("找不到订单");
- }
- returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
- return;
- }
- returnErrorMsg("找不到订单");
- }
- }
- }
|