sync.order.cs 576 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_trade_info;
  41. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  42. using static SiteCore.taoObj.work_core_vo;
  43. using static System.Net.Mime.MediaTypeNames;
  44. namespace SiteCore.Handler
  45. {
  46. public partial class sync
  47. {
  48. public void get_erp_orderlist()
  49. {
  50. string poscode = CurrentUser.UserPost.Post.Code;
  51. DataStruct dStruct = GetPostStruct();
  52. //apiHelper.Api_SyncOrderByTime("598825");
  53. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  54. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  55. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  56. //banniuApiHelper.sendLogisticsInfo(null);
  57. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  58. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  59. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  60. //int sid = commonHelper.autoDistributeToSupplier(entity);
  61. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  62. //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\"}}");
  63. //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}}");
  64. List<string> lw = new List<string>();
  65. string tid = GetPostString("ctid");
  66. string date1 = GetPostString("date1");
  67. //12-1 修改
  68. string urgent = GetPostString("urgent");
  69. string back = GetPostString("back");
  70. string offlineSearch = GetPostString("offlineSearch");
  71. int paramsCount = 0;
  72. if (!string.IsNullOrWhiteSpace(urgent))
  73. {
  74. if (urgent.Equals("true"))
  75. {
  76. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  77. }
  78. }
  79. if (!string.IsNullOrWhiteSpace(back))
  80. {
  81. if (back.Equals("true"))
  82. {
  83. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  84. }
  85. }
  86. if (!string.IsNullOrWhiteSpace(offlineSearch))
  87. {
  88. if (offlineSearch.Equals("true"))
  89. {
  90. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  91. }
  92. }
  93. //end
  94. string date2 = GetPostString("date2");
  95. string buyernick = GetPostString("buyer_nick");
  96. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  97. {
  98. if (tid.Length <= 0 && buyernick.Length <= 0)
  99. {
  100. return;
  101. }
  102. }
  103. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  104. {
  105. if (tid.Length > 0)
  106. {
  107. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  108. }
  109. if (buyernick.Length > 0)
  110. {
  111. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  112. }
  113. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  114. if (dw.Length > 0)
  115. {
  116. lw.Add(dw);
  117. }
  118. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  119. {
  120. string usershop = CurrentUser.User.pemShop;
  121. lw.Add(string.Format("ShopId in ({0})", usershop));
  122. }
  123. }
  124. else
  125. {
  126. if (ex_psize == 0)
  127. {
  128. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  129. }
  130. if (PKey != "admin")
  131. {
  132. string usershop = CurrentUser.User.pemShop;
  133. lw.Add(string.Format("ShopId in ({0})", usershop));
  134. paramsCount++;
  135. }
  136. }
  137. string uploaddate1 = GetPostString("uploaddate1");
  138. string uploaddate2 = GetPostString("uploaddate2");
  139. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  140. if (update.Length > 0) lw.Add(update);
  141. string deliverydate1 = GetPostString("deliverydate1");
  142. string deliverydate2 = GetPostString("deliverydate2");
  143. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  144. if (deliverydate.Length > 0)
  145. {
  146. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  147. };
  148. string shopname = GetPostString("shopname");
  149. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  150. string addwechat = GetPostString("addwechat");
  151. if (addwechat.Length > 0)
  152. {
  153. int addWt = Convert.ToInt32(addwechat);
  154. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  155. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  156. }
  157. string customer = GetPostString("customer");
  158. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  159. string design = GetPostString("design");
  160. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  161. string orderState = GetPostString("orderState");
  162. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  163. string address = GetPostString("address");
  164. 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));
  165. string sellermemo = GetPostString("seller_memo");
  166. if (sellermemo.Length > 0)
  167. {
  168. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  169. }
  170. string backReason = GetPostString("backReason");
  171. if (backReason.Length > 0)
  172. {
  173. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  174. }
  175. string apdate1 = GetPostString("apdate1");
  176. string apdate2 = GetPostString("apdate2");
  177. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  178. if (dwap.Length > 0) lw.Add(dwap);
  179. string price1 = GetPostString("price1");
  180. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  181. string price2 = GetPostString("price2");
  182. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  183. string isoldcustomer = GetPostString("isoldcus");
  184. string finishdate1 = GetPostString("finishdate1");
  185. string finishdate2 = GetPostString("finishdate2");
  186. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  187. bool isFinish = false;
  188. if (finishdate.Length > 0)
  189. {
  190. lw.Add(finishdate);
  191. isFinish = true;
  192. paramsCount++;
  193. }
  194. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  195. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  196. if (ex_psize > 0)
  197. {
  198. int UserID = CurrentUser.UserID;
  199. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  200. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  201. {
  202. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  203. }
  204. dStruct.Order = "pay_time desc";
  205. }
  206. string isNew = GetPostString("isNew");
  207. if (isNew == "true")
  208. {
  209. lw.Add(string.Format("IsNew = {0}", 1));
  210. }
  211. string overtime = GetPostString("overtime");
  212. if (overtime == "1")
  213. {
  214. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  215. }
  216. String usePost = CurrentUser.UserPost.Post.Code;
  217. if (usePost.Equals("Operation") == true)
  218. {
  219. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  220. }
  221. else
  222. {
  223. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  224. }
  225. //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";
  226. if (dStruct.PageSize == 100000)
  227. {
  228. dStruct.Order = "";
  229. }
  230. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  231. DataTable dt = null;
  232. string tablename = "view_orderlist";
  233. if (isFinish)
  234. {
  235. tablename = "view_orderlist_end";
  236. }
  237. dt = WebCache.GetData(tablename, dStruct);
  238. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  239. if (dt != null && dt.Rows.Count > 0)
  240. {
  241. foreach (DataRow dr in dt.Rows)
  242. {
  243. try
  244. {
  245. if (dr["refund_fees"] != null)
  246. {
  247. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  248. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  249. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  250. if (payment == refund_fees)
  251. {
  252. dr["refund_fees"] = Math.Round(refund_fees, 2);
  253. }
  254. else if (refund_fees == total_fee)
  255. {
  256. dr["refund_fees"] = payment;
  257. }
  258. else
  259. {
  260. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  261. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  262. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  263. }
  264. }
  265. // 对象操作
  266. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  267. ceErpTradeCell.ctid = dr["ctid"].ToString();
  268. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  269. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  270. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  271. if (dStruct.PageSize != 100000)
  272. {
  273. if (dr["DispatchSort"].ToString() == "2")
  274. {
  275. dr["gongchuang"] = 200;
  276. }
  277. else
  278. {
  279. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  280. dr["gongchuang"] = response.code;
  281. }
  282. }
  283. }
  284. catch (NullReferenceException ex)
  285. {
  286. // 处理空引用异常
  287. dr["refund_fees"] = "0.00";
  288. }
  289. }
  290. }
  291. writeGridDataTableJson(dStruct.TotalCount, dt);
  292. }
  293. public void get_erp_orderlist_sumprice()
  294. {
  295. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  296. return;
  297. List<string> lw = new List<string>();
  298. string tid = GetPostString("ctid");
  299. string date1 = GetPostString("date1");
  300. string date2 = GetPostString("date2");
  301. if (tid.Length > 0 || date1.Length > 0)
  302. {
  303. lw.Add(string.Format("ctid like '%{0}%'", tid));
  304. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  305. if (dw.Length > 0) lw.Add(dw);
  306. }
  307. else
  308. {
  309. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  310. }
  311. string shopname = GetPostString("shopname");
  312. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  313. string buyernick = GetPostString("buyer_nick");
  314. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  315. string customer = GetPostString("customer");
  316. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  317. string design = GetPostString("design");
  318. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  319. string orderState = GetPostString("orderState");
  320. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  321. string address = GetPostString("address");
  322. 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));
  323. string sellermemo = GetPostString("seller_memo");
  324. if (sellermemo.Length > 0)
  325. {
  326. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  327. }
  328. string apdate1 = GetPostString("apdate1");
  329. string apdate2 = GetPostString("apdate2");
  330. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  331. if (dwap.Length > 0) lw.Add(dwap);
  332. string price1 = GetPostString("price1");
  333. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  334. string price2 = GetPostString("price2");
  335. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  336. string isoldcustomer = GetPostString("isoldcus");
  337. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  338. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  339. if (PKey != "admin")
  340. {
  341. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  342. lw.Add(string.Format("shopId in ({0})", usershop));
  343. }
  344. //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";
  345. string mainWhere = string.Join(" and ", lw.ToArray());
  346. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  347. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  348. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  349. decimal total = 0;
  350. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  351. {
  352. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  353. }
  354. var res = new
  355. {
  356. data = total
  357. };
  358. string ro_jsond = JsonConvert.SerializeObject(res);
  359. returnSuccess(ro_jsond);
  360. return;
  361. }
  362. public void get_erp_CustomerServiceGather()
  363. {
  364. string userWhere = "", orderWhere = "";
  365. List<string> lw = new List<string>();
  366. string customer = GetPostString("customer");
  367. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  368. string shopname = GetPostString("shopname");
  369. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  370. string date1 = GetPostString("date1");
  371. string date2 = GetPostString("date2");
  372. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  373. if (dw.Length > 0) lw.Add(dw);
  374. orderWhere = string.Join(" and ", lw.ToArray());
  375. 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 " +
  376. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  377. "left join " +
  378. "( " +
  379. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  380. ") as b on a.ID = b.CustomerUserId " +
  381. "left join " +
  382. "( " +
  383. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  384. ") as d on a.ID = d.CustomerUserId " +
  385. "left join " +
  386. "( " +
  387. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  388. ") as e on a.ID = e.CustomerUserId " +
  389. "left join " +
  390. "( " +
  391. " select CustomerUserId, RefundCount, RefundSum from " +
  392. " ( " +
  393. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  394. " from CE_ErpTradeRefund a " +
  395. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  396. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  397. " group by CustomerUserId " +
  398. " ) as a " +
  399. ") as f on a.ID = f.CustomerUserId " +
  400. "where a.PostCode = 'CustomerService'",
  401. userWhere, orderWhere);
  402. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  403. writeGridDataTableJson(dt.Rows.Count, dt);
  404. //writeGridDataTableJson(dt.Rows.Count, dt);
  405. }
  406. //设计汇总
  407. public void get_erp_DesignerGather()
  408. {
  409. string userWhere = "", orderWhere = "";
  410. List<string> lw = new List<string>();
  411. string Designer = GetPostString("designer");
  412. int org = GetPostInt("org");
  413. if (Designer.Length > 0)
  414. {
  415. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  416. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  417. }
  418. else if (org > 0)
  419. {
  420. userWhere = string.Format(" where OrgID ={0}", org);
  421. }
  422. string shopname = GetPostString("shopname");
  423. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  424. string state = GetPostString("state");
  425. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  426. string OrderArea = GetPostString("order_area");
  427. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  428. string date1 = GetPostString("date1");
  429. string date2 = GetPostString("date2");
  430. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  431. if (dw.Length > 0) lw.Add(dw);
  432. string UpDate1 = GetPostString("UpDate1");
  433. string UpDate2 = GetPostString("UpDate2");
  434. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  435. if (dw.Length > 0) lw.Add(dw);
  436. orderWhere = string.Join(" and ", lw.ToArray());
  437. 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 (" +
  438. "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 " +
  439. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  440. "left join " +
  441. "( " +
  442. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  443. ") as b on a.ID = b.DesignUserId " +
  444. "left join " +
  445. "( " +
  446. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  447. ") as d on a.ID = d.DesignUserId " +
  448. "left join " +
  449. "( " +
  450. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  451. ") as e on a.ID = e.DesignUserId " +
  452. "left join " +
  453. "( " +
  454. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  455. ") as g on a.ID = g.DesignUserId " +
  456. "left join " +
  457. "( " +
  458. " select CustomerUserId, RefundCount, RefundSum from " +
  459. " ( " +
  460. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  461. " from CE_ErpTradeRefund a " +
  462. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  463. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  464. " group by CustomerUserId " +
  465. " ) as a " +
  466. ") as f on a.ID = f.CustomerUserId " +
  467. "where a.PostCode = 'Designer') as z",
  468. userWhere, orderWhere);
  469. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  470. writeGridDataTableJson(dt.Rows.Count, dt);
  471. }
  472. //删除tradecell的订单
  473. public void del_erp_cellorder()
  474. {
  475. if (UrlPostParmsCheck("ctid"))
  476. {
  477. string eid = GetPostString("ctid");
  478. CeErpTradeCell.DelByCtid(eid);
  479. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  480. returnSuccessMsg("删除成功");
  481. }
  482. }
  483. public void clear_erp_refundstate()
  484. {
  485. if (UrlPostParmsCheck("ids"))
  486. {
  487. string eids = GetPostString("ids");
  488. string[] ctidList = eids.Split(',');
  489. foreach (string ctid in ctidList)
  490. {
  491. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  492. if (entity != null)
  493. {
  494. entity.IsRefund = 0;
  495. entity.Update();
  496. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  497. }
  498. else
  499. continue;
  500. }
  501. returnSuccessMsg("操作成功");
  502. return;
  503. }
  504. returnErrorMsg("缺少必要参数");
  505. }
  506. public void set_erp_urgency()
  507. {
  508. if (UrlPostParmsCheck("ctid"))
  509. {
  510. string eid = GetPostString("ctid");
  511. CeErpTradeCell entity = null;
  512. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  513. if (entity != null)
  514. {
  515. string utime = GetPostString("urgencytime");
  516. if (utime.Length > 0)
  517. {
  518. entity.UrgencyTime = Convert.ToDateTime(utime);
  519. }
  520. else
  521. {
  522. returnErrorMsg("请选择加急时间");
  523. return;
  524. }
  525. if (entity.OrderState <= 4)
  526. {
  527. //entity.seller_memo = entity.seller_memo + "-加急";
  528. string smemo = entity.seller_memo;
  529. int kindex = smemo.IndexOf(")");
  530. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  531. if (lastoneStr != "-")
  532. {
  533. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  534. }
  535. string prememo = smemo.Substring(0, kindex + 2);
  536. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  537. int lastkindex = lastmemo.IndexOf("(");
  538. DateTime urgtime = Convert.ToDateTime(utime);
  539. string newlastmemo = "";
  540. if (lastkindex == 0)
  541. {
  542. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  543. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  544. }
  545. else
  546. {
  547. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  548. }
  549. entity.seller_memo = prememo + newlastmemo;
  550. }
  551. entity.IsUrgency = true;
  552. entity.Update();
  553. ApiVo apiVo = new ApiVo();
  554. apiVo.orderNumber = entity.ctid;
  555. apiVo.actionName = "changeDesign";
  556. apiVo.orderRemarks = entity.seller_memo;
  557. apiVo.remarkSign = 3;
  558. designHelper.API_WorkCore(apiVo); //changeDesign
  559. CeErpSukuraData.createInfo(entity.ctid, 7);
  560. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  561. returnSuccessMsg("设置成功!");
  562. return;
  563. }
  564. returnErrorMsg("找不到记录");
  565. }
  566. }
  567. public void set_erp_reset()
  568. {
  569. if (UrlPostParmsCheck("ctid"))
  570. {
  571. string eid = GetPostString("ctid");
  572. CeErpTradeCell entity = null;
  573. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  574. if (entity != null)
  575. {
  576. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  577. {
  578. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  579. {
  580. returnErrorMsg("财务要求已下单已发货无法重置");
  581. return;
  582. }
  583. }
  584. entity.IsUrgency = false;
  585. entity.seller_memo = "";
  586. entity.OtherMemo = "";
  587. entity.OrderState = 0;
  588. entity.IsReturn = 0;
  589. //entity.IsRefund = 0;
  590. entity.MemoOpt = 0;
  591. entity.AfterSaleState = 0;
  592. entity.AfterSaleResponsible = "";
  593. entity.AfterSaleUserId = 0;
  594. entity.IsNeedBill = 0;
  595. entity.CustomerUserId = 0;
  596. entity.DesignUserId = 0;
  597. entity.SupplierId = 0;
  598. entity.PlaceUserId = 0;
  599. entity.ptid = "";
  600. entity.IsSample = 0;
  601. entity.IsXianHuo = 0;
  602. entity.isDianziOrder = 0;
  603. entity.DispatchSort = 0;
  604. entity.FinishPlaceTime = null;
  605. entity.Update();
  606. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  607. if (trade != null)
  608. {
  609. trade.seller_memo = "";
  610. trade.Update();
  611. }
  612. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  613. returnSuccessMsg("重置成功!");
  614. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  615. if (desginBill != null)
  616. {
  617. desginBill.isDel = 1;
  618. desginBill.Update();
  619. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  620. }
  621. ApiVo apiVo = new ApiVo();
  622. apiVo.orderNumber = entity.ctid;
  623. apiVo.actionName = "resetDesign";
  624. designHelper.API_WorkCore(apiVo);//resetDesign
  625. return;
  626. }
  627. returnErrorMsg("找不到记录");
  628. }
  629. }
  630. public void save_erp_sellermemo()
  631. {
  632. if (UrlPostParmsCheck("ctid"))
  633. {
  634. string ctid = GetPostString("ctid");
  635. CeErpTradeCell entity = null;
  636. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  637. if (entity != null)
  638. {
  639. string memo = GetPostString("seller_memo");
  640. memo = memo.Replace(" ", "");
  641. if (memo.Contains("补差"))
  642. {
  643. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  644. return;
  645. }
  646. if (entity.seller_memo != memo)
  647. {
  648. if (entity.IsSample == 2)
  649. {
  650. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  651. return;
  652. }
  653. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  654. {
  655. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  656. {
  657. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  658. return;
  659. }
  660. }
  661. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  662. }
  663. commonHelper.getCytPrice(entity);
  664. int memoopt = GetPostInt("MemoOpt");
  665. Boolean ismemoopt = false;
  666. if (memoopt > 0)
  667. {
  668. string stropt = "";
  669. if (memoopt == 1)
  670. {
  671. stropt = "“改稿”";
  672. ismemoopt = true;
  673. }
  674. else if (memoopt == 2)
  675. {
  676. stropt = "“定稿”";
  677. }
  678. else if (memoopt == 3)
  679. {
  680. stropt = "“查货”";
  681. CeErpSukuraData.createInfo(entity.ctid, 6);
  682. }
  683. entity.MemoOpt = Convert.ToInt32(memoopt);
  684. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  685. }
  686. if (entity.OrderState < 5)
  687. {
  688. memo = memo.Replace("(", "(");
  689. memo = memo.Replace(")", ")");
  690. }
  691. entity.seller_memo = memo;
  692. entity.Update();
  693. ApiVo apiVo = new ApiVo();
  694. apiVo.orderNumber = entity.ctid;
  695. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  696. apiVo.orderRemarks = memo;
  697. apiVo.remarkSign = memoopt;
  698. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  699. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  700. returnSuccessMsg("保存成功!");
  701. return;
  702. }
  703. returnErrorMsg("找不到记录");
  704. }
  705. }
  706. public void ins_erp_checkorder()
  707. {
  708. if (UrlPostParmsCheck("ctid"))
  709. {
  710. string ctid = GetPostString("ctid");
  711. CeErpTradeCell entity = null;
  712. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  713. if (entity != null)
  714. {
  715. if (entity.OrderState < 6)
  716. {
  717. returnErrorMsg("下单完成后才可查货");
  718. return;
  719. }
  720. /*if (entity.OrderState > 6)
  721. {
  722. returnErrorMsg("订单已发货");
  723. return;
  724. }*/
  725. if (entity.FinishPlaceTime != null)
  726. {
  727. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  728. {
  729. returnErrorMsg("下单时间不足,无法查货");
  730. return;
  731. }
  732. }
  733. entity.MemoOpt = 3;
  734. entity.CheckOrderTime = DateTime.Now;
  735. entity.Update();
  736. CeErpSukuraData.createInfo(entity.ctid, 6);
  737. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  738. returnSuccessMsg("操作成功!");
  739. return;
  740. }
  741. returnErrorMsg("找不到记录");
  742. }
  743. }
  744. public void save_erp_othermemo()
  745. {
  746. if (UrlPostParmsCheck("ctid"))
  747. {
  748. string ctid = GetPostString("ctid");
  749. CeErpTradeCell entity = null;
  750. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  751. if (entity != null)
  752. {
  753. entity.OtherMemo = GetPostString("otherMemo");
  754. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  755. {
  756. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  757. StringBuilder sql = new StringBuilder();
  758. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  759. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  760. if (dt != null && dt.Rows.Count > 0)
  761. {
  762. foreach (DataRow dr in dt.Rows)
  763. {
  764. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  765. {
  766. //品类一直
  767. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  768. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  769. if (ceErpSampleCustomer == null)
  770. {
  771. ceErpSampleCustomer = new CeErpSampleCustomer();
  772. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  773. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  774. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  775. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  776. ceErpSampleCustomer.shopId = entity.ShopId;
  777. }
  778. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  779. ceErpSampleCustomer.lastTid = entity.tid;
  780. if (ceErpSampleCustomer.ID > 0)
  781. {
  782. ceErpSampleCustomer.Update();
  783. }
  784. else
  785. {
  786. ceErpSampleCustomer.Create();
  787. }
  788. }
  789. }
  790. }
  791. }
  792. //if (entity.IsOldCustomer == 1)
  793. //{
  794. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  795. //{
  796. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  797. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  798. //}
  799. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  800. //{
  801. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  802. // {
  803. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  804. // {
  805. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  806. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  807. // }
  808. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  809. // {
  810. // entity.OrderState = 2;
  811. // entity.DesignUserId = 0;
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  813. // }
  814. // else
  815. // {
  816. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  817. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  818. // }
  819. // }
  820. //}
  821. //}
  822. entity.Update();
  823. returnSuccessMsg("保存成功!");
  824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  825. return;
  826. }
  827. returnErrorMsg("找不到记录");
  828. }
  829. }
  830. public void save_erp_customermemo()
  831. {
  832. if (UrlPostParmsCheck("ctid"))
  833. {
  834. string ctid = GetPostString("ctid");
  835. CeErpTradeCell entity = null;
  836. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  837. if (entity != null)
  838. {
  839. entity.CustomerMemo = GetPostString("CustomerMemo");
  840. entity.Update();
  841. ApiVo apiVo = new ApiVo();
  842. apiVo.orderNumber = entity.ctid;
  843. apiVo.actionName = "followRemarks";
  844. apiVo.orderRemarks = entity.CustomerMemo;
  845. designHelper.API_WorkCore(apiVo);//followRemarks
  846. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  847. returnSuccessMsg("保存成功!");
  848. return;
  849. }
  850. returnErrorMsg("找不到记录");
  851. }
  852. }
  853. public void upd_erp_addmemotag()
  854. {
  855. if (UrlPostParmsCheck("ctid"))
  856. {
  857. ;
  858. string eid = GetPostString("ctid");
  859. string sfTagstr = GetPostString("memotag");
  860. CeErpTradeCell entity = null;
  861. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  862. if (entity != null)
  863. {
  864. if (entity.OrderState == 0)
  865. {
  866. returnErrorMsg("请先领单");
  867. return;
  868. }
  869. //撤销顺丰
  870. if (sfTagstr == "撤销顺丰")
  871. {
  872. entity.IsSF = 0;
  873. string reMsg = "";
  874. string oldmemo = entity.seller_memo;
  875. if (entity.OrderState < 5)
  876. {
  877. oldmemo = oldmemo.Replace("顺丰到付", "");
  878. oldmemo = oldmemo.Replace("顺丰寄付", "");
  879. entity.seller_memo = oldmemo;
  880. }
  881. else
  882. {
  883. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  884. {
  885. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  886. }
  887. }
  888. entity.Update();
  889. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  890. api.orderNumber = entity.ctid;
  891. api.actionName = "followRemarks";
  892. api.orderRemarks = entity.seller_memo;
  893. api.isSf = entity.IsSF.ToString();
  894. designHelper.API_WorkCore(api);//followRemarks
  895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  896. returnSuccessMsg("撤销成功!" + reMsg);
  897. return;
  898. }
  899. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  900. {
  901. //string oldmemo = entity.seller_memo;
  902. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  903. string sfStr = GetPostString("memotag");
  904. string smemo = entity.seller_memo;
  905. int kindex = smemo.IndexOf(")");
  906. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  907. if (lastoneStr != "-")
  908. {
  909. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  910. }
  911. string prememo = smemo.Substring(0, kindex + 2);
  912. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  913. int lastkindex = lastmemo.IndexOf("(");
  914. string newlastmemo = "";
  915. if (lastkindex == 0)
  916. {
  917. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  918. newlastmemo = "(" + sfStr + "." + useLastmemo;
  919. }
  920. else
  921. {
  922. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  923. }
  924. entity.seller_memo = prememo + newlastmemo;
  925. }
  926. string sfTagMSg = "";
  927. if (sfTagstr == "顺丰寄付")
  928. {
  929. entity.IsSF = 1;
  930. sfTagMSg = "顺丰寄付";
  931. }
  932. else if (sfTagstr == "顺丰到付")
  933. {
  934. entity.IsSF = 2;
  935. sfTagMSg = "顺丰到付";
  936. }
  937. entity.Update();
  938. ApiVo apiVo = new ApiVo();
  939. apiVo.orderNumber = entity.ctid;
  940. apiVo.actionName = "orderRemarks";
  941. apiVo.orderRemarks = entity.seller_memo;
  942. apiVo.isSf = entity.IsSF.ToString();
  943. designHelper.API_WorkCore(apiVo);//orderRemarks
  944. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  945. returnSuccessMsg("标记成功!");
  946. return;
  947. }
  948. returnErrorMsg("找不到记录");
  949. }
  950. }
  951. public void upd_erp_ordertag()
  952. {
  953. if (UrlPostParmsCheck("ctid"))
  954. {
  955. string eid = GetPostString("ctid");
  956. CeErpTradeCell entity = null;
  957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  958. if (entity != null)
  959. {
  960. int tag = GetPostInt("wechattag");
  961. //if(tag==4 && entity.IsSample == 2)
  962. //{
  963. // returnErrorMsg("补差价单不能标记微信单");
  964. // return;
  965. //}
  966. entity.wechatTag = tag;
  967. entity.Update();
  968. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  969. if (tag == 1)
  970. {
  971. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  972. if (cash == null)
  973. {
  974. CeErpTrade main = CeErpTrade.Get(entity.tid);
  975. cash = new CeErpReturnCash();
  976. cash.tid = entity.tid;
  977. cash.seller_nick = main.seller_nick;
  978. cash.payment = trade.payment;
  979. cash.buyer_nick = main.buyer_nick;
  980. cash.cashstate = 0;
  981. cash.rtype = "微信返现";
  982. cash.returnprice = 0;
  983. cash.created = DateTime.Now;
  984. cash.con = "订单标记微信单";
  985. cash.img = "";
  986. cash.applyuserid = CurrentUser.UserID;
  987. cash.Create();
  988. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  989. }
  990. else
  991. {
  992. cash.cashstate = 0;
  993. cash.Update();
  994. }
  995. CeErpSukuraData.createInfo(entity.ctid, 9);
  996. }
  997. else if (tag == 2)
  998. {
  999. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1000. if (cash == null)
  1001. {
  1002. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1003. cash = new CeErpReturnCash();
  1004. cash.tid = entity.tid;
  1005. cash.seller_nick = main.seller_nick;
  1006. cash.payment = trade.payment;
  1007. cash.buyer_nick = main.buyer_nick;
  1008. cash.cashstate = 0;
  1009. cash.rtype = "推购返现";
  1010. cash.returnprice = 5;
  1011. cash.created = DateTime.Now;
  1012. cash.con = "订单标记推购单";
  1013. cash.img = "";
  1014. cash.applyuserid = CurrentUser.UserID;
  1015. cash.Create();
  1016. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1017. }
  1018. else
  1019. {
  1020. cash.cashstate = 0;
  1021. cash.Update();
  1022. }
  1023. CeErpSukuraData.createInfo(entity.ctid, 9);
  1024. }
  1025. else if (tag == 3)
  1026. {
  1027. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1028. if (pers == null)
  1029. {
  1030. pers = new CeErpPersuade();
  1031. pers.ctid = entity.ctid;
  1032. pers.pstate = 0;
  1033. pers.created = DateTime.Now;
  1034. pers.applyuserid = CurrentUser.UserID;
  1035. pers.Create();
  1036. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1037. }
  1038. else
  1039. {
  1040. pers.pstate = 0;
  1041. pers.Update();
  1042. }
  1043. }
  1044. else if (tag == 4 || tag == 5)
  1045. {
  1046. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1047. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1048. if (pers == null)
  1049. {
  1050. pers = new CeErpStayGoods();
  1051. pers.t_id = entity.tid;
  1052. pers.status = "待审核";
  1053. pers.audit_type = 0;
  1054. if (tag == 4)
  1055. {
  1056. pers.stay_type = "微信推购";
  1057. }
  1058. else
  1059. {
  1060. pers.stay_type = "旺旺推购";
  1061. }
  1062. if (entity.IsXianHuo == 0)
  1063. {
  1064. pers.product_id = entity.ProductId;
  1065. }
  1066. pers.wangwang = main.buyer_nick;
  1067. pers.shop_name = main.seller_nick;
  1068. pers.creata_time = DateTime.Now;
  1069. pers.create_u_id = CurrentUser.UserID;
  1070. pers.create_u_name = CurrentUser.UserName;
  1071. pers.Create();
  1072. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1073. }
  1074. else
  1075. {
  1076. pers.audit_type = 0;
  1077. pers.Update();
  1078. }
  1079. CeErpSukuraData.createInfo(entity.ctid, 10);
  1080. }
  1081. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1082. returnSuccessMsg("标记成功!");
  1083. return;
  1084. }
  1085. returnErrorMsg("找不到记录");
  1086. }
  1087. }
  1088. public void upd_erp_ordertag_cancel()
  1089. {
  1090. if (UrlPostParmsCheck("ctid"))
  1091. {
  1092. string eid = GetPostString("ctid");
  1093. CeErpTradeCell entity = null;
  1094. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1095. if (entity != null)
  1096. {
  1097. entity.wechatTag = 0;
  1098. entity.Update();
  1099. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1100. if (pers != null)
  1101. {
  1102. pers.status = "取消推购";
  1103. pers.audit_type = 3;
  1104. pers.Update();
  1105. }
  1106. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1107. returnSuccessMsg("标记成功!");
  1108. return;
  1109. }
  1110. returnErrorMsg("找不到记录");
  1111. }
  1112. }
  1113. public void upd_erp_addweichattag()
  1114. {
  1115. if (UrlPostParmsCheck("ctid"))
  1116. {
  1117. ;
  1118. string eid = GetPostString("ctid");
  1119. CeErpTradeCell entity = null;
  1120. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1121. if (entity != null)
  1122. {
  1123. if (entity.IsAddWechat > 0)
  1124. {
  1125. returnErrorMsg("此单已经标记过了");
  1126. return;
  1127. }
  1128. 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);
  1129. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1130. if (dt.Rows.Count > 0)
  1131. {
  1132. entity.IsAddWechat = 2;
  1133. }
  1134. else
  1135. {
  1136. entity.IsAddWechat = 1;
  1137. }
  1138. entity.Update();
  1139. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1140. returnSuccessMsg("标记成功!");
  1141. return;
  1142. }
  1143. returnErrorMsg("找不到记录");
  1144. }
  1145. }
  1146. public void upd_erp_getmyorder()
  1147. {
  1148. if (UrlPostParmsCheck("ctid"))
  1149. {
  1150. ;
  1151. string eid = GetPostString("ctid");
  1152. CeErpTradeCell entity = null;
  1153. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1154. if (entity != null)
  1155. {
  1156. if (entity.ctid.IndexOf("C") != -1)
  1157. {
  1158. StringBuilder sql = new StringBuilder();
  1159. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1160. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1161. if (dt.Rows.Count > 0)
  1162. {
  1163. decimal total = 0;
  1164. foreach (DataRow dr in dt.Rows)
  1165. {
  1166. total += Convert.ToDecimal(dr["payment"]);
  1167. }
  1168. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1169. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1170. {
  1171. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1172. return;
  1173. }
  1174. }
  1175. }
  1176. entity.CustomerUserId = CurrentUser.UserID;
  1177. if (entity.OrderState < 2)
  1178. {
  1179. entity.OrderState = 2;
  1180. if (entity.ShopId != 0)
  1181. {
  1182. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1183. }
  1184. }
  1185. entity.Update();
  1186. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1187. returnSuccessMsg("领单成功!");
  1188. return;
  1189. }
  1190. returnErrorMsg("找不到记录");
  1191. }
  1192. }
  1193. public void getmyorder_from_init()
  1194. {
  1195. if (UrlPostParmsCheck("ctid"))
  1196. {
  1197. string eid = GetPostString("ctid");
  1198. CeErpTradeCell entity = null;
  1199. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1200. if (entity != null)
  1201. {
  1202. string sellerMemo = GetPostString("sellerMemo");
  1203. if (sellerMemo.Length > 0)
  1204. {
  1205. entity.seller_memo = sellerMemo;
  1206. }
  1207. string oterhMemo = GetPostString("otherMemo");
  1208. if (oterhMemo.Length > 0)
  1209. {
  1210. entity.OtherMemo = oterhMemo;
  1211. }
  1212. int urg = GetPostInt("urgency");
  1213. entity.IsUrgency = (urg == 1 ? true : false);
  1214. int wechat = GetPostInt("wechat");
  1215. int command = GetPostInt("command");
  1216. if (wechat == 1)
  1217. {
  1218. entity.wechatTag = 1;
  1219. }
  1220. if (command == 1)
  1221. {
  1222. entity.wechatTag = 2;
  1223. }
  1224. string pPro = GetPostString("pprofession");
  1225. if (pPro.Length > 0)
  1226. {
  1227. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1228. string spro = GetPostString("profession");
  1229. if (spro.Length > 0)
  1230. {
  1231. entity.ProfessionId = Convert.ToInt32(spro);
  1232. }
  1233. }
  1234. string proId = GetPostString("productId");
  1235. if (proId.Length > 0)
  1236. {
  1237. entity.ProductId = Convert.ToInt32(proId);
  1238. }
  1239. entity.Material = GetPostString("material");
  1240. entity.Craft = GetPostString("craft");
  1241. entity.CustomerUserId = CurrentUser.UserID;
  1242. if (entity.OrderState < 2)
  1243. {
  1244. entity.OrderState = 2;
  1245. if (entity.ShopId != 0)
  1246. {
  1247. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1248. }
  1249. }
  1250. entity.Update();
  1251. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1252. returnSuccessMsg("领单成功!");
  1253. return;
  1254. }
  1255. returnErrorMsg("找不到记录");
  1256. }
  1257. }
  1258. public void upd_erp_setrelationorder()
  1259. {
  1260. if (UrlPostParmsCheck("ctid"))
  1261. {
  1262. ;
  1263. string eid = GetPostString("ctid");
  1264. string ftid = GetPostString("ftid");
  1265. CeErpTradeCell entity = null;
  1266. CeErpTradeCell fentity = null;
  1267. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1268. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1269. if (fentity == null)
  1270. {
  1271. returnErrorMsg("找不到关联的主订单");
  1272. return;
  1273. }
  1274. if (entity != null)
  1275. {
  1276. if (entity.OrderState >= 5)
  1277. {
  1278. returnErrorMsg("本单已经设计完成无法关联");
  1279. return;
  1280. }
  1281. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1282. {
  1283. returnErrorMsg("线下单续审核后才能关联!");
  1284. return;
  1285. }
  1286. entity.ptid = ftid;
  1287. entity.OrderState = fentity.OrderState;
  1288. //entity.status = fentity.status;
  1289. entity.CustomerUserId = fentity.CustomerUserId;
  1290. entity.DesignUserId = fentity.DesignUserId;
  1291. entity.seller_memo = "补差价单:" + ftid;
  1292. entity.IsSample = 2;
  1293. entity.Update();
  1294. ApiVo apiVo = new ApiVo();
  1295. apiVo.orderNumber = ftid;
  1296. apiVo.payment = entity.payment;
  1297. apiVo.actionName = "repairDesign";
  1298. designHelper.API_WorkCore(apiVo);//repairDesign
  1299. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1300. returnSuccessMsg("关联成功!");
  1301. return;
  1302. }
  1303. else
  1304. returnErrorMsg("找不到记录");
  1305. }
  1306. }
  1307. public void download_erp_neworder()
  1308. {
  1309. string seller = GetPostString("seller_nick");
  1310. string tid = GetPostString("tid");
  1311. if (seller.Length <= 0 || tid.Length <= 0)
  1312. {
  1313. returnErrorMsg("数据错误");
  1314. }
  1315. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1316. //{
  1317. // returnErrorMsg("找不到店铺Sessionkey");
  1318. //}
  1319. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1320. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1321. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1322. if (res.IndexOf("refOid") == -1)
  1323. {
  1324. returnErrorMsg("下载订单数据失败");
  1325. return;
  1326. }
  1327. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1328. returnSuccessMsg("下载完成");
  1329. //tmcHelper.createNewOrder(res);
  1330. //CeErpTrade entr = null;
  1331. //entr = CeErpTrade.Get(tid);
  1332. //if (entr != null)
  1333. //{
  1334. // returnSuccess("下载成功");
  1335. // //下载成功之后,Cell表生成对应的订单;
  1336. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1337. //}
  1338. //else
  1339. //{
  1340. // returnErrorMsg("下载失败或者创建订单失败");
  1341. //}
  1342. }
  1343. public void set_erp_atersale()
  1344. {
  1345. if (UrlPostParmsCheck("ctid"))
  1346. {
  1347. string eid = GetPostString("ctid");
  1348. string reason = GetPostString("AfterSaleReason");
  1349. CeErpTradeCell entity = null;
  1350. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1351. if (entity != null)
  1352. {
  1353. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1354. {
  1355. returnErrorMsg("此订单已经在售后");
  1356. return;
  1357. }
  1358. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1359. //entity.AfterSaleReason = reason;
  1360. entity.AfterSaleTime = DateTime.Now;
  1361. entity.Update();
  1362. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1363. returnSuccessMsg("转售后成功!");
  1364. return;
  1365. }
  1366. returnErrorMsg("找不到记录");
  1367. }
  1368. }
  1369. public void set_erp_withdraw()
  1370. {
  1371. if (UrlPostParmsCheck("ctid"))
  1372. {
  1373. try
  1374. {
  1375. string eid = GetPostString("ctid");//商品id
  1376. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1377. CeWithdraw ceWithdrawSelect = null;
  1378. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1379. if (ceWithdrawSelect != null)
  1380. {
  1381. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1382. {
  1383. ceWithdrawSelect.status = -1;
  1384. ceWithdrawSelect.Update();
  1385. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1386. returnSuccessMsg("重新发起审核成功");
  1387. return;
  1388. }
  1389. else
  1390. {
  1391. returnSuccessMsg("请勿重复申请!");
  1392. return;
  1393. }
  1394. }
  1395. else
  1396. {
  1397. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1398. if (string.IsNullOrEmpty(CustomerUserId))
  1399. {
  1400. CustomerUserId = "-1";
  1401. }
  1402. int Userid = CurrentUser.UserID;//用户id
  1403. CeWithdraw ceWithdraw = new CeWithdraw();
  1404. ceWithdraw.tid = eid;
  1405. ceWithdraw.userid = Userid;
  1406. ceWithdraw.providerid = CustomerUserId;
  1407. ceWithdraw.status = 3;
  1408. ceWithdraw.creationtime = DateTime.Now;
  1409. ceWithdraw.Create();
  1410. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1411. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1412. return;
  1413. }
  1414. }
  1415. catch
  1416. {
  1417. returnErrorMsg("申请撤回订单失败");
  1418. return;
  1419. }
  1420. }
  1421. }
  1422. public void ins_erp_billinfo()
  1423. {
  1424. if (UrlPostParmsCheck("ctid"))
  1425. {
  1426. string eid = GetPostString("ctid");
  1427. CeErpTradeCell entity = null;
  1428. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1429. if (entity != null)
  1430. {
  1431. CeErpBill bill = CeErpBill.GetByTid(eid);
  1432. bool isHave = false;
  1433. if (bill != null)
  1434. {
  1435. isHave = true;
  1436. if (bill.state != 4)
  1437. {
  1438. returnErrorMsg("此单已经申请过发票了");
  1439. return;
  1440. }
  1441. }
  1442. if (entity.IsNeedBill == 0)
  1443. {
  1444. entity.IsNeedBill = 1;
  1445. }
  1446. entity.Update();
  1447. string errjson = "";
  1448. try
  1449. {
  1450. CeErpBill bill_entity = new CeErpBill();
  1451. bill_entity.tid = entity.tid;
  1452. bill_entity.title = GetPostString("title");
  1453. string taxstr = GetPostString("tax");
  1454. taxstr = taxstr.Replace(" ", "");
  1455. bill_entity.tax = taxstr;
  1456. bill_entity.bank = GetPostString("bank");
  1457. string bankacstr = GetPostString("bankac");
  1458. bankacstr = bankacstr.Replace(" ", "");
  1459. bill_entity.bankac = bankacstr;
  1460. bill_entity.address = GetPostString("address");
  1461. bill_entity.phone = GetPostString("phone");
  1462. bill_entity.price = GetPostString("price");
  1463. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1464. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1465. {
  1466. billCount += 1;
  1467. }
  1468. string prebill = "ltb";
  1469. for (int idx = 1; idx <= billCount; idx++)
  1470. {
  1471. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1472. string billoid = prebill + idx + dtstr;
  1473. bill_entity.billOrderId += billoid;
  1474. if (idx < billCount)
  1475. {
  1476. bill_entity.billOrderId += ",";
  1477. }
  1478. }
  1479. bill_entity.productId = GetPostInt("ProductName");
  1480. bill_entity.num = GetPostInt("num");
  1481. bill_entity.unit = GetPostString("unit");
  1482. bill_entity.type = GetPostString("type");
  1483. bill_entity.sendType = GetPostString("SendType");
  1484. bill_entity.email = GetPostString("email");
  1485. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1486. bill_entity.shopName = GetPostString("ShopName");
  1487. bill_entity.applymemo = GetPostString("applyMemo");
  1488. bill_entity.createTime = DateTime.Now;
  1489. bill_entity.state = 0;
  1490. bill_entity.userId = CurrentUser.UserID;
  1491. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1492. bill_entity.Create();
  1493. }
  1494. catch (Exception ex)
  1495. {
  1496. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1497. returnErrorMsg("创建发票出错!");
  1498. return;
  1499. }
  1500. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1501. returnSuccessMsg("发票申请成功!");
  1502. return;
  1503. }
  1504. returnErrorMsg("找不到记录");
  1505. }
  1506. }
  1507. public void ins_erp_neworder()
  1508. {
  1509. if (UrlPostParmsCheck("receiver_name"))
  1510. {
  1511. CeErpTrade entity = new CeErpTrade();
  1512. string plat_form = GetPostString("platform");
  1513. string preStr = "N_";
  1514. if (plat_form == "拼多多")
  1515. {
  1516. preStr = "P_";
  1517. }
  1518. else if (plat_form == "阿里巴巴")
  1519. {
  1520. preStr = "A_";
  1521. }
  1522. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1523. entity.seller_nick = GetPostString("seller_nick");
  1524. entity.buyer_nick = GetPostString("buyer_nick");
  1525. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1526. entity.total_fee = entity.payment;
  1527. entity.pay_time = DateTime.Now;
  1528. entity.status = "NOT_SHIPPED";
  1529. entity.receiver_name = GetPostString("receiver_name");
  1530. entity.receiver_mobile = GetPostString("receiver_mobile");
  1531. entity.receiver_state = GetPostString("receiver_state");
  1532. entity.receiver_city = GetPostString("receiver_city");
  1533. entity.receiver_district = GetPostString("receiver_district");
  1534. entity.receiver_address = GetPostString("receiver_address");
  1535. if (entity.receiver_state == "" || entity.receiver_city == "")
  1536. {
  1537. returnErrorMsg("收件地址不能为空");
  1538. return;
  1539. }
  1540. int shopId = 0;
  1541. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1542. if (nShop != null)
  1543. {
  1544. shopId = nShop.ID;
  1545. }
  1546. if (shopId != 34 && entity.payment == 0)
  1547. {
  1548. returnErrorMsg("公司自用的单金额才能为0");
  1549. return;
  1550. }
  1551. entity.Create();
  1552. CeErpTradeCell entitycell = new CeErpTradeCell();
  1553. entitycell.ctid = entity.tid;
  1554. entitycell.tid = entity.tid;
  1555. entitycell.ShopId = shopId;
  1556. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1557. entitycell.OrderState = 0;
  1558. entitycell.pay_time = entity.pay_time;
  1559. entitycell.IsOffLineOrder = 1;
  1560. entitycell.Create();
  1561. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1562. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1563. return;
  1564. }
  1565. }
  1566. public void ins_erp_neworder2()
  1567. {
  1568. if (UrlPostParmsCheck("receiver_name"))
  1569. {
  1570. //string plat_form = GetPostString("platform");
  1571. string preStr = "X_";
  1572. string memo = GetPostString("memo");
  1573. string productId = GetPostString("productId");
  1574. string primg = GetPostString("proofimg");
  1575. string sellerNick = GetPostString("seller_nick");
  1576. string addFrom = GetPostString("addfrom");
  1577. if (addFrom == "1")
  1578. {
  1579. preStr = "N_";
  1580. }
  1581. int shopId = 0;
  1582. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1583. if (nShop != null)
  1584. {
  1585. shopId = nShop.ID;
  1586. }
  1587. else
  1588. {
  1589. returnErrorMsg("找不到对应店铺");
  1590. return;
  1591. }
  1592. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1593. {
  1594. returnErrorMsg("必须上传付款凭证");
  1595. return;
  1596. }
  1597. CeErpTrade entity = new CeErpTrade();
  1598. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1599. entity.seller_nick = sellerNick;
  1600. entity.buyer_nick = GetPostString("buyer_nick");
  1601. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1602. entity.total_fee = entity.payment;
  1603. entity.pay_time = DateTime.Now;
  1604. entity.status = "NOT_SHIPPED";
  1605. entity.receiver_name = GetPostString("receiver_name");
  1606. entity.receiver_mobile = GetPostString("receiver_mobile");
  1607. entity.receiver_state = GetPostString("receiver_state");
  1608. entity.receiver_city = GetPostString("receiver_city");
  1609. entity.receiver_district = GetPostString("receiver_district");
  1610. entity.receiver_address = GetPostString("receiver_address");
  1611. entity.seller_memo = memo;
  1612. entity.orderFrom = 20;
  1613. entity.orderType = 15;
  1614. if (entity.receiver_state == "" || entity.receiver_city == "")
  1615. {
  1616. returnErrorMsg("收件地址不能为空");
  1617. return;
  1618. }
  1619. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1620. {
  1621. returnErrorMsg("公司自用的单金额才能为0");
  1622. return;
  1623. }
  1624. entity.Create();
  1625. string toWhere = GetPostString("towhere");
  1626. CeErpTradeCell entitycell = new CeErpTradeCell();
  1627. entitycell.ctid = entity.tid;
  1628. //唯一标识
  1629. entitycell.OrderSn = entity.tid;
  1630. //string orderSn = dataHelper.getSaleOrderSn();
  1631. //if (orderSn != "")
  1632. // {
  1633. // entitycell.OrderSn = orderSn;
  1634. // }
  1635. entitycell.tid = entity.tid;
  1636. //if (preStr == "X_")
  1637. //{
  1638. entitycell.IsOffLineOrder = 1;
  1639. //}
  1640. entitycell.CustomerUserId = CurrentUser.UserID;
  1641. entitycell.PayProofImg = primg;
  1642. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1643. entitycell.ProductId = Convert.ToInt32(productId);
  1644. entitycell.ShopId = shopId;
  1645. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1646. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1647. {
  1648. entitycell.IsXianHuo = 1;
  1649. }
  1650. entitycell.pay_time = entity.pay_time;
  1651. if (toWhere == "1")
  1652. {
  1653. entitycell.OrderState = 2;
  1654. }
  1655. else
  1656. {
  1657. entitycell.OrderState = 6;
  1658. entitycell.FinishPlaceTime = entitycell.pay_time;
  1659. }
  1660. if (shopId == 94)
  1661. {
  1662. entitycell.OrderState = 4;
  1663. entitycell.WaitDesignTime = entitycell.pay_time;
  1664. entitycell.StartDesignTime = entitycell.pay_time;
  1665. entitycell.DesignUserId = 218;
  1666. }
  1667. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1668. {
  1669. entitycell.OrderState = -1;//修改12-5
  1670. CeWithdraw ceWithdraw = new CeWithdraw();
  1671. ceWithdraw.tid = entity.tid;
  1672. ceWithdraw.providerid = "-1";
  1673. ceWithdraw.status = -1;
  1674. ceWithdraw.creationtime = DateTime.Now;
  1675. ceWithdraw.userid = 1337;
  1676. ceWithdraw.Create();
  1677. }
  1678. entitycell.Create();
  1679. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1680. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1681. {
  1682. addPlaceRegist(entitycell, CurrentUser.UserID);
  1683. }
  1684. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1685. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1686. return;
  1687. }
  1688. }
  1689. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1690. {
  1691. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1692. entity.PlactTime = tradecell.pay_time;
  1693. entity.AddUserId = userid;
  1694. entity.FileName = tradecell.seller_memo;
  1695. entity.Supplier = 24;
  1696. entity.CreateTime = DateTime.Now;
  1697. entity.Did = tradecell.ctid;
  1698. entity.tid = tradecell.tid;
  1699. entity.splitTag = tradecell.SplitTag;
  1700. entity.CurState = "未完成";
  1701. entity.Create();
  1702. }
  1703. public void get_erp_offlinelist()
  1704. {
  1705. DataStruct dStruct = GetPostStruct();
  1706. List<string> lw = new List<string>();
  1707. string tid = GetPostString("ctid");
  1708. string date1 = GetPostString("date1");
  1709. string date2 = GetPostString("date2");
  1710. if (tid.Length > 0 || date1.Length > 0)
  1711. {
  1712. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1713. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1714. if (dw.Length > 0) lw.Add(dw);
  1715. }
  1716. else
  1717. {
  1718. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1719. }
  1720. string shopname = GetPostString("shopname");
  1721. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1722. string buyernick = GetPostString("buyer_nick");
  1723. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1724. string customer = GetPostString("customer");
  1725. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1726. string design = GetPostString("design");
  1727. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1728. string orderState = GetPostString("orderState");
  1729. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1730. string address = GetPostString("address");
  1731. 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));
  1732. string sellermemo = GetPostString("seller_memo");
  1733. if (sellermemo.Length > 0)
  1734. {
  1735. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1736. }
  1737. string price1 = GetPostString("price1");
  1738. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1739. string price2 = GetPostString("price2");
  1740. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1741. //if (PKey != "admin")
  1742. //{
  1743. // string usershop = CurrentUser.User.pemShop;
  1744. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1745. //}
  1746. //if (ex_psize > 0)
  1747. //{
  1748. dStruct.Order = "pay_time desc";
  1749. //}
  1750. //else
  1751. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1752. lw.Add(string.Format("IsOffLineOrder=1"));
  1753. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1754. DataTable dt = null;
  1755. dt = WebCache.GetData("view_erptradecell", dStruct);
  1756. writeGridDataTableJson(dStruct.TotalCount, dt);
  1757. }
  1758. public void get_erp_returncashrecord()
  1759. {
  1760. DataStruct dStruct = GetPostStruct();
  1761. List<string> lw = new List<string>();
  1762. string tid = GetPostString("ctid");
  1763. if (tid.Length > 0)
  1764. {
  1765. lw.Add(string.Format("tid like '%{0}%'", tid));
  1766. dStruct.Order = "id desc";
  1767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1768. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1769. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1770. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1771. return;
  1772. }
  1773. returnErrorMsg("id数据错误!");
  1774. }
  1775. public void ins_erp_returncashrecord()
  1776. {
  1777. if (UrlPostParmsCheck("tid"))
  1778. {
  1779. string tid = GetPostString("tid");
  1780. string retype = GetPostString("type");
  1781. StringBuilder sql = new StringBuilder();
  1782. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1783. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1784. if (dt.Rows.Count > 0)
  1785. {
  1786. returnErrorMsg("相同返现类型记录已存在");
  1787. return;
  1788. }
  1789. CeErpReturnCash entity = new CeErpReturnCash();
  1790. entity.tid = tid;
  1791. entity.seller_nick = GetPostString("seller_nick");
  1792. string pment = GetPostString("payment");
  1793. if (pment.Length > 0)
  1794. {
  1795. entity.payment = Convert.ToDouble(pment);
  1796. }
  1797. entity.buyer_nick = GetPostString("buyer_nick");
  1798. entity.cashstate = 0;
  1799. entity.rtype = retype;
  1800. string rPrice = GetPostString("returnprice");
  1801. if (rPrice.Length > 0)
  1802. {
  1803. entity.returnprice = Convert.ToDouble(rPrice);
  1804. }
  1805. entity.created = DateTime.Now;
  1806. entity.con = GetPostString("con");
  1807. entity.img = GetPostString("img");
  1808. entity.applyuserid = CurrentUser.UserID;
  1809. entity.Create();
  1810. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1811. returnSuccessMsg("操作成功!");
  1812. return;
  1813. }
  1814. }
  1815. public void set_erp_predelivery()
  1816. {
  1817. if (UrlPostParmsCheck("ctid"))
  1818. {
  1819. string eid = GetPostString("ctid");
  1820. CeErpTradeCell entity = null;
  1821. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1822. if (entity != null)
  1823. {
  1824. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1825. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1826. //{
  1827. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1828. // return;
  1829. //}
  1830. entity.IsPreDelivery = 1;
  1831. entity.Update();
  1832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1833. returnSuccessMsg("预发货成功!");
  1834. return;
  1835. //string shop = GetPostString("seller_nick");
  1836. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1837. //string comName = GetPostString("comName");
  1838. //string comCode = GetPostString("comCode");
  1839. //string outSid = GetPostString("outSid");//运单号
  1840. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1841. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1842. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1843. //string apires = "";
  1844. //if (deliveryType == "虚拟发货")
  1845. //{
  1846. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1847. //}
  1848. //else
  1849. //{
  1850. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1851. //}
  1852. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1853. ////{
  1854. //if (apires.IndexOf("发货成功") != -1)
  1855. //{
  1856. // if (deliveryType != "虚拟发货")
  1857. // {
  1858. // //还要插入快递信息到 快递信息表
  1859. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1860. // exinfo.tid = eid;
  1861. // exinfo.out_sid = outSid;
  1862. // exinfo.company_code = comCode;
  1863. // exinfo.company_name = comName;
  1864. // exinfo.delivery_memo = deliveryMemo;
  1865. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1866. // exinfo.deliveryType = deliveryType;
  1867. // exinfo.Create();
  1868. // }
  1869. // returnSuccessMsg("发货成功!");
  1870. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1871. //}
  1872. //else
  1873. //{
  1874. // returnErrorMsg("淘宝发货失败!!");
  1875. //}
  1876. //return;
  1877. }
  1878. returnErrorMsg("找不到订单记录");
  1879. }
  1880. }
  1881. public void get_erp_unusuallist()
  1882. {
  1883. DataStruct dStruct = GetPostStruct();
  1884. List<string> lw = new List<string>();
  1885. string tid = GetPostString("ctid");
  1886. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1887. string shopname = GetPostString("shopname");
  1888. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1889. string buyernick = GetPostString("buyer_nick");
  1890. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1891. string ResponsibleMan = GetPostString("responsible");
  1892. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1893. string date1 = GetPostString("date1");
  1894. string date2 = GetPostString("date2");
  1895. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1896. if (dw.Length > 0) lw.Add(dw);
  1897. string price1 = GetPostString("price1");
  1898. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1899. string price2 = GetPostString("price2");
  1900. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1901. string orderState = GetPostString("orderState");
  1902. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1903. string sellermemo = GetPostString("seller_memo");
  1904. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1905. lw.Add(string.Format("UnusualTag > 0"));
  1906. lw.Add(string.Format("IsRefund<={0}", 1));
  1907. dStruct.Order = "pay_time desc";
  1908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1910. writeGridDataTableJson(dStruct.TotalCount, dt);
  1911. }
  1912. public void set_erp_unusualtonomal()
  1913. {
  1914. if (UrlPostParmsCheck("ctid"))
  1915. {
  1916. string eid = GetPostString("ctid");
  1917. CeErpTradeCell entity = null;
  1918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1919. if (entity != null)
  1920. {
  1921. entity.UnusualTag = -1;
  1922. entity.Update();
  1923. returnSuccessMsg("忽略成功!");
  1924. return;
  1925. }
  1926. returnErrorMsg("找不到记录");
  1927. }
  1928. }
  1929. public void ins_erp_unusualreason()
  1930. {
  1931. if (UrlPostParmsCheck("ctid"))
  1932. {
  1933. string eid = GetPostString("ctid");
  1934. CeErpTradeCell entity = null;
  1935. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1936. if (entity != null)
  1937. {
  1938. entity.MemoOpt = 4;
  1939. entity.UnusualCon = GetPostString("con");
  1940. entity.Update();
  1941. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1942. if (trade != null)
  1943. {
  1944. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1945. }
  1946. //查货是否超时
  1947. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1948. if (ceErpTradeCellExtend == null)
  1949. {
  1950. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1951. ceErpTradeCellExtend.ctid = entity.ctid;
  1952. }
  1953. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1954. {
  1955. ceErpTradeCellExtend.CheckOut += 1;
  1956. }
  1957. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1958. if (ceErpTradeCellExtend.ID > 0)
  1959. {
  1960. ceErpTradeCellExtend.Update();
  1961. }
  1962. else
  1963. {
  1964. ceErpTradeCellExtend.Create();
  1965. }
  1966. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1967. returnSuccessMsg("操作成功!");
  1968. return;
  1969. }
  1970. returnErrorMsg("找不到记录");
  1971. }
  1972. }
  1973. public void upd_erp_sampleorder()
  1974. {
  1975. if (UrlPostParmsCheck("ctid"))
  1976. {
  1977. string eid = GetPostString("ctid");
  1978. string[] eArr = eid.Split(',');
  1979. if (eArr.Length > 1)
  1980. {
  1981. List<string> eLst = new List<string>();
  1982. for (int i = 0; i < eArr.Length; i++)
  1983. {
  1984. eLst.Add("'" + eArr[i] + "'");
  1985. }
  1986. eid = string.Join(",", eLst.ToArray());
  1987. }
  1988. else
  1989. {
  1990. eid = "'" + eid + "'";
  1991. }
  1992. StringBuilder sql = new StringBuilder();
  1993. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1994. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1995. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1996. if (dt.Rows.Count > 0)
  1997. {
  1998. string errmsg = "";
  1999. foreach (DataRow dr in dt.Rows)
  2000. {
  2001. StringBuilder sqlsb = new StringBuilder();
  2002. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2003. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2004. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2005. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2006. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2007. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2008. {
  2009. continue;
  2010. }
  2011. else
  2012. {
  2013. string emsg = commonHelper.KeepChinese(apires);
  2014. errmsg += emsg;
  2015. }
  2016. }
  2017. if (errmsg.Length > 0)
  2018. {
  2019. returnErrorMsg(errmsg);
  2020. return;
  2021. }
  2022. returnSuccessMsg("操作成功");
  2023. return;
  2024. }
  2025. returnErrorMsg("找不到记录");
  2026. }
  2027. }
  2028. public void upd_erp_transcustomer()
  2029. {
  2030. if (UrlPostParmsCheck("ctid"))
  2031. {
  2032. string eid = GetPostString("ctid");
  2033. int userid = GetPostInt("CustomerUserId");
  2034. CeErpTradeCell entity = null;
  2035. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2036. if (entity != null)
  2037. {
  2038. //string[] mlist = entity.seller_memo.Split('-');
  2039. //string sql = "select * from view_erpuser where id=" + userid;
  2040. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2041. //if (dt != null && dt.Rows.Count > 0)
  2042. //{
  2043. // string nmemo = "";
  2044. // for(int i = 0; i < mlist.Length - 1; i++)
  2045. // {
  2046. // nmemo += mlist[i];
  2047. // nmemo += "-";
  2048. // }
  2049. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2050. // entity.seller_memo = nmemo;
  2051. //}
  2052. entity.CustomerUserId = userid;
  2053. entity.Update();
  2054. returnSuccessMsg("操作成功!");
  2055. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2056. return;
  2057. }
  2058. returnErrorMsg("找不到记录");
  2059. }
  2060. }
  2061. public void upd_erp_transdesigner()
  2062. {
  2063. if (UrlPostParmsCheck("ctid"))
  2064. {
  2065. string eids = GetPostString("ctid");
  2066. string[] ctidList = eids.Split(',');
  2067. int userid = GetPostInt("DesignUserId");
  2068. foreach (string ctid in ctidList)
  2069. {
  2070. CeErpTradeCell entity = null;
  2071. CeErpDesignerBill entitys = null;
  2072. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2073. entitys = CeErpDesignerBill.GetByTid(ctid);
  2074. if (entity != null)
  2075. {
  2076. if (entity.OrderState > 4)
  2077. {
  2078. continue;
  2079. }
  2080. //存在退款不能流转
  2081. if (entity.IsRefund > 0)
  2082. {
  2083. continue;
  2084. }
  2085. entity.DesignUserId = userid;
  2086. entity.WaitDesignTime = DateTime.Now;
  2087. entity.Update();
  2088. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2089. }
  2090. }
  2091. returnSuccessMsg("操作成功!");
  2092. }
  2093. }
  2094. public void upd_erp_distributedesigner()
  2095. {
  2096. if (UrlPostParmsCheck("ctid"))
  2097. {
  2098. string eid = GetPostString("ctid");
  2099. int userid = GetPostInt("DesignUserId");
  2100. string[] idlist = eid.Split(',');
  2101. if (idlist.Length <= 0)
  2102. {
  2103. returnErrorMsg("订单不能为空");
  2104. return;
  2105. }
  2106. foreach (string ctid in idlist)
  2107. {
  2108. CeErpTradeCell entity = null;
  2109. CeErpDesignerBill entitys = null;
  2110. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2111. else continue;
  2112. if (entity != null)
  2113. {
  2114. if (userid == 2125 || userid == 3542)
  2115. { }
  2116. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2117. {
  2118. returnErrorMsg("金额错误的订单无法指派");
  2119. return;
  2120. }
  2121. if (entity.OrderState >= 5)
  2122. {
  2123. returnErrorMsg("已经设计完成无法指派");
  2124. return;
  2125. }
  2126. if (entity.OrderState == -1)
  2127. {
  2128. returnErrorMsg("审核中的订单无法指派");
  2129. return;
  2130. }
  2131. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2132. {
  2133. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2134. return;
  2135. }
  2136. //157赖橙帆 159林晨
  2137. 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)
  2138. {
  2139. returnErrorMsg("指派设计共创无法再次指派!");
  2140. return;
  2141. }
  2142. entity.OrderState = 3;
  2143. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2144. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2145. {
  2146. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2147. entity.SupplierId = suid;
  2148. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2149. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2150. }
  2151. if (userid == 2125 && entity.seller_memo != "")
  2152. {
  2153. apiDesign.API_GetPrintData_CreateOrder(entity);
  2154. }
  2155. if (userid == 3542 && entity.seller_memo != "")
  2156. {
  2157. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2158. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2159. if (response.msg != "设计共创:成功")
  2160. {
  2161. returnErrorMsg(response.msg);
  2162. return;
  2163. }
  2164. entity.DispatchSort = 2;
  2165. }
  2166. else
  2167. {
  2168. if (entity.DispatchSort == 2)
  2169. {
  2170. ApiVo apiVo = new ApiVo();
  2171. apiVo.actionName = "closeDesign";
  2172. apiVo.orderNumber = entity.ctid;
  2173. designHelper.API_WorkCore(apiVo);//closeDesign
  2174. }
  2175. entity.DispatchSort = 0;
  2176. }
  2177. entity.DesignUserId = userid;
  2178. entity.WaitDesignTime = DateTime.Now;
  2179. entity.Update();
  2180. string name = commonHelper.getUserNameById(userid);
  2181. commonHelper.UpdateRelationOrder(entity.ctid);
  2182. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2183. }
  2184. }
  2185. returnSuccessMsg("操作成功!");
  2186. return;
  2187. }
  2188. }
  2189. public void get_erp_myorderlist()
  2190. {
  2191. DataStruct dStruct = GetPostStruct();
  2192. List<string> lw = new List<string>();
  2193. string tid = GetPostString("ctid");
  2194. if (tid.Length > 0)
  2195. {
  2196. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2197. }
  2198. else
  2199. {
  2200. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2201. }
  2202. //12-1 修改
  2203. string urgent = GetPostString("urgent");
  2204. string back = GetPostString("back");
  2205. string offlineSearch = GetPostString("offlineSearch");
  2206. if (!string.IsNullOrWhiteSpace(urgent))
  2207. {
  2208. if (urgent.Equals("true"))
  2209. {
  2210. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2211. }
  2212. }
  2213. if (!string.IsNullOrWhiteSpace(back))
  2214. {
  2215. if (back.Equals("true"))
  2216. {
  2217. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2218. }
  2219. }
  2220. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2221. {
  2222. if (offlineSearch.Equals("true"))
  2223. {
  2224. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2225. }
  2226. }
  2227. //end
  2228. string shopname = GetPostString("shopname");
  2229. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2230. string buyernick = GetPostString("buyer_nick");
  2231. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2232. string design = GetPostString("design");
  2233. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2234. string orderState = GetPostString("orderState");
  2235. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2236. string sellermemo = GetPostString("seller_memo");
  2237. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2238. string date1 = GetPostString("date1");
  2239. string date2 = GetPostString("date2");
  2240. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2241. if (dw.Length > 0) lw.Add(dw);
  2242. string price1 = GetPostString("price1");
  2243. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2244. string price2 = GetPostString("price2");
  2245. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2246. string urgency = GetPostString("urgency");
  2247. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2248. string after = GetPostString("after");
  2249. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2250. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2251. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2252. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2253. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2254. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2255. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2256. if (dt != null && dt.Rows.Count > 0)
  2257. {
  2258. foreach (DataRow dr in dt.Rows)
  2259. {
  2260. try
  2261. {
  2262. // 对象操作
  2263. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2264. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2265. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2266. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2267. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2268. if (dStruct.PageSize != 100000)
  2269. {
  2270. if (dr["DispatchSort"].ToString() == "2")
  2271. {
  2272. dr["gongchuang"] = 200;
  2273. }
  2274. else
  2275. {
  2276. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2277. dr["gongchuang"] = response.code;
  2278. }
  2279. }
  2280. }
  2281. catch (NullReferenceException ex)
  2282. {
  2283. }
  2284. }
  2285. }
  2286. writeGridDataTableJson(dStruct.TotalCount, dt);
  2287. }
  2288. public void get_erp_myreturnorderlist()
  2289. {
  2290. DataStruct dStruct = GetPostStruct();
  2291. List<string> lw = new List<string>();
  2292. string tid = GetPostString("ctid");
  2293. if (tid.Length > 0)
  2294. {
  2295. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2296. }
  2297. else
  2298. {
  2299. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2300. }
  2301. string shopname = GetPostString("shopname");
  2302. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2303. string buyernick = GetPostString("buyer_nick");
  2304. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2305. string design = GetPostString("design");
  2306. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2307. string orderState = GetPostString("orderState");
  2308. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2309. string sellermemo = GetPostString("seller_memo");
  2310. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2311. string date1 = GetPostString("date1");
  2312. string date2 = GetPostString("date2");
  2313. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2314. if (dw.Length > 0) lw.Add(dw);
  2315. string price1 = GetPostString("price1");
  2316. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2317. string price2 = GetPostString("price2");
  2318. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2319. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2320. {
  2321. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2322. }
  2323. else
  2324. {
  2325. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2326. }
  2327. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2328. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2329. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2330. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2331. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2332. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2333. if (dt != null && dt.Rows.Count > 0)
  2334. {
  2335. foreach (DataRow dr in dt.Rows)
  2336. {
  2337. try
  2338. {
  2339. // 对象操作
  2340. if (dStruct.PageSize != 100000)
  2341. {
  2342. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2343. dr["gongchuang"] = response.code;
  2344. }
  2345. }
  2346. catch (NullReferenceException ex)
  2347. {
  2348. // 处理空引用异常
  2349. }
  2350. }
  2351. }
  2352. writeGridDataTableJson(dStruct.TotalCount, dt);
  2353. }
  2354. public void get_erp_myorderlist_pregather()
  2355. {
  2356. string date1 = GetPostString("date1");
  2357. string date2 = GetPostString("date2");
  2358. int userId = CurrentUser.UserID; //客服id
  2359. string orderWhere = "";
  2360. List<string> lw = new List<string>();
  2361. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2362. if (dw.Length > 0) lw.Add(dw);
  2363. lw.Add(string.Format("CustomerUserId={0}", userId));
  2364. lw.Add(string.Format("OrderState<9"));
  2365. orderWhere = string.Join(" and ", lw.ToArray());
  2366. string orderWhere2 = "";
  2367. List<string> lw2 = new List<string>();
  2368. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2369. if (dw2.Length > 0) lw2.Add(dw2);
  2370. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2371. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2372. string sql = string.Format("select *" +
  2373. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2374. "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 " +
  2375. "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 " +
  2376. "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");
  2377. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2378. //writeGridDataTableJson(dt.Rows.Count, dt);
  2379. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2380. }
  2381. public void upd_erp_publishorder()
  2382. {
  2383. if (UrlPostParmsCheck("ctid"))
  2384. {
  2385. string eid = GetPostString("ctid");
  2386. CeErpTradeCell entity = null;
  2387. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2388. if (entity != null)
  2389. {
  2390. entity.OrderState = 0; //发布后,变为待抢单
  2391. entity.Update();
  2392. commonHelper.UpdateRelationOrder(entity.ctid);
  2393. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2394. returnSuccessMsg("发布成功!");
  2395. return;
  2396. }
  2397. returnErrorMsg("找不到记录");
  2398. }
  2399. }
  2400. public void get_erp_my_tiporder()
  2401. {
  2402. StringBuilder sql = new StringBuilder();
  2403. int userId = 0;
  2404. if (CurrentUser != null) userId = CurrentUser.UserID;
  2405. string posCode = CurrentUser.UserPost.Post.Code;
  2406. string isTipedAfterSaleVerify = GetPostString("af");
  2407. DataTable dt = new DataTable();
  2408. if (posCode != "Supplier")
  2409. {
  2410. if (posCode == "CustomerService" || posCode == "Director")
  2411. {
  2412. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2413. }
  2414. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2415. {
  2416. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2417. }
  2418. else
  2419. {
  2420. string teamIds = CurrentUser.User.TeamIds;
  2421. if (teamIds == "")
  2422. {
  2423. teamIds = "0";
  2424. }
  2425. 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);
  2426. }
  2427. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2428. }
  2429. if (dt.Rows.Count <= 0)
  2430. {
  2431. string key = "aftersale_order_" + userId;
  2432. if (RedisHelper.HasKey(key))
  2433. {
  2434. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2435. dt.Columns.Add("ctid", typeof(string));
  2436. dt.Columns.Add("IsReadTag", typeof(int));
  2437. foreach (var i in list)
  2438. {
  2439. DataRow data = dt.NewRow();
  2440. data["ctid"] = i;
  2441. data["IsReadTag"] = 4;
  2442. dt.Rows.Add(data);
  2443. }
  2444. RedisHelper.StringDelete(key);
  2445. }
  2446. }
  2447. if (dt.Rows.Count <= 0)
  2448. {
  2449. sql = new StringBuilder();
  2450. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2451. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2452. }
  2453. if (posCode == "Supplier")
  2454. {
  2455. string ids = CurrentUser.User.pemVend;
  2456. if (ids != null && ids.Length > 0)
  2457. {
  2458. string[] ids_list = ids.Split(',');
  2459. foreach (var item in ids_list)
  2460. {
  2461. string key = "return_order_" + item;
  2462. if (RedisHelper.HasKey(key))
  2463. {
  2464. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2465. dt.Columns.Add("ctid", typeof(string));
  2466. dt.Columns.Add("IsReadTag", typeof(int));
  2467. foreach (var i in list)
  2468. {
  2469. DataRow data = dt.NewRow();
  2470. data["ctid"] = i;
  2471. data["IsReadTag"] = 1;
  2472. dt.Rows.Add(data);
  2473. }
  2474. RedisHelper.StringDelete(key);
  2475. }
  2476. }
  2477. }
  2478. if (dt.Rows.Count <= 0)
  2479. {
  2480. sql = new StringBuilder();
  2481. 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);
  2482. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2483. }
  2484. }
  2485. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2486. }
  2487. public void reset_erp_tiporder()
  2488. {
  2489. string ids = GetPostString("ids");
  2490. string[] ctidList = ids.Split(',');
  2491. foreach (string ctid in ctidList)
  2492. {
  2493. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2494. if (enty != null)
  2495. {
  2496. enty.IsReadTag = 0;
  2497. enty.Update();
  2498. }
  2499. }
  2500. returnSuccessMsg("成功!");
  2501. return;
  2502. }
  2503. public void get_erp_designlist()
  2504. {
  2505. DataStruct dStruct = GetPostStruct();
  2506. List<string> lw = new List<string>();
  2507. string tid = GetPostString("ctid");
  2508. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2509. string shopname = GetPostString("shopname");
  2510. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2511. string buyernick = GetPostString("buyer_nick");
  2512. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2513. string customer = GetPostString("customer");
  2514. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2515. string design = GetPostString("design");
  2516. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2517. string orderState = GetPostString("orderState");
  2518. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2519. lw.Add(string.Format("OrderState<6"));
  2520. string address = GetPostString("address");
  2521. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2522. string sellermemo = GetPostString("seller_memo");
  2523. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2524. string date1 = GetPostString("date1");
  2525. string date2 = GetPostString("date2");
  2526. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2527. if (dw.Length > 0) lw.Add(dw);
  2528. string apdate1 = GetPostString("apdate1");
  2529. string apdate2 = GetPostString("apdate2");
  2530. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2531. if (dwap.Length > 0) lw.Add(dwap);
  2532. string price1 = GetPostString("price1");
  2533. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2534. string price2 = GetPostString("price2");
  2535. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2536. string designTime = GetPostString("designtime");
  2537. if (designTime.Length > 0)
  2538. {
  2539. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2540. }
  2541. string usershop = CurrentUser.User.pemShop;
  2542. if (usershop.Length > 0)
  2543. {
  2544. lw.Add(string.Format("shopId in ({0})", usershop));
  2545. }
  2546. int myOrgid = CurrentUser.UserPost.OrgID;
  2547. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2548. if (myOrgCode.IndexOf("Designer") != -1)
  2549. {
  2550. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2551. {
  2552. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2553. }
  2554. else
  2555. {
  2556. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2557. }
  2558. }
  2559. else
  2560. {
  2561. string orgId = GetPostString("designerhd");
  2562. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2563. }
  2564. if (tid.Length > 0 || buyernick.Length > 0)
  2565. {
  2566. lw.Add(string.Format("OrderState >= 3"));
  2567. }
  2568. else
  2569. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2570. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2571. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2572. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2573. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2574. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2575. if (dt != null && dt.Rows.Count > 0)
  2576. {
  2577. foreach (DataRow dr in dt.Rows)
  2578. {
  2579. try
  2580. {
  2581. // 对象操作
  2582. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2583. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2584. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2585. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2586. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2587. if (dStruct.PageSize != 100000)
  2588. {
  2589. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2590. dr["gongchuang"] = response.code;
  2591. }
  2592. }
  2593. catch (NullReferenceException ex)
  2594. {
  2595. }
  2596. }
  2597. }
  2598. writeGridDataTableJson(dStruct.TotalCount, dt);
  2599. }
  2600. public void get_erp_mydesignlist()
  2601. {
  2602. DataStruct dStruct = GetPostStruct();
  2603. List<string> lw = new List<string>();
  2604. string tid = GetPostString("ctid");
  2605. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2606. string shopname = GetPostString("shopname");
  2607. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2608. string buyernick = GetPostString("buyer_nick");
  2609. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2610. string customer = GetPostString("customer");
  2611. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2612. string orderState = GetPostString("orderState");
  2613. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2614. //lw.Add(string.Format("OrderState<6"));
  2615. string date1 = GetPostString("date1");
  2616. string date2 = GetPostString("date2");
  2617. string dw = GetDateWhere("pay_time", date1, date2);
  2618. if (dw.Length > 0) lw.Add(dw);
  2619. string apdate1 = GetPostString("apdate1");
  2620. string apdate2 = GetPostString("apdate2");
  2621. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2622. if (dwap.Length > 0) lw.Add(dwap);
  2623. string price1 = GetPostString("price1");
  2624. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2625. string price2 = GetPostString("price2");
  2626. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2627. string olddownload = GetPostString("olddown");
  2628. if (olddownload == "1")
  2629. {
  2630. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2631. }
  2632. else if (olddownload == "2")
  2633. {
  2634. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2635. }
  2636. string sellermemo = GetPostString("seller_memo");
  2637. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2638. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2639. if (CurrentUser.User.TeamIds.Length > 0)
  2640. {
  2641. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2642. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2643. else
  2644. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2645. }
  2646. else
  2647. {
  2648. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2649. }
  2650. if (tid.Length <= 0)
  2651. {
  2652. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2653. }
  2654. lw.Add(string.Format("IsReturn!=3"));
  2655. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2656. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2657. string teamids = CurrentUser.User.TeamIds.ToString();
  2658. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2659. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2660. if (dt != null && dt.Rows.Count > 0)
  2661. {
  2662. foreach (DataRow dr in dt.Rows)
  2663. {
  2664. try
  2665. {
  2666. // 对象操作
  2667. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2668. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2669. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2670. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2671. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2672. if (dStruct.PageSize != 100000)
  2673. {
  2674. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2675. dr["gongchuang"] = response.code;
  2676. }
  2677. }
  2678. catch (NullReferenceException ex)
  2679. {
  2680. }
  2681. }
  2682. }
  2683. writeGridDataTableJson(dStruct.TotalCount, dt);
  2684. }
  2685. public void set_erp_startdesign()
  2686. {
  2687. if (UrlPostParmsCheck("ctid"))
  2688. {
  2689. string eid = GetPostString("ctid");
  2690. CeErpTradeCell entity = null;
  2691. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2692. if (entity != null)
  2693. {
  2694. if (entity.OrderState != 3)
  2695. {
  2696. returnErrorMsg("请刷新,订单已经设计了");
  2697. return;
  2698. }
  2699. entity.StartDesignTime = DateTime.Now;
  2700. entity.OrderState = 4;
  2701. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2702. {
  2703. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2704. entity.SupplierId = suid;
  2705. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2706. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2707. }
  2708. //entity.MakeSupplier = suname;
  2709. entity.Update();
  2710. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2711. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2712. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2713. commonHelper.getCytPrice(entity);
  2714. returnSuccessMsg("操作成功!");
  2715. return;
  2716. }
  2717. returnErrorMsg("找不到记录");
  2718. }
  2719. }
  2720. public void ins_erp_designselfmemo()
  2721. {
  2722. if (UrlPostParmsCheck("ctid"))
  2723. {
  2724. string eid = GetPostString("ctid");
  2725. string con = GetPostString("con");
  2726. CeErpTradeCell entity = null;
  2727. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2728. if (entity != null)
  2729. {
  2730. entity.DesignSelfMemo = con;
  2731. entity.Update();
  2732. returnSuccessMsg("操作成功!");
  2733. return;
  2734. }
  2735. returnErrorMsg("找不到记录");
  2736. }
  2737. }
  2738. public void ins_erp_designprice()
  2739. {
  2740. if (UrlPostParmsCheck("ctid"))
  2741. {
  2742. string eid = GetPostString("ctid");
  2743. int uid = CurrentUser.UserID;
  2744. string userName = CurrentUser.UserName;
  2745. CeErpTradeCell entity = null;
  2746. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2747. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2748. if (entitys == null)
  2749. {
  2750. entitys = new CeErpDesignerBill();
  2751. }
  2752. if (entity != null)
  2753. {
  2754. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2755. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2756. entity.StartDesignTime = DateTime.Now;
  2757. entity.OrderState = 4;
  2758. string suname = "";
  2759. if (entity.SupplierId == 0)
  2760. {
  2761. int sid = commonHelper.autoDistributeToSupplier(entity);
  2762. entity.SupplierId = sid;
  2763. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2764. }
  2765. entity.Update();
  2766. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2767. if (ceErpUserPost != null)
  2768. {
  2769. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2770. if (ceErpPost != null)
  2771. {
  2772. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2773. {
  2774. entitys.tid = entity.ctid;
  2775. entitys.oid = entity.tid;
  2776. entitys.uid = uid;
  2777. entitys.userName = userName;
  2778. entitys.designerType = 1;
  2779. entitys.designerTypeText = "内部设计师";
  2780. entitys.price = Convert.ToDouble(GetPostString("price"));
  2781. entitys.designNum = GetPostInt("designNum");
  2782. entitys.modifyNum = GetPostInt("modifyNum");
  2783. entitys.designSize = GetPostString("designSize");
  2784. entitys.modifySize = GetPostString("modifySize");
  2785. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2786. {
  2787. entitys.create_time = DateTime.Now;
  2788. entitys.create_u_id = uid;
  2789. entitys.create_u_name = userName;
  2790. entitys.Save();
  2791. }
  2792. else
  2793. {
  2794. entitys.update_time = DateTime.Now;
  2795. entitys.update_u_id = uid;
  2796. entitys.update_u_name = userName;
  2797. entitys.Update();
  2798. }
  2799. }
  2800. }
  2801. }
  2802. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2803. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2804. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2805. if (suname != "")
  2806. {
  2807. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2808. }
  2809. commonHelper.getCytPrice(entity);
  2810. returnSuccessMsg("操作成功!");
  2811. return;
  2812. }
  2813. returnErrorMsg("找不到记录");
  2814. }
  2815. }
  2816. public void upload_erp_filecomplete()
  2817. {
  2818. if (UrlPostParmsCheck("ctid"))
  2819. {
  2820. string eid = GetPostString("ctid");
  2821. CeErpTradeCell entity = null;
  2822. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2823. if (entity != null)
  2824. {
  2825. entity.OrderState = 5; //设计完成
  2826. entity.Update();
  2827. returnSuccessMsg(eid + "上传成功,设计完成!");
  2828. return;
  2829. }
  2830. returnErrorMsg("找不到订单记录");
  2831. }
  2832. }
  2833. public void get_erp_designovertimelist()
  2834. {
  2835. DataStruct dStruct = GetPostStruct();
  2836. List<string> lw = new List<string>();
  2837. string tid = GetPostString("ctid");
  2838. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2839. string shopname = GetPostString("shopname");
  2840. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2841. string buyernick = GetPostString("buyer_nick");
  2842. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2843. string ResponsibleMan = GetPostString("responsible");
  2844. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2845. string date1 = GetPostString("date1");
  2846. string date2 = GetPostString("date2");
  2847. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2848. if (dw.Length > 0) lw.Add(dw);
  2849. string price1 = GetPostString("price1");
  2850. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2851. string price2 = GetPostString("price2");
  2852. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2853. string orderState = GetPostString("orderState");
  2854. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2855. string sellermemo = GetPostString("seller_memo");
  2856. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2857. lw.Add(string.Format("UnusualTag=3"));
  2858. lw.Add(string.Format("IsRefund<={0}", 1));
  2859. dStruct.Order = "WaitDesignTime desc";
  2860. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2861. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2862. writeGridDataTableJson(dStruct.TotalCount, dt);
  2863. }
  2864. //设计管理 获取抢单大厅列表
  2865. public void get_erp_grabinglist()
  2866. {
  2867. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2868. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2869. bool oldOrder = false;
  2870. if (org != null)
  2871. {
  2872. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2873. }
  2874. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2875. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2876. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2877. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2878. //先处理订单数据
  2879. if (dt.Rows.Count > 0)
  2880. {
  2881. Dictionary<string, int> design = null;
  2882. int count = 0;
  2883. foreach (DataRow row in dt.Rows)
  2884. {
  2885. if (map.ContainsKey(row["ShopId"].ToString()))
  2886. {
  2887. map.TryGetValue(row["ShopId"].ToString(), out design);
  2888. }
  2889. else
  2890. {
  2891. design = new Dictionary<string, int>();
  2892. }
  2893. if (design.ContainsKey(row["ProductId"].ToString()))
  2894. {
  2895. design.TryGetValue(row["ProductId"].ToString(), out count);
  2896. }
  2897. count++;
  2898. design[row["ProductId"].ToString()] = count;
  2899. map[row["ShopId"].ToString()] = design;
  2900. }
  2901. }
  2902. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2903. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2904. //把店铺排序和技能排序分类
  2905. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2906. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2907. if (design_dt.Rows.Count > 0)
  2908. {
  2909. Dictionary<string, string> design = null;
  2910. List<string> shopIds = null;
  2911. foreach (DataRow row in design_dt.Rows)
  2912. {
  2913. if ("0".Equals(row["designId"].ToString()))
  2914. {
  2915. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2916. {
  2917. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2918. }
  2919. else
  2920. {
  2921. shopIds = new List<string>();
  2922. }
  2923. shopIds.Add(row["shopId"].ToString());
  2924. shop_orders[row["orders"].ToString()] = shopIds;
  2925. }
  2926. else
  2927. {
  2928. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2929. {
  2930. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2931. }
  2932. else
  2933. {
  2934. design = new Dictionary<string, string>();
  2935. }
  2936. design[row["orders"].ToString()] = row["designId"].ToString();
  2937. design_orders[row["shopId"].ToString()] = design;
  2938. }
  2939. }
  2940. //处理成key value后根据key排序
  2941. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2942. foreach (List<string> val in shop_orders.Values)
  2943. {
  2944. if (val != null)
  2945. {
  2946. foreach (string key in val)
  2947. {
  2948. if (design_orders.ContainsKey(key.ToString()))
  2949. {
  2950. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2951. }
  2952. }
  2953. }
  2954. }
  2955. }
  2956. //校验哪个优先级有订单
  2957. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2958. foreach (string key in shop_orders.Keys)
  2959. {
  2960. List<string> ids = null;
  2961. shop_orders.TryGetValue(key, out ids);
  2962. //id为shopid
  2963. foreach (string id in ids)
  2964. {
  2965. Dictionary<string, int> list = null;
  2966. Dictionary<string, string> desing = null;
  2967. map.TryGetValue(id, out list);
  2968. design_orders.TryGetValue(id, out desing);
  2969. if (list != null && desing != null)
  2970. {
  2971. foreach (var item in desing)
  2972. {
  2973. int count = 0;
  2974. if (list.ContainsKey(item.Value))
  2975. {
  2976. list.TryGetValue(item.Value, out count);
  2977. if (count > 0)
  2978. {
  2979. designIds[id] = item.Value;
  2980. break;
  2981. }
  2982. }
  2983. }
  2984. }
  2985. }
  2986. if (designIds.Count > 0)
  2987. {
  2988. break;
  2989. }
  2990. }
  2991. DataTable table = new DataTable();
  2992. table.Columns.Add("tid", typeof(string));
  2993. table.Columns.Add("ctid", typeof(string));
  2994. table.Columns.Add("seller_nick", typeof(string));
  2995. table.Columns.Add("productName", typeof(string));
  2996. table.Columns.Add("pay_time", typeof(string));
  2997. table.Columns.Add("seller_memo", typeof(string));
  2998. if (designIds.Count > 0)
  2999. {
  3000. string shopId = "";
  3001. string productId = "";
  3002. foreach (var designInfo in designIds)
  3003. {
  3004. shopId = designInfo.Key;
  3005. productId = designInfo.Value;
  3006. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3007. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3008. if (dt.Rows.Count > 0)
  3009. {
  3010. foreach (DataRow row in dt.Rows)
  3011. {
  3012. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3013. {
  3014. DataRow data = table.NewRow();
  3015. data["ctid"] = row["ctid"].ToString();
  3016. data["tid"] = row["tid"].ToString();
  3017. data["seller_nick"] = ceErpShop.ShopName;
  3018. data["pay_time"] = row["pay_time"].ToString();
  3019. data["seller_memo"] = row["seller_memo"].ToString();
  3020. data["productName"] = ceErpProduct.PType;
  3021. table.Rows.Add(data);
  3022. }
  3023. }
  3024. }
  3025. }
  3026. }
  3027. writeGridDataTableJson(table.Rows.Count, table);
  3028. }
  3029. private object rushLockObject = new object();
  3030. public void set_erp_grabingorder()
  3031. {
  3032. if (UrlPostParmsCheck("ctid"))
  3033. {
  3034. int total = CurrentUser.User.Person.Total;
  3035. int userId = CurrentUser.User.ID;
  3036. int noFinish = CurrentUser.User.Person.NoFinish;
  3037. int finalization = CurrentUser.User.Person.Finalization;
  3038. string eids = GetPostString("ctid");
  3039. string key = "RushKey_" + userId;
  3040. int count = 0;
  3041. if (erpRedis.RedisHelper.KeyExists(key))
  3042. {
  3043. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3044. if (redisCount != null)
  3045. {
  3046. count = Convert.ToInt32(redisCount);
  3047. }
  3048. }
  3049. if (count >= total)
  3050. {
  3051. returnErrorMsg("半小时内已经抢" + total + "单");
  3052. return;
  3053. }
  3054. string[] ctidlist = eids.Split(',');
  3055. if (count + ctidlist.Length > total)
  3056. {
  3057. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3058. return;
  3059. }
  3060. int itag = 0;
  3061. lock (rushLockObject)
  3062. {
  3063. if (ctidlist.Length > 0)
  3064. {
  3065. string[] dtList = new string[ctidlist.Length];
  3066. for (int i = 0; i < ctidlist.Length; i++)
  3067. {
  3068. dtList[i] = "'" + ctidlist[i] + "'";
  3069. }
  3070. 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"));
  3071. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3072. if (dt_user.Rows.Count > 0)
  3073. {
  3074. int doing = 0;//未定稿
  3075. int finish = 0;//已完成
  3076. foreach (DataRow dr in dt_user.Rows)
  3077. {
  3078. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3079. {
  3080. doing++;
  3081. }
  3082. else
  3083. {
  3084. finish++;
  3085. }
  3086. }
  3087. if (doing >= noFinish)
  3088. {
  3089. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3090. return;
  3091. }
  3092. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3093. {
  3094. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3095. return;
  3096. }
  3097. }
  3098. //校验选择单子状态
  3099. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3100. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3101. if (dt.Rows.Count > 0)
  3102. {
  3103. List<string> list = new List<string>();
  3104. foreach (DataRow dr in dt.Rows)
  3105. {
  3106. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3107. {
  3108. list.Add(dr["ctid"].ToString());
  3109. }
  3110. }
  3111. if (list.Count > 0)
  3112. {
  3113. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3114. return;
  3115. }
  3116. }
  3117. foreach (string ctid in ctidlist)
  3118. {
  3119. CeErpTradeCell entity = null;
  3120. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3121. if (entity != null)
  3122. {
  3123. entity.OrderState = 3;
  3124. entity.DesignUserId = CurrentUser.UserID;
  3125. entity.WaitDesignTime = DateTime.Now;
  3126. entity.StartDesignTime = DateTime.Now;
  3127. entity.Update();
  3128. commonHelper.UpdateRelationOrder(entity.ctid);
  3129. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3131. itag++;
  3132. }
  3133. }
  3134. }
  3135. }
  3136. count += ctidlist.Length;
  3137. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3138. if (itag == 0)
  3139. returnErrorMsg("没有找到相关订单");
  3140. else
  3141. returnSuccessMsg("抢单成功!");
  3142. return;
  3143. }
  3144. }
  3145. public void get_erp_waitorderlist()
  3146. {
  3147. DataStruct dStruct = GetPostStruct();
  3148. List<string> lw = new List<string>();
  3149. string tid = GetPostString("ctid");
  3150. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3151. string shopname = GetPostString("shopname");
  3152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3153. string buyernick = GetPostString("buyer_nick");
  3154. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3155. string customer = GetPostString("customer");
  3156. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3157. string design = GetPostString("design");
  3158. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3159. string orderState = GetPostString("orderState");
  3160. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3161. string supplier = GetPostString("supplier");
  3162. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3163. string sellermemo = GetPostString("seller_memo");
  3164. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3165. string otherMemo = GetPostString("otherMemo");
  3166. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3167. string address = GetPostString("address");
  3168. 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));
  3169. string date1 = GetPostString("date1");
  3170. string date2 = GetPostString("date2");
  3171. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3172. if (dw.Length > 0) lw.Add(dw);
  3173. string price1 = GetPostString("price1");
  3174. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3175. string price2 = GetPostString("price2");
  3176. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3177. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3178. lw.Add(string.Format("IsSample != 2 "));
  3179. lw.Add(string.Format("OrderState = 5 "));
  3180. lw.Add(string.Format("IsRefund<={0}", 1));
  3181. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3182. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3183. string pagesize = GetPostString("pagesize");
  3184. if (pagesize != null)
  3185. {
  3186. dStruct.PageSize = 200;
  3187. }
  3188. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3189. if (dt != null)
  3190. {
  3191. foreach (DataRow dr in dt.Rows)
  3192. {
  3193. 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();
  3194. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3195. {
  3196. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3197. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3198. entity.SupplierId = suid;
  3199. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3200. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3201. entity.Update();
  3202. }
  3203. }
  3204. }
  3205. writeGridDataTableJson(dStruct.TotalCount, dt);
  3206. }
  3207. public void get_erp_supplierwaitorderlist()
  3208. {
  3209. DataStruct dStruct = GetPostStruct();
  3210. List<string> lw = new List<string>();
  3211. string tid = GetPostString("ctid");
  3212. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3213. string shopname = GetPostString("shopname");
  3214. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3215. string sellermemo = GetPostString("seller_memo");
  3216. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3217. string date1 = GetPostString("date1");
  3218. string date2 = GetPostString("date2");
  3219. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3220. if (dw.Length > 0) lw.Add(dw);
  3221. lw.Add(string.Format("OrderState = 5 "));
  3222. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3223. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3224. {
  3225. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3226. }
  3227. string supplier = GetPostString("supplier");
  3228. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3229. {
  3230. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3231. }
  3232. lw.Add(string.Format("IsRefund<={0}", 1));
  3233. dStruct.Order = "FinishDesignTime desc";
  3234. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3235. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3236. if (dt != null)
  3237. {
  3238. foreach (DataRow dr in dt.Rows)
  3239. {
  3240. 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();
  3241. }
  3242. }
  3243. writeGridDataTableJson(dStruct.TotalCount, dt);
  3244. }
  3245. public void upd_erp_verifytosupplier()
  3246. {
  3247. if (UrlPostParmsCheck("ctid"))
  3248. {
  3249. string eids = GetPostString("ctid");
  3250. CeErpTradeCell entity = null;
  3251. string[] eidsList = eids.Split(',');
  3252. if (eidsList.Length <= 0)
  3253. {
  3254. returnErrorMsg("订单号不能空");
  3255. return;
  3256. }
  3257. List<string> tLst = new List<string>();
  3258. foreach (string ctidstr in eidsList)
  3259. {
  3260. tLst.Add("'" + ctidstr + "'");
  3261. CeErpDataSendOrderInfo.createObject(ctidstr);
  3262. }
  3263. string needtids = string.Join(",", tLst.ToArray());
  3264. StringBuilder sql = new StringBuilder();
  3265. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3266. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3267. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3268. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3269. returnSuccessMsg("操作成功!");
  3270. return;
  3271. /**foreach (string ctidstr in eidsList)
  3272. {
  3273. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3274. if (entity != null)
  3275. {
  3276. if (entity.SupplierId == 0)
  3277. {
  3278. continue;
  3279. }
  3280. entity.IsVerifyToSupplier = true;
  3281. if (entity.IsReturn == 1) //1是供应商打回
  3282. {
  3283. entity.IsReturn = 0;
  3284. }
  3285. entity.FinishPlaceTime = DateTime.Now;
  3286. entity.PlaceUserId = CurrentUser.UserID;
  3287. entity.Update();
  3288. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3289. }
  3290. }
  3291. returnSuccessMsg("操作成功!");
  3292. return;**/
  3293. }
  3294. }
  3295. public void upd_erp_supplierback()
  3296. {
  3297. if (UrlPostParmsCheck("ctid"))
  3298. {
  3299. string eid = GetPostString("ctid");
  3300. string reason = GetPostString("returnreason");
  3301. CeErpTradeCell entity = null;
  3302. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3303. if (entity != null)
  3304. {
  3305. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3306. {
  3307. string key = "return_order_" + entity.SupplierId;
  3308. List<string> list = new List<string>();
  3309. if (RedisHelper.HasKey(key))
  3310. {
  3311. object data = RedisHelper.StringGet(key);
  3312. list = Convert.ToString(data).Split(',').ToList();
  3313. }
  3314. list.Add(eid);
  3315. RedisHelper.StringSet(key, string.Join(",", list));
  3316. }
  3317. entity.IsVerifyToSupplier = false;
  3318. entity.IsReturn = 1;
  3319. entity.ReturnTime = DateTime.Now;
  3320. entity.ReturnReason = reason;
  3321. if (entity.OrderState == 6)
  3322. {
  3323. entity.OrderState = 5;
  3324. }
  3325. entity.Update();
  3326. CeErpSukuraData.createInfo(entity.ctid, 5);
  3327. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3328. returnSuccessMsg("操作成功!");
  3329. return;
  3330. }
  3331. returnErrorMsg("找不到订单记录");
  3332. }
  3333. }
  3334. public void upd_erp_toaftersaleorder()
  3335. {
  3336. if (UrlPostParmsCheck("ctid"))
  3337. {
  3338. string eid = GetPostString("ctid");
  3339. string reason = GetPostString("returnreason");
  3340. CeErpTradeCell entity = null;
  3341. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3342. if (entity != null)
  3343. {
  3344. if (entity.isAfterSaleOrder != 1)
  3345. {
  3346. returnErrorMsg("带S的售后单才能打回给售后");
  3347. return;
  3348. }
  3349. if (entity.OrderState >= 5)
  3350. {
  3351. returnErrorMsg("已经设计完成了不能打回给售后");
  3352. return;
  3353. }
  3354. entity.OrderState = 0;
  3355. entity.IsReturn = 3;
  3356. entity.ReturnTime = DateTime.Now;
  3357. entity.ReturnReason = reason;
  3358. entity.Update();
  3359. CeErpSukuraData.createInfo(entity.ctid, 5);
  3360. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3361. returnSuccessMsg("操作成功!");
  3362. return;
  3363. }
  3364. returnErrorMsg("找不到订单记录");
  3365. }
  3366. }
  3367. public void upd_erp_aftersaletodesign()
  3368. {
  3369. if (UrlPostParmsCheck("ctid"))
  3370. {
  3371. string eid = GetPostString("ctid");
  3372. CeErpTradeCell entity = null;
  3373. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3374. if (entity != null)
  3375. {
  3376. entity.OrderState = 3;
  3377. entity.IsReturn = 0;
  3378. entity.Update();
  3379. CeErpSukuraData.createInfo(entity.ctid, 5);
  3380. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3381. returnSuccessMsg("操作成功!");
  3382. return;
  3383. }
  3384. returnErrorMsg("找不到订单记录");
  3385. }
  3386. }
  3387. public void assign_erp_supplier()
  3388. {
  3389. if (UrlPostParmsCheck("ctid"))
  3390. {
  3391. string eids = GetPostString("ctid");
  3392. int sid = GetPostInt("SupplierName");
  3393. string fromTag = GetPostString("tag");
  3394. string[] eidList = eids.Split(',');
  3395. if (eidList.Length <= 0)
  3396. {
  3397. returnErrorMsg("指派不能为空");
  3398. return;
  3399. }
  3400. string errMsg = "";
  3401. string suname = commonHelper.getSupplierNameById(sid);
  3402. foreach (string ctid in eidList)
  3403. {
  3404. CeErpTradeCell entity = null;
  3405. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3406. if (entity != null)
  3407. {
  3408. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3409. {
  3410. errMsg += (ctid + "指派失败!!!");
  3411. continue;
  3412. }
  3413. entity.SupplierId = sid;
  3414. entity.Update();
  3415. commonHelper.UpdateRelationOrder(entity.ctid);
  3416. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3417. if (entity.OrderState >= 6)
  3418. {
  3419. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3420. //{
  3421. // string msl = entity.MakeSupplier;
  3422. // string[] mslist = msl.Split(',');
  3423. // 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);
  3424. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3425. //}
  3426. //else
  3427. //{
  3428. StringBuilder sql = new StringBuilder();
  3429. 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);
  3430. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3431. //}
  3432. }
  3433. }
  3434. else
  3435. {
  3436. continue;
  3437. }
  3438. }
  3439. if (errMsg.Length > 0)
  3440. {
  3441. returnErrorMsg(errMsg);
  3442. return;
  3443. }
  3444. returnSuccessMsg("操作成功!");
  3445. return;
  3446. }
  3447. }
  3448. public void assign_erp_makesupplier()
  3449. {
  3450. if (UrlPostParmsCheck("ctid"))
  3451. {
  3452. string eids = GetPostString("ctid");
  3453. string sname = GetPostString("SupplierName");
  3454. string[] eidList = eids.Split(',');
  3455. if (eidList.Length <= 0)
  3456. {
  3457. returnErrorMsg("指派不能为空");
  3458. return;
  3459. }
  3460. List<string> tLst = new List<string>();
  3461. foreach (string ctid in eidList)
  3462. {
  3463. CeErpTradeCell entity = null;
  3464. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3465. if (entity != null)
  3466. {
  3467. entity.MakeSupplier = sname;
  3468. entity.Update();
  3469. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3470. tLst.Add("'" + ctid + "'");
  3471. }
  3472. else
  3473. {
  3474. continue;
  3475. }
  3476. }
  3477. string ctids = string.Join(",", tLst.ToArray());
  3478. StringBuilder sql2 = new StringBuilder();
  3479. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3480. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3481. returnSuccessMsg("操作成功!");
  3482. return;
  3483. }
  3484. }
  3485. public void ins_erp_returnreason()
  3486. {
  3487. if (UrlPostParmsCheck("ctid"))
  3488. {
  3489. string eid = GetPostString("ctid");
  3490. CeErpTradeCell entity = null;
  3491. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3492. string userpost = CurrentUser.UserPost.Post.Code;
  3493. if (entity != null)
  3494. {
  3495. bool isPlace = false;
  3496. if (entity.OrderState > 6)
  3497. {
  3498. returnErrorMsg("已发货无法打回!");
  3499. return;
  3500. }
  3501. if (entity.OrderState == 6)
  3502. {
  3503. isPlace = true;
  3504. }
  3505. bool isNeedUpdateCell2 = false;
  3506. if (entity.OrderState >= 6)
  3507. {
  3508. isNeedUpdateCell2 = true;
  3509. }
  3510. int returnTag = 2;
  3511. if (userpost == "Supplier")
  3512. {
  3513. returnTag = 1;
  3514. }
  3515. int toType = GetPostInt("totype");
  3516. string fromType = "3";
  3517. if (entity.OrderState < 5)
  3518. {
  3519. fromType = "3";
  3520. }
  3521. else
  3522. {
  3523. fromType = "4";
  3524. }
  3525. if (entity.IsXianHuo == 0)
  3526. {
  3527. if (returnTag == 2)
  3528. {
  3529. if (toType == 1)
  3530. {
  3531. entity.OrderState = 0;
  3532. entity.ReturnUserType = 1;
  3533. string clearman = GetPostString("clearman");
  3534. if (!string.IsNullOrEmpty(clearman))
  3535. {
  3536. entity.DesignUserId = 0;
  3537. }
  3538. }
  3539. else
  3540. {
  3541. entity.OrderState = 3;
  3542. entity.ReturnUserType = 2;
  3543. }
  3544. entity.IsReadTag = 1;
  3545. }
  3546. else if (returnTag == 1)
  3547. {
  3548. entity.OrderState = 5;
  3549. }
  3550. entity.IsVerifyToSupplier = false;
  3551. }
  3552. if (entity.IsXianHuo == 1)
  3553. {
  3554. entity.OrderState = 5;
  3555. }
  3556. entity.UnusualTag = 0;
  3557. entity.UnusualTime = null;
  3558. entity.UnusualCon = "";
  3559. entity.IsReturn = returnTag;
  3560. entity.ReturnTime = DateTime.Now;
  3561. entity.ReturnReason = GetPostString("returnreason");
  3562. entity.Update();
  3563. if (entity.OrderState == 3)
  3564. {
  3565. ApiVo apiVo = new ApiVo();
  3566. apiVo.orderNumber = entity.ctid;
  3567. apiVo.actionName = "rebutDesign";
  3568. apiVo.orderRemarks = entity.ReturnReason;
  3569. designHelper.API_WorkCore(apiVo);//rebutDesign
  3570. }
  3571. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3572. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3573. {
  3574. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3575. }
  3576. CeErpSukuraData.createInfo(entity.ctid, 5);
  3577. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3578. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3579. if (isPlace)
  3580. {
  3581. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3582. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3583. if (dth != null && dth.Rows.Count > 0)
  3584. {
  3585. dataSendOrderBean dataSendOrderBean = null;
  3586. foreach (DataRow item in dth.Rows)
  3587. {
  3588. try
  3589. {
  3590. dataSendOrderBean = new dataSendOrderBean();
  3591. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3592. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3593. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3594. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3595. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3596. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3597. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3598. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3599. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3600. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3601. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3602. dataSendOrderBean.Radio1723534706288 = "打回";
  3603. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3604. if (result != null)
  3605. {
  3606. if ("0".Equals(result.errcode))
  3607. {
  3608. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3609. }
  3610. else
  3611. {
  3612. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3613. }
  3614. }
  3615. }
  3616. catch (Exception ex)
  3617. {
  3618. }
  3619. }
  3620. }
  3621. }
  3622. if (isNeedUpdateCell2)
  3623. {
  3624. if (entity.MakeSupplier.IndexOf(",") != -1)
  3625. {
  3626. StringBuilder sql2 = new StringBuilder();
  3627. 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);
  3628. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3629. }
  3630. else
  3631. {
  3632. StringBuilder sql2 = new StringBuilder();
  3633. 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);
  3634. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3635. }
  3636. }
  3637. returnSuccessMsg("操作成功!");
  3638. return;
  3639. }
  3640. returnErrorMsg("找不到订单记录");
  3641. }
  3642. }
  3643. public void cyt_erp_returnreason()
  3644. {
  3645. if (UrlPostParmsCheck("ctid"))
  3646. {
  3647. string eid = GetPostString("ctid");
  3648. CeErpTradeCell entity = null;
  3649. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3650. string userpost = CurrentUser.UserPost.Post.Code;
  3651. if (entity != null)
  3652. {
  3653. if (entity.OrderState > 6)
  3654. {
  3655. returnErrorMsg("已发货无法打回!");
  3656. return;
  3657. }
  3658. JObject jsonObject = new JObject
  3659. {
  3660. { "Userid", "77886" },
  3661. { "Pwd", "lt666888" },
  3662. { "LTOrderId",eid }
  3663. };
  3664. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3665. JObject jsonObjects = JObject.Parse(response);
  3666. string msg = (string)jsonObjects["msg"];
  3667. if (msg != "取消成功")
  3668. {
  3669. returnErrorMsg(msg);
  3670. return;
  3671. }
  3672. bool isNeedUpdateCell2 = false;
  3673. if (entity.OrderState >= 6)
  3674. {
  3675. isNeedUpdateCell2 = true;
  3676. }
  3677. int returnTag = 2;
  3678. if (userpost == "Supplier")
  3679. {
  3680. returnTag = 1;
  3681. }
  3682. if (entity.IsXianHuo == 0)
  3683. {
  3684. if (returnTag == 2)
  3685. {
  3686. int toType = GetPostInt("totype");
  3687. if (toType == 1)
  3688. {
  3689. entity.OrderState = 0;
  3690. entity.ReturnUserType = 1;
  3691. }
  3692. else
  3693. {
  3694. entity.OrderState = 4;
  3695. entity.ReturnUserType = 2;
  3696. }
  3697. entity.IsReadTag = 1;
  3698. }
  3699. else if (returnTag == 1)
  3700. {
  3701. entity.OrderState = 5;
  3702. }
  3703. entity.IsVerifyToSupplier = false;
  3704. }
  3705. entity.UnusualTag = 0;
  3706. entity.UnusualTime = null;
  3707. entity.UnusualCon = "";
  3708. entity.IsReturn = returnTag;
  3709. entity.ReturnTime = DateTime.Now;
  3710. entity.ReturnReason = GetPostString("returnreason");
  3711. entity.Update();
  3712. if (entity.OrderState == 4)
  3713. {
  3714. ApiVo apiVo = new ApiVo();
  3715. apiVo.orderNumber = entity.ctid;
  3716. apiVo.actionName = "rebutDesign";
  3717. apiVo.orderRemarks = entity.ReturnReason;
  3718. designHelper.API_WorkCore(apiVo);//rebutDesign
  3719. }
  3720. CeErpSukuraData.createInfo(entity.ctid, 5);
  3721. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3723. if (isNeedUpdateCell2)
  3724. {
  3725. if (entity.MakeSupplier.IndexOf(",") != -1)
  3726. {
  3727. StringBuilder sql2 = new StringBuilder();
  3728. 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);
  3729. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3730. }
  3731. else
  3732. {
  3733. StringBuilder sql2 = new StringBuilder();
  3734. 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);
  3735. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3736. }
  3737. }
  3738. returnSuccessMsg("操作成功!");
  3739. return;
  3740. }
  3741. returnErrorMsg("找不到订单记录");
  3742. }
  3743. }
  3744. public void upd_erp_xianhuoreturntag()
  3745. {
  3746. if (UrlPostParmsCheck("ctid"))
  3747. {
  3748. string eids = GetPostString("ctid");
  3749. string[] ctids = eids.Split(',');
  3750. foreach (string ctid in ctids)
  3751. {
  3752. CeErpTradeCell entity = null;
  3753. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3754. if (entity != null)
  3755. {
  3756. entity.IsReturn = 0;
  3757. entity.Update();
  3758. CeErpSukuraData.createInfo(entity.ctid, 5);
  3759. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3760. }
  3761. }
  3762. returnSuccessMsg("操作成功!");
  3763. return;
  3764. }
  3765. }
  3766. public void get_erp_waitdeliverylist()
  3767. {
  3768. DataStruct dStruct = GetPostStruct();
  3769. List<string> lw = new List<string>();
  3770. string tid = GetPostString("ctid");
  3771. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3772. string shopname = GetPostString("shopname");
  3773. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3774. string buyernick = GetPostString("buyer_nick");
  3775. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3776. //if (tid.Length == 0 && buyernick.Length == 0)
  3777. //{
  3778. // lw.Add(string.Format("IsRefund<={0}", 1));
  3779. //}
  3780. string customer = GetPostString("customer");
  3781. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3782. string design = GetPostString("design");
  3783. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3784. string orderState = GetPostString("orderState");
  3785. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3786. string address = GetPostString("address");
  3787. 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));
  3788. string sellermemo = GetPostString("seller_memo");
  3789. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3790. string supplier = GetPostString("supplier");
  3791. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3792. string OrderArea = GetPostString("order_area");
  3793. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3794. string placedate1 = GetPostString("placedate1");
  3795. string placedate2 = GetPostString("placedate2");
  3796. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3797. if (fdw.Length > 0) lw.Add(fdw);
  3798. string price1 = GetPostString("price1");
  3799. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3800. string price2 = GetPostString("price2");
  3801. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3802. string unusualCon = GetPostString("unusualcon");
  3803. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3804. string otherMemo = GetPostString("otherMemo");
  3805. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3806. string posTag = CurrentUser.UserPost.Post.Code;
  3807. if (posTag == "Supplier")
  3808. {
  3809. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3810. }
  3811. lw.Add(string.Format("OrderState = 6 "));
  3812. lw.Add(string.Format("type != 'PDD' "));
  3813. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3814. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3815. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3816. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3817. writeGridDataTableJson(dStruct.TotalCount, dt);
  3818. }
  3819. public void get_erp_pddderiving()
  3820. {
  3821. DataStruct dStruct = GetPostStruct();
  3822. List<string> lw = new List<string>();
  3823. string tid = GetPostString("ctid");
  3824. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3825. string shopname = GetPostString("shopname");
  3826. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3827. string buyernick = GetPostString("buyer_nick");
  3828. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3829. //if (tid.Length == 0 && buyernick.Length == 0)
  3830. //{
  3831. // lw.Add(string.Format("IsRefund<={0}", 1));
  3832. //}
  3833. string customer = GetPostString("customer");
  3834. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3835. string design = GetPostString("design");
  3836. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3837. string orderState = GetPostString("orderState");
  3838. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3839. string address = GetPostString("address");
  3840. 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));
  3841. string sellermemo = GetPostString("seller_memo");
  3842. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3843. string supplier = GetPostString("supplier");
  3844. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3845. string OrderArea = GetPostString("order_area");
  3846. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3847. string placedate1 = GetPostString("placedate1");
  3848. string placedate2 = GetPostString("placedate2");
  3849. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3850. if (fdw.Length > 0) lw.Add(fdw);
  3851. string price1 = GetPostString("price1");
  3852. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3853. string price2 = GetPostString("price2");
  3854. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3855. string unusualCon = GetPostString("unusualcon");
  3856. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3857. string posTag = CurrentUser.UserPost.Post.Code;
  3858. if (posTag == "Supplier")
  3859. {
  3860. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3861. }
  3862. lw.Add(string.Format("OrderState = 6 "));
  3863. lw.Add(string.Format("type = 'PDD' "));
  3864. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3865. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3866. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3867. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3868. writeGridDataTableJson(dStruct.TotalCount, dt);
  3869. }
  3870. public void get_erp_jdderiving()
  3871. {
  3872. DataStruct dStruct = GetPostStruct();
  3873. List<string> lw = new List<string>();
  3874. string tid = GetPostString("ctid");
  3875. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3876. string shopname = GetPostString("shopname");
  3877. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3878. string buyernick = GetPostString("buyer_nick");
  3879. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3880. //if (tid.Length == 0 && buyernick.Length == 0)
  3881. //{
  3882. // lw.Add(string.Format("IsRefund<={0}", 1));
  3883. //}
  3884. string customer = GetPostString("customer");
  3885. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3886. string design = GetPostString("design");
  3887. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3888. string orderState = GetPostString("orderState");
  3889. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3890. string address = GetPostString("address");
  3891. 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));
  3892. string sellermemo = GetPostString("seller_memo");
  3893. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3894. string supplier = GetPostString("supplier");
  3895. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3896. string OrderArea = GetPostString("order_area");
  3897. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3898. string placedate1 = GetPostString("placedate1");
  3899. string placedate2 = GetPostString("placedate2");
  3900. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3901. if (fdw.Length > 0) lw.Add(fdw);
  3902. string price1 = GetPostString("price1");
  3903. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3904. string price2 = GetPostString("price2");
  3905. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3906. string unusualCon = GetPostString("unusualcon");
  3907. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3908. string posTag = CurrentUser.UserPost.Post.Code;
  3909. if (posTag == "Supplier")
  3910. {
  3911. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3912. }
  3913. lw.Add(string.Format("OrderState = 6 "));
  3914. lw.Add(string.Format("type = 'JD' "));
  3915. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3916. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3917. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3918. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3919. writeGridDataTableJson(dStruct.TotalCount, dt);
  3920. }
  3921. public void get_erp_demoorderlist()
  3922. {
  3923. DataStruct dStruct = GetPostStruct();
  3924. List<string> lw = new List<string>();
  3925. string tid = GetPostString("ctid");
  3926. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3927. string shopname = GetPostString("shopname");
  3928. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3929. string buyernick = GetPostString("buyer_nick");
  3930. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3931. string customer = GetPostString("customer");
  3932. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3933. string design = GetPostString("design");
  3934. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3935. string orderState = GetPostString("orderState");
  3936. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3937. string address = GetPostString("address");
  3938. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3939. string sellermemo = GetPostString("seller_memo");
  3940. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3941. string supplier = GetPostString("supplier");
  3942. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3943. string OrderArea = GetPostString("order_area");
  3944. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3945. string date1 = GetPostString("date1");
  3946. string date2 = GetPostString("date2");
  3947. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3948. if (dw.Length > 0) lw.Add(dw);
  3949. string price1 = GetPostString("price1");
  3950. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3951. string price2 = GetPostString("price2");
  3952. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3953. string posTag = CurrentUser.UserPost.Post.Code;
  3954. if (posTag == "Supplier")
  3955. {
  3956. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3957. }
  3958. //lw.Add(string.Format("OrderState = 6 "));
  3959. lw.Add(string.Format("IsSample={0}", 3));
  3960. lw.Add(string.Format("IsRefund<={0}", 1));
  3961. dStruct.Order = "pay_time desc";
  3962. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3963. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3964. writeGridDataTableJson(dStruct.TotalCount, dt);
  3965. }
  3966. public void save_erp_checkmemo()
  3967. {
  3968. if (UrlPostParmsCheck("ctid"))
  3969. {
  3970. string ctid = GetPostString("ctid");
  3971. CeErpTradeCell entity = null;
  3972. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3973. if (entity != null)
  3974. {
  3975. entity.CheckMemo = GetPostString("CheckMemo");
  3976. entity.Update();
  3977. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3978. if (trade != null)
  3979. {
  3980. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3981. }
  3982. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3983. returnSuccessMsg("保存成功!");
  3984. return;
  3985. }
  3986. returnErrorMsg("找不到记录");
  3987. }
  3988. }
  3989. public void get_erp_returnlist()
  3990. {
  3991. DataStruct dStruct = GetPostStruct();
  3992. List<string> lw = new List<string>();
  3993. string tid = GetPostString("ctid");
  3994. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3995. string shopname = GetPostString("shopname");
  3996. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3997. string buyernick = GetPostString("buyer_nick");
  3998. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3999. string customer = GetPostString("customer");
  4000. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4001. string design = GetPostString("design");
  4002. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4003. string orderState = GetPostString("orderState");
  4004. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4005. string address = GetPostString("address");
  4006. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4007. string sellermemo = GetPostString("seller_memo");
  4008. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4009. string supplier = GetPostString("supplier");
  4010. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4011. string date1 = GetPostString("date1");
  4012. string date2 = GetPostString("date2");
  4013. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4014. if (dw.Length > 0) lw.Add(dw);
  4015. string bdate1 = GetPostString("backdate1");
  4016. string bdate2 = GetPostString("backdate2");
  4017. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4018. if (dw_back.Length > 0) lw.Add(dw_back);
  4019. string price1 = GetPostString("price1");
  4020. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4021. string price2 = GetPostString("price2");
  4022. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4023. lw.Add(string.Format("IsReturn>0"));
  4024. lw.Add(string.Format("IsXianHuo=0"));
  4025. lw.Add(string.Format("IsReturn!=3"));
  4026. string backtype = GetPostString("backtype");
  4027. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4028. dStruct.Order = "FinishDesignTime desc";
  4029. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4030. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4031. writeGridDataTableJson(dStruct.TotalCount, dt);
  4032. }
  4033. public void get_erp_today_sumreturn()
  4034. {
  4035. DataStruct dStruct = GetPostStruct();
  4036. List<string> lw = new List<string>();
  4037. string bdate1 = GetPostString("returnTimeS");
  4038. string bdate2 = GetPostString("returnTimeE");
  4039. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4040. if (dw_back.Length > 0) lw.Add(dw_back);
  4041. lw.Add(string.Format("IsReturn=0"));
  4042. lw.Add(string.Format("IsXianHuo=0"));
  4043. string mainWhere = string.Join(" and ", lw.ToArray());
  4044. string sql = "";
  4045. if (dw_back.Length > 0)
  4046. {
  4047. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4048. }
  4049. else
  4050. {
  4051. 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 + "'";
  4052. }
  4053. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4054. decimal total = 0, today_finish = 0;
  4055. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4056. {
  4057. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4058. }
  4059. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4060. {
  4061. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4062. }
  4063. var res = new
  4064. {
  4065. data = total,
  4066. data1 = today_finish,
  4067. };
  4068. string ro_jsond = JsonConvert.SerializeObject(res);
  4069. returnSuccess(ro_jsond);
  4070. return;
  4071. }
  4072. public void get_erp_allreturnlist()
  4073. {
  4074. DataStruct dStruct = GetPostStruct();
  4075. List<string> lw = new List<string>();
  4076. string tid = GetPostString("ctid");
  4077. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4078. string shopname = GetPostString("shopname");
  4079. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4080. string buyernick = GetPostString("buyer_nick");
  4081. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4082. string customer = GetPostString("customer");
  4083. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4084. string design = GetPostString("design");
  4085. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4086. string orderState = GetPostString("orderState");
  4087. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4088. string address = GetPostString("address");
  4089. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4090. string sellermemo = GetPostString("seller_memo");
  4091. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4092. string supplier = GetPostString("supplier");
  4093. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4094. string date1 = GetPostString("date1");
  4095. string date2 = GetPostString("date2");
  4096. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4097. if (dw.Length > 0) lw.Add(dw);
  4098. string bdate1 = GetPostString("backdate1");
  4099. string bdate2 = GetPostString("backdate2");
  4100. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4101. if (dw_back.Length > 0) lw.Add(dw_back);
  4102. string price1 = GetPostString("price1");
  4103. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4104. string price2 = GetPostString("price2");
  4105. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4106. string backreason = GetPostString("backreason");
  4107. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4108. lw.Add(string.Format("IsXianHuo=0"));
  4109. lw.Add(string.Format("ReturnTime != ''"));
  4110. string backtype = GetPostString("backtype");
  4111. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4112. dStruct.Order = "FinishDesignTime desc";
  4113. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4114. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4115. writeGridDataTableJson(dStruct.TotalCount, dt);
  4116. }
  4117. public void get_erp_aftersalereturnlist()
  4118. {
  4119. DataStruct dStruct = GetPostStruct();
  4120. List<string> lw = new List<string>();
  4121. string tid = GetPostString("ctid");
  4122. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4123. string shopname = GetPostString("shopname");
  4124. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4125. string buyernick = GetPostString("buyer_nick");
  4126. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4127. string customer = GetPostString("customer");
  4128. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4129. string design = GetPostString("design");
  4130. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4131. string orderState = GetPostString("orderState");
  4132. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4133. string address = GetPostString("address");
  4134. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4135. string sellermemo = GetPostString("seller_memo");
  4136. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4137. string supplier = GetPostString("supplier");
  4138. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4139. string date1 = GetPostString("date1");
  4140. string date2 = GetPostString("date2");
  4141. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4142. if (dw.Length > 0) lw.Add(dw);
  4143. string bdate1 = GetPostString("backdate1");
  4144. string bdate2 = GetPostString("backdate2");
  4145. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4146. if (dw_back.Length > 0) lw.Add(dw_back);
  4147. string price1 = GetPostString("price1");
  4148. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4149. string price2 = GetPostString("price2");
  4150. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4151. lw.Add(string.Format("IsReturn=3"));
  4152. string backtype = GetPostString("backtype");
  4153. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4154. string backreason = GetPostString("backreason");
  4155. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4156. dStruct.Order = "ReturnTime desc";
  4157. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4158. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4159. writeGridDataTableJson(dStruct.TotalCount, dt);
  4160. }
  4161. public void get_erp_xianhuoreturnlist()
  4162. {
  4163. DataStruct dStruct = GetPostStruct();
  4164. List<string> lw = new List<string>();
  4165. string tid = GetPostString("ctid");
  4166. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4167. string shopname = GetPostString("shopname");
  4168. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4169. string buyernick = GetPostString("buyer_nick");
  4170. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4171. string customer = GetPostString("customer");
  4172. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4173. string design = GetPostString("design");
  4174. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4175. string orderState = GetPostString("orderState");
  4176. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4177. string address = GetPostString("address");
  4178. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4179. string sellermemo = GetPostString("seller_memo");
  4180. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4181. string supplier = GetPostString("supplier");
  4182. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4183. string OrderArea = GetPostString("order_area");
  4184. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4185. string date1 = GetPostString("date1");
  4186. string date2 = GetPostString("date2");
  4187. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4188. if (dw.Length > 0) lw.Add(dw);
  4189. string price1 = GetPostString("price1");
  4190. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4191. string price2 = GetPostString("price2");
  4192. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4193. string posTag = CurrentUser.UserPost.Post.Code;
  4194. if (posTag == "Supplier")
  4195. {
  4196. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4197. }
  4198. lw.Add(string.Format("OrderState=6 "));
  4199. lw.Add(string.Format("IsXianHuo=1 "));
  4200. lw.Add(string.Format("IsReturn>0 "));
  4201. lw.Add(string.Format("IsReturn!=3"));
  4202. lw.Add(string.Format("IsRefund<={0}", 1));
  4203. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4204. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4205. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4206. writeGridDataTableJson(dStruct.TotalCount, dt);
  4207. }
  4208. public void set_erp_orderdelivery()
  4209. {
  4210. if (UrlPostParmsCheck("ctid"))
  4211. {
  4212. string eid = GetPostString("ctid");
  4213. CeErpTradeCell entity = null;
  4214. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4215. if (entity != null)
  4216. {
  4217. if (entity.OrderState >= 7)
  4218. {
  4219. returnErrorMsg("此单已发货,无需重复发货");
  4220. return;
  4221. }
  4222. if (entity.OrderState != 6)
  4223. {
  4224. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4225. return;
  4226. }
  4227. string shop = GetPostString("seller_nick");
  4228. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4229. string comName = GetPostString("comName");
  4230. string comCode = GetPostString("comCode");
  4231. string outSid = GetPostString("outSid");
  4232. string deliveryType = GetPostString("deliveryType");
  4233. string deliveryMemo = GetPostString("deliveryMemo");
  4234. outSid = outSid.Trim();
  4235. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4236. if (mainEn == null)
  4237. {
  4238. returnErrorMsg("找不到原始订单记录");
  4239. return;
  4240. }
  4241. bool isInitOrderDeliv = false;
  4242. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4243. {
  4244. isInitOrderDeliv = true;
  4245. }
  4246. string apires = "";
  4247. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4248. 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)
  4249. {
  4250. apires = "发货成功true";
  4251. }
  4252. else
  4253. {
  4254. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4255. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4256. }
  4257. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4258. {
  4259. entity.OrderState = 7;//发货后订单已发货
  4260. entity.OutSid = outSid;
  4261. entity.MemoOpt = 0;
  4262. entity.FinishDeliveryTime = DateTime.Now;
  4263. entity.Update();
  4264. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4265. commonHelper.UpdateRelationOrder(entity.ctid);
  4266. //还要插入快递信息到 快递信息表
  4267. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4268. exinfo.tid = eid;
  4269. exinfo.out_sid = outSid;
  4270. exinfo.company_code = comCode;
  4271. exinfo.company_name = comName;
  4272. exinfo.delivery_memo = deliveryMemo;
  4273. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4274. exinfo.deliveryType = deliveryType;
  4275. exinfo.Create();
  4276. returnSuccessMsg("发货操作成功!");
  4277. commonHelper.UpdateRelationOrder(entity.ctid);
  4278. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4279. CeErpSukuraData.createInfo(entity.ctid, 4);
  4280. if (entity.SupplierId == 64)
  4281. {
  4282. commonHelper.sendCytExpress(exinfo);
  4283. }
  4284. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4285. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4286. }
  4287. else
  4288. {
  4289. string errmsg = commonHelper.KeepChinese(apires);
  4290. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4291. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4292. }
  4293. return;
  4294. }
  4295. returnErrorMsg("找不到订单记录");
  4296. }
  4297. }
  4298. public void set_erp_multidelivery()
  4299. {
  4300. string eids = GetPostString("tids");
  4301. string[] eidList = eids.Split(',');
  4302. if (eidList.Length <= 0)
  4303. {
  4304. returnErrorMsg("发货不能为空");
  4305. return;
  4306. }
  4307. foreach (string ctid in eidList)
  4308. {
  4309. if (ctid.Length <= 0) continue;
  4310. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4311. if (expInfo != null)
  4312. {
  4313. StringBuilder sql = new StringBuilder();
  4314. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4315. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4316. if (dt.Rows.Count > 0)
  4317. {
  4318. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4319. {
  4320. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4321. expInfo.state = "异常";
  4322. expInfo.isMultiDelivery = 1;
  4323. expInfo.Update();
  4324. continue;
  4325. }
  4326. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4327. {
  4328. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4329. expInfo.state = "异常";
  4330. expInfo.Update();
  4331. continue;
  4332. }
  4333. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4334. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4335. bool isInitOrderDeliv = false;
  4336. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4337. {
  4338. isInitOrderDeliv = true;
  4339. expInfo.isMultiDelivery = 1;
  4340. }
  4341. if (ctid.IndexOf("N") != -1)
  4342. {
  4343. StringBuilder sqlbucha = new StringBuilder();
  4344. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4345. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4346. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4347. commonHelper.UpdateRelationOrder(ctid);
  4348. expInfo.delivery_memo = "发货成功";
  4349. expInfo.state = "发货成功";
  4350. expInfo.isMultiDelivery = 1;
  4351. expInfo.Update();
  4352. }
  4353. else
  4354. {
  4355. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4356. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4357. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4358. {
  4359. expInfo.delivery_memo = "发货成功";
  4360. expInfo.state = "发货成功";
  4361. expInfo.isMultiDelivery = 1;
  4362. expInfo.Update();
  4363. commonHelper.UpdateRelationOrder(ctid);
  4364. CeErpSukuraData.createInfo(ctid, 4);
  4365. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4366. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4367. }
  4368. else
  4369. {
  4370. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4371. expInfo.state = "异常";
  4372. expInfo.Update();
  4373. }
  4374. }
  4375. }
  4376. }
  4377. }
  4378. returnSuccessMsg("操作完成");
  4379. }
  4380. public void reset_erp_memoopt()
  4381. {
  4382. if (UrlPostParmsCheck("ctid"))
  4383. {
  4384. string eid = GetPostString("ctid");
  4385. CeErpTradeCell entity = null;
  4386. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4387. if (entity != null)
  4388. {
  4389. string stropt = "";
  4390. if (entity.MemoOpt == 1)
  4391. {
  4392. stropt = "“改稿”";
  4393. }
  4394. else if (entity.MemoOpt == 2)
  4395. {
  4396. stropt = "“定稿”";
  4397. }
  4398. else if (entity.MemoOpt == 3)
  4399. {
  4400. stropt = "“完成查货”";
  4401. CeErpSukuraData.createInfo(entity.ctid, 6);
  4402. }
  4403. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4404. entity.MemoOpt = 0;
  4405. entity.Update();
  4406. returnSuccessMsg("操作成功!");
  4407. return;
  4408. }
  4409. returnErrorMsg("找不到记录");
  4410. }
  4411. }
  4412. public void get_erp_deliveryunusual()
  4413. {
  4414. DataStruct dStruct = GetPostStruct();
  4415. List<string> lw = new List<string>();
  4416. string tid = GetPostString("ctid");
  4417. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4418. string shopname = GetPostString("shopname");
  4419. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4420. string buyernick = GetPostString("buyer_nick");
  4421. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4422. string customer = GetPostString("customer");
  4423. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4424. string design = GetPostString("design");
  4425. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4426. string sellermemo = GetPostString("seller_memo");
  4427. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4428. string supplier = GetPostString("supplier");
  4429. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4430. string date1 = GetPostString("date1");
  4431. string date2 = GetPostString("date2");
  4432. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4433. if (dw.Length > 0) lw.Add(dw);
  4434. string placedate1 = GetPostString("placedate1");
  4435. string placedate2 = GetPostString("placedate2");
  4436. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4437. if (dw_place.Length > 0) lw.Add(dw_place);
  4438. string price1 = GetPostString("price1");
  4439. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4440. string price2 = GetPostString("price2");
  4441. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4442. string unusualCon = GetPostString("unusualcon");
  4443. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4444. string posTag = CurrentUser.UserPost.Post.Code;
  4445. if (posTag == "Supplier")
  4446. {
  4447. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4448. }
  4449. lw.Add(string.Format("OrderState = 6"));
  4450. lw.Add(string.Format("UnusualTag = 5"));
  4451. lw.Add(string.Format("IsRefund<={0}", 1));
  4452. dStruct.Order = "FinishPlaceTime desc";
  4453. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4454. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4455. writeGridDataTableJson(dStruct.TotalCount, dt);
  4456. }
  4457. public void get_erp_deliveryedlist()
  4458. {
  4459. DataStruct dStruct = GetPostStruct();
  4460. List<string> lw = new List<string>();
  4461. string tid = GetPostString("ctid");
  4462. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4463. string shopname = GetPostString("shopname");
  4464. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4465. string buyernick = GetPostString("buyer_nick");
  4466. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4467. string customer = GetPostString("customer");
  4468. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4469. string design = GetPostString("design");
  4470. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4471. string sellermemo = GetPostString("seller_memo");
  4472. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4473. string logistics = GetPostString("logistics");
  4474. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4475. string date1 = GetPostString("date1");
  4476. string date2 = GetPostString("date2");
  4477. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4478. //if (dw.Length > 0) lw.Add(dw);
  4479. string placedate1 = GetPostString("placedate1");
  4480. string placedate2 = GetPostString("placedate2");
  4481. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4482. if (fdw.Length > 0) lw.Add(fdw);
  4483. string devdate1 = GetPostString("deliverydate1");
  4484. string devdate2 = GetPostString("deliverydate2");
  4485. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4486. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4487. string price1 = GetPostString("price1");
  4488. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4489. string price2 = GetPostString("price2");
  4490. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4491. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4492. {
  4493. if (tid.Length > 0)
  4494. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4495. if (buyernick.Length > 0)
  4496. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4497. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4498. if (dw.Length > 0) lw.Add(dw);
  4499. }
  4500. else
  4501. {
  4502. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4503. }
  4504. string posTag = CurrentUser.UserPost.Post.Code;
  4505. if (posTag == "Supplier")
  4506. {
  4507. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4508. }
  4509. else
  4510. {
  4511. string supplier = GetPostString("supplier");
  4512. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4513. }
  4514. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4515. lw.Add(string.Format("IsRefund!={0}", 2));
  4516. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4517. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4518. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4519. if (dt != null)
  4520. {
  4521. foreach (DataRow dr in dt.Rows)
  4522. {
  4523. 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();
  4524. }
  4525. }
  4526. writeGridDataTableJson(dStruct.TotalCount, dt);
  4527. }
  4528. public void get_erp_pdddeliveryed()
  4529. {
  4530. DataStruct dStruct = GetPostStruct();
  4531. List<string> lw = new List<string>();
  4532. string tid = GetPostString("ctid");
  4533. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4534. string shopname = GetPostString("shopname");
  4535. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4536. string buyernick = GetPostString("buyer_nick");
  4537. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4538. string customer = GetPostString("customer");
  4539. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4540. string design = GetPostString("design");
  4541. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4542. string sellermemo = GetPostString("seller_memo");
  4543. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4544. string logistics = GetPostString("logistics");
  4545. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4546. string date1 = GetPostString("date1");
  4547. string date2 = GetPostString("date2");
  4548. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4549. //if (dw.Length > 0) lw.Add(dw);
  4550. string placedate1 = GetPostString("placedate1");
  4551. string placedate2 = GetPostString("placedate2");
  4552. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4553. if (fdw.Length > 0) lw.Add(fdw);
  4554. string devdate1 = GetPostString("deliverydate1");
  4555. string devdate2 = GetPostString("deliverydate2");
  4556. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4557. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4558. string price1 = GetPostString("price1");
  4559. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4560. string price2 = GetPostString("price2");
  4561. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4562. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4563. {
  4564. if (tid.Length > 0)
  4565. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4566. if (buyernick.Length > 0)
  4567. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4568. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4569. if (dw.Length > 0) lw.Add(dw);
  4570. }
  4571. else
  4572. {
  4573. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4574. }
  4575. string posTag = CurrentUser.UserPost.Post.Code;
  4576. if (posTag == "Supplier")
  4577. {
  4578. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4579. }
  4580. else
  4581. {
  4582. string supplier = GetPostString("supplier");
  4583. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4584. }
  4585. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4586. lw.Add(string.Format("type = 'PDD' "));
  4587. lw.Add(string.Format("IsRefund!={0}", 2));
  4588. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4589. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4590. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4591. foreach (DataRow dr in dt.Rows)
  4592. {
  4593. 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();
  4594. }
  4595. writeGridDataTableJson(dStruct.TotalCount, dt);
  4596. }
  4597. public void get_erp_jddeliveryed()
  4598. {
  4599. DataStruct dStruct = GetPostStruct();
  4600. List<string> lw = new List<string>();
  4601. string tid = GetPostString("ctid");
  4602. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4603. string shopname = GetPostString("shopname");
  4604. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4605. string buyernick = GetPostString("buyer_nick");
  4606. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4607. string customer = GetPostString("customer");
  4608. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4609. string design = GetPostString("design");
  4610. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4611. string sellermemo = GetPostString("seller_memo");
  4612. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4613. string date1 = GetPostString("date1");
  4614. string date2 = GetPostString("date2");
  4615. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4616. //if (dw.Length > 0) lw.Add(dw);
  4617. string placedate1 = GetPostString("placedate1");
  4618. string placedate2 = GetPostString("placedate2");
  4619. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4620. if (fdw.Length > 0) lw.Add(fdw);
  4621. string devdate1 = GetPostString("deliverydate1");
  4622. string devdate2 = GetPostString("deliverydate2");
  4623. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4624. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4625. string price1 = GetPostString("price1");
  4626. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4627. string price2 = GetPostString("price2");
  4628. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4629. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4630. {
  4631. if (tid.Length > 0)
  4632. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4633. if (buyernick.Length > 0)
  4634. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4635. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4636. if (dw.Length > 0) lw.Add(dw);
  4637. }
  4638. else
  4639. {
  4640. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4641. }
  4642. string posTag = CurrentUser.UserPost.Post.Code;
  4643. if (posTag == "Supplier")
  4644. {
  4645. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4646. }
  4647. else
  4648. {
  4649. string supplier = GetPostString("supplier");
  4650. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4651. }
  4652. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4653. lw.Add(string.Format("type = 'JD' "));
  4654. lw.Add(string.Format("IsRefund!={0}", 2));
  4655. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4656. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4657. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4658. foreach (DataRow dr in dt.Rows)
  4659. {
  4660. 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();
  4661. }
  4662. writeGridDataTableJson(dStruct.TotalCount, dt);
  4663. }
  4664. public void get_erp_allplacelist()
  4665. {
  4666. DataStruct dStruct = GetPostStruct();
  4667. List<string> lw = new List<string>();
  4668. string tid = GetPostString("ctid");
  4669. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4670. string shopname = GetPostString("shopname");
  4671. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4672. string buyernick = GetPostString("buyer_nick");
  4673. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4674. string customer = GetPostString("customer");
  4675. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4676. string design = GetPostString("design");
  4677. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4678. string sellermemo = GetPostString("seller_memo");
  4679. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4680. string supplier = GetPostString("supplier");
  4681. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4682. string date1 = GetPostString("date1");
  4683. string date2 = GetPostString("date2");
  4684. string pldate1 = GetPostString("placedate1");
  4685. string pldate2 = GetPostString("placedate2");
  4686. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4687. //if (dw.Length > 0) lw.Add(dw);
  4688. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4689. {
  4690. if (tid.Length > 0)
  4691. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4692. if (buyernick.Length > 0)
  4693. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4694. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4695. if (dw.Length > 0) lw.Add(dw);
  4696. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4697. if (dw_place.Length > 0) lw.Add(dw_place);
  4698. }
  4699. else
  4700. {
  4701. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4702. {
  4703. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4704. }
  4705. }
  4706. string price1 = GetPostString("price1");
  4707. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4708. string price2 = GetPostString("price2");
  4709. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4710. string posTag = CurrentUser.UserPost.Post.Code;
  4711. if (posTag == "Supplier")
  4712. {
  4713. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4714. }
  4715. lw.Add(string.Format("OrderState >= 6"));
  4716. lw.Add(string.Format("IsSample != 2 "));
  4717. lw.Add(string.Format("isDianziOrder = 0 "));
  4718. //lw.Add(string.Format("IsRefund<={0}", 1));
  4719. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4720. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4721. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4722. foreach (DataRow dr in dt.Rows)
  4723. {
  4724. 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();
  4725. }
  4726. writeGridDataTableJson(dStruct.TotalCount, dt);
  4727. }
  4728. public void get_erp_financeallplacelist()
  4729. {
  4730. DataStruct dStruct = GetPostStruct();
  4731. List<string> lw = new List<string>();
  4732. string tid = GetPostString("ctid");
  4733. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4734. string shopname = GetPostString("shopname");
  4735. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4736. string buyernick = GetPostString("buyer_nick");
  4737. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4738. string customer = GetPostString("customer");
  4739. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4740. string design = GetPostString("design");
  4741. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4742. string sellermemo = GetPostString("seller_memo");
  4743. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4744. string supplier = GetPostString("supplier");
  4745. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4746. string date1 = GetPostString("date1");
  4747. string date2 = GetPostString("date2");
  4748. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4749. if (dw.Length > 0) lw.Add(dw);
  4750. string pldate1 = GetPostString("placedate1");
  4751. string pldate2 = GetPostString("placedate2");
  4752. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4753. if (dw_place.Length > 0) lw.Add(dw_place);
  4754. string price1 = GetPostString("price1");
  4755. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4756. string price2 = GetPostString("price2");
  4757. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4758. string posTag = CurrentUser.UserPost.Post.Code;
  4759. if (posTag == "Supplier")
  4760. {
  4761. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4762. }
  4763. //lw.Add(string.Format("OrderState >= 6"));
  4764. lw.Add(string.Format("IsSample != 2 "));
  4765. lw.Add(string.Format("isDianziOrder = 0 "));
  4766. //lw.Add(string.Format("IsRefund<={0}", 1));
  4767. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4768. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4769. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4770. foreach (DataRow dr in dt.Rows)
  4771. {
  4772. 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();
  4773. }
  4774. writeGridDataTableJson(dStruct.TotalCount, dt);
  4775. }
  4776. public void get_erp_expresslist()
  4777. {
  4778. int listtype = GetInt("ltype");
  4779. DataStruct dStruct = GetPostStruct();
  4780. List<string> lw = new List<string>();
  4781. string tid = GetPostString("tid");
  4782. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4783. string outsid = GetPostString("out_sid");
  4784. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4785. string importer = GetPostString("ImportUserName");
  4786. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4787. string file = GetPostString("import_file");
  4788. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4789. string printman = GetPostString("printman");
  4790. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4791. string date1 = GetPostString("date1");
  4792. string date2 = GetPostString("date2");
  4793. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4794. if (dw.Length > 0) lw.Add(dw);
  4795. string fdate1 = GetPostString("finishdate1");
  4796. string fdate2 = GetPostString("finishdate2");
  4797. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4798. if (fdw.Length > 0) lw.Add(fdw);
  4799. string supplierId = GetPostString("supplierId");
  4800. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  4801. if (listtype == 1)
  4802. {
  4803. lw.Add(string.Format("importUserId !=0"));
  4804. }
  4805. string posTag = CurrentUser.UserPost.Post.Code;
  4806. if (posTag == "Supplier")
  4807. {
  4808. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4809. }
  4810. if (dStruct.PageSize != 100000)
  4811. {
  4812. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4813. }
  4814. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4815. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4816. writeGridDataTableJson(dStruct.TotalCount, dt);
  4817. }
  4818. public void set_erp_buchaorderdelivery()
  4819. {
  4820. if (UrlPostParmsCheck("ctid"))
  4821. {
  4822. string eid = GetPostString("ctid");
  4823. CeErpTradeCell entity = null;
  4824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4825. if (entity != null)
  4826. {
  4827. if (entity.IsSample != 2)
  4828. {
  4829. returnErrorMsg("补差价单才能标记为已发货");
  4830. return;
  4831. }
  4832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4833. entity.OrderState = 7;
  4834. entity.Update();
  4835. returnSuccessMsg("操作成功!");
  4836. return;
  4837. }
  4838. returnErrorMsg("找不到记录");
  4839. }
  4840. }
  4841. public void get_stdtemplates()
  4842. {
  4843. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4844. //string res = taobaoHelper.test();
  4845. string res = apiHelper.API_PrintTemplate();
  4846. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4847. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4848. {
  4849. int sidx = res.IndexOf("error_code");
  4850. int eidx = res.IndexOf("success");
  4851. string msg = res.Substring(sidx, eidx - sidx);
  4852. returnErrorMsg(msg);
  4853. return;
  4854. }
  4855. if (res.Length <= 0)
  4856. {
  4857. returnErrorMsg("模板数据为空!");
  4858. return;
  4859. }
  4860. ReturnSuccess(res);
  4861. }
  4862. public void cancel_print_order()
  4863. {
  4864. if (UrlPostParmsCheck("ctid"))
  4865. {
  4866. string ctid = GetPostString("ctid");
  4867. CeErpTradeCell entity = null;
  4868. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4869. if (entity != null)
  4870. {
  4871. string res = "";
  4872. string code = entity.LastBillWaybillCode;
  4873. if (code == "")
  4874. {
  4875. code = entity.OutSid;
  4876. }
  4877. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4878. XLog.SaveLog(0, "取消面单" + res);
  4879. }
  4880. }
  4881. }
  4882. public void set_erp_printwaybill()
  4883. {
  4884. if (UrlPostParmsCheck("ctid"))
  4885. {
  4886. string ctid = GetPostString("ctid");
  4887. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4888. string cpName = GetPostString("cpname");
  4889. string isTogether = GetPostString("together");
  4890. //var res_obj = new
  4891. //{
  4892. // restype = 1,
  4893. // 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\"}"
  4894. //};
  4895. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4896. //ReturnSuccess(ro_json);
  4897. //return;
  4898. bool isUseLastWayBillCode = false;
  4899. CeErpTradeCell entity = null;
  4900. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4901. if (entity != null)
  4902. {
  4903. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4904. {
  4905. isUseLastWayBillCode = true;
  4906. }
  4907. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4908. {
  4909. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4910. return;
  4911. }
  4912. }
  4913. string res = "";
  4914. Api_waybill_code_response_Obj fullObj = null;
  4915. string pData_str = "";
  4916. string curUseWayBillCode = "";
  4917. if (isUseLastWayBillCode == false)
  4918. {
  4919. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4920. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4921. if (res.IndexOf("failure") != -1)
  4922. {
  4923. //int idx = res.IndexOf("sub_message");
  4924. //int idx2 = res.IndexOf("flag");
  4925. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4926. string errMsgNeed = commonHelper.KeepChinese(res);
  4927. var res_objd = new
  4928. {
  4929. restype = 0,
  4930. data = "获取面单失败" + errMsgNeed
  4931. };
  4932. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4933. returnSuccess(ro_jsond);
  4934. if (res.IndexOf("停发") != -1)
  4935. {
  4936. entity.UnusualCon = "物流停发";
  4937. entity.Update();
  4938. }
  4939. //returnErrorMsg("获取面单失败,"+emsg);
  4940. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4941. return;
  4942. }
  4943. else if (res.IndexOf("errorMsg") != -1)
  4944. {
  4945. //int idx = res.IndexOf("errorMsg");
  4946. //int idx2 = res.IndexOf("}]}");
  4947. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4948. string errMsgNeed = commonHelper.KeepChinese(res);
  4949. var res_objf = new
  4950. {
  4951. restype = 0,
  4952. data = "获取面单失败2" + errMsgNeed
  4953. };
  4954. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4955. if (res.IndexOf("停发") != -1)
  4956. {
  4957. entity.UnusualCon = "物流停发";
  4958. entity.Update();
  4959. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4960. if (trade != null)
  4961. {
  4962. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4963. }
  4964. }
  4965. returnSuccess(ro_jsonf);
  4966. //returnErrorMsg("获取面单失败," + emsg);
  4967. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4968. return;
  4969. }
  4970. try
  4971. {
  4972. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4973. //res = res.Replace(" ", "");
  4974. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4975. }
  4976. catch (Exception ex)
  4977. {
  4978. XLog.SaveLog(0, "生成fullObj" + res);
  4979. var res_objf = new
  4980. {
  4981. restype = 0,
  4982. data = "生成fullObj发生错误" + ex.Message
  4983. };
  4984. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4985. returnSuccess(ro_jsonf);
  4986. return;
  4987. }
  4988. if (fullObj.response.data.content.Count > 0)
  4989. {
  4990. ContentItem codeObj = fullObj.response.data.content[0];
  4991. if (cpCode.IndexOf("SFFQ-") != -1)
  4992. {
  4993. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4994. }
  4995. else
  4996. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4997. curUseWayBillCode = codeObj.waybillCode;
  4998. }
  4999. else
  5000. {
  5001. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5002. var res_objf = new
  5003. {
  5004. restype = 0,
  5005. data = "生成fullObj找不到快递单号waybillCode"
  5006. };
  5007. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5008. returnSuccess(ro_jsonf);
  5009. return;
  5010. }
  5011. }
  5012. else
  5013. {
  5014. //使用上次打印的快递单号
  5015. if (cpCode == "SFFQ-LY")
  5016. {
  5017. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5018. }
  5019. else
  5020. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5021. curUseWayBillCode = entity.LastBillWaybillCode;
  5022. }
  5023. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5024. {
  5025. var res_obje = new
  5026. {
  5027. restype = 0,
  5028. data = "获取加密打印数据失败"
  5029. };
  5030. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5031. returnSuccess(ro_jsone);
  5032. entity.LastBillCpCode = cpCode;
  5033. entity.LastBillWaybillCode = curUseWayBillCode;
  5034. entity.Update();
  5035. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5036. //returnErrorMsg("获取加密打印数据失败");
  5037. return;
  5038. }
  5039. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5040. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5041. string btnType = "";
  5042. if (entity != null)
  5043. {
  5044. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5045. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5046. //cpcode是 YTO-CAINIAO
  5047. //string comCode = cpCode.Split('-')[0].ToString();
  5048. string apires = "";
  5049. if (ctid.IndexOf("N") != -1)
  5050. {
  5051. apires = "发货成功";
  5052. }
  5053. else
  5054. {
  5055. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5056. }
  5057. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5058. //打单后发货
  5059. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5060. {
  5061. try
  5062. {
  5063. btnType = "待发货";
  5064. entity.OutSid = curUseWayBillCode;
  5065. entity.OrderState = 7;
  5066. entity.IsUrgency = false;
  5067. entity.LastBillCpCode = "";
  5068. entity.LastBillWaybillCode = "";
  5069. entity.FinishDeliveryTime = DateTime.Now;
  5070. entity.IsReturn = 0;
  5071. entity.MemoOpt = 0;
  5072. entity.Update();
  5073. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5074. //还要插入快递信息到 快递信息表
  5075. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5076. exinfo.tid = entity.ctid;
  5077. exinfo.out_sid = entity.OutSid;
  5078. exinfo.company_code = cpCode;
  5079. exinfo.company_name = cpName;
  5080. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5081. exinfo.deliveryType = "发货成功";
  5082. exinfo.print_time = DateTime.Now;
  5083. exinfo.printUser = CurrentUser.UserName;
  5084. exinfo.Create();
  5085. commonHelper.UpdateRelationOrder(entity.ctid);
  5086. CeErpSukuraData.createInfo(ctid, 4);
  5087. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5088. if (entity.SupplierId == 64)
  5089. {
  5090. commonHelper.sendCytExpress(exinfo);
  5091. }
  5092. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5093. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5094. if (isTogether == "1")
  5095. {
  5096. StringBuilder sqlsb = new StringBuilder();
  5097. 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);
  5098. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5099. }
  5100. }
  5101. catch (Exception ex)
  5102. {
  5103. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5104. }
  5105. }
  5106. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5107. {
  5108. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5109. if (entity.OrderState == 6)
  5110. {
  5111. entity.OrderState = 7;
  5112. }
  5113. entity.FinishDeliveryTime = DateTime.Now;
  5114. btnType = "已发货";
  5115. entity.Update();
  5116. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5117. exinfo.tid = entity.ctid;
  5118. exinfo.out_sid = entity.OutSid;
  5119. exinfo.company_code = cpCode;
  5120. exinfo.company_name = cpName;
  5121. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5122. exinfo.deliveryType = "发货成功";
  5123. exinfo.print_time = DateTime.Now;
  5124. exinfo.printUser = CurrentUser.UserName;
  5125. exinfo.Create();
  5126. commonHelper.UpdateRelationOrder(entity.ctid);
  5127. CeErpSukuraData.createInfo(entity.ctid, 4);
  5128. if (entity.SupplierId == 64)
  5129. {
  5130. commonHelper.sendCytExpress(exinfo);
  5131. }
  5132. if (isTogether == "1")
  5133. {
  5134. StringBuilder sqlsb = new StringBuilder();
  5135. 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);
  5136. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5137. }
  5138. //不处理
  5139. }
  5140. else
  5141. {
  5142. entity.LastBillCpCode = cpCode;
  5143. entity.LastBillWaybillCode = curUseWayBillCode;
  5144. entity.Update();
  5145. string errmsg = commonHelper.KeepChinese(apires);
  5146. var res_objz = new
  5147. {
  5148. restype = 0,
  5149. data = "打单后发货失败"
  5150. };
  5151. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5152. returnSuccess(ro_jsonz);
  5153. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5154. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5155. return;
  5156. }
  5157. }
  5158. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5159. var res_obj = new
  5160. {
  5161. restype = 1,
  5162. data = pData_str
  5163. };
  5164. string ro_json = JsonConvert.SerializeObject(res_obj);
  5165. ReturnSuccess(ro_json);
  5166. return;
  5167. }
  5168. }
  5169. private string GetUTF8String(byte[] vs)
  5170. {
  5171. throw new NotImplementedException();
  5172. }
  5173. public void set_erp_printwaybill_cn()
  5174. {
  5175. if (UrlPostParmsCheck("ctid"))
  5176. {
  5177. string ctid = GetPostString("ctid");
  5178. string cpCode = GetPostString("cpcode");
  5179. string cpName = GetPostString("cpname");
  5180. string tempUrl = GetPostString("tempurl");
  5181. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5182. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5183. //string res = taobaoHelper.test();
  5184. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5185. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5186. {
  5187. int sidx = res.IndexOf("errorMsg");
  5188. int eidx = res.IndexOf("}");
  5189. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5190. var res_objzxx = new
  5191. {
  5192. restype = 0,
  5193. data = msg
  5194. };
  5195. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5196. returnSuccess(ro_jsonzxx);
  5197. //returnErrorMsg(msg);
  5198. return;
  5199. }
  5200. int idx = res.IndexOf("waybillCode");
  5201. int idx2 = res.IndexOf("printData");
  5202. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5203. string eid = GetPostString("ctid");
  5204. CeErpTradeCell entity = null;
  5205. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5206. if (entity != null)
  5207. {
  5208. string osid = entity.OutSid;
  5209. entity.OutSid = osid + "," + outsid;
  5210. entity.FinishDeliveryTime = DateTime.Now;
  5211. entity.OrderState = 7;
  5212. entity.IsReturn = 0;
  5213. entity.Update();
  5214. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5215. exinfo.tid = entity.ctid;
  5216. exinfo.out_sid = outsid;
  5217. exinfo.company_code = cpCode;
  5218. exinfo.company_name = cpName;
  5219. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5220. exinfo.deliveryType = "发货成功";
  5221. exinfo.print_time = DateTime.Now;
  5222. exinfo.printUser = CurrentUser.UserName;
  5223. exinfo.Create();
  5224. if (entity.SupplierId == 64)
  5225. {
  5226. commonHelper.sendCytExpress(exinfo);
  5227. }
  5228. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5229. }
  5230. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5231. var res_objz = new
  5232. {
  5233. restype = 1,
  5234. data = res
  5235. };
  5236. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5237. returnSuccess(ro_jsonz);
  5238. //ReturnSuccess(res);
  5239. }
  5240. }
  5241. ////打单,打印面单 获取面单号
  5242. //public void set_erp_printwaybill()
  5243. //{
  5244. // if (UrlPostParmsCheck("ctid"))
  5245. // {
  5246. // string ctid = GetPostString("ctid");
  5247. // string cpCode = GetPostString("cpcode");
  5248. // string tempUrl = GetPostString("tempurl");
  5249. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5250. // //string res = taobaoHelper.test();
  5251. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5252. // if (res.IndexOf("error_response") != -1)
  5253. // {
  5254. // int sidx = res.IndexOf("sub_msg");
  5255. // int eidx = res.IndexOf("request_id");
  5256. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5257. // returnErrorMsg(msg);
  5258. // return;
  5259. // }
  5260. // int idx = res.IndexOf("waybill_code");
  5261. // int idx2 = res.IndexOf("}]}");
  5262. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5263. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5264. // ReturnSuccess(res);
  5265. // }
  5266. //}
  5267. public void cancel_erp_aftersale()
  5268. {
  5269. if (UrlPostParmsCheck("ctid"))
  5270. {
  5271. string eid = GetPostString("ctid");
  5272. CeErpTradeCell entity = null;
  5273. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5274. if (entity != null)
  5275. {
  5276. //有过处理的售后,取消也不能删除 售 字,保留
  5277. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5278. {
  5279. entity.AfterSaleState = 4;
  5280. }
  5281. else
  5282. entity.AfterSaleState = 0;
  5283. entity.Update();
  5284. returnSuccessMsg("操作成功!");
  5285. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5286. return;
  5287. }
  5288. returnErrorMsg("找不到订单记录");
  5289. }
  5290. }
  5291. public void get_erp_aftersalelist()
  5292. {
  5293. DataStruct dStruct = GetPostStruct();
  5294. List<string> lw = new List<string>();
  5295. int st = GetInt("st");
  5296. string tid = GetPostString("ctid");
  5297. if (st == 3)
  5298. {
  5299. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5300. }
  5301. else
  5302. {
  5303. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5304. }
  5305. string shopname = GetPostString("shopname");
  5306. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5307. string buyernick = GetPostString("buyer_nick");
  5308. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5309. string sellermemo = GetPostString("seller_memo");
  5310. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5311. string orderState = GetPostString("orderState");
  5312. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5313. string afterState = GetPostString("afterstate");
  5314. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5315. string date1 = GetPostString("date1");
  5316. string date2 = GetPostString("date2");
  5317. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5318. if (dw.Length > 0) lw.Add(dw);
  5319. string price1 = GetPostString("price1");
  5320. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5321. string price2 = GetPostString("price2");
  5322. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5323. //lw.Add(string.Format("IsRefund!={0}", 1));
  5324. string reason = GetPostString("reason");
  5325. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5326. string method = GetPostString("method");
  5327. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5328. string handler = GetPostString("handler");
  5329. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5330. string handledate1 = GetPostString("handledate1");
  5331. string handledate2 = GetPostString("handledate2");
  5332. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5333. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5334. string finish1 = GetPostString("finishdate1");
  5335. string finish2 = GetPostString("finishdate2");
  5336. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5337. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5338. string afterdate1 = GetPostString("afterdate1");
  5339. string afterdate2 = GetPostString("afterdate2");
  5340. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5341. if (afterDate.Length > 0) lw.Add(afterDate);
  5342. string supplier = GetPostString("supplier");
  5343. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5344. string responsible = GetPostString("responsibleman");
  5345. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5346. string customer = GetPostString("customer");
  5347. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5348. string design = GetPostString("design");
  5349. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5350. string afterMemoType = GetPostString("aftermemotype");
  5351. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5352. string posCode = CurrentUser.UserPost.Post.Code;
  5353. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5354. //{
  5355. // string vstate = GetPostString("vstate");
  5356. // if (vstate.Length > 0)
  5357. // {
  5358. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5359. // }
  5360. // if (posCode == "Supplier")
  5361. // {
  5362. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5363. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5364. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5365. // }
  5366. // else
  5367. // {
  5368. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5369. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5370. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5371. // {
  5372. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5373. // }
  5374. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5375. // {
  5376. // int orgid = CurrentUser.UserPost.OrgID;
  5377. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5378. // }
  5379. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5380. // {
  5381. // string shopid = CurrentUser.User.pemShop;
  5382. // lw.Add(string.Format("shopId in ({0})", shopid));
  5383. // }
  5384. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5385. // //{
  5386. // // int org_id = CurrentUser.UserPost.OrgID;
  5387. // // lw.Add(string.Format("OrgID={0}", org_id));
  5388. // //}
  5389. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5390. // }
  5391. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5392. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5393. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5394. //}
  5395. if (st == 5)
  5396. {
  5397. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5398. {
  5399. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5400. {
  5401. string shopid = CurrentUser.User.pemShop;
  5402. lw.Add(string.Format("shopId in ({0})", shopid));
  5403. }
  5404. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5405. {
  5406. int mrOrgid = CurrentUser.UserPost.OrgID;
  5407. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5408. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5409. }
  5410. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5411. //{
  5412. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5413. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5414. //}
  5415. else
  5416. {
  5417. string userIdStr = "";
  5418. if (posCode == "CustomerService")
  5419. {
  5420. userIdStr = CurrentUser.UserID + "_k";
  5421. }
  5422. else if (posCode == "Designer" || posCode == "wxDesigner")
  5423. {
  5424. userIdStr = CurrentUser.UserID + "_s";
  5425. }
  5426. else if (posCode == "Place")
  5427. {
  5428. userIdStr = CurrentUser.UserID + "_x";
  5429. }
  5430. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5431. }
  5432. }
  5433. string placedate1 = GetPostString("placedate1");
  5434. string placedate2 = GetPostString("placedate2");
  5435. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5436. if (dwplace.Length > 0) lw.Add(dwplace);
  5437. string supState = GetPostString("supState");
  5438. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5439. string searchType = GetPostString("searchType");
  5440. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5441. {
  5442. lw.Add(string.Format("BackNum>1"));
  5443. }
  5444. lw.Add(string.Format("AfterSaleState>0"));
  5445. if (ex_psize > 0)
  5446. {
  5447. if (CurrentUser.UserPost.Post.Code == "Finance")
  5448. dStruct.Order = "pay_time desc";
  5449. else
  5450. dStruct.Order = "HandleTime desc";
  5451. }
  5452. else
  5453. dStruct.Order = "HandleTime desc";
  5454. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5455. DataTable dt = WebCache.GetData("view_test", dStruct);
  5456. writeGridDataTableJson(dStruct.TotalCount, dt);
  5457. }
  5458. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5459. //{
  5460. // lw.Add(string.Format("AfterSaleState=4"));
  5461. // string code = CurrentUser.UserPost.Post.Code;
  5462. // if (code == "CustomerService")
  5463. // {
  5464. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5465. // }
  5466. // else if (code == "Designer" || code == "DesignerMr")
  5467. // {
  5468. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5469. // }
  5470. // else if (code == "Place" || code == "PlaceMr")
  5471. // {
  5472. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5473. // }
  5474. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5475. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5476. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5477. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5478. //}
  5479. //else //处理中的售后,待处理和处理中合并
  5480. //{
  5481. // if (afterState.Length <= 0)
  5482. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5483. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5484. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5485. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5486. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5487. //}
  5488. }
  5489. public void get_erp_disagreeftersalelist()
  5490. {
  5491. DataStruct dStruct = GetPostStruct();
  5492. List<string> lw = new List<string>();
  5493. int st = 2;
  5494. string tid = GetPostString("ctid");
  5495. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5496. string shopname = GetPostString("shopname");
  5497. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5498. string buyernick = GetPostString("buyer_nick");
  5499. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5500. string sellermemo = GetPostString("seller_memo");
  5501. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5502. string orderState = GetPostString("orderState");
  5503. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5504. string afterState = GetPostString("afterstate");
  5505. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5506. string date1 = GetPostString("date1");
  5507. string date2 = GetPostString("date2");
  5508. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5509. if (dw.Length > 0) lw.Add(dw);
  5510. string price1 = GetPostString("price1");
  5511. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5512. string price2 = GetPostString("price2");
  5513. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5514. //lw.Add(string.Format("IsRefund!={0}", 1));
  5515. string reason = GetPostString("reason");
  5516. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5517. string method = GetPostString("method");
  5518. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5519. string handler = GetPostString("handler");
  5520. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5521. string handledate1 = GetPostString("handledate1");
  5522. string handledate2 = GetPostString("handledate2");
  5523. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5524. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5525. string afterdate1 = GetPostString("afterdate1");
  5526. string afterdate2 = GetPostString("afterdate2");
  5527. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5528. if (afterDate.Length > 0) lw.Add(afterDate);
  5529. string backdate1 = GetPostString("backdate1");
  5530. string backdate2 = GetPostString("backdate2");
  5531. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5532. if (backDate.Length > 0) lw.Add(backDate);
  5533. string supplier = GetPostString("supplier");
  5534. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5535. string responsible = GetPostString("responsibleman");
  5536. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5537. string customer = GetPostString("customer");
  5538. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5539. string design = GetPostString("design");
  5540. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5541. string afterSaleMemo = GetPostString("afterSaleMemo");
  5542. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5543. string afterMemoType = GetPostString("aftermemotype");
  5544. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5545. string aftersakereason = GetPostString("aftersakereason");
  5546. if (aftersakereason.Length > 0)
  5547. {
  5548. if (aftersakereason == "1")
  5549. {
  5550. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5551. }
  5552. if (aftersakereason == "2")
  5553. {
  5554. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5555. }
  5556. }
  5557. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5558. string poscode = CurrentUser.UserPost.Post.Code;
  5559. if (poscode != "SysAdmin")
  5560. {
  5561. string shopid = CurrentUser.User.pemShop;
  5562. lw.Add(string.Format("shopId in ({0})", shopid));
  5563. }
  5564. string searchType = GetPostString("searchType");
  5565. if (searchType == "wait")
  5566. {
  5567. lw.Add(string.Format("HandleTime is null"));
  5568. }
  5569. if (searchType == "handling")
  5570. {
  5571. lw.Add(string.Format("HandleTime is not null "));
  5572. }
  5573. if (searchType == "back" || searchType == "puBack")
  5574. {
  5575. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5576. }
  5577. if (searchType == "reBack")
  5578. {
  5579. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5580. }
  5581. if (searchType == "moreBack")
  5582. {
  5583. lw.Add(string.Format("backNum > 1"));
  5584. }
  5585. lw.Add(string.Format("(AfterSaleState=5)"));
  5586. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5587. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5588. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5589. writeGridDataTableJson(dStruct.TotalCount, dt);
  5590. }
  5591. public void get_erp_handlingaftersalelist()
  5592. {
  5593. DataStruct dStruct = GetPostStruct();
  5594. List<string> lw = new List<string>();
  5595. int st = 2;
  5596. string tid = GetPostString("ctid");
  5597. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5598. string shopname = GetPostString("shopname");
  5599. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5600. string buyernick = GetPostString("buyer_nick");
  5601. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5602. string sellermemo = GetPostString("seller_memo");
  5603. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5604. string orderState = GetPostString("orderState");
  5605. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5606. string afterState = GetPostString("afterstate");
  5607. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5608. string date1 = GetPostString("date1");
  5609. string date2 = GetPostString("date2");
  5610. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5611. if (dw.Length > 0) lw.Add(dw);
  5612. string price1 = GetPostString("price1");
  5613. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5614. string price2 = GetPostString("price2");
  5615. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5616. //lw.Add(string.Format("IsRefund!={0}", 1));
  5617. string reason = GetPostString("reason");
  5618. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5619. string method = GetPostString("method");
  5620. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5621. string handler = GetPostString("handler");
  5622. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5623. string handledate1 = GetPostString("handledate1");
  5624. string handledate2 = GetPostString("handledate2");
  5625. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5626. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5627. string afterdate1 = GetPostString("afterdate1");
  5628. string afterdate2 = GetPostString("afterdate2");
  5629. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5630. if (afterDate.Length > 0) lw.Add(afterDate);
  5631. string supplier = GetPostString("supplier");
  5632. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5633. string responsible = GetPostString("responsibleman");
  5634. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5635. string customer = GetPostString("customer");
  5636. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5637. string design = GetPostString("design");
  5638. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5639. string afterSaleMemo = GetPostString("afterSaleMemo");
  5640. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5641. string afterMemoType = GetPostString("aftermemotype");
  5642. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5643. string afterresult = GetPostString("afterresult");
  5644. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5645. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5646. string poscode = CurrentUser.UserPost.Post.Code;
  5647. if (poscode != "SysAdmin")
  5648. {
  5649. string shopid = CurrentUser.User.pemShop;
  5650. lw.Add(string.Format("shopId in ({0})", shopid));
  5651. }
  5652. string searchType = GetPostString("searchType");
  5653. if (searchType == "wait")
  5654. {
  5655. lw.Add(string.Format("HandleTime is null"));
  5656. }
  5657. if (searchType == "documentary")
  5658. {
  5659. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5660. }
  5661. if (searchType == "handling")
  5662. {
  5663. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5664. }
  5665. if (searchType == "back" || searchType == "puBack")
  5666. {
  5667. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5668. }
  5669. if (searchType == "reBack")
  5670. {
  5671. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5672. }
  5673. if (afterState.Length <= 0)
  5674. {
  5675. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5676. }
  5677. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5678. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5679. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5680. writeGridDataTableJson(dStruct.TotalCount, dt);
  5681. }
  5682. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5683. //public void get_erp_back_handlingaftersalelist()
  5684. //{
  5685. // DataStruct dStruct = GetPostStruct();
  5686. // List<string> lw = new List<string>();
  5687. // string tid = GetPostString("ctid");
  5688. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5689. // string shopname = GetPostString("shopname");
  5690. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5691. // string buyernick = GetPostString("buyer_nick");
  5692. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5693. // string sellermemo = GetPostString("seller_memo");
  5694. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5695. // string orderState = GetPostString("orderState");
  5696. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5697. // string afterState = GetPostString("afterstate");
  5698. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5699. // string date1 = GetPostString("date1");
  5700. // string date2 = GetPostString("date2");
  5701. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5702. // if (dw.Length > 0) lw.Add(dw);
  5703. // string price1 = GetPostString("price1");
  5704. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5705. // string price2 = GetPostString("price2");
  5706. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5707. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5708. // string reason = GetPostString("reason");
  5709. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5710. // string method = GetPostString("method");
  5711. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5712. // string handler = GetPostString("handler");
  5713. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5714. // string handledate1 = GetPostString("handledate1");
  5715. // string handledate2 = GetPostString("handledate2");
  5716. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5717. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5718. // string afterdate1 = GetPostString("afterdate1");
  5719. // string afterdate2 = GetPostString("afterdate2");
  5720. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5721. // if (afterDate.Length > 0) lw.Add(afterDate);
  5722. // string supplier = GetPostString("supplier");
  5723. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5724. // string responsible = GetPostString("responsibleman");
  5725. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5726. // string customer = GetPostString("customer");
  5727. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5728. // string design = GetPostString("design");
  5729. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5730. // string afterMemoType = GetPostString("aftermemotype");
  5731. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5732. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5733. // if (afterState.Length <= 0)
  5734. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5735. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5736. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5737. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5738. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5739. //}
  5740. public void get_erp_aftersaleverifylist()
  5741. {
  5742. DataStruct dStruct = GetPostStruct();
  5743. List<string> lw = new List<string>();
  5744. string tid = GetPostString("ctid");
  5745. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5746. string shopname = GetPostString("shopname");
  5747. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5748. string buyernick = GetPostString("buyer_nick");
  5749. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5750. string sellermemo = GetPostString("seller_memo");
  5751. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5752. string orderState = GetPostString("orderState");
  5753. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5754. //lw.Add(string.Format("IsRefund!={0}", 1));
  5755. string reason = GetPostString("reason");
  5756. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5757. string method = GetPostString("method");
  5758. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5759. string handler = GetPostString("handler");
  5760. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5761. string handledate1 = GetPostString("handledate1");
  5762. string handledate2 = GetPostString("handledate2");
  5763. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5764. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5765. string finish1 = GetPostString("finishdate1");
  5766. string finish2 = GetPostString("finishdate2");
  5767. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5768. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5769. string supplier = GetPostString("supplier");
  5770. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5771. string responsible = GetPostString("responsibleman");
  5772. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5773. string posCode = CurrentUser.UserPost.Post.Code;
  5774. string vstate = GetPostString("vstate");
  5775. if (vstate.Length > 0)
  5776. {
  5777. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5778. }
  5779. if (posCode == "Supplier")
  5780. {
  5781. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5782. lw.Add(string.Format("VerifyState = 0"));
  5783. lw.Add("type = 1");
  5784. lw.Add(string.Format("AfterSaleState={0}", 3));
  5785. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5786. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5787. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5788. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5789. writeGridDataTableJson(dStruct.TotalCount, dt);
  5790. }
  5791. else if (posCode == "logistics")
  5792. {
  5793. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5794. lw.Add(string.Format("VerifyState = 0"));
  5795. lw.Add("type = 2");
  5796. lw.Add(string.Format("AfterSaleState={0}", 3));
  5797. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5798. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5799. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5800. writeGridDataTableJson(dStruct.TotalCount, dt);
  5801. }
  5802. else
  5803. {
  5804. lw.Add(string.Format("(AfterSaleState = 3)"));
  5805. string reasonState = GetPostString("reasonState");
  5806. lw.Add("type = 0");
  5807. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5808. || posCode == "Summarize" || posCode == "Finance")
  5809. {
  5810. if (reasonState == "2")
  5811. {
  5812. lw.Add("VerifyState = 3");
  5813. }
  5814. else if (reasonState == "1")
  5815. {
  5816. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5817. }
  5818. else
  5819. {
  5820. lw.Add("VerifyState in (0,3)");
  5821. }
  5822. //不加条件,可以看全部
  5823. }
  5824. 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")
  5825. {
  5826. int orgid = CurrentUser.UserPost.OrgID;
  5827. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5828. if (string.IsNullOrEmpty(manageOrgId))
  5829. {
  5830. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5831. }
  5832. else
  5833. {
  5834. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5835. }
  5836. if (reasonState == "1")
  5837. {
  5838. lw.Add("VerifyState = 3");
  5839. }
  5840. else if (reasonState == "2")
  5841. {
  5842. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5843. }
  5844. else
  5845. {
  5846. }
  5847. }
  5848. else
  5849. {
  5850. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5851. }
  5852. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5853. //{
  5854. // int org_id = CurrentUser.UserPost.OrgID;
  5855. // lw.Add(string.Format("OrgID={0}", org_id));
  5856. //}
  5857. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5858. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5859. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5860. writeGridDataTableJson(dStruct.TotalCount, dt);
  5861. }
  5862. }
  5863. public void get_erp_finishaftersalelist()
  5864. {
  5865. DataStruct dStruct = GetPostStruct();
  5866. List<string> lw = new List<string>();
  5867. int st = 4;
  5868. string tid = GetPostString("ctid");
  5869. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5870. string shopname = GetPostString("shopname");
  5871. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5872. //lw.Add(string.Format("IsRefund!={0}", 1));
  5873. string reason = GetPostString("reason");
  5874. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5875. string method = GetPostString("method");
  5876. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5877. string buyernick = GetPostString("buyer_nick");
  5878. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5879. string handler = GetPostString("handler");
  5880. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5881. string handledate1 = GetPostString("handledate1");
  5882. string handledate2 = GetPostString("handledate2");
  5883. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5884. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5885. string finish1 = GetPostString("finishdate1");
  5886. string finish2 = GetPostString("finishdate2");
  5887. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5888. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5889. string supplier = GetPostString("supplier");
  5890. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5891. string responsible = GetPostString("responsibleman");
  5892. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5893. string vstate = GetPostString("vstate");
  5894. if (vstate.Length > 0)
  5895. {
  5896. if ("3".Equals(vstate))
  5897. {
  5898. lw.Add(string.Format("IsTem=1"));
  5899. }
  5900. else
  5901. {
  5902. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5903. }
  5904. }
  5905. lw.Add(string.Format("AfterSaleState=4"));
  5906. string code = CurrentUser.UserPost.Post.Code;
  5907. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5908. {
  5909. //不加条件,可以看全部
  5910. }
  5911. else if (code == "Supplier")
  5912. {
  5913. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5914. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5915. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5916. }
  5917. else if (code == "logistics")
  5918. {
  5919. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5920. lw.Add("type = 2");
  5921. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5922. }
  5923. 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")
  5924. {
  5925. int orgid = CurrentUser.UserPost.OrgID;
  5926. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5927. if (string.IsNullOrEmpty(manageOrgIds))
  5928. {
  5929. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5930. }
  5931. else
  5932. {
  5933. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5934. }
  5935. }
  5936. else
  5937. {
  5938. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5939. }
  5940. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5941. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5942. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5943. writeGridDataTableJson(dStruct.TotalCount, dt);
  5944. }
  5945. public void handle_erp_aftersale()
  5946. {
  5947. if (UrlPostParmsCheck("ctid"))
  5948. {
  5949. string eid = GetPostString("ctid");
  5950. string responStr = GetPostString("AfterSaleResponsible");
  5951. if (responStr.Length <= 0)
  5952. {
  5953. returnErrorMsg("售后责任人不能为空");
  5954. return;
  5955. }
  5956. bool isDesign = false;
  5957. double designFree = 0.00;
  5958. int responsibleId = 0;
  5959. CeErpTradeCell entity = null;
  5960. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5961. if (entity != null)
  5962. {
  5963. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5964. string afterMethod = GetPostString("AfterSaleMethod");
  5965. if (isNeedNewOrder == 1)
  5966. {
  5967. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5968. bool ishav = true;
  5969. if (newentity == null)
  5970. {
  5971. newentity = entity.Clone() as CeErpTradeCell;
  5972. ishav = false;
  5973. newentity.ctid = "S_" + entity.ctid;
  5974. newentity.OrderState = 0;
  5975. }
  5976. //唯一标识
  5977. newentity.OrderSn = newentity.ctid;
  5978. /* string orderSn = dataHelper.getSaleOrderSn();
  5979. if (orderSn != "")
  5980. {
  5981. newentity.OrderSn = orderSn;
  5982. }*/
  5983. newentity.AfterSaleState = 0;
  5984. newentity.AfterSaleMethod = afterMethod;
  5985. if (!ishav)
  5986. {
  5987. string memo_str = newentity.seller_memo;
  5988. memo_str = memo_str.Replace("(", "(");
  5989. memo_str = memo_str.Replace(")", ")");
  5990. int sIndex = memo_str.IndexOf("(");
  5991. int eIndex = memo_str.IndexOf(")");
  5992. if (sIndex == -1 || eIndex == -1)
  5993. {
  5994. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5995. return;
  5996. }
  5997. string first = memo_str.Substring(0, sIndex + 1);
  5998. string memoCtid = newentity.OrderSn;
  5999. //if (memoCtid.IndexOf("C") != -1)
  6000. //{
  6001. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6002. //if (CIdx.IndexOf("+") != -1)
  6003. //{
  6004. //CIdx = "C" + CIdx.Split('+')[1];
  6005. //}
  6006. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6007. //}
  6008. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6009. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6010. string newMemo = first + memoCtid + last;
  6011. newentity.seller_memo = newMemo;
  6012. newentity.FinishPlaceTime = null;
  6013. newentity.UnusualTag = 0;
  6014. newentity.UnusualCon = "";
  6015. newentity.UnusualTime = null;
  6016. newentity.AfterSaleMemo = "";
  6017. newentity.AfterSaleMethod = afterMethod;
  6018. newentity.AfterSalePreTime = null;
  6019. newentity.AfterSaleReason = "";
  6020. newentity.AfterSaleResponsible = "";
  6021. newentity.AfterSaleState = 0;
  6022. newentity.AfterSaleTime = null;
  6023. newentity.AfterSaleUserId = 0;
  6024. newentity.AfterSaleSupplierState = 0;
  6025. newentity.LastBillWaybillCode = "";
  6026. newentity.LastBillCpCode = "";
  6027. newentity.FinishAfterSaleTime = null;
  6028. newentity.HandleTime = null;
  6029. newentity.IsSF = 0;
  6030. newentity.IsOldCustomer = 0;
  6031. newentity.UrgencyTime = null;
  6032. newentity.ResponsibleUserId = "";
  6033. newentity.IsVerifyToSupplier = false;
  6034. newentity.payment = 0;
  6035. newentity.CheckMemo = "";
  6036. newentity.OutSid = "";
  6037. newentity.CheckOrderTime = null;
  6038. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6039. }
  6040. newentity.isAfterSaleOrder = 1;
  6041. newentity.IsRefund = 0;
  6042. string receiveMobile = GetPostString("receiver_mobile");
  6043. if (receiveMobile.Length > 0)
  6044. {
  6045. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6046. if (trade != null)
  6047. {
  6048. trade.receiver_name = GetPostString("receiver_name");
  6049. trade.receiver_mobile = receiveMobile;
  6050. trade.receiver_state = GetPostString("receiver_state");
  6051. trade.receiver_city = GetPostString("receiver_city");
  6052. trade.receiver_district = GetPostString("receiver_district");
  6053. trade.receiver_address = GetPostString("receiver_address");
  6054. newentity.IsOffLineOrder = 1;
  6055. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6056. }
  6057. }
  6058. string st = GetPostString("ToState");
  6059. if (st.Length > 0)
  6060. {
  6061. if (newentity.OrderState <= 3)
  6062. {
  6063. newentity.WaitDesignTime = DateTime.Now;
  6064. newentity.StartDesignTime = null;
  6065. newentity.FinishDesignTime = null;
  6066. newentity.OrderState = 3;
  6067. if (st == "下单员")
  6068. {
  6069. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6070. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6071. {
  6072. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6073. }
  6074. }
  6075. else
  6076. {
  6077. newentity.WaitDesignTime = DateTime.Now;
  6078. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6079. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6080. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6081. {
  6082. DataRow user = dt1.Rows[0];
  6083. //找主管
  6084. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6085. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6086. if (dt != null && dt.Rows.Count > 0)
  6087. {
  6088. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6089. newentity.DesignUserId = designMr;
  6090. string key = "aftersale_order_" + designMr;
  6091. if (RedisHelper.HasKey(key))
  6092. {
  6093. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6094. list.Add(newentity.ctid);
  6095. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6096. }
  6097. }
  6098. //账号正常
  6099. if (user["State"].ToString() == "0")
  6100. {
  6101. newentity.DesignUserId = entity.DesignUserId;
  6102. string key = "aftersale_order_" + entity.DesignUserId;
  6103. if (RedisHelper.HasKey(key))
  6104. {
  6105. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6106. list.Add(newentity.ctid);
  6107. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6108. }
  6109. }
  6110. }
  6111. }
  6112. }
  6113. if (entity.IsXianHuo == 1)
  6114. {
  6115. newentity.OrderState = 6;
  6116. entity.FinishPlaceTime = DateTime.Now;
  6117. }
  6118. }
  6119. if (ishav)
  6120. {
  6121. newentity.Update();
  6122. }
  6123. else
  6124. {
  6125. newentity.Create();
  6126. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6127. newCellExtend.ctid = newentity.ctid;
  6128. newCellExtend.orderFrom = 20;
  6129. newCellExtend.orderType = 30;
  6130. if (st == "下单员")
  6131. {
  6132. }
  6133. else
  6134. {
  6135. newCellExtend.ReprintTime = DateTime.Now;
  6136. }
  6137. newCellExtend.Create();
  6138. }
  6139. if (st != "下单员")
  6140. {
  6141. designHelper.API_GetPrintData_CreateOrder(newentity);
  6142. }
  6143. }
  6144. //处理售后扩展
  6145. string resIdStr = GetPostString("ResponsibleUserId");
  6146. string refundFees = GetPostString("refundFrees");
  6147. int IsComplain = GetPostInt("isComplain");
  6148. int IsBad = GetPostInt("isBad");
  6149. string IsOriginal = GetPostString("isOriginal");
  6150. double diffResultPrice = GetPostDouble("diffResultPrice");
  6151. string textResult = GetPostString("textResult");
  6152. string supplierResponsible = GetPostString("supplierResponsible");
  6153. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6154. if (ceErpTradeAfterSaleExtend == null)
  6155. {
  6156. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6157. ceErpTradeAfterSaleExtend.tid = eid;
  6158. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6159. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6160. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6161. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6162. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6163. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6164. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6165. ceErpTradeAfterSaleExtend.Create();
  6166. }
  6167. else
  6168. {
  6169. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6170. {
  6171. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6172. }
  6173. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6174. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6175. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6176. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6177. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6178. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6179. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6180. ceErpTradeAfterSaleExtend.Update();
  6181. }
  6182. int gysid = GetPostInt("ResponsibleSupId");
  6183. if (entity.AfterSaleUserId == 0)
  6184. {
  6185. entity.AfterSaleUserId = CurrentUser.UserID;
  6186. }
  6187. entity.ResponsibleUserId = resIdStr;
  6188. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6189. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6190. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6191. {
  6192. CeErpTradeResponsible.DelByTid(eid, -1);
  6193. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6194. int backNum = 0;
  6195. if (number != null)
  6196. {
  6197. backNum = number.BackNum;
  6198. }
  6199. char[] separator = { ',' };
  6200. string[] sArray = resIdStr.Split(separator);
  6201. string[] refundFreeList = { };
  6202. if (refundFees.Length > 0)
  6203. {
  6204. refundFreeList = refundFees.Split(separator);
  6205. }
  6206. int index = -1;
  6207. foreach (string i in sArray)
  6208. {
  6209. index++;
  6210. if (i.Length <= 0) continue;
  6211. char[] separator2 = { '_' };
  6212. string idstr = i.Split(separator2)[0];
  6213. string idtype = i.Split(separator2)[1];
  6214. double refudFree = 0;
  6215. if (refundFreeList.Length > 0)
  6216. {
  6217. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6218. }
  6219. if (idtype == "s")
  6220. {
  6221. isDesign = true;
  6222. designFree = refudFree;
  6223. }
  6224. int userId = Convert.ToInt32(idstr);
  6225. int type = 0;
  6226. if (idtype == "g")
  6227. {
  6228. type = 1;
  6229. }
  6230. if (idtype == "w")
  6231. {
  6232. type = 2;
  6233. }
  6234. if (idtype == "t")
  6235. {
  6236. type = 3;
  6237. }
  6238. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6239. if (ceErpTradeResponsible == null)
  6240. {
  6241. ceErpTradeResponsible = new CeErpTradeResponsible();
  6242. ceErpTradeResponsible.tid = eid;
  6243. ceErpTradeResponsible.UserId = userId;
  6244. ceErpTradeResponsible.createdTime = DateTime.Now;
  6245. ceErpTradeResponsible.type = type;
  6246. if (type == 1)
  6247. {
  6248. ceErpTradeResponsible.IsSup = 1;
  6249. }
  6250. if (type == 2)
  6251. {
  6252. ceErpTradeResponsible.IsFlow = 1;
  6253. }
  6254. }
  6255. ceErpTradeResponsible.RefundFee = refudFree;
  6256. ceErpTradeResponsible.VerifyState = 0;
  6257. if (userId == 2125 || idtype == "w")
  6258. {
  6259. ceErpTradeResponsible.VerifyState = 1;
  6260. }
  6261. if (idtype == "w" && userId == 101)
  6262. {
  6263. ceErpTradeResponsible.VerifyState = 0;
  6264. }
  6265. if (ceErpTradeResponsible.ID > 0)
  6266. {
  6267. ceErpTradeResponsible.Update();
  6268. }
  6269. else
  6270. {
  6271. ceErpTradeResponsible.Create();
  6272. }
  6273. if (isDesign)
  6274. {
  6275. responsibleId = ceErpTradeResponsible.ID;
  6276. }
  6277. }
  6278. CeErpTradeResponsible.NumByTid(backNum, eid);
  6279. }
  6280. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6281. if (ceErpTradeCellExtend != null)
  6282. {
  6283. ceErpTradeCellExtend.returnVisit = 0;
  6284. ceErpTradeCellExtend.Update();
  6285. }
  6286. if (entity.HandleTime != null)
  6287. {
  6288. if (entity.AfterSaleState == 1)
  6289. {
  6290. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6291. }
  6292. else
  6293. {
  6294. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6295. }
  6296. }
  6297. else
  6298. {
  6299. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6300. entity.HandleTime = DateTime.Now;
  6301. }
  6302. bool isCompale = false;
  6303. if (entity.AfterSaleState == 5)
  6304. {
  6305. isCompale = true;
  6306. entity.AfterSaleState = 3;
  6307. }
  6308. entity.AfterSaleSupplierState = 0;
  6309. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6310. {
  6311. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6312. }
  6313. string sImgs = GetPostString("img");
  6314. entity.AfterSaleSupplierImg = sImgs;
  6315. entity.supRefundType = GetPostString("supRefundType");
  6316. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6317. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6318. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6319. entity.AfterSaleMemoType = GetPostString("MemoType");
  6320. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6321. {
  6322. //entity.AfterSaleSupplierState = 2;
  6323. }
  6324. string df = GetPostString("DeductFee");
  6325. if (df == "")
  6326. {
  6327. df = "0";
  6328. }
  6329. string rf = GetPostString("RefundFee");
  6330. if (rf == "")
  6331. {
  6332. rf = "0";
  6333. }
  6334. string pm = GetPostString("AfterSalePayment");
  6335. if (pm == "")
  6336. {
  6337. pm = "0";
  6338. }
  6339. entity.AfterSalePayment = Convert.ToDouble(pm);
  6340. entity.DeductFee = Convert.ToDouble(df);
  6341. entity.RefundFee = Convert.ToDouble(rf);
  6342. entity.Update();
  6343. string toState = GetPostString("ToState");
  6344. string original = GetPostString("isOriginal");
  6345. ApiVo apiVo = new ApiVo();
  6346. apiVo.orderNumber = entity.ctid;
  6347. apiVo.actionName = "afterDesign";
  6348. apiVo.orderRemarks = entity.AfterSaleMethod;
  6349. apiVo.reasonRemarks = entity.AfterSaleReason;
  6350. apiVo.isDesign = isDesign;
  6351. apiVo.designFree = designFree;
  6352. apiVo.responsibleId = responsibleId;
  6353. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6354. if (toState == "设计师")
  6355. {
  6356. apiVo.isOriginal = Convert.ToBoolean(original);
  6357. }
  6358. designHelper.API_WorkCore(apiVo);//afterDesign
  6359. CeErpMethod methodSql = new CeErpMethod();
  6360. methodSql.con = entity.AfterSaleMethod;
  6361. methodSql.addTime = DateTime.Now;
  6362. methodSql.Create();
  6363. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6364. CeErpMethod.ExecuteNonQuery(delsql);
  6365. if (isCompale)
  6366. {
  6367. aftersale_data_change(entity.ctid);
  6368. }
  6369. returnSuccessMsg("操作成功!");
  6370. return;
  6371. }
  6372. returnErrorMsg("找不到订单记录");
  6373. }
  6374. }
  6375. public void ins_erp_toresponsible()
  6376. {
  6377. if (UrlPostParmsCheck("ctid"))
  6378. {
  6379. string eid = GetPostString("ctid");
  6380. CeErpTradeCell entity = null;
  6381. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6382. if (entity != null)
  6383. {
  6384. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6385. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6386. {
  6387. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6388. return;
  6389. }
  6390. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6391. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6392. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6393. if (entity.AfterSalePreTime == null)
  6394. {
  6395. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6396. {
  6397. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6398. }
  6399. }
  6400. entity.AfterSalePreTime = DateTime.Now;
  6401. //预完成给售后主管审核客户问题直接完成
  6402. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6403. {
  6404. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6405. {
  6406. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6407. }
  6408. }
  6409. ceErpTradeAfterSaleExtend.Update();
  6410. entity.AfterSaleState = 2;
  6411. entity.Update();
  6412. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6413. aftersale_data_change(entity.ctid);
  6414. returnSuccessMsg("操作成功!");
  6415. return;
  6416. }
  6417. returnErrorMsg("找不到订单记录");
  6418. }
  6419. }
  6420. public void cancel_erp_aftersaleanddelnew()
  6421. {
  6422. if (UrlPostParmsCheck("ctid"))
  6423. {
  6424. string eid = GetPostString("ctid");
  6425. CeErpTradeCell entity = null;
  6426. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6427. if (entity != null)
  6428. {
  6429. entity.AfterSaleState = 0;
  6430. entity.AfterSaleReason = "";
  6431. entity.AfterSaleMethod = "";
  6432. entity.AfterSaleMemo = "";
  6433. entity.AfterSaleResponsible = "";
  6434. entity.ResponsibleUserId = "";
  6435. entity.DeductFee = 0;
  6436. entity.RefundFee = 0;
  6437. entity.IsArbitrate = 0;
  6438. CeErpTradeResponsible.DelByTid(eid, -1);
  6439. entity.Update();
  6440. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6441. if (after != null)
  6442. {
  6443. if (after.OrderState < 5)
  6444. CeErpTradeCell.DelByCtid("S_" + eid);
  6445. }
  6446. returnSuccessMsg("操作成功!");
  6447. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6448. return;
  6449. }
  6450. returnErrorMsg("找不到订单记录");
  6451. }
  6452. }
  6453. public void get_erp_aftersale_pregather()
  6454. {
  6455. List<string> lw = new List<string>();
  6456. int st = GetInt("st");
  6457. string tid = GetPostString("ctid");
  6458. if (tid.Length > 0) lw.Add(string.Format("(tid = '{0}' or ctid = '{0}' or orderSn = '{0}')", tid));
  6459. string shopname = GetPostString("shopname");
  6460. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6461. string buyernick = GetPostString("buyer_nick");
  6462. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6463. string sellermemo = GetPostString("seller_memo");
  6464. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6465. string orderState = GetPostString("orderState");
  6466. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6467. string reason = GetPostString("reason");
  6468. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6469. string method = GetPostString("method");
  6470. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6471. string handler = GetPostString("handler");
  6472. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6473. string handledate1 = GetPostString("handledate1");
  6474. string handledate2 = GetPostString("handledate2");
  6475. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6476. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6477. string supplier = GetPostString("supplier");
  6478. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6479. string responsible = GetPostString("responsibleman");
  6480. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6481. string customer = GetPostString("customer");
  6482. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6483. string design = GetPostString("design");
  6484. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6485. string afterMemoType = GetPostString("aftermemotype");
  6486. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6487. string afterSaleMemo = GetPostString("afterSaleMemo");
  6488. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6489. string afterresult = GetPostString("afterresult");
  6490. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6491. string poscode = CurrentUser.UserPost.Post.Code;
  6492. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6493. {
  6494. string shopid = CurrentUser.User.pemShop;
  6495. lw.Add(string.Format("shopId in ({0})", shopid));
  6496. }
  6497. var mainwhere = string.Join(" and ", lw.ToArray());
  6498. string ro_json = "";
  6499. string type = GetPostString("gather_type");
  6500. if (poscode == "AfterSale")
  6501. {
  6502. //处理中
  6503. if (type == "Handling")
  6504. {
  6505. 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) : ""));
  6506. DataTable dt = null;
  6507. try
  6508. {
  6509. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6510. }
  6511. catch (Exception e)
  6512. {
  6513. dt = new DataTable();
  6514. }
  6515. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6516. return;
  6517. }
  6518. if (type == "Wait")
  6519. {
  6520. //待处理
  6521. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6522. DataTable dt1 = null;
  6523. try
  6524. {
  6525. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6526. }
  6527. catch (Exception e)
  6528. {
  6529. dt1 = new DataTable();
  6530. }
  6531. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6532. return;
  6533. }
  6534. if (type == "back")
  6535. {
  6536. //打回
  6537. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6538. DataTable dt2 = null;
  6539. try
  6540. {
  6541. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6542. }
  6543. catch (Exception e)
  6544. {
  6545. dt2 = new DataTable();
  6546. }
  6547. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6548. return;
  6549. }
  6550. if (type == "preCompletion")
  6551. {
  6552. //预完成
  6553. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6554. DataTable dt3 = null;
  6555. try
  6556. {
  6557. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6558. }
  6559. catch (Exception e)
  6560. {
  6561. dt3 = new DataTable();
  6562. }
  6563. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6564. return;
  6565. }
  6566. if (type == "documentary")
  6567. {
  6568. //跟单中
  6569. 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) : ""));
  6570. DataTable dt4 = null;
  6571. try
  6572. {
  6573. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6574. }
  6575. catch (Exception e)
  6576. {
  6577. dt4 = new DataTable();
  6578. }
  6579. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6580. return;
  6581. }
  6582. if (type == "reBack")
  6583. {
  6584. //被打回
  6585. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6586. DataTable dt1 = null;
  6587. try
  6588. {
  6589. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6590. }
  6591. catch (Exception e)
  6592. {
  6593. dt1 = new DataTable();
  6594. }
  6595. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6596. return;
  6597. }
  6598. }
  6599. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6600. {
  6601. if (type == "puBack")
  6602. {
  6603. //退回
  6604. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6605. DataTable dt = null;
  6606. try
  6607. {
  6608. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6609. }
  6610. catch (Exception e)
  6611. {
  6612. dt = new DataTable();
  6613. }
  6614. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6615. return;
  6616. }
  6617. if (type == "reBack")
  6618. {
  6619. //打回
  6620. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6621. DataTable dt1 = null;
  6622. try
  6623. {
  6624. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6625. }
  6626. catch (Exception e)
  6627. {
  6628. dt1 = new DataTable();
  6629. }
  6630. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6631. return;
  6632. }
  6633. if (type == "examEd")
  6634. {
  6635. //已审核
  6636. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6637. DataTable dt2 = null;
  6638. try
  6639. {
  6640. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6641. }
  6642. catch (Exception e)
  6643. {
  6644. dt2 = new DataTable();
  6645. }
  6646. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6647. return;
  6648. }
  6649. if (type == "waitExam")
  6650. {
  6651. //待审核
  6652. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6653. DataTable dt3 = null;
  6654. try
  6655. {
  6656. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6657. }
  6658. catch (Exception e)
  6659. {
  6660. dt3 = new DataTable();
  6661. }
  6662. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6663. return;
  6664. }
  6665. if (type == "Handling")
  6666. {
  6667. //处理中
  6668. 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) : ""));
  6669. DataTable dt4 = null;
  6670. try
  6671. {
  6672. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6673. }
  6674. catch (Exception e)
  6675. {
  6676. dt4 = new DataTable();
  6677. }
  6678. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6679. return;
  6680. }
  6681. if (type == "Wait")
  6682. {
  6683. //待处理
  6684. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6685. DataTable dt5 = null;
  6686. try
  6687. {
  6688. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6689. }
  6690. catch (Exception e)
  6691. {
  6692. dt5 = new DataTable();
  6693. }
  6694. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6695. return;
  6696. }
  6697. if (type == "documentary")
  6698. {
  6699. //跟单中
  6700. 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) : ""));
  6701. DataTable dt6 = null;
  6702. try
  6703. {
  6704. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6705. }
  6706. catch (Exception e)
  6707. {
  6708. dt6 = new DataTable();
  6709. }
  6710. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6711. return;
  6712. }
  6713. }
  6714. returnSuccess(ro_json);
  6715. }
  6716. public void end_erp_aftersale()
  6717. {
  6718. if (UrlPostParmsCheck("ctid"))
  6719. {
  6720. string eid = GetPostString("ctid");
  6721. CeErpTradeCell entity = null;
  6722. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6723. if (entity != null)
  6724. {
  6725. string stype = GetPostString("stype");
  6726. string typeStr = stype;
  6727. entity.AfterSaleState = 4;
  6728. entity.FinishAfterSaleTime = DateTime.Now;
  6729. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6730. entity.Update();
  6731. ApiVo apiVo = new ApiVo();
  6732. apiVo.orderNumber = entity.ctid;
  6733. apiVo.actionName = "afterOver";
  6734. designHelper.API_WorkCore(apiVo); //afterOver
  6735. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6736. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6737. CeErpSukuraData.createInfo(entity.ctid, 8);
  6738. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6739. returnSuccessMsg("操作成功!");
  6740. return;
  6741. }
  6742. returnErrorMsg("找不到订单记录");
  6743. }
  6744. }
  6745. public void ins_erp_finishaftersale()
  6746. {
  6747. if (UrlPostParmsCheck("id"))
  6748. {
  6749. string eid = GetPostString("id");
  6750. CeErpTradeResponsible entity = null;
  6751. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6752. if (entity != null)
  6753. {
  6754. entity.VerifyState = 1;
  6755. entity.VerifyTime = DateTime.Now;
  6756. entity.Update();
  6757. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6758. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6759. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6760. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6761. if (dt.Rows.Count <= 0)
  6762. {
  6763. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6764. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6765. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6766. CeErpSukuraData.createInfo(entity.tid, 8);
  6767. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6768. {
  6769. CeErpDesignerBill.Del(entity.tid);
  6770. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6771. }
  6772. }
  6773. returnSuccessMsg("操作成功!");
  6774. return;
  6775. }
  6776. returnErrorMsg("找不到订单记录");
  6777. }
  6778. }
  6779. public void upd_erp_arbitrateaftersale()
  6780. {
  6781. if (UrlPostParmsCheck("id"))
  6782. {
  6783. string eid = GetPostString("id");
  6784. CeErpTradeResponsible entity = null;
  6785. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6786. if (entity != null)
  6787. {
  6788. entity.IsArbitrate = 1;
  6789. entity.ArbitradeMemo = GetPostString("reason");
  6790. entity.VerifyState = 2;
  6791. entity.Update();
  6792. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6793. if (tradecell != null)
  6794. {
  6795. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6796. tradecell.IsArbitrate = 1;
  6797. tradecell.Update();
  6798. }
  6799. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6800. returnSuccessMsg("操作成功!");
  6801. return;
  6802. }
  6803. returnErrorMsg("找不到订单记录");
  6804. }
  6805. }
  6806. public void upd_erp_backaftersale()
  6807. {
  6808. if (UrlPostParmsCheck("tid"))
  6809. {
  6810. string eid = GetPostString("tid");
  6811. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6812. int backNum = 0;
  6813. if (number != null)
  6814. {
  6815. backNum = number.BackNum;
  6816. }
  6817. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6818. CeErpTradeCell entity = null;
  6819. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6820. if (entity != null)
  6821. {
  6822. entity.AfterSaleBackReason = GetPostString("backreason");
  6823. entity.AfterSaleState = 1;
  6824. entity.AfterSaleSupplierState = 0;
  6825. entity.Update();
  6826. returnSuccessMsg("操作成功!");
  6827. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6828. return;
  6829. }
  6830. returnErrorMsg("找不到订单记录");
  6831. }
  6832. }
  6833. public void get_erp_supplieraftersalelist()
  6834. {
  6835. DataStruct dStruct = GetPostStruct();
  6836. List<string> lw = new List<string>();
  6837. string tid = GetPostString("ctid");
  6838. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6839. string shopname = GetPostString("shopname");
  6840. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6841. string buyernick = GetPostString("buyer_nick");
  6842. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6843. string sellermemo = GetPostString("seller_memo");
  6844. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6845. string orderState = GetPostString("orderState");
  6846. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6847. string afterState = GetPostString("afterstate");
  6848. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6849. string date1 = GetPostString("date1");
  6850. string date2 = GetPostString("date2");
  6851. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6852. if (dw.Length > 0) lw.Add(dw);
  6853. string price1 = GetPostString("price1");
  6854. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6855. string price2 = GetPostString("price2");
  6856. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6857. string reason = GetPostString("reason");
  6858. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6859. string method = GetPostString("method");
  6860. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6861. string handledate1 = GetPostString("handledate1");
  6862. string handledate2 = GetPostString("handledate2");
  6863. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6864. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6865. string handler = GetPostString("handler");
  6866. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6867. string afterdate1 = GetPostString("afterdate1");
  6868. string afterdate2 = GetPostString("afterdate2");
  6869. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6870. if (afterDate.Length > 0) lw.Add(afterDate);
  6871. string customer = GetPostString("customer");
  6872. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6873. string design = GetPostString("design");
  6874. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6875. string afterMemoType = GetPostString("aftermemotype");
  6876. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6877. string vstate = GetPostString("vstate");
  6878. if (vstate.Length > 0)
  6879. {
  6880. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6881. }
  6882. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6883. string supplier = GetPostString("supplier");
  6884. int supid = commonHelper.getSupplierIDByName(supplier);
  6885. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6886. string posCode = CurrentUser.UserPost.Post.Code;
  6887. if (posCode == "Supplier")
  6888. {
  6889. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6890. }
  6891. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6892. {
  6893. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6894. }
  6895. else
  6896. {
  6897. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6898. }
  6899. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6900. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6901. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6902. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6903. writeGridDataTableJson(dStruct.TotalCount, dt);
  6904. }
  6905. public void upd_erp_supverifyaftersale()
  6906. {
  6907. if (UrlPostParmsCheck("id"))
  6908. {
  6909. string id = GetPostString("id");
  6910. int st = GetPostInt("afterstate");
  6911. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6912. CeErpTradeCell entity = null;
  6913. if (ceErpTradeResponsible != null)
  6914. {
  6915. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6916. }
  6917. string afmemo = GetPostString("supmemo");
  6918. string image = GetPostString("image");
  6919. if (entity != null)
  6920. {
  6921. entity.AfterSaleSupplierState = st;
  6922. entity.AfterSaleSupplierMemo = afmemo;
  6923. if (st == 1)
  6924. {
  6925. ceErpTradeResponsible.VerifyState = 1;
  6926. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6927. ceErpTradeResponsible.Update();
  6928. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6929. if (isAll)
  6930. {
  6931. entity.AfterSaleState = 4;
  6932. entity.FinishAfterSaleTime = DateTime.Now;
  6933. }
  6934. }
  6935. else
  6936. {
  6937. CeErpTradeResponsible.dateByTid(entity.ctid);
  6938. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6939. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6940. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6941. if (num <= 1)
  6942. {
  6943. entity.AfterSaleState = 1;
  6944. }
  6945. else
  6946. {
  6947. entity.AfterSaleState = 5;
  6948. }
  6949. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6950. if (ceErpTradeAfterSaleExtend != null)
  6951. {
  6952. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6953. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6954. ceErpTradeAfterSaleExtend.Update();
  6955. }
  6956. else
  6957. {
  6958. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6959. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6960. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6961. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6962. ceErpTradeAfterSaleExtend.Create();
  6963. }
  6964. }
  6965. if (entity.AfterSaleState == 4)
  6966. {
  6967. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6968. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6969. {
  6970. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6971. }
  6972. ApiVo apiVo = new ApiVo();
  6973. apiVo.orderNumber = entity.ctid;
  6974. apiVo.actionName = "afterOver";
  6975. designHelper.API_WorkCore(apiVo); //afterOver
  6976. }
  6977. entity.Update();
  6978. returnSuccessMsg("操作成功!");
  6979. CeErpSukuraData.createInfo(entity.ctid, 8);
  6980. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6981. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6982. return;
  6983. }
  6984. returnErrorMsg("找不到订单记录");
  6985. }
  6986. }
  6987. public void upd_erp_masteraftersale()
  6988. {
  6989. if (UrlPostParmsCheck("id"))
  6990. {
  6991. string id = GetPostString("id");
  6992. int st = GetPostInt("afterstate");
  6993. string afmemo = GetPostString("supmemo");
  6994. string image = GetPostString("image");
  6995. string textResult = GetPostString("textResult");
  6996. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6997. if (ceErpTradeResponsible != null)
  6998. {
  6999. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7000. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7001. ceErpTradeResponsible.Update();
  7002. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7003. if (entity != null)
  7004. {
  7005. entity.AfterSaleSupplierState = st;
  7006. entity.AfterSaleSupplierMemo = afmemo;
  7007. if (st == 1)
  7008. {
  7009. }
  7010. else
  7011. {
  7012. CeErpTradeResponsible.dateByTid(entity.ctid);
  7013. //退回到售后
  7014. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7015. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7016. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7017. if (num <= 1)
  7018. {
  7019. entity.AfterSaleState = 1;
  7020. }
  7021. else
  7022. {
  7023. entity.AfterSaleState = 5;
  7024. }
  7025. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7026. if (ceErpTradeAfterSaleExtend != null)
  7027. {
  7028. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7029. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7030. ceErpTradeAfterSaleExtend.Update();
  7031. }
  7032. else
  7033. {
  7034. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7035. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7036. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7037. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7038. ceErpTradeAfterSaleExtend.Create();
  7039. }
  7040. }
  7041. entity.Update();
  7042. returnSuccessMsg("操作成功!");
  7043. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7044. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7045. return;
  7046. }
  7047. }
  7048. returnErrorMsg("找不到订单记录");
  7049. }
  7050. }
  7051. public void upd_erp_personaftersale()
  7052. {
  7053. if (UrlPostParmsCheck("id"))
  7054. {
  7055. string id = GetPostString("id");
  7056. int st = GetPostInt("afterstate");
  7057. string afmemo = GetPostString("supmemo");
  7058. string image = GetPostString("image");
  7059. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7060. if (ceErpTradeResponsible != null)
  7061. {
  7062. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7063. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7064. ceErpTradeResponsible.Update();
  7065. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7066. if (entity != null)
  7067. {
  7068. entity.AfterSaleSupplierMemo = afmemo;
  7069. entity.AfterSaleSupplierState = st;
  7070. if (st == 1)
  7071. {
  7072. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7073. if (isAll)
  7074. {
  7075. entity.AfterSaleState = 4;
  7076. entity.FinishAfterSaleTime = DateTime.Now;
  7077. }
  7078. }
  7079. else
  7080. {
  7081. CeErpTradeResponsible.dateByTid(entity.ctid);
  7082. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7083. if (ceErpTradeAfterSaleExtend != null)
  7084. {
  7085. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7086. ceErpTradeAfterSaleExtend.Update();
  7087. }
  7088. else
  7089. {
  7090. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7091. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7092. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7093. ceErpTradeAfterSaleExtend.Create();
  7094. }
  7095. //退回到主管
  7096. //entity.AfterSaleState = 2;
  7097. }
  7098. if (entity.AfterSaleState == 4)
  7099. {
  7100. ApiVo apiVo = new ApiVo();
  7101. apiVo.orderNumber = entity.ctid;
  7102. apiVo.actionName = "afterOver";
  7103. designHelper.API_WorkCore(apiVo); //afterOver
  7104. }
  7105. entity.Update();
  7106. returnSuccessMsg("操作成功!");
  7107. CeErpSukuraData.createInfo(entity.ctid, 8);
  7108. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7109. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7110. return;
  7111. }
  7112. }
  7113. returnErrorMsg("找不到订单记录");
  7114. }
  7115. }
  7116. public void set_erp_supplierrefundtag()
  7117. {
  7118. if (UrlPostParmsCheck("ctid"))
  7119. {
  7120. string eid = GetPostString("ctid");
  7121. CeErpTradeCell entity = null;
  7122. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7123. if (entity != null)
  7124. {
  7125. entity.IsSupplierRefund = GetPostInt("tag");
  7126. entity.Update();
  7127. returnSuccessMsg("操作成功!");
  7128. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7129. return;
  7130. }
  7131. returnErrorMsg("找不到订单记录");
  7132. }
  7133. }
  7134. public void get_erp_refundlist()
  7135. {
  7136. DataStruct dStruct = GetPostStruct();
  7137. List<string> lw = new List<string>();
  7138. string tid = GetPostString("tid");
  7139. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7140. //string rid = GetPostString("refund_id");
  7141. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7142. string shopname = GetPostString("shopname");
  7143. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7144. string buyernick = GetPostString("buyer_nick");
  7145. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7146. string customer = GetPostString("customer");
  7147. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7148. string design = GetPostString("design");
  7149. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7150. string sellermemo = GetPostString("seller_memo");
  7151. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7152. //string date1 = GetPostString("date1");
  7153. //string date2 = GetPostString("date2");
  7154. //string dateType = GetPostString("dateType");
  7155. //if (dateType.Length > 0)
  7156. //{
  7157. // if (dateType == "1001") dateType = "0";
  7158. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7159. // if (searchDT.Count == 2)
  7160. // {
  7161. // date1 = searchDT[0].ToString();
  7162. // date2 = searchDT[1].ToString();
  7163. // }
  7164. //}
  7165. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7166. //if (dw.Length > 0) lw.Add(dw);
  7167. string redate1 = GetPostString("refunddate1");
  7168. string redate2 = GetPostString("refunddate2");
  7169. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7170. if (dwdate.Length > 0) lw.Add(dwdate);
  7171. string price1 = GetPostString("price1");
  7172. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7173. string price2 = GetPostString("price2");
  7174. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7175. string ispartrefund = GetPostString("ispartrefund");
  7176. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7177. string refundState = GetPostString("refundvstate");
  7178. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7179. int st = GetInt("st");
  7180. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7181. {
  7182. string responsible = GetPostString("responsibleman");
  7183. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7184. lw.Add(string.Format("RefundState>={0}", st));
  7185. string code = CurrentUser.UserPost.Post.Code;
  7186. if (code == "CustomerService")
  7187. {
  7188. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7189. }
  7190. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7191. {
  7192. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7193. }
  7194. else if (code == "Place" || code == "PlaceMr")
  7195. {
  7196. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7197. }
  7198. dStruct.Order = "RefundState asc,created desc";
  7199. }
  7200. else if (st == 10)
  7201. {
  7202. string responsible = GetPostString("responsibleman");
  7203. if (responsible == "空白")
  7204. {
  7205. lw.Add(string.Format("ResponsibleUserName = ''"));
  7206. }
  7207. else if (responsible.Length > 0)
  7208. {
  7209. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7210. }
  7211. lw.Add(string.Format("RefundState>=0"));
  7212. dStruct.Order = "created desc";
  7213. }
  7214. else
  7215. {
  7216. string responsible = GetPostString("responsibleman");
  7217. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7218. lw.Add(string.Format("RefundState={0}", st));
  7219. dStruct.Order = "created desc";
  7220. }
  7221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7222. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7223. dt.Columns.Add("refund_fees");
  7224. foreach (DataRow dr in dt.Rows)
  7225. {
  7226. String status = dr["status"].ToString();
  7227. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7228. {
  7229. dr["refund_fees"] = dr["refund_fee"];
  7230. }
  7231. else
  7232. {
  7233. dr["refund_fees"] = "0.0";
  7234. }
  7235. }
  7236. writeGridDataTableJson(dStruct.TotalCount, dt);
  7237. }
  7238. public void get_erp_refunddesignlist()
  7239. {
  7240. DataStruct dStruct = GetPostStruct();
  7241. List<string> lw = new List<string>();
  7242. string tid = GetPostString("tid");
  7243. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7244. string shopname = GetPostString("shopname");
  7245. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7246. string buyernick = GetPostString("buyer_nick");
  7247. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7248. string customer = GetPostString("customer");
  7249. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7250. string design = GetPostString("design");
  7251. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7252. string sellermemo = GetPostString("seller_memo");
  7253. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7254. string redate1 = GetPostString("refunddate1");
  7255. string redate2 = GetPostString("refunddate2");
  7256. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7257. if (dwdate.Length > 0) lw.Add(dwdate);
  7258. string price1 = GetPostString("price1");
  7259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7260. string price2 = GetPostString("price2");
  7261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7262. string ispartrefund = GetPostString("ispartrefund");
  7263. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7264. string designerorg = GetPostString("designerorg");
  7265. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7266. string refundState = GetPostString("refundState");
  7267. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7268. int myOrgid = CurrentUser.UserPost.OrgID;
  7269. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7270. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7271. {
  7272. if (CurrentUser.User.TeamIds.Length > 0)
  7273. {
  7274. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7275. }
  7276. else
  7277. {
  7278. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7279. }
  7280. }
  7281. else if ("SysAdmin".Equals(myOrgCode))
  7282. {
  7283. }
  7284. else
  7285. {
  7286. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7287. {
  7288. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7289. }
  7290. else
  7291. {
  7292. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7293. }
  7294. }
  7295. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7296. dStruct.Order = "created desc";
  7297. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7298. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7299. dt.Columns.Add("refund_fees");
  7300. foreach (DataRow dr in dt.Rows)
  7301. {
  7302. String status = dr["status"].ToString();
  7303. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7304. {
  7305. dr["refund_fees"] = dr["refund_fee"];
  7306. }
  7307. else
  7308. {
  7309. dr["refund_fees"] = "0.0";
  7310. }
  7311. }
  7312. writeGridDataTableJson(dStruct.TotalCount, dt);
  7313. }
  7314. public void handle_erp_refundtag()
  7315. {
  7316. if (UrlPostParmsCheck("refund_id"))
  7317. {
  7318. string eid = GetPostString("refund_id");
  7319. string respMan = GetPostString("ResponsibleName");
  7320. if (respMan.Length <= 0)
  7321. {
  7322. returnErrorMsg("责任人不能为空");
  7323. return;
  7324. }
  7325. CeErpTradeRefund entity = null;
  7326. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7327. if (entity != null)
  7328. {
  7329. entity.ResponsibleUserName = respMan;
  7330. string userid = GetPostString("ResponsibleUserId");
  7331. if (userid.Length > 0)
  7332. {
  7333. entity.ResponsibleUserId = userid;
  7334. }
  7335. entity.Memo = GetPostString("Memo");
  7336. if (respMan.IndexOf("客服") != -1 ||
  7337. respMan.IndexOf("设计师") != -1 ||
  7338. respMan.IndexOf("下单员") != -1)
  7339. {
  7340. entity.RefundState = 2;
  7341. }
  7342. else
  7343. {
  7344. entity.RefundState = 3;
  7345. }
  7346. entity.modified = DateTime.Now;
  7347. entity.Update();
  7348. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7349. returnSuccessMsg("操作成功!");
  7350. return;
  7351. }
  7352. returnErrorMsg("找不到订单记录");
  7353. }
  7354. }
  7355. public void handle_erp_designrefundtag()
  7356. {
  7357. if (UrlPostParmsCheck("refund_id"))
  7358. {
  7359. string eid = GetPostString("refund_id");
  7360. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7361. if (ceErpTradeCellExtend == null)
  7362. {
  7363. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7364. ceErpTradeCellExtend.ctid = eid;
  7365. }
  7366. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7367. if (ceErpTradeCellExtend.ID > 0)
  7368. {
  7369. ceErpTradeCellExtend.Update();
  7370. }
  7371. else
  7372. {
  7373. ceErpTradeCellExtend.Create();
  7374. }
  7375. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7376. returnSuccessMsg("操作成功!");
  7377. return;
  7378. }
  7379. returnErrorMsg("找不到订单记录");
  7380. }
  7381. public void upd_erp_refundverify()
  7382. {
  7383. if (UrlPostParmsCheck("refund_id"))
  7384. {
  7385. string eid = GetPostString("refund_id");
  7386. CeErpTradeRefund entity = null;
  7387. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7388. if (entity != null)
  7389. {
  7390. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7391. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7392. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7393. {
  7394. entity.RefundState = 2;
  7395. }
  7396. else
  7397. {
  7398. entity.RefundState = 3;
  7399. }
  7400. entity.Update();
  7401. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7402. returnSuccessMsg("操作成功!");
  7403. return;
  7404. }
  7405. returnErrorMsg("找不到订单记录");
  7406. }
  7407. }
  7408. public void upd_erp_refundapprove()
  7409. {
  7410. if (UrlPostParmsCheck("refund_id"))
  7411. {
  7412. string eid = GetPostString("refund_id");
  7413. CeErpTradeRefund entity = null;
  7414. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7415. if (entity != null)
  7416. {
  7417. int apr = GetPostInt("approve");
  7418. if (apr == 0)
  7419. {
  7420. entity.RefundState = 1;
  7421. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7422. }
  7423. else if (apr == 1)
  7424. {
  7425. entity.RefundState = 3;
  7426. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7427. }
  7428. entity.modified = DateTime.Now;
  7429. entity.Update();
  7430. returnSuccessMsg("操作成功!");
  7431. return;
  7432. }
  7433. returnErrorMsg("找不到订单记录");
  7434. }
  7435. }
  7436. public void get_erp_billlist()
  7437. {
  7438. DataStruct dStruct = GetPostStruct();
  7439. List<string> lw = new List<string>();
  7440. string title = GetPostString("title");
  7441. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7442. string tid = GetPostString("tid");
  7443. string tids = GetPostString("tids");
  7444. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7445. if (tids.Length > 0)
  7446. {
  7447. tids = "'" + tids + "'";
  7448. tids = tids.Replace(",", "','");
  7449. lw.Add(string.Format("tid in ({0})", tids));
  7450. }
  7451. string shopname = GetPostString("shopname");
  7452. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7453. string buyernick = GetPostString("buyer_nick");
  7454. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7455. string customer = GetPostString("customer");
  7456. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7457. string date1 = GetPostString("date1");
  7458. string date2 = GetPostString("date2");
  7459. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7460. if (dw.Length > 0) lw.Add(dw);
  7461. string price1 = GetPostString("price1");
  7462. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7463. string price2 = GetPostString("price2");
  7464. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7465. string returndate1 = GetPostString("returndate1");
  7466. string returndate2 = GetPostString("returndate2");
  7467. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7468. if (dw1.Length > 0) lw.Add(dw1);
  7469. string billtype = GetPostString("billtype");
  7470. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7471. string billstate = GetPostString("billstate");
  7472. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7473. string usershop = CurrentUser.User.pemShop;
  7474. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7475. dStruct.Order = "createTime desc";
  7476. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7477. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7478. //foreach (DataRow dr in dt.Rows)
  7479. //{
  7480. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7481. //}
  7482. writeGridDataTableJson(dStruct.TotalCount, dt);
  7483. }
  7484. public void modify_erp_billinfo()
  7485. {
  7486. if (UrlPostParmsCheck("ID"))
  7487. {
  7488. string eid = GetPostString("ID");
  7489. CeErpBill bill_entity = null;
  7490. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7491. if (bill_entity != null)
  7492. {
  7493. bill_entity.tid = GetPostString("tid");
  7494. bill_entity.title = GetPostString("title");
  7495. bill_entity.tax = GetPostString("tax");
  7496. bill_entity.bank = GetPostString("bank");
  7497. bill_entity.bankac = GetPostString("bankac");
  7498. bill_entity.address = GetPostString("address");
  7499. bill_entity.phone = GetPostString("phone");
  7500. bill_entity.price = GetPostString("price");
  7501. bill_entity.productId = GetPostInt("ProductName");
  7502. bill_entity.num = GetPostInt("num");
  7503. bill_entity.unit = GetPostString("unit");
  7504. bill_entity.type = GetPostString("type");
  7505. bill_entity.sendType = GetPostString("SendType");
  7506. bill_entity.email = GetPostString("email");
  7507. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7508. bill_entity.shopName = GetPostString("ShopName");
  7509. bill_entity.applymemo = GetPostString("applymemo");
  7510. bill_entity.modifyTime = DateTime.Now;
  7511. bill_entity.createTime = DateTime.Now;
  7512. bill_entity.state = 0;
  7513. bill_entity.Update();
  7514. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7515. returnSuccessMsg("发票修改成功!");
  7516. return;
  7517. }
  7518. returnErrorMsg("找不到对应记录");
  7519. }
  7520. }
  7521. public void set_erp_invoicing()
  7522. {
  7523. if (UrlPostParmsCheck("id"))
  7524. {
  7525. try
  7526. {
  7527. string eid = GetPostString("id");
  7528. CeErpBill bill_entity = null;
  7529. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7530. if (bill_entity != null)
  7531. {
  7532. int ComId = GetPostInt("ComId");
  7533. //string memo = GetPostString("Memo");
  7534. int allInfo = GetPostInt("allinfo");
  7535. string clert = CurrentUser.User.Name;
  7536. //string detailValue = GetPostString("detailvalue");
  7537. string billId = bill_entity.billOrderId;
  7538. string[] billIdList = billId.Split(',');
  7539. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7540. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7541. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7542. {
  7543. billCount += 1;
  7544. }
  7545. if (billId.Length <= 0 || billIdList.Length != billCount)
  7546. {
  7547. bill_entity.billOrderId = "";
  7548. string prebill = "ltb";
  7549. for (int idx = 1; idx <= billCount; idx++)
  7550. {
  7551. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7552. string billoid = prebill + idx + dtstr;
  7553. bill_entity.billOrderId += billoid;
  7554. if (idx < billCount)
  7555. {
  7556. bill_entity.billOrderId += ",";
  7557. }
  7558. }
  7559. }
  7560. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7561. if (bill_entity.state == 5)
  7562. {
  7563. string errMsg = bill_entity.failerror;
  7564. string[] errlist = errMsg.Split('|');
  7565. string[] errTags = new string[errlist.Length];
  7566. for (int itag = 0; itag < errlist.Length; itag++)
  7567. {
  7568. if (errlist[itag].Length <= 0) continue;
  7569. errTags[itag] = errlist[itag].Split('&')[0];
  7570. }
  7571. for (int iii = 0; iii < errTags.Length; iii++)
  7572. {
  7573. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7574. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7575. if (billOrderList.Length >= erroBillOrderTag)
  7576. {
  7577. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7578. if (needModifyBillId.Length <= 19)
  7579. {
  7580. needModifyBillId = needModifyBillId + "1";
  7581. }
  7582. else
  7583. {
  7584. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7585. last = last + 1;
  7586. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7587. }
  7588. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7589. }
  7590. }
  7591. }
  7592. bool isHaveBillSucces = false;
  7593. string totalRes = "";
  7594. bill_entity.failerror = "";
  7595. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7596. {
  7597. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7598. totalRes += res;
  7599. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7600. {
  7601. isHaveBillSucces = true;
  7602. bill_entity.comId = ComId;
  7603. bill_entity.state = 1;
  7604. bill_entity.executeTime = DateTime.Now;
  7605. bill_entity.executeUser = clert;
  7606. }
  7607. else
  7608. {
  7609. bill_entity.state = 5;
  7610. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7611. }
  7612. }
  7613. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7614. bill_entity.Update();
  7615. if (isHaveBillSucces)
  7616. {
  7617. StringBuilder sql = new StringBuilder();
  7618. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7619. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7620. }
  7621. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7622. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7623. {
  7624. returnErrorMsg("开票失败");
  7625. }
  7626. else
  7627. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7628. return;
  7629. }
  7630. returnErrorMsg("找不到对应记录");
  7631. }
  7632. catch (Exception ex)
  7633. {
  7634. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7635. returnErrorMsg("操作失败");
  7636. }
  7637. }
  7638. }
  7639. public void get_erp_invoicing_back()
  7640. {
  7641. if (UrlPostParmsCheck("id"))
  7642. {
  7643. try
  7644. {
  7645. string id = GetPostString("id");
  7646. CeErpBill entiy = CeErpBill.Get(id);
  7647. if (entiy != null)
  7648. {
  7649. if (entiy.state == 0)
  7650. {
  7651. returnErrorMsg("发票还未开具");
  7652. return;
  7653. }
  7654. string[] billOrderList = entiy.billOrderId.Split(',');
  7655. int iTag = 0;
  7656. entiy.fplsh = "";
  7657. entiy.fpdm = "";
  7658. entiy.fphm = "";
  7659. foreach (string billOrderId in billOrderList)
  7660. {
  7661. iTag++;
  7662. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7663. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7664. {
  7665. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7666. try
  7667. {
  7668. Invoicing_get_response_Obj iObj = null;
  7669. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7670. if (iObj != null)
  7671. {
  7672. entiy.state = 2;
  7673. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7674. entiy.fpdm += iObj.list[0].c_fpdm;
  7675. entiy.fphm += iObj.list[0].c_fphm;
  7676. if (iTag < billOrderList.Length)
  7677. {
  7678. entiy.fplsh += ",";
  7679. entiy.fpdm += ",";
  7680. entiy.fphm += ",";
  7681. }
  7682. entiy.Update();
  7683. }
  7684. StringBuilder sql = new StringBuilder();
  7685. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7686. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7687. returnSuccessMsg("开票成功");
  7688. }
  7689. catch (Exception ex)
  7690. {
  7691. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7692. }
  7693. return;
  7694. }
  7695. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7696. {
  7697. var res_obj = new
  7698. {
  7699. data = "开票中"
  7700. };
  7701. string ro_json = JsonConvert.SerializeObject(res_obj);
  7702. returnSuccess(ro_json);
  7703. return;
  7704. }
  7705. else
  7706. {
  7707. int eidx = res.IndexOf("c_resultmsg");
  7708. int lidx = res.IndexOf("c_status");
  7709. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7710. entiy.state = 5;
  7711. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7712. entiy.Update();
  7713. returnErrorMsg("开票失败");
  7714. return;
  7715. }
  7716. }
  7717. }
  7718. }
  7719. catch (Exception ex)
  7720. {
  7721. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7722. }
  7723. return;
  7724. }
  7725. }
  7726. public void get_erp_invoicing()
  7727. {
  7728. if (UrlPostParmsCheck("id"))
  7729. {
  7730. try
  7731. {
  7732. string id = GetPostString("id");
  7733. CeErpBill entiy = CeErpBill.Get(id);
  7734. if (entiy != null)
  7735. {
  7736. if (entiy.state == 0)
  7737. {
  7738. returnErrorMsg("发票还未开具");
  7739. return;
  7740. }
  7741. if (entiy.sendType == "纸质发票")
  7742. {
  7743. if (entiy.img.Length <= 0)
  7744. {
  7745. returnErrorMsg("查无纸质发票");
  7746. return;
  7747. }
  7748. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7749. returnSuccess(returnres);
  7750. return;
  7751. }
  7752. string[] billOrderList = entiy.billOrderId.Split(',');
  7753. int iTag = 0;
  7754. string fpUrl = "";
  7755. entiy.fplsh = "";
  7756. entiy.fpdm = "";
  7757. entiy.fphm = "";
  7758. foreach (string billOrderId in billOrderList)
  7759. {
  7760. iTag++;
  7761. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7762. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7763. {
  7764. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7765. Invoicing_get_response_Obj iObj = null;
  7766. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7767. if (iObj != null)
  7768. {
  7769. //entiy.state = 2;
  7770. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7771. entiy.fpdm += iObj.list[0].c_fpdm;
  7772. entiy.fphm += iObj.list[0].c_fphm;
  7773. if (iTag < billOrderList.Length)
  7774. {
  7775. entiy.fplsh += ",";
  7776. entiy.fpdm += ",";
  7777. entiy.fphm += ",";
  7778. }
  7779. entiy.Update();
  7780. fpUrl += iObj.list[0].c_url + ",";
  7781. }
  7782. //returnSuccess(res);
  7783. StringBuilder sql = new StringBuilder();
  7784. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7785. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7786. }
  7787. else
  7788. {
  7789. int eidx = res.IndexOf("c_resultmsg");
  7790. //int lidx = res.IndexOf("c_status");
  7791. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7792. //开票失败
  7793. entiy.state = 5;
  7794. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7795. entiy.Update();
  7796. returnErrorMsg("开票失败");
  7797. return;
  7798. }
  7799. }
  7800. var returnObj = new
  7801. {
  7802. data = fpUrl
  7803. };
  7804. string ro_json = JsonConvert.SerializeObject(returnObj);
  7805. returnSuccess(ro_json);
  7806. }
  7807. }
  7808. catch (Exception ex)
  7809. {
  7810. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7811. }
  7812. return;
  7813. }
  7814. }
  7815. public void save_erp_billimg()
  7816. {
  7817. if (UrlPostParmsCheck("id"))
  7818. {
  7819. string eid = GetPostString("id");
  7820. CeErpBill bill_entity = null;
  7821. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7822. if (bill_entity != null)
  7823. {
  7824. bill_entity.img = GetPostString("img");
  7825. bill_entity.executeTime = DateTime.Now;
  7826. bill_entity.state = 2;
  7827. bill_entity.Update();
  7828. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7829. returnSuccessMsg("保存成功");
  7830. }
  7831. return;
  7832. }
  7833. }
  7834. public void upd_erp_billreturnback()
  7835. {
  7836. if (UrlPostParmsCheck("id"))
  7837. {
  7838. int eid = GetPostInt("id");
  7839. CeErpBill bill_entity = null;
  7840. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7841. if (bill_entity != null)
  7842. {
  7843. bill_entity.state = 3;
  7844. bill_entity.returnReason = GetPostString("reason");
  7845. bill_entity.Update();
  7846. returnSuccessMsg("驳回成功!");
  7847. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7848. }
  7849. return;
  7850. }
  7851. }
  7852. public void cancel_erp_bill()
  7853. {
  7854. if (UrlPostParmsCheck("id"))
  7855. {
  7856. int eid = GetPostInt("id");
  7857. int detailValue = GetPostInt("detailvalue");
  7858. CeErpBill bill_entity = null;
  7859. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7860. string cres = "";
  7861. string gres = "";
  7862. if (bill_entity != null)
  7863. {
  7864. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7865. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7866. {
  7867. int iTag = 0;
  7868. bill_entity.fplsh = "";
  7869. bill_entity.fpdm = "";
  7870. bill_entity.fphm = "";
  7871. foreach (string billOrderId in billOrderList)
  7872. {
  7873. iTag++;
  7874. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7875. if (gres.IndexOf("success") != -1)
  7876. {
  7877. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7878. Invoicing_get_response_Obj iObj = null;
  7879. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7880. if (iObj != null)
  7881. {
  7882. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7883. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7884. bill_entity.fphm += iObj.list[0].c_fphm;
  7885. if (iTag < billOrderList.Length)
  7886. {
  7887. bill_entity.fplsh += ",";
  7888. bill_entity.fpdm += ",";
  7889. bill_entity.fphm += ",";
  7890. }
  7891. bill_entity.Update();
  7892. }
  7893. }
  7894. else
  7895. {
  7896. returnErrorMsg(gres);
  7897. return;
  7898. }
  7899. }
  7900. }
  7901. if (bill_entity.sendType == "纸质发票")
  7902. {
  7903. //作废
  7904. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7905. //if (DateTime.Now.Month == extime.Month)
  7906. //{
  7907. //cres = taobaoHelper.cancel_invoicing(eid);
  7908. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7909. //{
  7910. bill_entity.state = 4;//已作废
  7911. bill_entity.Update();
  7912. returnSuccessMsg("发票已作废");
  7913. return;
  7914. //}
  7915. //else
  7916. //{
  7917. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7918. // bill_entity.Update();
  7919. // returnErrorMsg(cres);
  7920. // return;
  7921. //}
  7922. //}
  7923. //else
  7924. //{
  7925. // returnErrorMsg("纸质发票只能作废本月的发票");
  7926. // return;
  7927. //}
  7928. }
  7929. //红冲
  7930. int redTag = 0;
  7931. string[] fpdmList = bill_entity.fpdm.Split(',');
  7932. string[] fphmList = bill_entity.fphm.Split(',');
  7933. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7934. {
  7935. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7936. return;
  7937. }
  7938. foreach (string billOrderId in billOrderList)
  7939. {
  7940. redTag++;
  7941. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7942. cres += onecres;
  7943. cres += ",";
  7944. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7945. {
  7946. bill_entity.state = 4;//已作废
  7947. //bill_entity.Update();
  7948. //returnSuccessMsg("发票已红冲");
  7949. }
  7950. else if (onecres.IndexOf("重复冲红") != -1)
  7951. {
  7952. bill_entity.state = 4;//已作废
  7953. //bill_entity.Update();
  7954. //returnSuccessMsg("发票已红冲");
  7955. }
  7956. else
  7957. {
  7958. string errmsg = commonHelper.KeepChinese(onecres);
  7959. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7960. }
  7961. }
  7962. bill_entity.Update();
  7963. if (cres.IndexOf("失败") != -1)
  7964. returnErrorMsg("红冲失败");
  7965. else
  7966. returnSuccessMsg("发票已红冲");
  7967. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7968. return;
  7969. }
  7970. return;
  7971. }
  7972. }
  7973. public void del_erp_billorder()
  7974. {
  7975. if (UrlPostParmsCheck("id"))
  7976. {
  7977. string eid = GetPostString("id");
  7978. CeErpBill.Del(eid);
  7979. CeErpBill bill = CeErpBill.Get(eid);
  7980. if (bill != null)
  7981. {
  7982. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7983. }
  7984. returnSuccessMsg("删除成功");
  7985. }
  7986. }
  7987. public void finish_erp_bill()
  7988. {
  7989. if (UrlPostParmsCheck("ids"))
  7990. {
  7991. string eids = GetPostString("ids");
  7992. string[] list = eids.Split(',');
  7993. foreach (string eid in list)
  7994. {
  7995. CeErpBill bill = CeErpBill.Get(eid);
  7996. if (bill != null)
  7997. {
  7998. bill.state = 2;
  7999. bill.Update();
  8000. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8001. }
  8002. }
  8003. returnSuccessMsg("操作成功");
  8004. }
  8005. }
  8006. public void get_erp_returncash()
  8007. {
  8008. DataStruct dStruct = GetPostStruct();
  8009. List<string> lw = new List<string>();
  8010. string tid = GetPostString("tid");
  8011. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8012. string shopname = GetPostString("shopname");
  8013. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8014. string buyernick = GetPostString("buyer_nick");
  8015. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8016. string customer = GetPostString("customer");
  8017. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8018. string returndate1 = GetPostString("returndate1");
  8019. string returndate2 = GetPostString("returndate2");
  8020. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8021. if (dw.Length > 0) lw.Add(dw);
  8022. string finishDate1 = GetPostString("finishdate1");
  8023. string finishDate2 = GetPostString("finishdate2");
  8024. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8025. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8026. string returntype = GetPostString("returntype");
  8027. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8028. string returnvstate = GetPostString("returnvstate");
  8029. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8030. dStruct.Order = "created desc";
  8031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8032. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8033. writeGridDataTableJson(dStruct.TotalCount, dt);
  8034. }
  8035. public void get_erp_staygoods()
  8036. {
  8037. DataStruct dStruct = GetPostStruct();
  8038. List<string> lw = new List<string>();
  8039. string tid = GetPostString("tid");
  8040. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8041. string shopname = GetPostString("shopname");
  8042. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8043. string wangwang = GetPostString("wangwang");
  8044. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8045. string customer = GetPostString("customer");
  8046. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8047. string returndate1 = GetPostString("returndate1");
  8048. string returndate2 = GetPostString("returndate2");
  8049. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8050. if (dw.Length > 0) lw.Add(dw);
  8051. string finishDate1 = GetPostString("finishdate1");
  8052. string finishDate2 = GetPostString("finishdate2");
  8053. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8054. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8055. string returnvstate = GetPostString("returnvstate");
  8056. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8057. string persuadetype = GetPostString("persuadetype");
  8058. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8059. string customerOrg = GetPostString("customerOrg");
  8060. if (customerOrg.Length > 0)
  8061. {
  8062. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8063. }
  8064. dStruct.Order = "creata_time desc";
  8065. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8066. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8067. writeGridDataTableJson(dStruct.TotalCount, dt);
  8068. }
  8069. public void upd_erp_staygoods()
  8070. {
  8071. if (UrlPostParmsCheck("id"))
  8072. {
  8073. int eid = GetPostInt("id");
  8074. CeErpStayGoods entity = null;
  8075. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8076. if (entity != null)
  8077. {
  8078. entity.audit_type = 1;
  8079. entity.audit_time = DateTime.Now;
  8080. entity.audit_u_id = CurrentUser.UserID;
  8081. entity.audit_u_name = CurrentUser.UserName;
  8082. entity.Update();
  8083. returnSuccessMsg("审核成功!");
  8084. return;
  8085. }
  8086. returnErrorMsg("找不到订单记录");
  8087. }
  8088. }
  8089. public void upd_erp_stayGoodsback()
  8090. {
  8091. if (UrlPostParmsCheck("id"))
  8092. {
  8093. int eid = GetPostInt("id");
  8094. CeErpStayGoods entity = null;
  8095. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8096. if (entity != null)
  8097. {
  8098. entity.audit_text = GetPostString("reason");
  8099. entity.audit_type = 2;
  8100. entity.audit_time = DateTime.Now;
  8101. entity.audit_u_id = CurrentUser.UserID;
  8102. entity.audit_u_name = CurrentUser.UserName;
  8103. entity.Update();
  8104. returnSuccessMsg("退回成功!");
  8105. return;
  8106. }
  8107. returnErrorMsg("找不到订单记录");
  8108. }
  8109. }
  8110. public void upd_erp_returncashverify()
  8111. {
  8112. if (UrlPostParmsCheck("ID"))
  8113. {
  8114. int eid = GetPostInt("ID");
  8115. CeErpReturnCash entity = null;
  8116. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8117. if (entity != null)
  8118. {
  8119. entity.cashstate = 1;
  8120. entity.verifytime = DateTime.Now;
  8121. entity.verifyuserid = CurrentUser.UserID;
  8122. entity.Update();
  8123. returnSuccessMsg("审核成功!");
  8124. return;
  8125. }
  8126. returnErrorMsg("找不到订单记录");
  8127. }
  8128. }
  8129. public void upd_all_erp_returncashverify()
  8130. {
  8131. if (UrlPostParmsCheck("ID"))
  8132. {
  8133. String[] list = GetPostString("ID").Split(',');
  8134. CeErpReturnCash entity = null;
  8135. for (int i = 0; i < list.Length; i++)
  8136. {
  8137. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8138. if (entity != null)
  8139. {
  8140. if (entity.cashstate == 1)
  8141. {
  8142. returnErrorMsg("已审核过的订单不需要在审核!");
  8143. return;
  8144. }
  8145. entity.cashstate = 1;
  8146. entity.verifytime = DateTime.Now;
  8147. entity.verifyuserid = CurrentUser.UserID;
  8148. entity.Update();
  8149. }
  8150. }
  8151. returnSuccessMsg("审核成功!");
  8152. return;
  8153. }
  8154. }
  8155. public void upd_erp_returncashback()
  8156. {
  8157. if (UrlPostParmsCheck("ID"))
  8158. {
  8159. int eid = GetPostInt("ID");
  8160. CeErpReturnCash entity = null;
  8161. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8162. if (entity != null)
  8163. {
  8164. entity.backreason = GetPostString("reason");
  8165. entity.cashstate = 2;
  8166. entity.verifytime = DateTime.Now;
  8167. entity.verifyuserid = CurrentUser.UserID;
  8168. entity.Update();
  8169. returnSuccessMsg("退回成功!");
  8170. return;
  8171. }
  8172. returnErrorMsg("找不到订单记录");
  8173. }
  8174. }
  8175. public void upd_erp_returnprice()
  8176. {
  8177. if (UrlPostParmsCheck("ID"))
  8178. {
  8179. int eid = GetPostInt("ID");
  8180. CeErpReturnCash entity = null;
  8181. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8182. if (entity != null)
  8183. {
  8184. if (entity.cashstate == 1)
  8185. {
  8186. returnErrorMsg("审核通过了不能改");
  8187. return;
  8188. }
  8189. entity.returnprice = GetPostDouble("returnprice");
  8190. entity.Update();
  8191. returnSuccessMsg("修改成功!");
  8192. return;
  8193. }
  8194. returnErrorMsg("找不到订单记录");
  8195. }
  8196. }
  8197. public void del_erp_returncash()
  8198. {
  8199. if (UrlPostParmsCheck("ID"))
  8200. {
  8201. int eid = GetPostInt("ID");
  8202. CeErpReturnCash.Del(eid);
  8203. returnSuccessMsg("操作成功");
  8204. return;
  8205. }
  8206. }
  8207. public void test_for_do_sql()
  8208. {
  8209. string sql = GetPostString("sqlstr");
  8210. if (sql.Length > 0)
  8211. {
  8212. try
  8213. {
  8214. DbHelper.DbConn.ExecuteNonQuery(sql);
  8215. var res_obj = new
  8216. {
  8217. data = "成功",
  8218. };
  8219. string ro_json = JsonConvert.SerializeObject(res_obj);
  8220. returnSuccess(ro_json);
  8221. }
  8222. catch (Exception ex)
  8223. {
  8224. var res_obj = new
  8225. {
  8226. data = ex.Message,
  8227. };
  8228. string ro_json = JsonConvert.SerializeObject(res_obj);
  8229. returnSuccess(ro_json);
  8230. }
  8231. }
  8232. }
  8233. public void get_user_info()
  8234. {
  8235. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8236. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8237. }
  8238. public void get_total_data()
  8239. {
  8240. int userId = CurrentUser.UserID;
  8241. string sql = "";
  8242. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8243. {
  8244. 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);
  8245. }
  8246. else
  8247. {
  8248. 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 " +
  8249. "(select ID from CE_ErpUser where ID = {0}) d " +
  8250. "left join " +
  8251. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8252. ") a on d.ID = a.id left join " +
  8253. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8254. ") b on a.id = b.id1 left join" +
  8255. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8256. ") c on a.id = c.id2;", userId);
  8257. }
  8258. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8259. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8260. }
  8261. public void get_date_area_total_data2()
  8262. {
  8263. int userId = CurrentUser.UserID;
  8264. string date_type = GetPostString("timetype");
  8265. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8266. string sql = "";
  8267. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8268. {
  8269. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8270. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8271. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8272. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8273. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8274. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8275. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8276. ") a on e.ID = a.id left join " +
  8277. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8278. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8279. ") b on a.id = b.id1 " +
  8280. "left join " +
  8281. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8282. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8283. ") c on a.id = c.id2 " +
  8284. "left join " +
  8285. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8286. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8287. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8288. }
  8289. else
  8290. {
  8291. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8292. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8293. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8294. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8295. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8296. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8297. ") a on e.ID = a.id left join " +
  8298. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8299. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8300. ") c on a.id = c.id2 " +
  8301. "left join " +
  8302. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8303. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8304. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8305. }
  8306. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8307. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8308. }
  8309. public void get_date_area_total_data()
  8310. {
  8311. int userId = CurrentUser.UserID;
  8312. string date_type = GetPostString("timetype");
  8313. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8314. string date1 = searchDT[0].ToString();
  8315. string date2 = searchDT[1].ToString();
  8316. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8317. {
  8318. SqlParameter[] sqlParameter ={
  8319. new SqlParameter("@userId", SqlDbType.Int,4),
  8320. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8321. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8322. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8323. };
  8324. sqlParameter[0].Value = userId;
  8325. sqlParameter[1].Value = date1;
  8326. sqlParameter[2].Value = date2;
  8327. sqlParameter[3].Direction = ParameterDirection.Output;
  8328. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8329. string res = sqlParameter[3].Value.ToString();
  8330. var res_obj = new
  8331. {
  8332. data = res
  8333. };
  8334. string ro_json = JsonConvert.SerializeObject(res_obj);
  8335. returnSuccess(ro_json);
  8336. }
  8337. else
  8338. {
  8339. SqlParameter[] sqlParameter ={
  8340. new SqlParameter("@userId", SqlDbType.Int,4),
  8341. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8342. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8343. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8344. };
  8345. sqlParameter[0].Value = userId;
  8346. sqlParameter[1].Value = date1;
  8347. sqlParameter[2].Value = date2;
  8348. sqlParameter[3].Direction = ParameterDirection.Output;
  8349. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8350. string res = sqlParameter[3].Value.ToString();
  8351. var res_obj = new
  8352. {
  8353. data = res
  8354. };
  8355. string ro_json = JsonConvert.SerializeObject(res_obj);
  8356. returnSuccess(ro_json);
  8357. }
  8358. //writeGridDataViewJson(dt.Rows.Count, dv);
  8359. }
  8360. public void get_order_list()
  8361. {
  8362. string strFields = GetPostString("paraFields");
  8363. string strOrder = GetPostString("paraOrder");
  8364. string strWhere = GetPostString("paraWhere");
  8365. string strPageSize = GetPostString("paraPageSize");
  8366. DataStruct dStruct = GetPostStruct();
  8367. dStruct.PageSize = int.Parse(strPageSize);
  8368. dStruct.Fileds = strFields;
  8369. dStruct.Order = strOrder;
  8370. dStruct.MainWhere = strWhere;
  8371. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8372. writeGridDataTableJson(dStruct.TotalCount, dt);
  8373. }
  8374. ////获取待开始订单列表
  8375. //public void get_wait_design_order_list()
  8376. //{
  8377. // string date_type = GetPostString("date_type");
  8378. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8379. // DataStruct dStruct = GetPostStruct();
  8380. // dStruct.PageSize = 1000;
  8381. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8382. // List<string> lw = new List<string>();
  8383. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8384. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8385. // dStruct.Order = "WaitDesignTime asc";
  8386. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8387. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8388. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8389. //}
  8390. //获取完成单量排名
  8391. public void get_finish_order_count_ranking()
  8392. {
  8393. /* string date_type = GetPostString("date_type");
  8394. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8395. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8396. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8397. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8398. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8399. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8400. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8401. writeGridDataTableJson(0, new DataTable());
  8402. }
  8403. public void get_finish_order_amount_ranking()
  8404. {
  8405. /*string date_type = GetPostString("date_type");
  8406. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8407. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8408. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8409. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8410. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8411. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8412. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8413. writeGridDataTableJson(0, new DataTable());
  8414. }
  8415. public void get_finish_refund_count_ranking()
  8416. {
  8417. string date_type = GetPostString("date_type");
  8418. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8419. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8420. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8421. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8422. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8423. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8424. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8425. writeGridDataTableJson(dt.Rows.Count, dt);
  8426. }
  8427. public void get_finish_refund_amount_ranking()
  8428. {
  8429. string date_type = GetPostString("date_type");
  8430. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8431. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8432. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8433. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8434. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8435. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8436. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8437. writeGridDataTableJson(dt.Rows.Count, dt);
  8438. }
  8439. public void set_erp_finishorder_director()
  8440. {
  8441. if (UrlPostParmsCheck("ctid"))
  8442. {
  8443. string eid = GetPostString("ctid");
  8444. CeErpTradeCell entity = null;
  8445. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8446. if (entity != null)
  8447. {
  8448. entity.OrderState = 8;
  8449. entity.Update();
  8450. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8451. returnSuccessMsg("操作成功!");
  8452. return;
  8453. }
  8454. returnErrorMsg("找不到记录");
  8455. }
  8456. }
  8457. public void get_erp_placeregistlist()
  8458. {
  8459. DataStruct dStruct = GetPostStruct();
  8460. List<string> lw = new List<string>();
  8461. string outsid = GetPostString("outsid");
  8462. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8463. string memo = GetPostString("memo");
  8464. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8465. string filename = GetPostString("filename");
  8466. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8467. string islate = GetPostString("islate");
  8468. if (islate.Length > 0)
  8469. {
  8470. if (islate == "1")
  8471. lw.Add(string.Format("OutLate>0"));
  8472. else
  8473. lw.Add(string.Format("OutLate=0"));
  8474. }
  8475. string placedate1 = GetPostString("placedate1");
  8476. string placedate2 = GetPostString("placedate2");
  8477. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8478. if (dw.Length > 0) lw.Add(dw);
  8479. string deliveryDate1 = GetPostString("deliverydate1");
  8480. string deliveryDate2 = GetPostString("deliverydate2");
  8481. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8482. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8483. dStruct.Order = "ID desc";
  8484. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8485. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8486. writeGridDataTableJson(dStruct.TotalCount, dt);
  8487. }
  8488. public void ins_erp_placeregist()
  8489. {
  8490. if (UrlPostParmsCheck("id"))
  8491. {
  8492. string eid = GetPostString("id");
  8493. CeErpPlaceRegister entity = null;
  8494. if (eid == "0")//新增
  8495. {
  8496. entity = new CeErpPlaceRegister();
  8497. string xdTime = GetPostString("placeTime");
  8498. if (xdTime.Length > 0)
  8499. {
  8500. entity.PlactTime = Convert.ToDateTime(xdTime);
  8501. }
  8502. string fhTime = GetPostString("deliveryTime");
  8503. if (fhTime.Length > 0)
  8504. {
  8505. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8506. }
  8507. string preTime = GetPostString("preOutTime");
  8508. if (preTime.Length > 0)
  8509. {
  8510. entity.PreOutTime = Convert.ToDateTime(preTime);
  8511. }
  8512. entity.DeliveryCount = GetPostInt("deliveryCount");
  8513. entity.ReceiveCount = GetPostInt("receiveCount");
  8514. entity.OutSid = GetPostString("outSid");
  8515. entity.FileName = GetPostString("fileName");
  8516. entity.Memo = GetPostString("memo");
  8517. entity.AddUserId = CurrentUser.UserID;
  8518. entity.CreateTime = DateTime.Now;
  8519. entity.Img = GetPostString("img");
  8520. entity.Supplier = GetPostInt("supplier");
  8521. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8522. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8523. {
  8524. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8525. DateTime dt2 = (DateTime)entity.PreOutTime;
  8526. TimeSpan span = dt1.Subtract(dt2);
  8527. if (span.Days > 0)
  8528. {
  8529. entity.OutLate = span.Days;
  8530. }
  8531. }
  8532. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8533. entity.Create();
  8534. returnSuccessMsg("添加成功!");
  8535. return;
  8536. }
  8537. else //修改
  8538. {
  8539. entity = CeErpPlaceRegister.Get(eid);
  8540. if (entity != null)
  8541. {
  8542. string xdTime = GetPostString("placeTime");
  8543. if (xdTime.Length > 0)
  8544. {
  8545. entity.PlactTime = Convert.ToDateTime(xdTime);
  8546. }
  8547. string fhTime = GetPostString("deliveryTime");
  8548. if (fhTime.Length > 0)
  8549. {
  8550. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8551. }
  8552. string preTime = GetPostString("preOutTime");
  8553. if (preTime.Length > 0)
  8554. {
  8555. entity.PreOutTime = Convert.ToDateTime(preTime);
  8556. }
  8557. entity.DeliveryCount = GetPostInt("deliveryCount");
  8558. entity.ReceiveCount = GetPostInt("receiveCount");
  8559. if (entity.DeliveryCount == entity.ReceiveCount)
  8560. {
  8561. entity.CurState = "已完成";
  8562. }
  8563. else
  8564. {
  8565. entity.CurState = "未完成";
  8566. }
  8567. entity.OutSid = GetPostString("outSid");
  8568. entity.FileName = GetPostString("fileName");
  8569. entity.Memo = GetPostString("memo");
  8570. entity.Img = GetPostString("img");
  8571. entity.Supplier = GetPostInt("supplier");
  8572. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8573. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8574. {
  8575. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8576. DateTime dt2 = (DateTime)entity.PreOutTime;
  8577. TimeSpan span = dt1.Subtract(dt2);
  8578. if (span.Days > 0)
  8579. {
  8580. entity.OutLate = span.Days;
  8581. }
  8582. }
  8583. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8584. entity.Update();
  8585. returnSuccessMsg("修改成功");
  8586. return;
  8587. }
  8588. returnErrorMsg("找不到对应的记录");
  8589. return;
  8590. }
  8591. }
  8592. returnErrorMsg("缺少必要参数");
  8593. }
  8594. public void del_erp_placeregist()
  8595. {
  8596. string eid = GetPostString("id");
  8597. CeErpPlaceRegister.Del(eid);
  8598. returnSuccessMsg("删除成功!");
  8599. return;
  8600. }
  8601. public void ins_erp_placeregistbyorder()
  8602. {
  8603. string ctid = GetPostString("ctid");
  8604. if (ctid.Length > 0)
  8605. {
  8606. StringBuilder sql = new StringBuilder();
  8607. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8608. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8609. if (dt.Rows.Count > 0)
  8610. {
  8611. foreach (DataRow dr in dt.Rows)
  8612. {
  8613. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8614. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8615. entity.AddUserId = CurrentUser.UserID;
  8616. entity.tid = dr["tid"].ToString();
  8617. entity.Did = Convert.ToString(dr["ctid"]);
  8618. entity.splitTag = dr["SplitTag"].ToString();
  8619. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8620. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8621. if (pre_ctid.Length > 0)
  8622. {
  8623. sellmemo = sellmemo.Replace(pre_ctid, "");
  8624. }
  8625. sellmemo = sellmemo.Replace("[", "");
  8626. sellmemo = sellmemo.Replace("]", "");
  8627. entity.FileName = sellmemo;
  8628. string count = dr["ProductCount"].ToString();
  8629. int usecount = commonHelper.getIntCountFromString(count);
  8630. entity.DeliveryCount = usecount;
  8631. entity.CurState = "未完成";
  8632. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8633. {
  8634. entity.Supplier = 24;//dl手提袋定制
  8635. }
  8636. else
  8637. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8638. entity.CreateTime = DateTime.Now;
  8639. entity.Create();
  8640. }
  8641. returnSuccessMsg("操作成功");
  8642. return;
  8643. }
  8644. returnErrorMsg("没有找到对应订单");
  8645. return;
  8646. }
  8647. returnErrorMsg("缺少订单编号");
  8648. return;
  8649. }
  8650. public void get_erp_persuadelist()
  8651. {
  8652. DataStruct dStruct = GetPostStruct();
  8653. List<string> lw = new List<string>();
  8654. string ctid = GetPostString("ctid");
  8655. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8656. string shopname = GetPostString("shopname");
  8657. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8658. string buyernick = GetPostString("buyer_nick");
  8659. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8660. string customer = GetPostString("customer");
  8661. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8662. string returndate1 = GetPostString("returndate1");
  8663. string returndate2 = GetPostString("returndate2");
  8664. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8665. if (dw.Length > 0) lw.Add(dw);
  8666. string finishDate1 = GetPostString("finishdate1");
  8667. string finishDate2 = GetPostString("finishdate2");
  8668. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8669. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8670. string persuadetype = GetPostString("persuadetype");
  8671. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8672. string returnvstate = GetPostString("returnvstate");
  8673. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8674. dStruct.Order = "created desc";
  8675. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8676. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8677. writeGridDataTableJson(dStruct.TotalCount, dt);
  8678. }
  8679. public void upd_erp_returnpersuadeback()
  8680. {
  8681. if (UrlPostParmsCheck("ID"))
  8682. {
  8683. int eid = GetPostInt("ID");
  8684. CeErpPersuade entity = null;
  8685. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8686. if (entity != null)
  8687. {
  8688. entity.backreason = GetPostString("reason");
  8689. entity.pstate = 2;
  8690. entity.verifytime = DateTime.Now;
  8691. entity.verifyuserid = CurrentUser.UserID;
  8692. entity.Update();
  8693. returnSuccessMsg("退回成功!");
  8694. return;
  8695. }
  8696. returnErrorMsg("找不到订单记录");
  8697. }
  8698. }
  8699. public void upd_erp_returnpersuadeverify()
  8700. {
  8701. if (UrlPostParmsCheck("ID"))
  8702. {
  8703. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8704. {
  8705. returnErrorMsg("暂无权限审核");
  8706. return;
  8707. }
  8708. int eid = GetPostInt("ID");
  8709. CeErpPersuade entity = null;
  8710. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8711. if (entity != null)
  8712. {
  8713. entity.pstate = 1;
  8714. entity.verifytime = DateTime.Now;
  8715. entity.verifyuserid = CurrentUser.UserID;
  8716. entity.Update();
  8717. returnSuccessMsg("审核成功!");
  8718. return;
  8719. }
  8720. returnErrorMsg("找不到订单记录");
  8721. }
  8722. }
  8723. public void del_erp_persuade()
  8724. {
  8725. if (UrlPostParmsCheck("ID"))
  8726. {
  8727. int eid = GetPostInt("ID");
  8728. CeErpPersuade.Del(eid);
  8729. returnSuccessMsg("操作成功");
  8730. return;
  8731. }
  8732. }
  8733. public void get_erp_oldcustoupload()
  8734. {
  8735. DataStruct dStruct = GetPostStruct();
  8736. List<string> lw = new List<string>();
  8737. string buyernick = GetPostString("buyer_nick");
  8738. if (buyernick.Length > 0)
  8739. {
  8740. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8741. }
  8742. else
  8743. return;
  8744. dStruct.Order = "pay_time desc";
  8745. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8746. DataTable dt = null;
  8747. dt = WebCache.GetData("view_erptradecell", dStruct);
  8748. writeGridDataTableJson(dStruct.TotalCount, dt);
  8749. }
  8750. public void get_erp_checkorderlist()
  8751. {
  8752. DataStruct dStruct = GetPostStruct();
  8753. List<string> lw = new List<string>();
  8754. string tid = GetPostString("ctid");
  8755. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8756. string shopname = GetPostString("shopname");
  8757. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8758. string buyernick = GetPostString("buyer_nick");
  8759. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8760. string customer = GetPostString("customer");
  8761. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8762. string design = GetPostString("design");
  8763. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8764. string orderState = GetPostString("orderState");
  8765. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8766. string address = GetPostString("address");
  8767. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8768. string sellermemo = GetPostString("seller_memo");
  8769. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8770. string supplier = GetPostString("supplier");
  8771. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8772. {
  8773. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8774. }
  8775. else
  8776. {
  8777. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8778. }
  8779. string date1 = GetPostString("date1");
  8780. string date2 = GetPostString("date2");
  8781. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8782. if (dw.Length > 0) lw.Add(dw);
  8783. string placedate1 = GetPostString("placedate1");
  8784. string placedate2 = GetPostString("placedate2");
  8785. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8786. if (fdw.Length > 0) lw.Add(fdw);
  8787. string price1 = GetPostString("price1");
  8788. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8789. string price2 = GetPostString("price2");
  8790. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8791. string checkst = GetPostString("checkstate");
  8792. if (checkst.Length > 0 && "10".Equals(checkst))
  8793. {
  8794. lw.Add(string.Format("CheckOut>0"));
  8795. }
  8796. else
  8797. {
  8798. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8799. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8800. }
  8801. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8802. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8803. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8804. writeGridDataTableJson(dStruct.TotalCount, dt);
  8805. }
  8806. public void ins_erp_startCheck()
  8807. {
  8808. if (UrlPostParmsCheck("ctid"))
  8809. {
  8810. string eid = GetPostString("ctid");
  8811. CeErpTradeCell entity = null;
  8812. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8813. if (entity != null)
  8814. {
  8815. entity.MemoOpt = 4;
  8816. entity.Update();
  8817. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8818. CeErpSukuraData.createInfo(entity.ctid, 6);
  8819. returnSuccessMsg("操作成功!");
  8820. return;
  8821. }
  8822. returnErrorMsg("找不到记录");
  8823. }
  8824. }
  8825. public void upd_erp_sendXlw()
  8826. {
  8827. if (UrlPostParmsCheck("ctid"))
  8828. {
  8829. string eid = GetPostString("ctid");
  8830. CeErpTradeCell entity = null;
  8831. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8832. if (entity != null)
  8833. {
  8834. if (entity.IsSendGift == 1)
  8835. {
  8836. returnErrorMsg("请勿重复标记");
  8837. return;
  8838. }
  8839. entity.IsSendGift = 1;
  8840. entity.Update();
  8841. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8842. returnSuccessMsg("操作成功!");
  8843. return;
  8844. }
  8845. returnErrorMsg("找不到记录");
  8846. }
  8847. }
  8848. public void cancel_sendXlw()
  8849. {
  8850. if (UrlPostParmsCheck("ctid"))
  8851. {
  8852. string eid = GetPostString("ctid");
  8853. CeErpTradeCell entity = null;
  8854. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8855. if (entity != null)
  8856. {
  8857. if (entity.IsSendGift == 0)
  8858. {
  8859. returnErrorMsg("未标记小礼物");
  8860. return;
  8861. }
  8862. entity.IsSendGift = 0;
  8863. entity.Update();
  8864. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8865. returnSuccessMsg("操作成功!");
  8866. return;
  8867. }
  8868. returnErrorMsg("找不到记录");
  8869. }
  8870. }
  8871. public void get_erp_designbill()
  8872. {
  8873. DataStruct dStruct = GetPostStruct();
  8874. List<string> lw = new List<string>();
  8875. int isMy = GetInt("my");
  8876. if (isMy == 1)
  8877. {
  8878. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8879. }
  8880. string tid = GetPostString("tid");
  8881. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8882. string userName = GetPostString("design");
  8883. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8884. string price1 = GetPostString("price1");
  8885. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8886. string price2 = GetPostString("price2");
  8887. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8888. string rePrice1 = GetPostString("rePrice1");
  8889. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8890. string rePrice2 = GetPostString("rePrice2");
  8891. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8892. string designerType = GetPostString("designerType");
  8893. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8894. string orderState = GetPostString("orderState");
  8895. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8896. string endTime1 = GetPostString("endTime1");
  8897. string endTime2 = GetPostString("endTime2");
  8898. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8899. if (dw.Length > 0) lw.Add(dw);
  8900. string isDk = GetPostString("isDk");
  8901. if (isDk == "1")
  8902. {
  8903. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8904. }
  8905. else if (isDk == "0")
  8906. {
  8907. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8908. }
  8909. dStruct.Order = "oid, create_time desc";
  8910. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8911. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8912. writeGridDataTableJson(dStruct.TotalCount, dt);
  8913. }
  8914. public void upd_erp_designerbill()
  8915. {
  8916. if (UrlPostParmsCheck("ID"))
  8917. {
  8918. string eid = GetPostString("ID");
  8919. CeErpDesignerBill entity = null;
  8920. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8921. if (entity != null)
  8922. {
  8923. if (GetPostDouble("designerpirce") > 0)
  8924. {
  8925. entity.realPrice = GetPostDouble("designerpirce");
  8926. entity.update_time = DateTime.Now;
  8927. entity.update_u_id = CurrentUser.UserID;
  8928. entity.update_u_name = CurrentUser.UserName;
  8929. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8930. entity.Update();
  8931. returnSuccessMsg("操作成功!");
  8932. return;
  8933. }
  8934. else
  8935. {
  8936. entity.price = GetPostDouble("price");
  8937. entity.update_time = DateTime.Now;
  8938. entity.update_u_id = CurrentUser.UserID;
  8939. entity.update_u_name = CurrentUser.UserName;
  8940. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8941. entity.Update();
  8942. returnSuccessMsg("操作成功!");
  8943. return;
  8944. }
  8945. }
  8946. returnErrorMsg("找不到记录");
  8947. }
  8948. }
  8949. public void audit_erp_designerbill()
  8950. {
  8951. if (UrlPostParmsCheck("ID"))
  8952. {
  8953. string eid = GetPostString("ID");
  8954. CeErpDesignerBill entity = null;
  8955. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8956. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8957. if (entity != null)
  8958. {
  8959. entity.realPrice = GetPostDouble("designerpirce");
  8960. entity.update_time = DateTime.Now;
  8961. entity.update_u_id = CurrentUser.UserID;
  8962. entity.update_u_name = CurrentUser.UserName;
  8963. entity.isAudit = 1;
  8964. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8965. entity.Update();
  8966. if (orderEntity != null)
  8967. {
  8968. orderEntity.IsReadTag = 3;
  8969. orderEntity.Update();
  8970. }
  8971. returnSuccessMsg("操作成功!");
  8972. return;
  8973. }
  8974. returnErrorMsg("找不到记录");
  8975. }
  8976. }
  8977. public void all_audit_erp_designerbill()
  8978. {
  8979. if (UrlPostParmsCheck("idList"))
  8980. {
  8981. string[] list = GetPostString("idList").Split(',');
  8982. CeErpDesignerBill entity = null;
  8983. for (int i = 0; i < list.Length; i++)
  8984. {
  8985. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8986. if (entity == null) return;
  8987. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8988. if (orderEntity == null) return;
  8989. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8990. entity.update_time = DateTime.Now;
  8991. entity.update_u_id = CurrentUser.UserID;
  8992. entity.update_u_name = CurrentUser.UserName;
  8993. entity.isAudit = 1;
  8994. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8995. entity.Update();
  8996. orderEntity.IsReadTag = 3;
  8997. orderEntity.Update();
  8998. }
  8999. returnSuccessMsg("操作成功!");
  9000. return;
  9001. }
  9002. }
  9003. public void get_erp_sameorders()
  9004. {
  9005. if (UrlPostParmsCheck("ctid"))
  9006. {
  9007. string eid = GetPostString("ctid");
  9008. CeErpTradeCell entity = null;
  9009. entity = CeErpTradeCell.GetByCtid(eid);
  9010. if (entity != null)
  9011. {
  9012. StringBuilder sql = new StringBuilder();
  9013. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9014. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9015. var res = new
  9016. {
  9017. data = dt.Rows.Count
  9018. };
  9019. string ro_jsond = JsonConvert.SerializeObject(res);
  9020. returnSuccess(ro_jsond);
  9021. return;
  9022. }
  9023. returnErrorMsg("未找到订单");
  9024. return;
  9025. }
  9026. returnErrorMsg("缺少必要的参数");
  9027. }
  9028. public void get_erp_islasthavesameorder()
  9029. {
  9030. if (UrlPostParmsCheck("ctid"))
  9031. {
  9032. string eid = GetPostString("ctid");
  9033. string[] ctidList = eid.Split(',');
  9034. StringBuilder sql = new StringBuilder();
  9035. string tisCtid = "";
  9036. foreach (string ctid in ctidList)
  9037. {
  9038. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9039. if (entity != null)
  9040. {
  9041. sql = new StringBuilder();
  9042. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9043. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9044. if (dth.Rows.Count > 0)
  9045. {
  9046. tisCtid += entity.ctid;
  9047. tisCtid += ",";
  9048. }
  9049. }
  9050. }
  9051. if (tisCtid.Length > 0)
  9052. {
  9053. var res = new
  9054. {
  9055. data = tisCtid
  9056. };
  9057. string ro_jsond = JsonConvert.SerializeObject(res);
  9058. returnSuccess(ro_jsond);
  9059. }
  9060. else
  9061. {
  9062. var res = new
  9063. {
  9064. data = ""
  9065. };
  9066. string ro_jsond = JsonConvert.SerializeObject(res);
  9067. returnSuccess(ro_jsond);
  9068. }
  9069. return;
  9070. }
  9071. returnErrorMsg("缺少必要的参数");
  9072. }
  9073. public void file_client_down_url()
  9074. {
  9075. if (!UrlPostParmsCheck("userId"))
  9076. {
  9077. returnErrorMsg("缺少必要的参数");
  9078. }
  9079. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9080. }
  9081. public void checkout_form_data()
  9082. {
  9083. if (!UrlPostParmsCheck("tid"))
  9084. {
  9085. returnErrorMsg("缺少必要的参数");
  9086. }
  9087. string tid = GetPostString("tid");
  9088. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9089. if (ceErpOrderFormData != null)
  9090. {
  9091. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9092. returnSuccess(ro_jsond);
  9093. return;
  9094. }
  9095. returnErrorMsg("尚未有文件!");
  9096. }
  9097. public void back_supplier_audit()
  9098. {
  9099. int userId = CurrentUser.UserID;
  9100. StringBuilder sql = new StringBuilder();
  9101. 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);
  9102. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9103. if (dt.Rows.Count > 0)
  9104. {
  9105. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9106. }
  9107. else
  9108. {
  9109. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9110. }
  9111. }
  9112. public void back_supplier_query()
  9113. {
  9114. string eid = GetPostString("ctid");
  9115. if (eid != "")
  9116. {
  9117. StringBuilder sql = new StringBuilder();
  9118. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9119. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9120. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9121. }
  9122. else
  9123. {
  9124. returnErrorMsg("找不到订单记录");
  9125. return;
  9126. }
  9127. }
  9128. public void verified_to_order()
  9129. {
  9130. int userId = CurrentUser.UserID;
  9131. StringBuilder sql = new StringBuilder();
  9132. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9133. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9134. if (dt.Rows.Count > 0)
  9135. {
  9136. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9137. }
  9138. else
  9139. {
  9140. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9141. }
  9142. }
  9143. public void upd_supplier_audit()
  9144. {
  9145. if (UrlPostParmsCheck("ctid"))
  9146. {
  9147. string eid = GetPostString("ctid");
  9148. string reason = GetPostString("returnreason");
  9149. CeErpTradeCell entity = null;
  9150. CeWithdraw withdraw = null;
  9151. withdraw = CeWithdraw.GetByTid(eid);
  9152. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9153. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9154. {
  9155. if (withdraw != null)
  9156. {
  9157. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9158. {
  9159. returnSuccessMsg("您没有权限操作!");
  9160. return;
  9161. }
  9162. else
  9163. {
  9164. if (reason.Equals("1"))
  9165. {
  9166. if (entity.OrderState == -1)
  9167. {
  9168. if (entity.FinishPlaceTime == null)
  9169. {
  9170. entity.OrderState = 2;
  9171. }
  9172. else
  9173. {
  9174. entity.OrderState = 6;
  9175. }
  9176. }
  9177. entity.Update();
  9178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9179. if (withdraw != null)
  9180. {
  9181. withdraw.status = int.Parse(reason);
  9182. withdraw.Update();
  9183. }
  9184. returnSuccessMsg("操作成功!");
  9185. return;
  9186. }
  9187. else
  9188. {
  9189. withdraw.status = int.Parse(reason);
  9190. withdraw.acknowledgingtime = DateTime.Now;
  9191. withdraw.Update();
  9192. returnSuccessMsg("查看详细请点击线下订单查询");
  9193. return;
  9194. }
  9195. }
  9196. }
  9197. // 第一个字符是 'N'
  9198. }
  9199. if (eid[0] != 'N')
  9200. {
  9201. }
  9202. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9203. {
  9204. entity.IsVerifyToSupplier = false;
  9205. entity.IsReturn = 1;
  9206. entity.ReturnTime = DateTime.Now;
  9207. entity.ReturnReason = reason;
  9208. if (entity.OrderState == 6)
  9209. {
  9210. entity.OrderState = 5;
  9211. }
  9212. entity.Update();
  9213. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9214. if (withdraw != null)
  9215. {
  9216. withdraw.status = int.Parse(reason);
  9217. withdraw.Update();
  9218. }
  9219. returnSuccessMsg("操作成功!");
  9220. return;
  9221. }
  9222. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9223. {
  9224. ;
  9225. if (withdraw != null)
  9226. {
  9227. withdraw.status = int.Parse(reason);
  9228. withdraw.acknowledgingtime = DateTime.Now;
  9229. withdraw.Update();
  9230. returnSuccessMsg("供应商取消撤回!");
  9231. return;
  9232. }
  9233. }
  9234. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9235. {
  9236. if (entity.OrderState == -1)
  9237. {
  9238. if (entity.FinishPlaceTime == null)
  9239. {
  9240. entity.OrderState = 2;
  9241. }
  9242. else
  9243. {
  9244. entity.OrderState = 3;
  9245. }
  9246. commonHelper.getCytPrice(entity);
  9247. }
  9248. entity.Update();
  9249. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9250. if (withdraw != null)
  9251. {
  9252. withdraw.status = int.Parse(reason);
  9253. withdraw.Update();
  9254. }
  9255. returnSuccessMsg("操作成功!");
  9256. return;
  9257. }
  9258. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9259. {
  9260. if (withdraw == null)
  9261. {
  9262. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9263. return;
  9264. }
  9265. }
  9266. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9267. {
  9268. if (withdraw != null)
  9269. {
  9270. withdraw.status = int.Parse(reason);
  9271. withdraw.acknowledgingtime = DateTime.Now;
  9272. withdraw.Update();
  9273. returnSuccessMsg("查看详细请点击线下订单查询");
  9274. return;
  9275. }
  9276. }
  9277. return;
  9278. }
  9279. }
  9280. //校验报价
  9281. public void refund_order_tip()
  9282. {
  9283. int userid = CurrentUser.UserID;
  9284. int sectionId = CurrentUser.UserPost.OrgID;
  9285. StringBuilder sql = new StringBuilder();
  9286. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9287. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9288. List<string> ids = new List<string>();
  9289. if (dth.Rows.Count > 0)
  9290. {
  9291. foreach (DataRow dr in dth.Rows)
  9292. {
  9293. ids.Add(dr["ID"].ToString());
  9294. }
  9295. try
  9296. {
  9297. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9298. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9299. }
  9300. catch (Exception ex)
  9301. {
  9302. }
  9303. }
  9304. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9305. }
  9306. public void refund_order_Design()
  9307. {
  9308. int userid = CurrentUser.UserID;
  9309. int sectionId = CurrentUser.UserPost.OrgID;
  9310. StringBuilder sql = new StringBuilder();
  9311. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9312. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9313. List<string> ids = new List<string>();
  9314. if (dth.Rows.Count > 0)
  9315. {
  9316. foreach (DataRow dr in dth.Rows)
  9317. {
  9318. ids.Add(dr["ID"].ToString());
  9319. }
  9320. try
  9321. {
  9322. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9323. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9324. }
  9325. catch (Exception ex)
  9326. {
  9327. }
  9328. }
  9329. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9330. }
  9331. public void change_order_info()
  9332. {
  9333. int userid = CurrentUser.UserID;
  9334. StringBuilder sql = new StringBuilder();
  9335. 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);
  9336. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9337. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9338. }
  9339. public void change_win_mome()
  9340. {
  9341. if (UrlPostParmsCheck("id,ctid"))
  9342. {
  9343. string id = GetPostString("id");
  9344. string ctid = GetPostString("ctid");
  9345. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9346. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9347. if (ce == null || ceErpMessageTip == null)
  9348. {
  9349. returnSuccessMsg("未找到对应的订单!");
  9350. return;
  9351. }
  9352. int type = GetPostInt("type");
  9353. string content = GetPostString("content");
  9354. if (type == 0)
  9355. {
  9356. content = content.Replace("(", "(");
  9357. content = content.Replace(")", ")");
  9358. string check = MidStrEx(content, "(", ")").Trim();
  9359. if (string.IsNullOrEmpty(check))
  9360. {
  9361. returnSuccessMsg("文件名格式不正确");
  9362. return;
  9363. }
  9364. }
  9365. ce.seller_memo = content;
  9366. ce.Update();
  9367. ceErpMessageTip.isVisit = true;
  9368. ceErpMessageTip.Update();
  9369. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9370. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9371. ApiVo apiVo = new ApiVo();
  9372. apiVo.orderNumber = ce.ctid;
  9373. apiVo.actionName = "demandDesign";
  9374. apiVo.orderRemarks = content;
  9375. apiVo.demandExamine = type + 1;
  9376. designHelper.API_WorkCore(apiVo);//demandDesign
  9377. returnSuccessMsg("修改成功!");
  9378. }
  9379. }
  9380. public static string MidStrEx(string sourse, string startstr, string endstr)
  9381. {
  9382. string result = string.Empty;
  9383. int startindex, endindex;
  9384. try
  9385. {
  9386. startindex = sourse.IndexOf(startstr);
  9387. if (startindex == -1)
  9388. return result;
  9389. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9390. endindex = tmpstr.IndexOf(endstr);
  9391. if (endindex == -1)
  9392. return result;
  9393. result = tmpstr.Remove(endindex);
  9394. }
  9395. catch (Exception ex)
  9396. {
  9397. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9398. }
  9399. return result;
  9400. }
  9401. public void refund_order_list()
  9402. {
  9403. int userid = CurrentUser.UserID;
  9404. int sectionId = CurrentUser.UserPost.OrgID;
  9405. StringBuilder sql = new StringBuilder();
  9406. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9407. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9408. DataStruct dStruct = GetPostStruct();
  9409. DataTable dt = null;
  9410. List<string> ids = new List<string>();
  9411. List<string> tids = new List<string>();
  9412. if (dth.Rows.Count > 0)
  9413. {
  9414. foreach (DataRow dr in dth.Rows)
  9415. {
  9416. tids.Add("'" + dr["tid"].ToString() + "'");
  9417. ids.Add(dr["id"].ToString());
  9418. }
  9419. try
  9420. {
  9421. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9422. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9423. List<string> lw = new List<string>();
  9424. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9425. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9426. dt = WebCache.GetData("view_orderlist", dStruct);
  9427. }
  9428. catch (Exception ex)
  9429. {
  9430. }
  9431. }
  9432. writeGridDataTableJson(dStruct.TotalCount, dt);
  9433. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9434. }
  9435. //新增
  9436. public void order_batch_downloads()
  9437. {
  9438. string ceid = GetPostString("tid");
  9439. String[] tid = ceid.Split(',');
  9440. order_batch_caiyingtong(tid);
  9441. /* (string success, string errors) = UploadFiles(tid);
  9442. returnSuccessMsg(success + errors);*/
  9443. return;
  9444. }
  9445. //报价接口
  9446. public void Get_To_Quote()
  9447. {
  9448. string ceid = GetPostString("ctid");
  9449. if (ceid != null)
  9450. {
  9451. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9452. if (entity != null)
  9453. {
  9454. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9455. {
  9456. return;
  9457. }
  9458. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9459. double price = 0;
  9460. if (cp == null)
  9461. {
  9462. JObject jsonObject12 = new JObject
  9463. {
  9464. { "UserId", "77886" },
  9465. { "Pwd", "lt666888" },
  9466. { "Filename", entity.seller_memo }
  9467. };
  9468. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9469. JObject jsonObjects1 = JObject.Parse(response1);
  9470. string ms1g = (string)jsonObjects1["msg"];
  9471. if (ms1g == "报价成功")
  9472. {
  9473. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9474. string data = (string)jsonObject1["price"];
  9475. 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 + "');";
  9476. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9477. returnSuccessMsg("获取报价成功:" + data);
  9478. price = Convert.ToDouble(data);
  9479. }
  9480. else
  9481. {
  9482. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9483. return;
  9484. }
  9485. }
  9486. String[] beizhu = entity.seller_memo.Split('-');
  9487. String chanp = "";
  9488. if (beizhu.Length > 0)
  9489. {
  9490. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9491. }
  9492. else
  9493. {
  9494. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9495. }
  9496. JObject jsonObject = new JObject
  9497. {
  9498. { "UserId", "77886" },
  9499. { "Pwd", "lt666888" },
  9500. { "Filename", chanp }
  9501. };
  9502. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9503. JObject jsonObjects = JObject.Parse(response);
  9504. string msg = (string)jsonObjects["msg"];
  9505. if (msg == "报价成功")
  9506. {
  9507. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9508. string data = (string)jsonObject1["price"];
  9509. 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 + "');";
  9510. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9511. returnSuccessMsg("获取报价成功:" + data);
  9512. price = Convert.ToDouble(data);
  9513. }
  9514. else
  9515. {
  9516. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9517. return;
  9518. }
  9519. if (price > 0)
  9520. {
  9521. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9522. if (ceErpTradeCellExtend == null)
  9523. {
  9524. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9525. ceErpTradeCellExtend.ctid = entity.ctid;
  9526. ceErpTradeCellExtend.payment_cyt = price;
  9527. ceErpTradeCellExtend.Create();
  9528. }
  9529. else
  9530. {
  9531. ceErpTradeCellExtend.payment_cyt = price;
  9532. ceErpTradeCellExtend.Update();
  9533. }
  9534. }
  9535. return;
  9536. }
  9537. }
  9538. else
  9539. {
  9540. returnErrorMsg("请至少选择一条数据");
  9541. return;
  9542. }
  9543. }
  9544. //新增
  9545. public void order_To_Supplier()
  9546. {
  9547. string ceid = GetPostString("tid");
  9548. String[] tid = ceid.Split(',');
  9549. if (tid.Length > 0)
  9550. {
  9551. try
  9552. {
  9553. for (int i = 0; i < tid.Length; i++)
  9554. {
  9555. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9556. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9557. entity.SupplierId = suid;
  9558. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9559. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9560. entity.Update();
  9561. }
  9562. }
  9563. catch (Exception ex)
  9564. {
  9565. returnErrorMsg("自动匹配供应商失败");
  9566. return;
  9567. }
  9568. }
  9569. else
  9570. {
  9571. returnErrorMsg("请至少选择一条数据");
  9572. return;
  9573. }
  9574. returnSuccessMsg("自动匹配供应商成功");
  9575. return;
  9576. }
  9577. public (string, string) UploadFiles(string[] urls)
  9578. {
  9579. string success = "";
  9580. string errors = "";
  9581. int userid = CurrentUser.UserID;
  9582. foreach (string url in urls)
  9583. {
  9584. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9585. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9586. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9587. {
  9588. JObject jsonObject = new JObject
  9589. {
  9590. { "Userid", "77886" },
  9591. { "pwd", "cyt86435015" },
  9592. { "content", base64FileContent },
  9593. { "ext", Path.GetExtension(fileName) }
  9594. };
  9595. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9596. JObject jsonObjects = JObject.Parse(response);
  9597. string msg = (string)jsonObjects["msg"];
  9598. if (msg.Equals("上传成功"))
  9599. {
  9600. success += url + " 上传成功";
  9601. }
  9602. else
  9603. {
  9604. errors += url + " 上传失败";
  9605. }
  9606. }
  9607. else
  9608. {
  9609. errors += url + " 格式出现问题";
  9610. }
  9611. }
  9612. if (urls.Length == 0)
  9613. {
  9614. return (success, errors);
  9615. }
  9616. return (success, errors);
  9617. }
  9618. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9619. {
  9620. return true; //总是接受
  9621. }
  9622. public static string HttpPost(string url, string param = null)
  9623. {
  9624. HttpWebRequest request;
  9625. //如果是发送HTTPS请求
  9626. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9627. {
  9628. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9629. request = WebRequest.Create(url) as HttpWebRequest;
  9630. request.ProtocolVersion = HttpVersion.Version10;
  9631. }
  9632. else
  9633. {
  9634. request = WebRequest.Create(url) as HttpWebRequest;
  9635. }
  9636. request.Method = "POST";
  9637. request.ContentType = "application/json";
  9638. request.Accept = "*/*";
  9639. request.Timeout = 120000;
  9640. request.AllowAutoRedirect = false;
  9641. StreamWriter requestStream = null;
  9642. WebResponse response = null;
  9643. string responseStr = null;
  9644. try
  9645. {
  9646. requestStream = new StreamWriter(request.GetRequestStream());
  9647. requestStream.Write(param);
  9648. requestStream.Close();
  9649. response = request.GetResponse();
  9650. if (response != null)
  9651. {
  9652. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9653. responseStr = reader.ReadToEnd();
  9654. reader.Close();
  9655. }
  9656. }
  9657. catch (Exception ex)
  9658. {
  9659. return ex.Message;
  9660. }
  9661. finally
  9662. {
  9663. request = null;
  9664. requestStream = null;
  9665. response = null;
  9666. }
  9667. return responseStr;
  9668. }
  9669. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9670. {
  9671. string base64FileContent;
  9672. string fileName;
  9673. using (WebClient webClient = new WebClient())
  9674. {
  9675. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9676. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9677. {
  9678. using (Stream stream = response.GetResponseStream())
  9679. {
  9680. using (MemoryStream memoryStream = new MemoryStream())
  9681. {
  9682. stream.CopyTo(memoryStream);
  9683. byte[] fileBytes = memoryStream.ToArray();
  9684. base64FileContent = Convert.ToBase64String(fileBytes);
  9685. fileName = response.Headers["Content-Disposition"];
  9686. if (!string.IsNullOrEmpty(fileName))
  9687. {
  9688. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9689. if (index >= 0)
  9690. {
  9691. fileName = fileName.Substring(index + 9).Trim('\"');
  9692. }
  9693. }
  9694. else
  9695. {
  9696. fileName = Path.GetFileName(downloadUrl);
  9697. }
  9698. }
  9699. }
  9700. }
  9701. }
  9702. return (fileName, base64FileContent);
  9703. }
  9704. //新增
  9705. public void order_batch_caiyingtong(string[] downloadUrls)
  9706. {
  9707. try
  9708. {
  9709. //遍历文件
  9710. DataStruct dStruct = GetPostStruct();
  9711. DataTable dt = null;
  9712. int userid = CurrentUser.UserID;
  9713. List<string> ids = new List<string>();//失败组
  9714. List<string> tids = new List<string>();
  9715. using (WebClient webClient = new WebClient())
  9716. {
  9717. foreach (var url in downloadUrls)
  9718. {
  9719. try
  9720. {
  9721. tids.Add("'" + url + "'");
  9722. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9723. if (entity != null)
  9724. {
  9725. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9726. if (cp == null)
  9727. {
  9728. JObject jsonObject = new JObject
  9729. {
  9730. { "Userid", "77886" },
  9731. { "pwd", "lt666888" },
  9732. { "Filename",entity.seller_memo }
  9733. };
  9734. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9735. JObject jsonObjects = JObject.Parse(response);
  9736. string msg = (string)jsonObjects["msg"];
  9737. if (msg == "报价成功")
  9738. {
  9739. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9740. DownloadAndConvertToBase64(url1);
  9741. }
  9742. else
  9743. {
  9744. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9745. }
  9746. }
  9747. else
  9748. {
  9749. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9750. JObject jsonObject = new JObject
  9751. {
  9752. { "Userid", "77886" },
  9753. { "pwd", "lt666888" },
  9754. { "Filename",chanp }
  9755. };
  9756. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9757. JObject jsonObjects = JObject.Parse(response);
  9758. string msg = (string)jsonObjects["msg"];
  9759. if (msg == "报价成功")
  9760. {
  9761. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9762. DownloadAndConvertToBase64(url1);
  9763. }
  9764. else
  9765. {
  9766. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9767. }
  9768. }
  9769. }
  9770. // 上传文件到FTP
  9771. }
  9772. catch (Exception ex)
  9773. {
  9774. Console.WriteLine($"An error occurred: {ex.Message}");
  9775. }
  9776. }
  9777. List<string> lw = new List<string>();
  9778. lw.Add(string.Format("( OrderState < 6 )"));
  9779. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9780. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9781. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9782. if (dt.Rows.Count > 0)
  9783. {
  9784. foreach (DataRow dr in dt.Rows)
  9785. {
  9786. ids.Add(dr["ctid"].ToString());
  9787. }
  9788. }
  9789. String ErrorMsgs = "";
  9790. foreach (String id in ids)
  9791. {
  9792. ErrorMsgs += id + ",";
  9793. }
  9794. if (ErrorMsgs.Length > 1)
  9795. {
  9796. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9797. }
  9798. if (ErrorMsgs.Length < 1)
  9799. {
  9800. ErrorMsgs = "上传成功";
  9801. returnSuccessMsg(ErrorMsgs);
  9802. }
  9803. else
  9804. {
  9805. returnErrorMsg("以下订单" + ErrorMsgs);
  9806. }
  9807. }
  9808. // 删除文件夹及其内容
  9809. /* Directory.Delete(localDirectory, true);*/
  9810. }
  9811. catch { }
  9812. }
  9813. public void get_center_data()
  9814. {
  9815. int userId = CurrentUser.UserID;
  9816. string postCode = CurrentUser.UserPost.Post.Code;
  9817. List<string> lw = new List<string>();
  9818. List<string> ww = new List<string>();
  9819. DateTime currentTime = DateTime.Now;
  9820. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9821. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9822. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9823. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9824. string sql = " SELECT ";
  9825. string startTime = "2023-10-01 11:22:31";
  9826. //设计
  9827. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9828. {
  9829. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9830. 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));
  9831. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9832. 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));
  9833. }
  9834. //客服
  9835. else if (postCode == "CustomerService" || postCode == "Director")
  9836. {
  9837. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9838. 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));
  9839. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9840. 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));
  9841. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9842. 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));
  9843. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9844. 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));
  9845. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9846. 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));
  9847. }
  9848. //售后
  9849. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9850. {
  9851. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9852. 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));
  9853. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9854. 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));
  9855. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9856. 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));
  9857. }
  9858. //下单部
  9859. else if (postCode == "Place" || postCode == "PlaceMr")
  9860. {
  9861. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9862. 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));
  9863. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9864. 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));
  9865. }
  9866. //车间
  9867. else if (postCode == "Supplier")
  9868. {
  9869. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9870. 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));
  9871. }
  9872. DataTable dt = new DataTable();
  9873. if (lw.Count > 0)
  9874. {
  9875. sql += string.Join(" , ", lw);
  9876. sql += " FROM ";
  9877. sql += string.Join(" , ", ww);
  9878. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9879. }
  9880. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9881. }
  9882. public void get_center_data_list()
  9883. {
  9884. int userId = CurrentUser.UserID;
  9885. string postCode = CurrentUser.UserPost.Post.Code;
  9886. string shopIds = CurrentUser.User.pemShop;
  9887. DataStruct dStruct = GetPostStruct();
  9888. List<string> lw = new List<string>();
  9889. DateTime currentTime = DateTime.Now;
  9890. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9891. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9892. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9893. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9894. string startTime = "2023-10-01 11:22:31";
  9895. int order_type = GetPostInt("order_type");
  9896. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9897. {
  9898. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9899. if (order_type == 0)
  9900. {
  9901. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9902. }
  9903. else if (order_type == 3)
  9904. {
  9905. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9906. }
  9907. else
  9908. {
  9909. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9910. }
  9911. }
  9912. //客服
  9913. if (postCode == "CustomerService" || postCode == "Director")
  9914. {
  9915. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9916. if (order_type == 0)
  9917. {
  9918. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9919. }
  9920. else if (order_type == 1)
  9921. {
  9922. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9923. }
  9924. else if (order_type == 2)
  9925. {
  9926. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9927. }
  9928. else if (order_type == 3)
  9929. {
  9930. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9931. }
  9932. else if (order_type == 4)
  9933. {
  9934. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9935. }
  9936. else
  9937. {
  9938. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9939. }
  9940. }
  9941. //售后
  9942. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9943. {
  9944. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9945. if (shopIds != "")
  9946. {
  9947. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9948. }
  9949. if (order_type == 2)
  9950. {
  9951. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9952. }
  9953. else if (order_type == 4)
  9954. {
  9955. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9956. }
  9957. else if (order_type == 5)
  9958. {
  9959. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9960. }
  9961. else
  9962. {
  9963. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9964. }
  9965. }
  9966. //下单部
  9967. if (postCode == "Place" || postCode == "PlaceMr")
  9968. {
  9969. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9970. if (shopIds != "")
  9971. {
  9972. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9973. }
  9974. else if (order_type == 1)
  9975. {
  9976. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9977. }
  9978. else if (order_type == 2)
  9979. {
  9980. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9981. }
  9982. else
  9983. {
  9984. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9985. }
  9986. }
  9987. //车间
  9988. if (postCode == "Supplier")
  9989. {
  9990. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9991. if (order_type == 5)
  9992. {
  9993. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9994. }
  9995. else
  9996. {
  9997. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9998. }
  9999. }
  10000. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10001. dStruct.Fileds = "tid,ctid";
  10002. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10003. writeGridDataTableJson(dStruct.TotalCount, dt);
  10004. }
  10005. public void aftersale_audit_master()
  10006. {
  10007. if (UrlPostParmsCheck("ctid"))
  10008. {
  10009. string ctid = GetPostString("ctid");
  10010. if (ctid.Length > 0)
  10011. {
  10012. bool result = aftersale_data_change(ctid);
  10013. if (result)
  10014. {
  10015. returnSuccessMsg("修改成功!");
  10016. return;
  10017. }
  10018. }
  10019. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10020. }
  10021. }
  10022. public void aftersale_batch_audit_master()
  10023. {
  10024. if (UrlPostParmsCheck("ctids"))
  10025. {
  10026. string ctids = GetPostString("ctids");
  10027. if (ctids.Length > 0)
  10028. {
  10029. List<string> list = new List<string>();
  10030. string[] ctid_list = ctids.Split(',');
  10031. foreach (var item in ctid_list)
  10032. {
  10033. bool result = aftersale_data_change(item);
  10034. if (!result)
  10035. {
  10036. list.Add(item);
  10037. }
  10038. }
  10039. if (list.Count > 0)
  10040. {
  10041. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10042. return;
  10043. }
  10044. returnSuccessMsg("修改成功!");
  10045. return;
  10046. }
  10047. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10048. }
  10049. }
  10050. public bool aftersale_data_change(string ctid)
  10051. {
  10052. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10053. if (ceErpTradeCell != null)
  10054. {
  10055. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10056. ceErpTradeCell.AfterSaleSupplierState = 0;
  10057. StringBuilder sql = new StringBuilder();
  10058. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10059. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10060. CeErpTradeResponsible.DelByTid(ctid, 0);
  10061. 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 == "不理赔")
  10062. {
  10063. CeErpTradeResponsible.DelByTid(ctid, 1);
  10064. ceErpTradeCell.AfterSaleSupplierState = 1;
  10065. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10066. ceErpTradeCell.AfterSaleState = 4;
  10067. }
  10068. else
  10069. {
  10070. ceErpTradeCell.AfterSaleState = 3;
  10071. }
  10072. bool needCyt = false;
  10073. if (dt != null)
  10074. {
  10075. if (dt.Rows.Count == 1)
  10076. {
  10077. bool isEnd = false;
  10078. foreach (DataRow dr in dt.Rows)
  10079. {
  10080. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10081. {
  10082. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10083. isEnd = true;
  10084. }
  10085. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10086. {
  10087. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10088. isEnd = true;
  10089. }
  10090. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10091. {
  10092. needCyt = true;
  10093. }
  10094. }
  10095. if (isEnd)
  10096. {
  10097. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10098. ceErpTradeCell.AfterSaleState = 4;
  10099. ceErpTradeCell.AfterSaleSupplierState = 1;
  10100. }
  10101. }
  10102. else
  10103. {
  10104. bool isAll = true;
  10105. foreach (DataRow dr in dt.Rows)
  10106. {
  10107. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10108. {
  10109. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10110. continue;
  10111. }
  10112. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10113. {
  10114. string path = "";
  10115. int OrgID = 0;
  10116. if (!Convert.IsDBNull(dr["OrgPath"]))
  10117. {
  10118. path = dr["OrgPath"].ToString();
  10119. }
  10120. if (!Convert.IsDBNull(dr["OrgID"]))
  10121. {
  10122. OrgID = Convert.ToInt32(dr["OrgID"]);
  10123. }
  10124. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10125. {
  10126. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10127. continue;
  10128. }
  10129. }
  10130. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10131. {
  10132. needCyt = true;
  10133. }
  10134. isAll = false;
  10135. }
  10136. if (isAll)
  10137. {
  10138. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10139. ceErpTradeCell.AfterSaleState = 4;
  10140. ceErpTradeCell.AfterSaleSupplierState = 1;
  10141. }
  10142. }
  10143. }
  10144. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10145. {
  10146. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10147. }
  10148. if (ceErpTradeCell.AfterSaleState == 4)
  10149. {
  10150. ApiVo apiVo = new ApiVo();
  10151. apiVo.orderNumber = ceErpTradeCell.ctid;
  10152. apiVo.actionName = "afterOver";
  10153. designHelper.API_WorkCore(apiVo); //afterOver
  10154. }
  10155. ceErpTradeCell.Update();
  10156. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10157. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10158. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10159. return true;
  10160. }
  10161. return false;
  10162. }
  10163. public void get_erp_wechatorder()
  10164. {
  10165. DataStruct dStruct = GetPostStruct();
  10166. List<string> lw = new List<string>();
  10167. string tid = GetPostString("tid");
  10168. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10169. string shopname = GetPostString("shopname");
  10170. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10171. string buyernick = GetPostString("buyer_nick");
  10172. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10173. string customer = GetPostString("customer");
  10174. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10175. string returndate1 = GetPostString("returndate1");
  10176. string returndate2 = GetPostString("returndate2");
  10177. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10178. if (dw.Length > 0) lw.Add(dw);
  10179. string finishDate1 = GetPostString("finishdate1");
  10180. string finishDate2 = GetPostString("finishdate2");
  10181. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10182. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10183. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10184. dStruct.Order = "created desc";
  10185. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10186. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10187. writeGridDataTableJson(dStruct.TotalCount, dt);
  10188. }
  10189. public void get_erp_wechatlist_sumprice()
  10190. {
  10191. DataStruct dStruct = GetPostStruct();
  10192. List<string> lw = new List<string>();
  10193. string tid = GetPostString("tid");
  10194. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10195. string shopname = GetPostString("shopname");
  10196. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10197. string buyernick = GetPostString("buyer_nick");
  10198. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10199. string customer = GetPostString("customer");
  10200. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10201. string returndate1 = GetPostString("returndate1");
  10202. string returndate2 = GetPostString("returndate2");
  10203. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10204. if (dw.Length > 0) lw.Add(dw);
  10205. string finishDate1 = GetPostString("finishdate1");
  10206. string finishDate2 = GetPostString("finishdate2");
  10207. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10208. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10209. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10210. string mainWhere = string.Join(" and ", lw.ToArray());
  10211. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10212. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10213. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10214. decimal total = 0;
  10215. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10216. {
  10217. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10218. }
  10219. var res = new
  10220. {
  10221. data = total
  10222. };
  10223. string ro_jsond = JsonConvert.SerializeObject(res);
  10224. returnSuccess(ro_jsond);
  10225. return;
  10226. }
  10227. public void get_erp_qr_waitdeliverylist()
  10228. {
  10229. DataStruct dStruct = GetPostStruct();
  10230. List<string> lw = new List<string>();
  10231. string tid = GetPostString("ctid");
  10232. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10234. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10235. var res_objz = new
  10236. {
  10237. restype = 1,
  10238. data = dt
  10239. };
  10240. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10241. returnSuccess(ro_jsonz);
  10242. }
  10243. public void get_erp_yield_list()
  10244. {
  10245. DataStruct dStruct = GetPostStruct();
  10246. List<string> lw = new List<string>();
  10247. string tid = GetPostString("ctid");
  10248. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10249. string shopname = GetPostString("shopname");
  10250. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10251. string buyernick = GetPostString("buyer_nick");
  10252. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10253. //if (tid.Length == 0 && buyernick.Length == 0)
  10254. //{
  10255. // lw.Add(string.Format("IsRefund<={0}", 1));
  10256. //}
  10257. string customer = GetPostString("customer");
  10258. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10259. string design = GetPostString("design");
  10260. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10261. string orderState = GetPostString("orderState");
  10262. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10263. string address = GetPostString("address");
  10264. 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));
  10265. string sellermemo = GetPostString("seller_memo");
  10266. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10267. string supplier = GetPostString("supplier");
  10268. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10269. string OrderArea = GetPostString("order_area");
  10270. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10271. string placedate1 = GetPostString("placedate1");
  10272. string placedate2 = GetPostString("placedate2");
  10273. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10274. if (fdw.Length > 0) lw.Add(fdw);
  10275. string price1 = GetPostString("price1");
  10276. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10277. string price2 = GetPostString("price2");
  10278. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10279. string unusualCon = GetPostString("unusualcon");
  10280. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10281. string posTag = CurrentUser.UserPost.Post.Code;
  10282. if (posTag == "Supplier")
  10283. {
  10284. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10285. }
  10286. lw.Add(string.Format("OrderState = 6 "));
  10287. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10288. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10289. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10290. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10291. writeGridDataTableJson(dStruct.TotalCount, dt);
  10292. }
  10293. public void change_erp_sup_state()
  10294. {
  10295. if (UrlPostParmsCheck("ctid"))
  10296. {
  10297. string ctid = GetPostString("ctid");
  10298. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10299. if (ceErpTradeCell != null)
  10300. {
  10301. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10302. if (ceErpTradeCellExtend == null)
  10303. {
  10304. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10305. ceErpTradeCellExtend.ctid = ctid;
  10306. ceErpTradeCellExtend.SupState = 1;
  10307. ceErpTradeCellExtend.Create();
  10308. }
  10309. else
  10310. {
  10311. ceErpTradeCellExtend.SupState = 1;
  10312. ceErpTradeCellExtend.Update();
  10313. }
  10314. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10315. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10316. return;
  10317. }
  10318. returnErrorMsg("找不到订单");
  10319. }
  10320. }
  10321. public void supplier_all_downs()
  10322. {
  10323. if (UrlPostParmsCheck("tids"))
  10324. {
  10325. string tids = GetPostString("tids");
  10326. if (tids != null && tids.Length > 0)
  10327. {
  10328. StringBuilder sql = new StringBuilder();
  10329. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10330. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10331. sql = new StringBuilder();
  10332. 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, "下载设计文件");
  10333. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10334. string[] list = tids.Split(',');
  10335. foreach (string ctid in list)
  10336. {
  10337. CeErpSukuraData.createInfo(ctid, 3);
  10338. }
  10339. designHelper.api_approveDesign(tids); //approveDesign
  10340. returnSuccessMsg("下载成功!");
  10341. return;
  10342. }
  10343. returnErrorMsg("下载订单更新失败");
  10344. }
  10345. }
  10346. public void uploaderFileSuccess()
  10347. {
  10348. if (UrlPostParmsCheck("fileName"))
  10349. {
  10350. string fileName = GetPostString("fileName");
  10351. ApiVo apiVo = new ApiVo();
  10352. apiVo.orderNumber = fileName;
  10353. apiVo.actionName = "finishDesign";
  10354. designHelper.API_WorkCore(apiVo);//finishDesign
  10355. returnSuccessMsg("");
  10356. }
  10357. }
  10358. public void get_sample2_order()
  10359. {
  10360. if (UrlPostParmsCheck("ctid"))
  10361. {
  10362. string ctid = GetPostString("ctid");
  10363. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10364. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10365. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10366. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10367. double total = 0.0;
  10368. double order_price = 0.0;
  10369. if (dt_bu.Rows.Count > 0)
  10370. {
  10371. foreach (DataRow dr in dt_bu.Rows)
  10372. {
  10373. total += Convert.ToDouble(dr["payment"]);
  10374. }
  10375. }
  10376. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10377. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10378. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10379. string tid = ctid.Replace("S_", "");
  10380. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10381. double paymant = 0.0;
  10382. if (entity != null)
  10383. {
  10384. paymant = entity.payment;
  10385. }
  10386. string return_reason = "";
  10387. if (dt_after != null && dt_after.Rows.Count > 0)
  10388. {
  10389. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10390. }
  10391. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10392. }
  10393. }
  10394. public void get_erp_design_status()
  10395. {
  10396. string designName = GetPostString("designName");
  10397. DataStruct dStruct = GetPostStruct();
  10398. if (designName.Length > 0)
  10399. {
  10400. 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";
  10401. sql_user += " and Name like '%" + designName + "%'";
  10402. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10403. List<string> ids_list = new List<string>();
  10404. if (user_table.Rows.Count > 0)
  10405. {
  10406. foreach (DataRow item in user_table.Rows)
  10407. {
  10408. ids_list.Add(item["id"].ToString());
  10409. string ids_s = item["TeamIds"].ToString();
  10410. if (ids_s.Length > 0)
  10411. {
  10412. ids_list.AddRange(ids_s.Split(','));
  10413. }
  10414. }
  10415. }
  10416. HashSet<string> set = new HashSet<string>(ids_list);
  10417. ids_list = set.ToList();
  10418. if (ids_list.Count > 0)
  10419. {
  10420. 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));
  10421. dStruct.MainWhere = sql;
  10422. DataTable dt = null;
  10423. dt = WebCache.GetData("view_ErpUser", dStruct);
  10424. writeGridDataTableJson(dStruct.TotalCount, dt);
  10425. }
  10426. }
  10427. }
  10428. public void change_erp_order_price()
  10429. {
  10430. string ctid = GetPostString("ctid");
  10431. double price = GetPostDouble("price");
  10432. if (ctid.Length > 0)
  10433. {
  10434. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10435. if (ceErpTradeCellExtend == null)
  10436. {
  10437. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10438. ceErpTradeCellExtend.ctid = ctid;
  10439. ceErpTradeCellExtend.payment_cyt = price;
  10440. ceErpTradeCellExtend.Create();
  10441. }
  10442. else
  10443. {
  10444. ceErpTradeCellExtend.payment_cyt = price;
  10445. ceErpTradeCellExtend.Update();
  10446. }
  10447. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10448. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10449. {
  10450. ceErpDataSendOrderInfo.isSync = false;
  10451. ceErpDataSendOrderInfo.Update();
  10452. }
  10453. if (ceErpDataSendOrderInfo == null)
  10454. {
  10455. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10456. ceErpDataSendOrderInfo.isSync = false;
  10457. ceErpDataSendOrderInfo.ctid = ctid;
  10458. ceErpDataSendOrderInfo.Create();
  10459. }
  10460. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10461. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10462. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10463. if (dth != null && dth.Rows.Count > 0)
  10464. {
  10465. dataSendOrderBean dataSendOrderBean = null;
  10466. foreach (DataRow item in dth.Rows)
  10467. {
  10468. try
  10469. {
  10470. dataSendOrderBean = new dataSendOrderBean();
  10471. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10472. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10473. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10474. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10475. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10476. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10477. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10478. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10479. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10480. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10481. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10482. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10483. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10484. if (result != null)
  10485. {
  10486. if ("0".Equals(result.errcode))
  10487. {
  10488. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10489. }
  10490. else
  10491. {
  10492. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10493. }
  10494. }
  10495. }
  10496. catch (Exception ex)
  10497. {
  10498. }
  10499. }
  10500. }
  10501. returnSuccessMsg("修改成功!");
  10502. return;
  10503. }
  10504. returnErrorMsg("找不到订单");
  10505. }
  10506. public void find_he_together()
  10507. {
  10508. string ctid = GetPostString("ctid");
  10509. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10510. List<string> list = new List<string>();
  10511. if (ceErpTradeCell != null)
  10512. {
  10513. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10514. {
  10515. 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);
  10516. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10517. if (table != null && table.Rows.Count > 0)
  10518. {
  10519. foreach (TableRow row in table.Rows)
  10520. {
  10521. }
  10522. }
  10523. }
  10524. }
  10525. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10526. }
  10527. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10528. {
  10529. //chy----19
  10530. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10531. //GD-CYT-----64
  10532. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10533. //ZHX----3
  10534. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10535. //JK----97
  10536. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10537. //ZT----70
  10538. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10539. //LHCY-----98
  10540. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10541. //XD-----90
  10542. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10543. //CYCY-----14
  10544. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10545. };
  10546. //其他改名
  10547. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10548. {
  10549. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10550. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10551. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10552. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10553. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10554. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10555. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10556. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10557. };
  10558. //不统计
  10559. List<int> no_suppliers = new List<int>()
  10560. {
  10561. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10562. };
  10563. //配件单
  10564. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10565. {
  10566. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10567. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10568. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10569. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10570. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10571. {"旗杆",new List<string>(){ "班旗" } },
  10572. {"牙签",new List<string>(){ "不干胶" } }
  10573. };
  10574. public void get_place_order_data()
  10575. {
  10576. string date1 = GetPostString("date1");
  10577. string date2 = GetPostString("date2");
  10578. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10579. DateTime start = DateTime.Parse(starttime);
  10580. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10581. DateTime end = DateTime.Parse(endtime);
  10582. if (date1 != null && date1.Length > 0)
  10583. {
  10584. DateTime dateTime = DateTime.Parse(date1);
  10585. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10586. start = DateTime.Parse(starttime);
  10587. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10588. end = DateTime.Parse(endtime);
  10589. }
  10590. if (date2 != null && date2.Length > 0)
  10591. {
  10592. DateTime dateTime = DateTime.Parse(date2);
  10593. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10594. end = DateTime.Parse(endtime);
  10595. }
  10596. 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);
  10597. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10598. //不干胶-----1,卡片-----29
  10599. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10600. foreach (DataRow row in data.Rows)
  10601. {
  10602. int productId = Convert.ToInt32(row["ProductId"]);
  10603. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10604. if (no_suppliers.Contains(supplierId))
  10605. {
  10606. continue;
  10607. }
  10608. string seller_memo = row["seller_memo"].ToString();
  10609. bool ispj = false;//是否配件单
  10610. bool isfirst = true;//第一个配
  10611. maps.Keys.ForEach(key =>
  10612. {
  10613. //备注包含配件
  10614. if (seller_memo.Contains(key) && isfirst)
  10615. {
  10616. List<string> list = maps[key];
  10617. ispj = true;
  10618. isfirst = false;
  10619. for (int i = 0; i < list.Count; i++)
  10620. {
  10621. if (seller_memo.Contains(list[i]))
  10622. {
  10623. ispj = false;
  10624. break;
  10625. }
  10626. }
  10627. }
  10628. });
  10629. if (ispj)
  10630. {
  10631. continue;
  10632. }
  10633. seller_memo = seller_memo.Replace("UV", "uv");
  10634. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10635. //吊牌归到卡片
  10636. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10637. seller_memo = seller_memo.Replace("卡套", "卡片");
  10638. seller_memo = seller_memo.Replace("封套", "卡片");
  10639. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10640. seller_memo = seller_memo.Replace("腰封", "卡片");
  10641. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10642. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10643. seller_memo = seller_memo.Replace("横幅", "条幅");
  10644. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10645. string map_key = "";
  10646. string type = "";
  10647. if (supplierMap.ContainsKey(supplierId))
  10648. {
  10649. foreach (var kvp in supplierMap[supplierId])
  10650. {
  10651. if (seller_memo.Contains(kvp.Key))
  10652. {
  10653. map_key = kvp.Value;
  10654. type = kvp.Value;
  10655. break;
  10656. }
  10657. }
  10658. }
  10659. if (map_key == "")
  10660. {
  10661. type = "其他";
  10662. map_key = "其他";
  10663. }
  10664. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10665. {
  10666. map_key = suppliers[supplierId];
  10667. }
  10668. if (supplierId == 70)
  10669. {
  10670. supplierId = 70;
  10671. }
  10672. map_key += "_" + row["SupplierName"].ToString();
  10673. Dictionary<string, int> map = null;
  10674. if (other_map.ContainsKey(map_key))
  10675. {
  10676. other_map.TryGetValue(map_key, out map);
  10677. }
  10678. else
  10679. {
  10680. map = new Dictionary<string, int>();
  10681. map.Add("dayDev", 0);//当天出货
  10682. map.Add("dayTotal", 0);//下单总数
  10683. map.Add("payTotal", 0);//500以上
  10684. map.Add("today", 0);//当天出货数量
  10685. map.Add("unusua", 0);//异常数
  10686. other_map.Add(map_key, map);
  10687. other_map.TryGetValue(map_key, out map);
  10688. }
  10689. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10690. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10691. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10692. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  10693. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10694. {
  10695. map["dayTotal"]++;
  10696. if (supplierId == 97)
  10697. {
  10698. supplierId = 97;
  10699. }
  10700. }
  10701. if (Convert.ToDecimal(row["payment"]) >= 500)
  10702. {
  10703. map["payTotal"]++;
  10704. }
  10705. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10706. {
  10707. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10708. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10709. {
  10710. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10711. {
  10712. map["today"]++;
  10713. }
  10714. }
  10715. else
  10716. {
  10717. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10718. {
  10719. map["today"]++;
  10720. }
  10721. }
  10722. }
  10723. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10724. {
  10725. map["unusua"]++;
  10726. }
  10727. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10728. //GD-CYT-----64
  10729. DateTime two = palceTimeStart.AddHours(14);
  10730. DateTime three = palceTimeStart.AddHours(15);
  10731. DateTime four = palceTimeStart.AddHours(16);
  10732. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10733. {
  10734. //下午四点前 500-1000
  10735. string count = row["ProductCount"].ToString();
  10736. if (count != null && count.Length > 0)
  10737. {
  10738. int productCount = commonHelper.getPlaceProductCount(count);
  10739. if (productCount >= 500 && productCount <= 1000)
  10740. {
  10741. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10742. {
  10743. map["dayDev"]++;
  10744. }
  10745. }
  10746. }
  10747. }
  10748. //UV
  10749. else if ("uv".Equals(type))
  10750. {
  10751. //ZT----70
  10752. //ZHX----3
  10753. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10754. {
  10755. map["dayDev"]++;
  10756. }
  10757. //JK----97
  10758. //HZX----105
  10759. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10760. {
  10761. map["dayDev"]++;
  10762. if (supplierId == 97)
  10763. {
  10764. supplierId = 97;
  10765. }
  10766. }
  10767. }
  10768. //帆布---52|条幅---27
  10769. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10770. {
  10771. //LHCY-----98
  10772. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10773. {
  10774. map["dayDev"]++;
  10775. }
  10776. }
  10777. //条幅
  10778. else if ("条幅".Equals(type))
  10779. {
  10780. //XD-----90
  10781. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10782. {
  10783. map["dayDev"]++;
  10784. }
  10785. }
  10786. //桌布
  10787. else if ("桌布".Equals(type))
  10788. {
  10789. //XD-----90
  10790. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10791. {
  10792. map["dayDev"]++;
  10793. }
  10794. }
  10795. //DL---10
  10796. //AYTW---119
  10797. //FS-CYT-DY ----80
  10798. //JK----97
  10799. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10800. {
  10801. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10802. {
  10803. map["dayDev"]++;
  10804. }
  10805. }
  10806. }
  10807. DataTable dt = new DataTable();
  10808. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10809. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10810. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10811. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10812. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10813. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10814. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10815. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10816. other_map.Keys.ForEach(key =>
  10817. {
  10818. DataRow dr = dt.NewRow();
  10819. Dictionary<string, int> map = other_map[key];
  10820. string[] key_list = key.Split('_');
  10821. dr[0] = key_list[0];
  10822. dr[1] = key_list[1];
  10823. if (key_list.Length > 2)
  10824. {
  10825. dr[1] += "(" + key_list[2] + ")";
  10826. }
  10827. dr[2] = map["dayTotal"];
  10828. dr[3] = map["payTotal"];
  10829. dr[4] = map["today"];
  10830. dr[5] = map["unusua"];
  10831. dr[6] = map["dayDev"];
  10832. double rate = 0.00;
  10833. if (map["dayDev"] > 0)
  10834. {
  10835. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10836. }
  10837. dr[7] = rate.ToString();
  10838. dt.Rows.Add(dr);
  10839. });
  10840. DataView dv = new DataView(dt);
  10841. dv.Sort = "SupplierName";
  10842. //dv.Sort = "AllOrder desc";
  10843. DataTable dtNew = dv.ToTable();
  10844. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10845. }
  10846. public void check_order_desing_info()
  10847. {
  10848. string ctid = GetPostString("ctid");
  10849. if (!string.IsNullOrEmpty(ctid))
  10850. {
  10851. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10852. if (ceErpTradeCell != null)
  10853. {
  10854. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10855. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10856. return;
  10857. }
  10858. returnErrorMsg("找不到订单");
  10859. return;
  10860. }
  10861. returnErrorMsg("找不到订单");
  10862. }
  10863. public void get_timeout_detail()
  10864. {
  10865. string poscode = CurrentUser.UserPost.Post.Code;
  10866. DataStruct dStruct = GetPostStruct();
  10867. List<string> lw = new List<string>();
  10868. string id = GetPostString("id");
  10869. string pay_date1 = GetPostString("pay_date1");
  10870. string pay_date2 = GetPostString("pay_date2");
  10871. int type = GetPostInt("type");
  10872. if (type == 0)
  10873. {
  10874. if (pay_date1.Length > 0)
  10875. {
  10876. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10877. }
  10878. if (pay_date2.Length > 0)
  10879. {
  10880. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10881. }
  10882. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10883. }
  10884. if (type == 1)
  10885. {
  10886. if (pay_date1.Length > 0)
  10887. {
  10888. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10889. }
  10890. if (pay_date2.Length > 0)
  10891. {
  10892. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10893. }
  10894. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10895. }
  10896. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10897. DataTable dt = null;
  10898. dt = WebCache.GetData("view_orderlist", dStruct);
  10899. writeGridDataTableJson(dStruct.TotalCount, dt);
  10900. }
  10901. public void saveUrgentChargePrice()
  10902. {
  10903. string ctid = GetPostString("ctid");
  10904. if (!string.IsNullOrEmpty(ctid))
  10905. {
  10906. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10907. if (ceErpTradeCell != null)
  10908. {
  10909. double price = GetPostDouble("price");
  10910. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10911. if (ceErpTradeCellExtend == null)
  10912. {
  10913. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10914. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10915. }
  10916. ceErpTradeCellExtend.urgentCharge = price;
  10917. if (ceErpTradeCellExtend.ID > 0)
  10918. {
  10919. ceErpTradeCellExtend.Update();
  10920. }
  10921. else
  10922. {
  10923. ceErpTradeCellExtend.Save();
  10924. }
  10925. returnSuccessMsg("修改成功!");
  10926. return;
  10927. }
  10928. returnErrorMsg("找不到订单");
  10929. return;
  10930. }
  10931. returnErrorMsg("找不到订单");
  10932. }
  10933. public void finish_erp_order()
  10934. {
  10935. string ctid = GetPostString("ctid");
  10936. if (!string.IsNullOrEmpty(ctid))
  10937. {
  10938. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10939. {
  10940. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10941. if (ceErpTradeCell != null)
  10942. {
  10943. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10944. ceErpTradeCell.Update();
  10945. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10946. returnSuccessMsg("修改成功!");
  10947. return;
  10948. }
  10949. }
  10950. }
  10951. returnErrorMsg("找不到订单");
  10952. }
  10953. public void get_trade_order_list()
  10954. {
  10955. string tid = GetPostString("tid");
  10956. if (!string.IsNullOrEmpty(tid))
  10957. {
  10958. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10959. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10960. writeGridDataTableJson(data.Rows.Count, data);
  10961. return;
  10962. }
  10963. returnErrorMsg("找不到订单");
  10964. }
  10965. public void save_cell_spu()
  10966. {
  10967. string ctid = GetPostString("ctid");
  10968. string spu_id = GetPostString("spu_id");
  10969. if (!string.IsNullOrEmpty(ctid))
  10970. {
  10971. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10972. if (ceErpTradeCellExtend == null)
  10973. {
  10974. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10975. ceErpTradeCellExtend.ctid = ctid;
  10976. }
  10977. ceErpTradeCellExtend.spu_id = spu_id;
  10978. if (ceErpTradeCellExtend.ID == 0)
  10979. {
  10980. ceErpTradeCellExtend.Create();
  10981. }
  10982. else
  10983. {
  10984. ceErpTradeCellExtend.Update();
  10985. }
  10986. returnSuccessMsg("修改成功!");
  10987. return;
  10988. }
  10989. returnErrorMsg("找不到订单");
  10990. }
  10991. public void change_express_info()
  10992. {
  10993. string ctid = GetPostString("ctid");
  10994. string transNo = GetPostString("transNo");
  10995. string transCom = GetPostString("transCom");
  10996. if (!string.IsNullOrEmpty(ctid))
  10997. {
  10998. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10999. if (ceErpTradeCellExtend == null)
  11000. {
  11001. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11002. ceErpTradeCellExtend.ctid = ctid;
  11003. }
  11004. ceErpTradeCellExtend.modExpressNo = transNo;
  11005. ceErpTradeCellExtend.modExpressCom = transCom;
  11006. ceErpTradeCellExtend.readMod = 2;
  11007. if (ceErpTradeCellExtend.ID == 0)
  11008. {
  11009. ceErpTradeCellExtend.Create();
  11010. }
  11011. else
  11012. {
  11013. ceErpTradeCellExtend.Update();
  11014. }
  11015. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11016. returnSuccessMsg("修改成功!");
  11017. return;
  11018. }
  11019. returnErrorMsg("找不到订单");
  11020. }
  11021. public void get_change_express_list()
  11022. {
  11023. DataStruct dStruct = GetPostStruct();
  11024. List<string> lw = new List<string>();
  11025. int st = 2;
  11026. string tid = GetPostString("ctid");
  11027. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11028. string shopname = GetPostString("shopname");
  11029. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11030. string buyernick = GetPostString("buyer_nick");
  11031. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11032. string sellermemo = GetPostString("seller_memo");
  11033. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11034. string supplier = GetPostString("supplier");
  11035. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11036. string customer = GetPostString("customer");
  11037. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11038. string design = GetPostString("design");
  11039. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11040. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11041. string poscode = CurrentUser.UserPost.Post.Code;
  11042. if (poscode != "SysAdmin")
  11043. {
  11044. string shopid = CurrentUser.User.pemShop;
  11045. lw.Add(string.Format("shopId in ({0})", shopid));
  11046. }
  11047. lw.Add("readMod = 2");
  11048. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11049. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11050. writeGridDataTableJson(dStruct.TotalCount, dt);
  11051. }
  11052. public void deal_express_complete()
  11053. {
  11054. string ctid = GetPostString("ctid");
  11055. if (!string.IsNullOrEmpty(ctid))
  11056. {
  11057. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11058. if (ceErpTradeCellExtend == null)
  11059. {
  11060. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11061. ceErpTradeCellExtend.ctid = ctid;
  11062. }
  11063. ceErpTradeCellExtend.readMod = 1;
  11064. if (ceErpTradeCellExtend.ID == 0)
  11065. {
  11066. ceErpTradeCellExtend.Create();
  11067. }
  11068. else
  11069. {
  11070. ceErpTradeCellExtend.Update();
  11071. }
  11072. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11073. returnSuccessMsg("修改成功!");
  11074. return;
  11075. }
  11076. returnErrorMsg("找不到订单");
  11077. }
  11078. public void aftersale_return_visit()
  11079. {
  11080. string ctid = GetPostString("ctid");
  11081. if (!string.IsNullOrEmpty(ctid))
  11082. {
  11083. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11084. if (ceErpTradeCellExtend == null)
  11085. {
  11086. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11087. ceErpTradeCellExtend.ctid = ctid;
  11088. }
  11089. ceErpTradeCellExtend.returnVisit = 1;
  11090. if (ceErpTradeCellExtend.ID == 0)
  11091. {
  11092. ceErpTradeCellExtend.Create();
  11093. }
  11094. else
  11095. {
  11096. ceErpTradeCellExtend.Update();
  11097. }
  11098. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11099. if (ceErpTradeAfterSaleExtend != null)
  11100. {
  11101. ceErpTradeAfterSaleExtend.TextResult = "";
  11102. ceErpTradeAfterSaleExtend.Update();
  11103. }
  11104. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11105. returnSuccessMsg("修改成功!");
  11106. return;
  11107. }
  11108. returnErrorMsg("找不到订单");
  11109. }
  11110. public void orderPlaceInfo()
  11111. {
  11112. string ctids = GetPostString("ctids");
  11113. string[] list = ctids.Split(',');
  11114. foreach (string ctid in list)
  11115. {
  11116. CeErpSukuraData.createInfo(ctid, 3);
  11117. }
  11118. designHelper.api_approveDesign(ctids); //approveDesign
  11119. returnSuccessMsg("");
  11120. }
  11121. public void get_issue_list()
  11122. {
  11123. DataStruct dStruct = GetPostStruct();
  11124. List<string> lw = new List<string>();
  11125. int st = 2;
  11126. string tid = GetPostString("ctid");
  11127. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11128. string shopname = GetPostString("shopname");
  11129. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11130. string buyernick = GetPostString("buyer_nick");
  11131. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11132. string sellermemo = GetPostString("seller_memo");
  11133. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11134. string supplier = GetPostString("supplier");
  11135. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11136. string customer = GetPostString("customer");
  11137. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11138. string design = GetPostString("design");
  11139. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11140. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11141. string poscode = CurrentUser.UserPost.Post.Code;
  11142. if (poscode != "SysAdmin")
  11143. {
  11144. string shopid = CurrentUser.User.pemShop;
  11145. lw.Add(string.Format("shopId in ({0})", shopid));
  11146. }
  11147. lw.Add("IssueState > 0");
  11148. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11149. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11150. writeGridDataTableJson(dStruct.TotalCount, dt);
  11151. }
  11152. public void saveIssueContent()
  11153. {
  11154. string ctid = GetPostString("ctid");
  11155. if (!string.IsNullOrEmpty(ctid))
  11156. {
  11157. string content = GetPostString("content");
  11158. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11159. if (ceErpTradeAfterSaleExtend == null)
  11160. {
  11161. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11162. ceErpTradeAfterSaleExtend.tid = ctid;
  11163. }
  11164. ceErpTradeAfterSaleExtend.IssueContent = content;
  11165. ceErpTradeAfterSaleExtend.IssueState = 1;
  11166. if (ceErpTradeAfterSaleExtend.ID > 0)
  11167. {
  11168. ceErpTradeAfterSaleExtend.Update();
  11169. }
  11170. else
  11171. {
  11172. ceErpTradeAfterSaleExtend.Create();
  11173. }
  11174. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11175. returnSuccessMsg("添加成功!");
  11176. return;
  11177. }
  11178. returnErrorMsg("找不到订单");
  11179. }
  11180. public void dealIssueContent()
  11181. {
  11182. string ctid = GetPostString("ctid");
  11183. if (!string.IsNullOrEmpty(ctid))
  11184. {
  11185. string content = GetPostString("content");
  11186. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11187. if (ceErpTradeAfterSaleExtend != null)
  11188. {
  11189. ceErpTradeAfterSaleExtend.IssueState = 2;
  11190. ceErpTradeAfterSaleExtend.Update();
  11191. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11192. returnSuccessMsg("修改完成!");
  11193. return;
  11194. }
  11195. }
  11196. returnErrorMsg("找不到订单");
  11197. }
  11198. }
  11199. }