sync.order.cs 585 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621
  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 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  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. /*if (tid.Length > 0)
  3818. {
  3819. List<string> tids = new List<string>();
  3820. if (dt != null && dt.Rows.Count > 0)
  3821. {
  3822. foreach (DataRow item in dt.Rows)
  3823. {
  3824. tids.Add("'" + item["tid"] + "'");
  3825. }
  3826. }
  3827. if (tids.Count > 0)
  3828. {
  3829. lw.RemoveAt(0);
  3830. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3831. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3832. dt = WebCache.GetData("view_erptradecell", dStruct);
  3833. }
  3834. }*/
  3835. writeGridDataTableJson(dStruct.TotalCount, dt);
  3836. }
  3837. public void get_erp_changedeliverylist()
  3838. {
  3839. DataStruct dStruct = GetPostStruct();
  3840. List<string> lw = new List<string>();
  3841. string tid = GetPostString("ctid");
  3842. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3843. string shopname = GetPostString("shopname");
  3844. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3845. string buyernick = GetPostString("buyer_nick");
  3846. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3847. //if (tid.Length == 0 && buyernick.Length == 0)
  3848. //{
  3849. // lw.Add(string.Format("IsRefund<={0}", 1));
  3850. //}
  3851. string customer = GetPostString("customer");
  3852. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3853. string design = GetPostString("design");
  3854. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3855. string orderState = GetPostString("orderState");
  3856. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3857. string address = GetPostString("address");
  3858. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  3859. string sellermemo = GetPostString("seller_memo");
  3860. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3861. string supplier = GetPostString("supplier");
  3862. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3863. string OrderArea = GetPostString("order_area");
  3864. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3865. string placedate1 = GetPostString("placedate1");
  3866. string placedate2 = GetPostString("placedate2");
  3867. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3868. if (fdw.Length > 0) lw.Add(fdw);
  3869. string price1 = GetPostString("price1");
  3870. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3871. string price2 = GetPostString("price2");
  3872. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3873. string unusualCon = GetPostString("unusualcon");
  3874. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3875. string otherMemo = GetPostString("otherMemo");
  3876. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3877. string posTag = CurrentUser.UserPost.Post.Code;
  3878. if (posTag == "Supplier")
  3879. {
  3880. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3881. }
  3882. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3883. lw.Add(string.Format("type != 'PDD' "));
  3884. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3885. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3886. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3887. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3888. /*if (tid.Length > 0)
  3889. {
  3890. List<string> tids = new List<string>();
  3891. if (dt != null && dt.Rows.Count > 0)
  3892. {
  3893. foreach (DataRow item in dt.Rows)
  3894. {
  3895. tids.Add("'" + item["tid"] + "'");
  3896. }
  3897. }
  3898. if (tids.Count > 0)
  3899. {
  3900. lw.RemoveAt(0);
  3901. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3902. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3903. dt = WebCache.GetData("view_erptradecell", dStruct);
  3904. }
  3905. }*/
  3906. writeGridDataTableJson(dStruct.TotalCount, dt);
  3907. }
  3908. public void get_erp_pddderiving()
  3909. {
  3910. DataStruct dStruct = GetPostStruct();
  3911. List<string> lw = new List<string>();
  3912. string tid = GetPostString("ctid");
  3913. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3914. string shopname = GetPostString("shopname");
  3915. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3916. string buyernick = GetPostString("buyer_nick");
  3917. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3918. //if (tid.Length == 0 && buyernick.Length == 0)
  3919. //{
  3920. // lw.Add(string.Format("IsRefund<={0}", 1));
  3921. //}
  3922. string customer = GetPostString("customer");
  3923. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3924. string design = GetPostString("design");
  3925. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3926. string orderState = GetPostString("orderState");
  3927. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3928. string address = GetPostString("address");
  3929. 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));
  3930. string sellermemo = GetPostString("seller_memo");
  3931. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3932. string supplier = GetPostString("supplier");
  3933. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3934. string OrderArea = GetPostString("order_area");
  3935. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3936. string placedate1 = GetPostString("placedate1");
  3937. string placedate2 = GetPostString("placedate2");
  3938. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3939. if (fdw.Length > 0) lw.Add(fdw);
  3940. string price1 = GetPostString("price1");
  3941. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3942. string price2 = GetPostString("price2");
  3943. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3944. string unusualCon = GetPostString("unusualcon");
  3945. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3946. string posTag = CurrentUser.UserPost.Post.Code;
  3947. if (posTag == "Supplier")
  3948. {
  3949. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3950. }
  3951. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3952. lw.Add(string.Format("type = 'PDD' "));
  3953. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3954. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3955. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3956. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3957. /*if (tid.Length > 0)
  3958. {
  3959. List<string> tids = new List<string>();
  3960. if (dt != null && dt.Rows.Count > 0)
  3961. {
  3962. foreach (DataRow item in dt.Rows)
  3963. {
  3964. tids.Add("'" + item["tid"] + "'");
  3965. }
  3966. }
  3967. if (tids.Count > 0)
  3968. {
  3969. lw.RemoveAt(0);
  3970. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3971. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3972. dt = WebCache.GetData("view_erptradecell", dStruct);
  3973. }
  3974. }*/
  3975. writeGridDataTableJson(dStruct.TotalCount, dt);
  3976. }
  3977. public void get_erp_jdderiving()
  3978. {
  3979. DataStruct dStruct = GetPostStruct();
  3980. List<string> lw = new List<string>();
  3981. string tid = GetPostString("ctid");
  3982. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3983. string shopname = GetPostString("shopname");
  3984. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3985. string buyernick = GetPostString("buyer_nick");
  3986. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3987. //if (tid.Length == 0 && buyernick.Length == 0)
  3988. //{
  3989. // lw.Add(string.Format("IsRefund<={0}", 1));
  3990. //}
  3991. string customer = GetPostString("customer");
  3992. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3993. string design = GetPostString("design");
  3994. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3995. string orderState = GetPostString("orderState");
  3996. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3997. string address = GetPostString("address");
  3998. 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));
  3999. string sellermemo = GetPostString("seller_memo");
  4000. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4001. string supplier = GetPostString("supplier");
  4002. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4003. string OrderArea = GetPostString("order_area");
  4004. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4005. string placedate1 = GetPostString("placedate1");
  4006. string placedate2 = GetPostString("placedate2");
  4007. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4008. if (fdw.Length > 0) lw.Add(fdw);
  4009. string price1 = GetPostString("price1");
  4010. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4011. string price2 = GetPostString("price2");
  4012. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4013. string unusualCon = GetPostString("unusualcon");
  4014. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4015. string posTag = CurrentUser.UserPost.Post.Code;
  4016. if (posTag == "Supplier")
  4017. {
  4018. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4019. }
  4020. lw.Add(string.Format("OrderState = 6 "));
  4021. lw.Add(string.Format("type = 'JD' "));
  4022. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4023. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4024. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4025. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4026. writeGridDataTableJson(dStruct.TotalCount, dt);
  4027. }
  4028. public void get_erp_demoorderlist()
  4029. {
  4030. DataStruct dStruct = GetPostStruct();
  4031. List<string> lw = new List<string>();
  4032. string tid = GetPostString("ctid");
  4033. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  4034. string shopname = GetPostString("shopname");
  4035. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4036. string buyernick = GetPostString("buyer_nick");
  4037. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4038. string customer = GetPostString("customer");
  4039. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4040. string design = GetPostString("design");
  4041. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4042. string orderState = GetPostString("orderState");
  4043. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4044. string address = GetPostString("address");
  4045. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4046. string sellermemo = GetPostString("seller_memo");
  4047. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4048. string supplier = GetPostString("supplier");
  4049. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4050. string OrderArea = GetPostString("order_area");
  4051. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4052. string date1 = GetPostString("date1");
  4053. string date2 = GetPostString("date2");
  4054. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4055. if (dw.Length > 0) lw.Add(dw);
  4056. string price1 = GetPostString("price1");
  4057. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4058. string price2 = GetPostString("price2");
  4059. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4060. string posTag = CurrentUser.UserPost.Post.Code;
  4061. if (posTag == "Supplier")
  4062. {
  4063. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4064. }
  4065. //lw.Add(string.Format("OrderState = 6 "));
  4066. lw.Add(string.Format("IsSample={0}", 3));
  4067. lw.Add(string.Format("IsRefund<={0}", 1));
  4068. dStruct.Order = "pay_time desc";
  4069. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4070. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4071. writeGridDataTableJson(dStruct.TotalCount, dt);
  4072. }
  4073. public void save_erp_checkmemo()
  4074. {
  4075. if (UrlPostParmsCheck("ctid"))
  4076. {
  4077. string ctid = GetPostString("ctid");
  4078. CeErpTradeCell entity = null;
  4079. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4080. if (entity != null)
  4081. {
  4082. entity.CheckMemo = GetPostString("CheckMemo");
  4083. entity.Update();
  4084. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4085. if (trade != null)
  4086. {
  4087. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4088. }
  4089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4090. returnSuccessMsg("保存成功!");
  4091. return;
  4092. }
  4093. returnErrorMsg("找不到记录");
  4094. }
  4095. }
  4096. public void get_erp_returnlist()
  4097. {
  4098. DataStruct dStruct = GetPostStruct();
  4099. List<string> lw = new List<string>();
  4100. string tid = GetPostString("ctid");
  4101. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4102. string shopname = GetPostString("shopname");
  4103. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4104. string buyernick = GetPostString("buyer_nick");
  4105. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4106. string customer = GetPostString("customer");
  4107. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4108. string design = GetPostString("design");
  4109. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4110. string orderState = GetPostString("orderState");
  4111. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4112. string address = GetPostString("address");
  4113. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4114. string sellermemo = GetPostString("seller_memo");
  4115. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4116. string supplier = GetPostString("supplier");
  4117. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4118. string date1 = GetPostString("date1");
  4119. string date2 = GetPostString("date2");
  4120. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4121. if (dw.Length > 0) lw.Add(dw);
  4122. string bdate1 = GetPostString("backdate1");
  4123. string bdate2 = GetPostString("backdate2");
  4124. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4125. if (dw_back.Length > 0) lw.Add(dw_back);
  4126. string price1 = GetPostString("price1");
  4127. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4128. string price2 = GetPostString("price2");
  4129. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4130. lw.Add(string.Format("IsReturn>0"));
  4131. lw.Add(string.Format("IsXianHuo=0"));
  4132. lw.Add(string.Format("IsReturn!=3"));
  4133. string backtype = GetPostString("backtype");
  4134. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4135. dStruct.Order = "FinishDesignTime desc";
  4136. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4137. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4138. writeGridDataTableJson(dStruct.TotalCount, dt);
  4139. }
  4140. public void get_erp_today_sumreturn()
  4141. {
  4142. DataStruct dStruct = GetPostStruct();
  4143. List<string> lw = new List<string>();
  4144. string bdate1 = GetPostString("returnTimeS");
  4145. string bdate2 = GetPostString("returnTimeE");
  4146. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4147. if (dw_back.Length > 0) lw.Add(dw_back);
  4148. lw.Add(string.Format("IsReturn=0"));
  4149. lw.Add(string.Format("IsXianHuo=0"));
  4150. string mainWhere = string.Join(" and ", lw.ToArray());
  4151. string sql = "";
  4152. if (dw_back.Length > 0)
  4153. {
  4154. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4155. }
  4156. else
  4157. {
  4158. 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 + "'";
  4159. }
  4160. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4161. decimal total = 0, today_finish = 0;
  4162. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4163. {
  4164. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4165. }
  4166. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4167. {
  4168. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4169. }
  4170. var res = new
  4171. {
  4172. data = total,
  4173. data1 = today_finish,
  4174. };
  4175. string ro_jsond = JsonConvert.SerializeObject(res);
  4176. returnSuccess(ro_jsond);
  4177. return;
  4178. }
  4179. public void get_erp_allreturnlist()
  4180. {
  4181. DataStruct dStruct = GetPostStruct();
  4182. List<string> lw = new List<string>();
  4183. string tid = GetPostString("ctid");
  4184. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4185. string shopname = GetPostString("shopname");
  4186. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4187. string buyernick = GetPostString("buyer_nick");
  4188. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4189. string customer = GetPostString("customer");
  4190. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4191. string design = GetPostString("design");
  4192. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4193. string orderState = GetPostString("orderState");
  4194. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4195. string address = GetPostString("address");
  4196. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4197. string sellermemo = GetPostString("seller_memo");
  4198. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4199. string supplier = GetPostString("supplier");
  4200. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4201. string date1 = GetPostString("date1");
  4202. string date2 = GetPostString("date2");
  4203. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4204. if (dw.Length > 0) lw.Add(dw);
  4205. string bdate1 = GetPostString("backdate1");
  4206. string bdate2 = GetPostString("backdate2");
  4207. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4208. if (dw_back.Length > 0) lw.Add(dw_back);
  4209. string price1 = GetPostString("price1");
  4210. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4211. string price2 = GetPostString("price2");
  4212. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4213. string backreason = GetPostString("backreason");
  4214. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4215. lw.Add(string.Format("IsXianHuo=0"));
  4216. lw.Add(string.Format("ReturnTime != ''"));
  4217. string backtype = GetPostString("backtype");
  4218. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4219. dStruct.Order = "FinishDesignTime desc";
  4220. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4221. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4222. writeGridDataTableJson(dStruct.TotalCount, dt);
  4223. }
  4224. public void get_erp_aftersalereturnlist()
  4225. {
  4226. DataStruct dStruct = GetPostStruct();
  4227. List<string> lw = new List<string>();
  4228. string tid = GetPostString("ctid");
  4229. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4230. string shopname = GetPostString("shopname");
  4231. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4232. string buyernick = GetPostString("buyer_nick");
  4233. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4234. string customer = GetPostString("customer");
  4235. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4236. string design = GetPostString("design");
  4237. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4238. string orderState = GetPostString("orderState");
  4239. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4240. string address = GetPostString("address");
  4241. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4242. string sellermemo = GetPostString("seller_memo");
  4243. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4244. string supplier = GetPostString("supplier");
  4245. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4246. string date1 = GetPostString("date1");
  4247. string date2 = GetPostString("date2");
  4248. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4249. if (dw.Length > 0) lw.Add(dw);
  4250. string bdate1 = GetPostString("backdate1");
  4251. string bdate2 = GetPostString("backdate2");
  4252. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4253. if (dw_back.Length > 0) lw.Add(dw_back);
  4254. string price1 = GetPostString("price1");
  4255. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4256. string price2 = GetPostString("price2");
  4257. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4258. lw.Add(string.Format("IsReturn=3"));
  4259. string backtype = GetPostString("backtype");
  4260. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4261. string backreason = GetPostString("backreason");
  4262. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4263. dStruct.Order = "ReturnTime desc";
  4264. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4265. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4266. writeGridDataTableJson(dStruct.TotalCount, dt);
  4267. }
  4268. public void get_erp_xianhuoreturnlist()
  4269. {
  4270. DataStruct dStruct = GetPostStruct();
  4271. List<string> lw = new List<string>();
  4272. string tid = GetPostString("ctid");
  4273. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4274. string shopname = GetPostString("shopname");
  4275. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4276. string buyernick = GetPostString("buyer_nick");
  4277. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4278. string customer = GetPostString("customer");
  4279. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4280. string design = GetPostString("design");
  4281. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4282. string orderState = GetPostString("orderState");
  4283. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4284. string address = GetPostString("address");
  4285. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4286. string sellermemo = GetPostString("seller_memo");
  4287. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4288. string supplier = GetPostString("supplier");
  4289. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4290. string OrderArea = GetPostString("order_area");
  4291. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4292. string date1 = GetPostString("date1");
  4293. string date2 = GetPostString("date2");
  4294. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4295. if (dw.Length > 0) lw.Add(dw);
  4296. string price1 = GetPostString("price1");
  4297. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4298. string price2 = GetPostString("price2");
  4299. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4300. string posTag = CurrentUser.UserPost.Post.Code;
  4301. if (posTag == "Supplier")
  4302. {
  4303. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4304. }
  4305. lw.Add(string.Format("OrderState=6 "));
  4306. lw.Add(string.Format("IsXianHuo=1 "));
  4307. lw.Add(string.Format("IsReturn>0 "));
  4308. lw.Add(string.Format("IsReturn!=3"));
  4309. lw.Add(string.Format("IsRefund<={0}", 1));
  4310. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4311. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4312. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4313. writeGridDataTableJson(dStruct.TotalCount, dt);
  4314. }
  4315. public void set_erp_orderdelivery()
  4316. {
  4317. if (UrlPostParmsCheck("ctid"))
  4318. {
  4319. string eid = GetPostString("ctid");
  4320. CeErpTradeCell entity = null;
  4321. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4322. if (entity != null)
  4323. {
  4324. if (entity.OrderState >= 7)
  4325. {
  4326. returnErrorMsg("此单已发货,无需重复发货");
  4327. return;
  4328. }
  4329. if (entity.OrderState != 6)
  4330. {
  4331. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4332. return;
  4333. }
  4334. string shop = GetPostString("seller_nick");
  4335. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4336. string comName = GetPostString("comName");
  4337. string comCode = GetPostString("comCode");
  4338. string outSid = GetPostString("outSid");
  4339. string deliveryType = GetPostString("deliveryType");
  4340. string deliveryMemo = GetPostString("deliveryMemo");
  4341. outSid = outSid.Trim();
  4342. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4343. if (mainEn == null)
  4344. {
  4345. returnErrorMsg("找不到原始订单记录");
  4346. return;
  4347. }
  4348. bool isInitOrderDeliv = false;
  4349. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4350. {
  4351. isInitOrderDeliv = true;
  4352. }
  4353. string apires = "";
  4354. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4355. 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)
  4356. {
  4357. apires = "发货成功true";
  4358. }
  4359. else
  4360. {
  4361. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4362. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4363. }
  4364. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4365. {
  4366. entity.OrderState = 7;//发货后订单已发货
  4367. entity.OutSid = outSid;
  4368. entity.MemoOpt = 0;
  4369. entity.FinishDeliveryTime = DateTime.Now;
  4370. entity.Update();
  4371. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4372. commonHelper.UpdateRelationOrder(entity.ctid);
  4373. //还要插入快递信息到 快递信息表
  4374. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4375. exinfo.tid = eid;
  4376. exinfo.out_sid = outSid;
  4377. exinfo.company_code = comCode;
  4378. exinfo.company_name = comName;
  4379. exinfo.delivery_memo = deliveryMemo;
  4380. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4381. exinfo.deliveryType = deliveryType;
  4382. exinfo.Create();
  4383. returnSuccessMsg("发货操作成功!");
  4384. commonHelper.UpdateRelationOrder(entity.ctid);
  4385. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4386. CeErpSukuraData.createInfo(entity.ctid, 4);
  4387. if (entity.SupplierId == 64)
  4388. {
  4389. commonHelper.sendCytExpress(exinfo);
  4390. }
  4391. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4392. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4393. }
  4394. else
  4395. {
  4396. string errmsg = commonHelper.KeepChinese(apires);
  4397. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4398. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4399. }
  4400. return;
  4401. }
  4402. returnErrorMsg("找不到订单记录");
  4403. }
  4404. }
  4405. public void set_erp_multidelivery()
  4406. {
  4407. string eids = GetPostString("tids");
  4408. string[] eidList = eids.Split(',');
  4409. if (eidList.Length <= 0)
  4410. {
  4411. returnErrorMsg("发货不能为空");
  4412. return;
  4413. }
  4414. foreach (string ctid in eidList)
  4415. {
  4416. if (ctid.Length <= 0) continue;
  4417. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4418. if (expInfo != null)
  4419. {
  4420. StringBuilder sql = new StringBuilder();
  4421. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4422. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4423. if (dt.Rows.Count > 0)
  4424. {
  4425. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4426. {
  4427. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4428. expInfo.state = "异常";
  4429. expInfo.isMultiDelivery = 1;
  4430. expInfo.Update();
  4431. continue;
  4432. }
  4433. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4434. {
  4435. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4436. expInfo.state = "异常";
  4437. expInfo.Update();
  4438. continue;
  4439. }
  4440. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4441. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4442. bool isInitOrderDeliv = false;
  4443. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4444. {
  4445. isInitOrderDeliv = true;
  4446. expInfo.isMultiDelivery = 1;
  4447. }
  4448. if (ctid.IndexOf("N") != -1)
  4449. {
  4450. StringBuilder sqlbucha = new StringBuilder();
  4451. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4452. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4453. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4454. commonHelper.UpdateRelationOrder(ctid);
  4455. expInfo.delivery_memo = "发货成功";
  4456. expInfo.state = "发货成功";
  4457. expInfo.isMultiDelivery = 1;
  4458. expInfo.Update();
  4459. }
  4460. else
  4461. {
  4462. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4463. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4464. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4465. {
  4466. expInfo.delivery_memo = "发货成功";
  4467. expInfo.state = "发货成功";
  4468. expInfo.isMultiDelivery = 1;
  4469. expInfo.Update();
  4470. commonHelper.UpdateRelationOrder(ctid);
  4471. CeErpSukuraData.createInfo(ctid, 4);
  4472. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4473. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4474. }
  4475. else
  4476. {
  4477. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4478. expInfo.state = "异常";
  4479. expInfo.Update();
  4480. }
  4481. }
  4482. }
  4483. }
  4484. }
  4485. returnSuccessMsg("操作完成");
  4486. }
  4487. public void reset_erp_memoopt()
  4488. {
  4489. if (UrlPostParmsCheck("ctid"))
  4490. {
  4491. string eid = GetPostString("ctid");
  4492. CeErpTradeCell entity = null;
  4493. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4494. if (entity != null)
  4495. {
  4496. string stropt = "";
  4497. if (entity.MemoOpt == 1)
  4498. {
  4499. stropt = "“改稿”";
  4500. }
  4501. else if (entity.MemoOpt == 2)
  4502. {
  4503. stropt = "“定稿”";
  4504. }
  4505. else if (entity.MemoOpt == 3)
  4506. {
  4507. stropt = "“完成查货”";
  4508. CeErpSukuraData.createInfo(entity.ctid, 6);
  4509. }
  4510. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4511. entity.MemoOpt = 0;
  4512. entity.Update();
  4513. returnSuccessMsg("操作成功!");
  4514. return;
  4515. }
  4516. returnErrorMsg("找不到记录");
  4517. }
  4518. }
  4519. public void get_erp_deliveryunusual()
  4520. {
  4521. DataStruct dStruct = GetPostStruct();
  4522. List<string> lw = new List<string>();
  4523. string tid = GetPostString("ctid");
  4524. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4525. string shopname = GetPostString("shopname");
  4526. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4527. string buyernick = GetPostString("buyer_nick");
  4528. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4529. string customer = GetPostString("customer");
  4530. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4531. string design = GetPostString("design");
  4532. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4533. string sellermemo = GetPostString("seller_memo");
  4534. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4535. string supplier = GetPostString("supplier");
  4536. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4537. string date1 = GetPostString("date1");
  4538. string date2 = GetPostString("date2");
  4539. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4540. if (dw.Length > 0) lw.Add(dw);
  4541. string placedate1 = GetPostString("placedate1");
  4542. string placedate2 = GetPostString("placedate2");
  4543. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4544. if (dw_place.Length > 0) lw.Add(dw_place);
  4545. string price1 = GetPostString("price1");
  4546. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4547. string price2 = GetPostString("price2");
  4548. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4549. string unusualCon = GetPostString("unusualcon");
  4550. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4551. string posTag = CurrentUser.UserPost.Post.Code;
  4552. if (posTag == "Supplier")
  4553. {
  4554. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4555. }
  4556. lw.Add(string.Format("OrderState = 6"));
  4557. lw.Add(string.Format("UnusualTag = 5"));
  4558. lw.Add(string.Format("IsRefund<={0}", 1));
  4559. dStruct.Order = "FinishPlaceTime desc";
  4560. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4561. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4562. writeGridDataTableJson(dStruct.TotalCount, dt);
  4563. }
  4564. public void get_erp_deliveryedlist()
  4565. {
  4566. DataStruct dStruct = GetPostStruct();
  4567. List<string> lw = new List<string>();
  4568. string tid = GetPostString("ctid");
  4569. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4570. string shopname = GetPostString("shopname");
  4571. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4572. string buyernick = GetPostString("buyer_nick");
  4573. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4574. string customer = GetPostString("customer");
  4575. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4576. string design = GetPostString("design");
  4577. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4578. string sellermemo = GetPostString("seller_memo");
  4579. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4580. string logistics = GetPostString("logistics");
  4581. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4582. string date1 = GetPostString("date1");
  4583. string date2 = GetPostString("date2");
  4584. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4585. //if (dw.Length > 0) lw.Add(dw);
  4586. string placedate1 = GetPostString("placedate1");
  4587. string placedate2 = GetPostString("placedate2");
  4588. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4589. if (fdw.Length > 0) lw.Add(fdw);
  4590. string devdate1 = GetPostString("deliverydate1");
  4591. string devdate2 = GetPostString("deliverydate2");
  4592. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4593. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4594. string price1 = GetPostString("price1");
  4595. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4596. string price2 = GetPostString("price2");
  4597. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4598. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4599. {
  4600. if (tid.Length > 0)
  4601. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4602. if (buyernick.Length > 0)
  4603. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4604. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4605. if (dw.Length > 0) lw.Add(dw);
  4606. }
  4607. else
  4608. {
  4609. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4610. }
  4611. string posTag = CurrentUser.UserPost.Post.Code;
  4612. if (posTag == "Supplier")
  4613. {
  4614. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4615. }
  4616. else
  4617. {
  4618. string supplier = GetPostString("supplier");
  4619. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4620. }
  4621. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4622. lw.Add(string.Format("IsRefund!={0}", 2));
  4623. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4624. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4625. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4626. /*if (tid.Length > 0)
  4627. {
  4628. List<string> tids = new List<string>();
  4629. if (dt != null && dt.Rows.Count > 0)
  4630. {
  4631. foreach (DataRow item in dt.Rows)
  4632. {
  4633. tids.Add("'" + item["tid"] + "'");
  4634. }
  4635. }
  4636. if (tids.Count > 0)
  4637. {
  4638. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4639. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4640. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4641. dt = WebCache.GetData("view_erptradecell", dStruct);
  4642. }
  4643. }*/
  4644. if (dt != null)
  4645. {
  4646. foreach (DataRow dr in dt.Rows)
  4647. {
  4648. 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();
  4649. }
  4650. }
  4651. writeGridDataTableJson(dStruct.TotalCount, dt);
  4652. }
  4653. public void get_erp_pdddeliveryed()
  4654. {
  4655. DataStruct dStruct = GetPostStruct();
  4656. List<string> lw = new List<string>();
  4657. string tid = GetPostString("ctid");
  4658. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4659. string shopname = GetPostString("shopname");
  4660. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4661. string buyernick = GetPostString("buyer_nick");
  4662. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4663. string customer = GetPostString("customer");
  4664. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4665. string design = GetPostString("design");
  4666. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4667. string sellermemo = GetPostString("seller_memo");
  4668. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4669. string logistics = GetPostString("logistics");
  4670. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4671. string date1 = GetPostString("date1");
  4672. string date2 = GetPostString("date2");
  4673. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4674. //if (dw.Length > 0) lw.Add(dw);
  4675. string placedate1 = GetPostString("placedate1");
  4676. string placedate2 = GetPostString("placedate2");
  4677. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4678. if (fdw.Length > 0) lw.Add(fdw);
  4679. string devdate1 = GetPostString("deliverydate1");
  4680. string devdate2 = GetPostString("deliverydate2");
  4681. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4682. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4683. string price1 = GetPostString("price1");
  4684. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4685. string price2 = GetPostString("price2");
  4686. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4687. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4688. {
  4689. if (tid.Length > 0)
  4690. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4691. if (buyernick.Length > 0)
  4692. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4693. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4694. if (dw.Length > 0) lw.Add(dw);
  4695. }
  4696. else
  4697. {
  4698. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4699. }
  4700. string posTag = CurrentUser.UserPost.Post.Code;
  4701. if (posTag == "Supplier")
  4702. {
  4703. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4704. }
  4705. else
  4706. {
  4707. string supplier = GetPostString("supplier");
  4708. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4709. }
  4710. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4711. lw.Add(string.Format("type = 'PDD' "));
  4712. lw.Add(string.Format("IsRefund!={0}", 2));
  4713. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4714. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4715. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4716. /* if (tid.Length > 0)
  4717. {
  4718. List<string> tids = new List<string>();
  4719. if (dt != null && dt.Rows.Count > 0)
  4720. {
  4721. foreach (DataRow item in dt.Rows)
  4722. {
  4723. tids.Add("'" + item["tid"] + "'");
  4724. }
  4725. }
  4726. if (tids.Count > 0)
  4727. {
  4728. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4729. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4730. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4731. dt = WebCache.GetData("view_erptradecell", dStruct);
  4732. }
  4733. }*/
  4734. foreach (DataRow dr in dt.Rows)
  4735. {
  4736. 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();
  4737. }
  4738. writeGridDataTableJson(dStruct.TotalCount, dt);
  4739. }
  4740. public void get_erp_jddeliveryed()
  4741. {
  4742. DataStruct dStruct = GetPostStruct();
  4743. List<string> lw = new List<string>();
  4744. string tid = GetPostString("ctid");
  4745. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4746. string shopname = GetPostString("shopname");
  4747. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4748. string buyernick = GetPostString("buyer_nick");
  4749. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4750. string customer = GetPostString("customer");
  4751. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4752. string design = GetPostString("design");
  4753. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4754. string sellermemo = GetPostString("seller_memo");
  4755. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4756. string date1 = GetPostString("date1");
  4757. string date2 = GetPostString("date2");
  4758. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4759. //if (dw.Length > 0) lw.Add(dw);
  4760. string placedate1 = GetPostString("placedate1");
  4761. string placedate2 = GetPostString("placedate2");
  4762. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4763. if (fdw.Length > 0) lw.Add(fdw);
  4764. string devdate1 = GetPostString("deliverydate1");
  4765. string devdate2 = GetPostString("deliverydate2");
  4766. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4767. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4768. string price1 = GetPostString("price1");
  4769. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4770. string price2 = GetPostString("price2");
  4771. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4772. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4773. {
  4774. if (tid.Length > 0)
  4775. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4776. if (buyernick.Length > 0)
  4777. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4778. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4779. if (dw.Length > 0) lw.Add(dw);
  4780. }
  4781. else
  4782. {
  4783. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4784. }
  4785. string posTag = CurrentUser.UserPost.Post.Code;
  4786. if (posTag == "Supplier")
  4787. {
  4788. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4789. }
  4790. else
  4791. {
  4792. string supplier = GetPostString("supplier");
  4793. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4794. }
  4795. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4796. lw.Add(string.Format("type = 'JD' "));
  4797. lw.Add(string.Format("IsRefund!={0}", 2));
  4798. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4799. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4800. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4801. foreach (DataRow dr in dt.Rows)
  4802. {
  4803. 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();
  4804. }
  4805. writeGridDataTableJson(dStruct.TotalCount, dt);
  4806. }
  4807. public void get_erp_allplacelist()
  4808. {
  4809. DataStruct dStruct = GetPostStruct();
  4810. List<string> lw = new List<string>();
  4811. string tid = GetPostString("ctid");
  4812. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4813. string shopname = GetPostString("shopname");
  4814. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4815. string buyernick = GetPostString("buyer_nick");
  4816. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4817. string customer = GetPostString("customer");
  4818. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4819. string design = GetPostString("design");
  4820. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4821. string sellermemo = GetPostString("seller_memo");
  4822. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4823. string supplier = GetPostString("supplier");
  4824. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4825. string date1 = GetPostString("date1");
  4826. string date2 = GetPostString("date2");
  4827. string pldate1 = GetPostString("placedate1");
  4828. string pldate2 = GetPostString("placedate2");
  4829. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4830. //if (dw.Length > 0) lw.Add(dw);
  4831. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4832. {
  4833. if (tid.Length > 0)
  4834. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4835. if (buyernick.Length > 0)
  4836. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4837. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4838. if (dw.Length > 0) lw.Add(dw);
  4839. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4840. if (dw_place.Length > 0) lw.Add(dw_place);
  4841. }
  4842. else
  4843. {
  4844. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4845. {
  4846. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4847. }
  4848. }
  4849. string price1 = GetPostString("price1");
  4850. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4851. string price2 = GetPostString("price2");
  4852. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4853. string posTag = CurrentUser.UserPost.Post.Code;
  4854. if (posTag == "Supplier")
  4855. {
  4856. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4857. }
  4858. lw.Add(string.Format("OrderState >= 6"));
  4859. lw.Add(string.Format("IsSample != 2 "));
  4860. lw.Add(string.Format("isDianziOrder = 0 "));
  4861. //lw.Add(string.Format("IsRefund<={0}", 1));
  4862. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4863. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4864. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4865. foreach (DataRow dr in dt.Rows)
  4866. {
  4867. 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();
  4868. }
  4869. writeGridDataTableJson(dStruct.TotalCount, dt);
  4870. }
  4871. public void get_erp_financeallplacelist()
  4872. {
  4873. DataStruct dStruct = GetPostStruct();
  4874. List<string> lw = new List<string>();
  4875. string tid = GetPostString("ctid");
  4876. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4877. string shopname = GetPostString("shopname");
  4878. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4879. string buyernick = GetPostString("buyer_nick");
  4880. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4881. string customer = GetPostString("customer");
  4882. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4883. string design = GetPostString("design");
  4884. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4885. string sellermemo = GetPostString("seller_memo");
  4886. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4887. string supplier = GetPostString("supplier");
  4888. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4889. string date1 = GetPostString("date1");
  4890. string date2 = GetPostString("date2");
  4891. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4892. if (dw.Length > 0) lw.Add(dw);
  4893. string pldate1 = GetPostString("placedate1");
  4894. string pldate2 = GetPostString("placedate2");
  4895. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4896. if (dw_place.Length > 0) lw.Add(dw_place);
  4897. string price1 = GetPostString("price1");
  4898. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4899. string price2 = GetPostString("price2");
  4900. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4901. string posTag = CurrentUser.UserPost.Post.Code;
  4902. if (posTag == "Supplier")
  4903. {
  4904. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4905. }
  4906. //lw.Add(string.Format("OrderState >= 6"));
  4907. lw.Add(string.Format("IsSample != 2 "));
  4908. lw.Add(string.Format("isDianziOrder = 0 "));
  4909. //lw.Add(string.Format("IsRefund<={0}", 1));
  4910. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4911. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4912. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4913. foreach (DataRow dr in dt.Rows)
  4914. {
  4915. 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();
  4916. }
  4917. writeGridDataTableJson(dStruct.TotalCount, dt);
  4918. }
  4919. public void get_erp_expresslist()
  4920. {
  4921. int listtype = GetInt("ltype");
  4922. DataStruct dStruct = GetPostStruct();
  4923. List<string> lw = new List<string>();
  4924. string tid = GetPostString("tid");
  4925. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4926. string outsid = GetPostString("out_sid");
  4927. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4928. string importer = GetPostString("ImportUserName");
  4929. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4930. string file = GetPostString("import_file");
  4931. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4932. string printman = GetPostString("printman");
  4933. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4934. string date1 = GetPostString("date1");
  4935. string date2 = GetPostString("date2");
  4936. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4937. if (dw.Length > 0) lw.Add(dw);
  4938. string fdate1 = GetPostString("finishdate1");
  4939. string fdate2 = GetPostString("finishdate2");
  4940. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4941. if (fdw.Length > 0) lw.Add(fdw);
  4942. string supplierId = GetPostString("supplierId");
  4943. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  4944. if (listtype == 1)
  4945. {
  4946. lw.Add(string.Format("importUserId !=0"));
  4947. }
  4948. string posTag = CurrentUser.UserPost.Post.Code;
  4949. if (posTag == "Supplier")
  4950. {
  4951. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4952. }
  4953. if (dStruct.PageSize != 100000)
  4954. {
  4955. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4956. }
  4957. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4958. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4959. writeGridDataTableJson(dStruct.TotalCount, dt);
  4960. }
  4961. public void set_erp_buchaorderdelivery()
  4962. {
  4963. if (UrlPostParmsCheck("ctid"))
  4964. {
  4965. string eid = GetPostString("ctid");
  4966. CeErpTradeCell entity = null;
  4967. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4968. if (entity != null)
  4969. {
  4970. if (entity.IsSample != 2)
  4971. {
  4972. returnErrorMsg("补差价单才能标记为已发货");
  4973. return;
  4974. }
  4975. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4976. entity.OrderState = 7;
  4977. entity.Update();
  4978. returnSuccessMsg("操作成功!");
  4979. return;
  4980. }
  4981. returnErrorMsg("找不到记录");
  4982. }
  4983. }
  4984. public void get_stdtemplates()
  4985. {
  4986. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4987. //string res = taobaoHelper.test();
  4988. string res = apiHelper.API_PrintTemplate();
  4989. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4990. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4991. {
  4992. int sidx = res.IndexOf("error_code");
  4993. int eidx = res.IndexOf("success");
  4994. string msg = res.Substring(sidx, eidx - sidx);
  4995. returnErrorMsg(msg);
  4996. return;
  4997. }
  4998. if (res.Length <= 0)
  4999. {
  5000. returnErrorMsg("模板数据为空!");
  5001. return;
  5002. }
  5003. ReturnSuccess(res);
  5004. }
  5005. public void cancel_print_order()
  5006. {
  5007. if (UrlPostParmsCheck("ctid"))
  5008. {
  5009. string ctid = GetPostString("ctid");
  5010. CeErpTradeCell entity = null;
  5011. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5012. if (entity != null)
  5013. {
  5014. string res = "";
  5015. string code = entity.LastBillWaybillCode;
  5016. if (code == "")
  5017. {
  5018. code = entity.OutSid;
  5019. }
  5020. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5021. XLog.SaveLog(0, "取消面单" + res);
  5022. }
  5023. }
  5024. }
  5025. public void set_erp_printwaybill()
  5026. {
  5027. if (UrlPostParmsCheck("ctid"))
  5028. {
  5029. string ctid = GetPostString("ctid");
  5030. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5031. string cpName = GetPostString("cpname");
  5032. string isTogether = GetPostString("together");
  5033. //var res_obj = new
  5034. //{
  5035. // restype = 1,
  5036. // 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\"}"
  5037. //};
  5038. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5039. //ReturnSuccess(ro_json);
  5040. //return;
  5041. bool isUseLastWayBillCode = false;
  5042. CeErpTradeCell entity = null;
  5043. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5044. if (entity != null)
  5045. {
  5046. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5047. {
  5048. isUseLastWayBillCode = true;
  5049. }
  5050. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5051. {
  5052. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5053. return;
  5054. }
  5055. }
  5056. string res = "";
  5057. Api_waybill_code_response_Obj fullObj = null;
  5058. string pData_str = "";
  5059. string curUseWayBillCode = "";
  5060. if (isUseLastWayBillCode == false)
  5061. {
  5062. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5063. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5064. if (res.IndexOf("failure") != -1)
  5065. {
  5066. //int idx = res.IndexOf("sub_message");
  5067. //int idx2 = res.IndexOf("flag");
  5068. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5069. string errMsgNeed = commonHelper.KeepChinese(res);
  5070. var res_objd = new
  5071. {
  5072. restype = 0,
  5073. data = "获取面单失败" + errMsgNeed
  5074. };
  5075. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5076. returnSuccess(ro_jsond);
  5077. if (res.IndexOf("停发") != -1)
  5078. {
  5079. entity.UnusualCon = "物流停发";
  5080. entity.Update();
  5081. }
  5082. //returnErrorMsg("获取面单失败,"+emsg);
  5083. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5084. return;
  5085. }
  5086. else if (res.IndexOf("errorMsg") != -1)
  5087. {
  5088. //int idx = res.IndexOf("errorMsg");
  5089. //int idx2 = res.IndexOf("}]}");
  5090. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5091. string errMsgNeed = commonHelper.KeepChinese(res);
  5092. var res_objf = new
  5093. {
  5094. restype = 0,
  5095. data = "获取面单失败2" + errMsgNeed
  5096. };
  5097. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5098. if (res.IndexOf("停发") != -1)
  5099. {
  5100. entity.UnusualCon = "物流停发";
  5101. entity.Update();
  5102. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5103. if (trade != null)
  5104. {
  5105. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5106. }
  5107. }
  5108. returnSuccess(ro_jsonf);
  5109. //returnErrorMsg("获取面单失败," + emsg);
  5110. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5111. return;
  5112. }
  5113. try
  5114. {
  5115. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5116. //res = res.Replace(" ", "");
  5117. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5118. }
  5119. catch (Exception ex)
  5120. {
  5121. XLog.SaveLog(0, "生成fullObj" + res);
  5122. var res_objf = new
  5123. {
  5124. restype = 0,
  5125. data = "生成fullObj发生错误" + ex.Message
  5126. };
  5127. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5128. returnSuccess(ro_jsonf);
  5129. return;
  5130. }
  5131. if (fullObj.response.data.content.Count > 0)
  5132. {
  5133. ContentItem codeObj = fullObj.response.data.content[0];
  5134. if (cpCode.IndexOf("SFFQ-") != -1)
  5135. {
  5136. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5137. }
  5138. else
  5139. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5140. curUseWayBillCode = codeObj.waybillCode;
  5141. }
  5142. else
  5143. {
  5144. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5145. var res_objf = new
  5146. {
  5147. restype = 0,
  5148. data = "生成fullObj找不到快递单号waybillCode"
  5149. };
  5150. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5151. returnSuccess(ro_jsonf);
  5152. return;
  5153. }
  5154. }
  5155. else
  5156. {
  5157. //使用上次打印的快递单号
  5158. if (cpCode == "SFFQ-LY")
  5159. {
  5160. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5161. }
  5162. else
  5163. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5164. curUseWayBillCode = entity.LastBillWaybillCode;
  5165. }
  5166. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5167. {
  5168. var res_obje = new
  5169. {
  5170. restype = 0,
  5171. data = "获取加密打印数据失败"
  5172. };
  5173. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5174. returnSuccess(ro_jsone);
  5175. entity.LastBillCpCode = cpCode;
  5176. entity.LastBillWaybillCode = curUseWayBillCode;
  5177. entity.Update();
  5178. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5179. //returnErrorMsg("获取加密打印数据失败");
  5180. return;
  5181. }
  5182. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5183. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5184. string btnType = "";
  5185. if (entity != null)
  5186. {
  5187. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5188. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5189. //cpcode是 YTO-CAINIAO
  5190. //string comCode = cpCode.Split('-')[0].ToString();
  5191. string apires = "";
  5192. if (ctid.IndexOf("N") != -1)
  5193. {
  5194. apires = "发货成功";
  5195. }
  5196. else
  5197. {
  5198. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5199. }
  5200. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5201. //打单后发货
  5202. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5203. {
  5204. try
  5205. {
  5206. btnType = "待发货";
  5207. entity.OutSid = curUseWayBillCode;
  5208. entity.OrderState = 7;
  5209. entity.IsUrgency = false;
  5210. entity.LastBillCpCode = "";
  5211. entity.LastBillWaybillCode = "";
  5212. entity.FinishDeliveryTime = DateTime.Now;
  5213. entity.IsReturn = 0;
  5214. entity.MemoOpt = 0;
  5215. entity.Update();
  5216. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5217. //还要插入快递信息到 快递信息表
  5218. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5219. exinfo.tid = entity.ctid;
  5220. exinfo.out_sid = entity.OutSid;
  5221. exinfo.company_code = cpCode;
  5222. exinfo.company_name = cpName;
  5223. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5224. exinfo.deliveryType = "发货成功";
  5225. exinfo.print_time = DateTime.Now;
  5226. exinfo.printUser = CurrentUser.UserName;
  5227. exinfo.Create();
  5228. commonHelper.UpdateRelationOrder(entity.ctid);
  5229. CeErpSukuraData.createInfo(ctid, 4);
  5230. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5231. if (entity.SupplierId == 64)
  5232. {
  5233. commonHelper.sendCytExpress(exinfo);
  5234. }
  5235. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5236. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5237. if (isTogether == "1")
  5238. {
  5239. StringBuilder sqlsb = new StringBuilder();
  5240. 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);
  5241. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5242. }
  5243. }
  5244. catch (Exception ex)
  5245. {
  5246. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5247. }
  5248. }
  5249. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5250. {
  5251. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5252. if (entity.OrderState == 6)
  5253. {
  5254. entity.OrderState = 7;
  5255. }
  5256. entity.FinishDeliveryTime = DateTime.Now;
  5257. btnType = "已发货";
  5258. entity.Update();
  5259. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5260. exinfo.tid = entity.ctid;
  5261. exinfo.out_sid = entity.OutSid;
  5262. exinfo.company_code = cpCode;
  5263. exinfo.company_name = cpName;
  5264. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5265. exinfo.deliveryType = "发货成功";
  5266. exinfo.print_time = DateTime.Now;
  5267. exinfo.printUser = CurrentUser.UserName;
  5268. exinfo.Create();
  5269. commonHelper.UpdateRelationOrder(entity.ctid);
  5270. CeErpSukuraData.createInfo(entity.ctid, 4);
  5271. if (entity.SupplierId == 64)
  5272. {
  5273. commonHelper.sendCytExpress(exinfo);
  5274. }
  5275. if (isTogether == "1")
  5276. {
  5277. StringBuilder sqlsb = new StringBuilder();
  5278. 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);
  5279. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5280. }
  5281. //不处理
  5282. }
  5283. else
  5284. {
  5285. entity.LastBillCpCode = cpCode;
  5286. entity.LastBillWaybillCode = curUseWayBillCode;
  5287. entity.Update();
  5288. string errmsg = commonHelper.KeepChinese(apires);
  5289. var res_objz = new
  5290. {
  5291. restype = 0,
  5292. data = "打单后发货失败"
  5293. };
  5294. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5295. returnSuccess(ro_jsonz);
  5296. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5297. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5298. return;
  5299. }
  5300. }
  5301. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5302. var res_obj = new
  5303. {
  5304. restype = 1,
  5305. data = pData_str
  5306. };
  5307. string ro_json = JsonConvert.SerializeObject(res_obj);
  5308. ReturnSuccess(ro_json);
  5309. return;
  5310. }
  5311. }
  5312. private string GetUTF8String(byte[] vs)
  5313. {
  5314. throw new NotImplementedException();
  5315. }
  5316. public void set_erp_printwaybill_cn()
  5317. {
  5318. if (UrlPostParmsCheck("ctid"))
  5319. {
  5320. string ctid = GetPostString("ctid");
  5321. string cpCode = GetPostString("cpcode");
  5322. string cpName = GetPostString("cpname");
  5323. string tempUrl = GetPostString("tempurl");
  5324. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5325. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5326. //string res = taobaoHelper.test();
  5327. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5328. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5329. {
  5330. int sidx = res.IndexOf("errorMsg");
  5331. int eidx = res.IndexOf("}");
  5332. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5333. var res_objzxx = new
  5334. {
  5335. restype = 0,
  5336. data = msg
  5337. };
  5338. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5339. returnSuccess(ro_jsonzxx);
  5340. //returnErrorMsg(msg);
  5341. return;
  5342. }
  5343. int idx = res.IndexOf("waybillCode");
  5344. int idx2 = res.IndexOf("printData");
  5345. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5346. string eid = GetPostString("ctid");
  5347. CeErpTradeCell entity = null;
  5348. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5349. if (entity != null)
  5350. {
  5351. string osid = entity.OutSid;
  5352. entity.OutSid = osid + "," + outsid;
  5353. entity.FinishDeliveryTime = DateTime.Now;
  5354. entity.OrderState = 7;
  5355. entity.IsReturn = 0;
  5356. entity.Update();
  5357. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5358. exinfo.tid = entity.ctid;
  5359. exinfo.out_sid = outsid;
  5360. exinfo.company_code = cpCode;
  5361. exinfo.company_name = cpName;
  5362. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5363. exinfo.deliveryType = "发货成功";
  5364. exinfo.print_time = DateTime.Now;
  5365. exinfo.printUser = CurrentUser.UserName;
  5366. exinfo.Create();
  5367. if (entity.SupplierId == 64)
  5368. {
  5369. commonHelper.sendCytExpress(exinfo);
  5370. }
  5371. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5372. }
  5373. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5374. var res_objz = new
  5375. {
  5376. restype = 1,
  5377. data = res
  5378. };
  5379. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5380. returnSuccess(ro_jsonz);
  5381. //ReturnSuccess(res);
  5382. }
  5383. }
  5384. ////打单,打印面单 获取面单号
  5385. //public void set_erp_printwaybill()
  5386. //{
  5387. // if (UrlPostParmsCheck("ctid"))
  5388. // {
  5389. // string ctid = GetPostString("ctid");
  5390. // string cpCode = GetPostString("cpcode");
  5391. // string tempUrl = GetPostString("tempurl");
  5392. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5393. // //string res = taobaoHelper.test();
  5394. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5395. // if (res.IndexOf("error_response") != -1)
  5396. // {
  5397. // int sidx = res.IndexOf("sub_msg");
  5398. // int eidx = res.IndexOf("request_id");
  5399. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5400. // returnErrorMsg(msg);
  5401. // return;
  5402. // }
  5403. // int idx = res.IndexOf("waybill_code");
  5404. // int idx2 = res.IndexOf("}]}");
  5405. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5406. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5407. // ReturnSuccess(res);
  5408. // }
  5409. //}
  5410. public void cancel_erp_aftersale()
  5411. {
  5412. if (UrlPostParmsCheck("ctid"))
  5413. {
  5414. string eid = GetPostString("ctid");
  5415. CeErpTradeCell entity = null;
  5416. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5417. if (entity != null)
  5418. {
  5419. //有过处理的售后,取消也不能删除 售 字,保留
  5420. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5421. {
  5422. entity.AfterSaleState = 4;
  5423. }
  5424. else
  5425. entity.AfterSaleState = 0;
  5426. entity.Update();
  5427. returnSuccessMsg("操作成功!");
  5428. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5429. return;
  5430. }
  5431. returnErrorMsg("找不到订单记录");
  5432. }
  5433. }
  5434. public void get_erp_aftersalelist()
  5435. {
  5436. DataStruct dStruct = GetPostStruct();
  5437. List<string> lw = new List<string>();
  5438. int st = GetInt("st");
  5439. string tid = GetPostString("ctid");
  5440. if (st == 3)
  5441. {
  5442. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5443. }
  5444. else
  5445. {
  5446. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5447. }
  5448. string shopname = GetPostString("shopname");
  5449. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5450. string buyernick = GetPostString("buyer_nick");
  5451. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5452. string sellermemo = GetPostString("seller_memo");
  5453. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5454. string orderState = GetPostString("orderState");
  5455. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5456. string afterState = GetPostString("afterstate");
  5457. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5458. string date1 = GetPostString("date1");
  5459. string date2 = GetPostString("date2");
  5460. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5461. if (dw.Length > 0) lw.Add(dw);
  5462. string price1 = GetPostString("price1");
  5463. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5464. string price2 = GetPostString("price2");
  5465. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5466. //lw.Add(string.Format("IsRefund!={0}", 1));
  5467. string reason = GetPostString("reason");
  5468. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5469. string method = GetPostString("method");
  5470. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5471. string handler = GetPostString("handler");
  5472. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5473. string handledate1 = GetPostString("handledate1");
  5474. string handledate2 = GetPostString("handledate2");
  5475. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5476. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5477. string finish1 = GetPostString("finishdate1");
  5478. string finish2 = GetPostString("finishdate2");
  5479. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5480. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5481. string afterdate1 = GetPostString("afterdate1");
  5482. string afterdate2 = GetPostString("afterdate2");
  5483. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5484. if (afterDate.Length > 0) lw.Add(afterDate);
  5485. string supplier = GetPostString("supplier");
  5486. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5487. string responsible = GetPostString("responsibleman");
  5488. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5489. string customer = GetPostString("customer");
  5490. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5491. string design = GetPostString("design");
  5492. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5493. string afterMemoType = GetPostString("aftermemotype");
  5494. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5495. string posCode = CurrentUser.UserPost.Post.Code;
  5496. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5497. //{
  5498. // string vstate = GetPostString("vstate");
  5499. // if (vstate.Length > 0)
  5500. // {
  5501. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5502. // }
  5503. // if (posCode == "Supplier")
  5504. // {
  5505. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5506. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5507. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5508. // }
  5509. // else
  5510. // {
  5511. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5512. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5513. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5514. // {
  5515. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5516. // }
  5517. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5518. // {
  5519. // int orgid = CurrentUser.UserPost.OrgID;
  5520. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5521. // }
  5522. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5523. // {
  5524. // string shopid = CurrentUser.User.pemShop;
  5525. // lw.Add(string.Format("shopId in ({0})", shopid));
  5526. // }
  5527. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5528. // //{
  5529. // // int org_id = CurrentUser.UserPost.OrgID;
  5530. // // lw.Add(string.Format("OrgID={0}", org_id));
  5531. // //}
  5532. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5533. // }
  5534. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5535. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5536. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5537. //}
  5538. if (st == 5)
  5539. {
  5540. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5541. {
  5542. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5543. {
  5544. string shopid = CurrentUser.User.pemShop;
  5545. lw.Add(string.Format("shopId in ({0})", shopid));
  5546. }
  5547. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5548. {
  5549. int mrOrgid = CurrentUser.UserPost.OrgID;
  5550. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5551. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5552. }
  5553. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5554. //{
  5555. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5556. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5557. //}
  5558. else
  5559. {
  5560. string userIdStr = "";
  5561. if (posCode == "CustomerService")
  5562. {
  5563. userIdStr = CurrentUser.UserID + "_k";
  5564. }
  5565. else if (posCode == "Designer" || posCode == "wxDesigner")
  5566. {
  5567. userIdStr = CurrentUser.UserID + "_s";
  5568. }
  5569. else if (posCode == "Place")
  5570. {
  5571. userIdStr = CurrentUser.UserID + "_x";
  5572. }
  5573. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5574. }
  5575. }
  5576. string placedate1 = GetPostString("placedate1");
  5577. string placedate2 = GetPostString("placedate2");
  5578. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5579. if (dwplace.Length > 0) lw.Add(dwplace);
  5580. string supState = GetPostString("supState");
  5581. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5582. string searchType = GetPostString("searchType");
  5583. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5584. {
  5585. lw.Add(string.Format("BackNum>1"));
  5586. }
  5587. lw.Add(string.Format("AfterSaleState>0"));
  5588. if (ex_psize > 0)
  5589. {
  5590. if (CurrentUser.UserPost.Post.Code == "Finance")
  5591. dStruct.Order = "pay_time desc";
  5592. else
  5593. dStruct.Order = "HandleTime desc";
  5594. }
  5595. else
  5596. dStruct.Order = "HandleTime desc";
  5597. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5598. DataTable dt = WebCache.GetData("view_test", dStruct);
  5599. writeGridDataTableJson(dStruct.TotalCount, dt);
  5600. }
  5601. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5602. //{
  5603. // lw.Add(string.Format("AfterSaleState=4"));
  5604. // string code = CurrentUser.UserPost.Post.Code;
  5605. // if (code == "CustomerService")
  5606. // {
  5607. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5608. // }
  5609. // else if (code == "Designer" || code == "DesignerMr")
  5610. // {
  5611. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5612. // }
  5613. // else if (code == "Place" || code == "PlaceMr")
  5614. // {
  5615. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5616. // }
  5617. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5618. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5619. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5620. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5621. //}
  5622. //else //处理中的售后,待处理和处理中合并
  5623. //{
  5624. // if (afterState.Length <= 0)
  5625. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5626. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5627. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5628. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5629. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5630. //}
  5631. }
  5632. public void get_erp_disagreeftersalelist()
  5633. {
  5634. DataStruct dStruct = GetPostStruct();
  5635. List<string> lw = new List<string>();
  5636. int st = 2;
  5637. string tid = GetPostString("ctid");
  5638. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5639. string shopname = GetPostString("shopname");
  5640. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5641. string buyernick = GetPostString("buyer_nick");
  5642. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5643. string sellermemo = GetPostString("seller_memo");
  5644. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5645. string orderState = GetPostString("orderState");
  5646. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5647. string afterState = GetPostString("afterstate");
  5648. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5649. string date1 = GetPostString("date1");
  5650. string date2 = GetPostString("date2");
  5651. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5652. if (dw.Length > 0) lw.Add(dw);
  5653. string price1 = GetPostString("price1");
  5654. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5655. string price2 = GetPostString("price2");
  5656. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5657. //lw.Add(string.Format("IsRefund!={0}", 1));
  5658. string reason = GetPostString("reason");
  5659. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5660. string method = GetPostString("method");
  5661. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5662. string handler = GetPostString("handler");
  5663. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5664. string handledate1 = GetPostString("handledate1");
  5665. string handledate2 = GetPostString("handledate2");
  5666. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5667. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5668. string afterdate1 = GetPostString("afterdate1");
  5669. string afterdate2 = GetPostString("afterdate2");
  5670. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5671. if (afterDate.Length > 0) lw.Add(afterDate);
  5672. string backdate1 = GetPostString("backdate1");
  5673. string backdate2 = GetPostString("backdate2");
  5674. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5675. if (backDate.Length > 0) lw.Add(backDate);
  5676. string supplier = GetPostString("supplier");
  5677. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5678. string responsible = GetPostString("responsibleman");
  5679. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5680. string customer = GetPostString("customer");
  5681. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5682. string design = GetPostString("design");
  5683. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5684. string afterSaleMemo = GetPostString("afterSaleMemo");
  5685. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5686. string afterMemoType = GetPostString("aftermemotype");
  5687. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5688. string aftersakereason = GetPostString("aftersakereason");
  5689. if (aftersakereason.Length > 0)
  5690. {
  5691. if (aftersakereason == "1")
  5692. {
  5693. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5694. }
  5695. if (aftersakereason == "2")
  5696. {
  5697. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5698. }
  5699. }
  5700. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5701. string poscode = CurrentUser.UserPost.Post.Code;
  5702. if (poscode != "SysAdmin")
  5703. {
  5704. string shopid = CurrentUser.User.pemShop;
  5705. lw.Add(string.Format("shopId in ({0})", shopid));
  5706. }
  5707. string searchType = GetPostString("searchType");
  5708. if (searchType == "wait")
  5709. {
  5710. lw.Add(string.Format("HandleTime is null"));
  5711. }
  5712. if (searchType == "handling")
  5713. {
  5714. lw.Add(string.Format("HandleTime is not null "));
  5715. }
  5716. if (searchType == "back" || searchType == "puBack")
  5717. {
  5718. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5719. }
  5720. if (searchType == "reBack")
  5721. {
  5722. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5723. }
  5724. if (searchType == "moreBack")
  5725. {
  5726. lw.Add(string.Format("backNum > 1"));
  5727. }
  5728. lw.Add(string.Format("(AfterSaleState=5)"));
  5729. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5730. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5731. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5732. writeGridDataTableJson(dStruct.TotalCount, dt);
  5733. }
  5734. public void get_erp_handlingaftersalelist()
  5735. {
  5736. DataStruct dStruct = GetPostStruct();
  5737. List<string> lw = new List<string>();
  5738. int st = 2;
  5739. string tid = GetPostString("ctid");
  5740. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5741. string shopname = GetPostString("shopname");
  5742. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5743. string buyernick = GetPostString("buyer_nick");
  5744. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5745. string sellermemo = GetPostString("seller_memo");
  5746. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5747. string orderState = GetPostString("orderState");
  5748. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5749. string afterState = GetPostString("afterstate");
  5750. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5751. string date1 = GetPostString("date1");
  5752. string date2 = GetPostString("date2");
  5753. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5754. if (dw.Length > 0) lw.Add(dw);
  5755. string price1 = GetPostString("price1");
  5756. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5757. string price2 = GetPostString("price2");
  5758. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5759. //lw.Add(string.Format("IsRefund!={0}", 1));
  5760. string reason = GetPostString("reason");
  5761. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5762. string method = GetPostString("method");
  5763. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5764. string handler = GetPostString("handler");
  5765. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5766. string handledate1 = GetPostString("handledate1");
  5767. string handledate2 = GetPostString("handledate2");
  5768. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5769. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5770. string afterdate1 = GetPostString("afterdate1");
  5771. string afterdate2 = GetPostString("afterdate2");
  5772. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5773. if (afterDate.Length > 0) lw.Add(afterDate);
  5774. string supplier = GetPostString("supplier");
  5775. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5776. string responsible = GetPostString("responsibleman");
  5777. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5778. string customer = GetPostString("customer");
  5779. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5780. string design = GetPostString("design");
  5781. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5782. string afterSaleMemo = GetPostString("afterSaleMemo");
  5783. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5784. string afterMemoType = GetPostString("aftermemotype");
  5785. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5786. string afterresult = GetPostString("afterresult");
  5787. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5788. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5789. string poscode = CurrentUser.UserPost.Post.Code;
  5790. if (poscode != "SysAdmin")
  5791. {
  5792. string shopid = CurrentUser.User.pemShop;
  5793. lw.Add(string.Format("shopId in ({0})", shopid));
  5794. }
  5795. string searchType = GetPostString("searchType");
  5796. if (searchType == "wait")
  5797. {
  5798. lw.Add(string.Format("HandleTime is null"));
  5799. }
  5800. if (searchType == "documentary")
  5801. {
  5802. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5803. }
  5804. if (searchType == "handling")
  5805. {
  5806. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5807. }
  5808. if (searchType == "back" || searchType == "puBack")
  5809. {
  5810. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5811. }
  5812. if (searchType == "reBack")
  5813. {
  5814. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5815. }
  5816. if (afterState.Length <= 0)
  5817. {
  5818. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5819. }
  5820. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5821. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5822. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5823. writeGridDataTableJson(dStruct.TotalCount, dt);
  5824. }
  5825. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5826. //public void get_erp_back_handlingaftersalelist()
  5827. //{
  5828. // DataStruct dStruct = GetPostStruct();
  5829. // List<string> lw = new List<string>();
  5830. // string tid = GetPostString("ctid");
  5831. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5832. // string shopname = GetPostString("shopname");
  5833. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5834. // string buyernick = GetPostString("buyer_nick");
  5835. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5836. // string sellermemo = GetPostString("seller_memo");
  5837. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5838. // string orderState = GetPostString("orderState");
  5839. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5840. // string afterState = GetPostString("afterstate");
  5841. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5842. // string date1 = GetPostString("date1");
  5843. // string date2 = GetPostString("date2");
  5844. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5845. // if (dw.Length > 0) lw.Add(dw);
  5846. // string price1 = GetPostString("price1");
  5847. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5848. // string price2 = GetPostString("price2");
  5849. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5850. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5851. // string reason = GetPostString("reason");
  5852. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5853. // string method = GetPostString("method");
  5854. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5855. // string handler = GetPostString("handler");
  5856. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5857. // string handledate1 = GetPostString("handledate1");
  5858. // string handledate2 = GetPostString("handledate2");
  5859. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5860. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5861. // string afterdate1 = GetPostString("afterdate1");
  5862. // string afterdate2 = GetPostString("afterdate2");
  5863. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5864. // if (afterDate.Length > 0) lw.Add(afterDate);
  5865. // string supplier = GetPostString("supplier");
  5866. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5867. // string responsible = GetPostString("responsibleman");
  5868. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5869. // string customer = GetPostString("customer");
  5870. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5871. // string design = GetPostString("design");
  5872. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5873. // string afterMemoType = GetPostString("aftermemotype");
  5874. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5875. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5876. // if (afterState.Length <= 0)
  5877. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5878. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5879. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5880. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5881. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5882. //}
  5883. public void get_erp_aftersaleverifylist()
  5884. {
  5885. DataStruct dStruct = GetPostStruct();
  5886. List<string> lw = new List<string>();
  5887. string tid = GetPostString("ctid");
  5888. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5889. string shopname = GetPostString("shopname");
  5890. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5891. string buyernick = GetPostString("buyer_nick");
  5892. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5893. string sellermemo = GetPostString("seller_memo");
  5894. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5895. string orderState = GetPostString("orderState");
  5896. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5897. //lw.Add(string.Format("IsRefund!={0}", 1));
  5898. string reason = GetPostString("reason");
  5899. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5900. string method = GetPostString("method");
  5901. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5902. string handler = GetPostString("handler");
  5903. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5904. string handledate1 = GetPostString("handledate1");
  5905. string handledate2 = GetPostString("handledate2");
  5906. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5907. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5908. string finish1 = GetPostString("finishdate1");
  5909. string finish2 = GetPostString("finishdate2");
  5910. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5911. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5912. string supplier = GetPostString("supplier");
  5913. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5914. string responsible = GetPostString("responsibleman");
  5915. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5916. string posCode = CurrentUser.UserPost.Post.Code;
  5917. string vstate = GetPostString("vstate");
  5918. if (vstate.Length > 0)
  5919. {
  5920. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5921. }
  5922. if (posCode == "Supplier")
  5923. {
  5924. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5925. lw.Add(string.Format("VerifyState = 0"));
  5926. lw.Add("type = 1");
  5927. lw.Add(string.Format("AfterSaleState={0}", 3));
  5928. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5929. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5930. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5931. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5932. writeGridDataTableJson(dStruct.TotalCount, dt);
  5933. }
  5934. else if (posCode == "logistics")
  5935. {
  5936. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5937. lw.Add(string.Format("VerifyState = 0"));
  5938. lw.Add("type = 2");
  5939. lw.Add(string.Format("AfterSaleState={0}", 3));
  5940. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5941. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5942. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5943. writeGridDataTableJson(dStruct.TotalCount, dt);
  5944. }
  5945. else
  5946. {
  5947. lw.Add(string.Format("(AfterSaleState = 3)"));
  5948. string reasonState = GetPostString("reasonState");
  5949. lw.Add("type = 0");
  5950. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5951. || posCode == "Summarize" || posCode == "Finance")
  5952. {
  5953. if (reasonState == "2")
  5954. {
  5955. lw.Add("VerifyState = 3");
  5956. }
  5957. else if (reasonState == "1")
  5958. {
  5959. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5960. }
  5961. else
  5962. {
  5963. lw.Add("VerifyState in (0,3)");
  5964. }
  5965. //不加条件,可以看全部
  5966. }
  5967. 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")
  5968. {
  5969. int orgid = CurrentUser.UserPost.OrgID;
  5970. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5971. if (string.IsNullOrEmpty(manageOrgId))
  5972. {
  5973. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5974. }
  5975. else
  5976. {
  5977. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5978. }
  5979. if (reasonState == "1")
  5980. {
  5981. lw.Add("VerifyState = 3");
  5982. }
  5983. else if (reasonState == "2")
  5984. {
  5985. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5986. }
  5987. else
  5988. {
  5989. }
  5990. }
  5991. else
  5992. {
  5993. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5994. }
  5995. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5996. //{
  5997. // int org_id = CurrentUser.UserPost.OrgID;
  5998. // lw.Add(string.Format("OrgID={0}", org_id));
  5999. //}
  6000. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6001. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6002. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6003. writeGridDataTableJson(dStruct.TotalCount, dt);
  6004. }
  6005. }
  6006. public void get_erp_finishaftersalelist()
  6007. {
  6008. DataStruct dStruct = GetPostStruct();
  6009. List<string> lw = new List<string>();
  6010. int st = 4;
  6011. string tid = GetPostString("ctid");
  6012. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  6013. string shopname = GetPostString("shopname");
  6014. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6015. //lw.Add(string.Format("IsRefund!={0}", 1));
  6016. string reason = GetPostString("reason");
  6017. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6018. string method = GetPostString("method");
  6019. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6020. string buyernick = GetPostString("buyer_nick");
  6021. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6022. string handler = GetPostString("handler");
  6023. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6024. string handledate1 = GetPostString("handledate1");
  6025. string handledate2 = GetPostString("handledate2");
  6026. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6027. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6028. string finish1 = GetPostString("finishdate1");
  6029. string finish2 = GetPostString("finishdate2");
  6030. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6031. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6032. string supplier = GetPostString("supplier");
  6033. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6034. string responsible = GetPostString("responsibleman");
  6035. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6036. string vstate = GetPostString("vstate");
  6037. if (vstate.Length > 0)
  6038. {
  6039. if ("3".Equals(vstate))
  6040. {
  6041. lw.Add(string.Format("IsTem=1"));
  6042. }
  6043. else
  6044. {
  6045. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6046. }
  6047. }
  6048. lw.Add(string.Format("AfterSaleState=4"));
  6049. string code = CurrentUser.UserPost.Post.Code;
  6050. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6051. {
  6052. //不加条件,可以看全部
  6053. }
  6054. else if (code == "Supplier")
  6055. {
  6056. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6057. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6058. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6059. }
  6060. else if (code == "logistics")
  6061. {
  6062. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6063. lw.Add("type = 2");
  6064. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6065. }
  6066. 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")
  6067. {
  6068. int orgid = CurrentUser.UserPost.OrgID;
  6069. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6070. if (string.IsNullOrEmpty(manageOrgIds))
  6071. {
  6072. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6073. }
  6074. else
  6075. {
  6076. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6077. }
  6078. }
  6079. else
  6080. {
  6081. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6082. }
  6083. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6084. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6085. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6086. writeGridDataTableJson(dStruct.TotalCount, dt);
  6087. }
  6088. public void handle_erp_aftersale()
  6089. {
  6090. if (UrlPostParmsCheck("ctid"))
  6091. {
  6092. string eid = GetPostString("ctid");
  6093. string responStr = GetPostString("AfterSaleResponsible");
  6094. if (responStr.Length <= 0)
  6095. {
  6096. returnErrorMsg("售后责任人不能为空");
  6097. return;
  6098. }
  6099. bool isDesign = false;
  6100. double designFree = 0.00;
  6101. int responsibleId = 0;
  6102. CeErpTradeCell entity = null;
  6103. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6104. if (entity != null)
  6105. {
  6106. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6107. string afterMethod = GetPostString("AfterSaleMethod");
  6108. if (isNeedNewOrder == 1)
  6109. {
  6110. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6111. bool ishav = true;
  6112. if (newentity == null)
  6113. {
  6114. newentity = entity.Clone() as CeErpTradeCell;
  6115. ishav = false;
  6116. newentity.ctid = "S_" + entity.ctid;
  6117. newentity.OrderState = 0;
  6118. }
  6119. //唯一标识
  6120. newentity.OrderSn = newentity.ctid;
  6121. /* string orderSn = dataHelper.getSaleOrderSn();
  6122. if (orderSn != "")
  6123. {
  6124. newentity.OrderSn = orderSn;
  6125. }*/
  6126. newentity.AfterSaleState = 0;
  6127. newentity.AfterSaleMethod = afterMethod;
  6128. if (!ishav)
  6129. {
  6130. string memo_str = newentity.seller_memo;
  6131. memo_str = memo_str.Replace("(", "(");
  6132. memo_str = memo_str.Replace(")", ")");
  6133. int sIndex = memo_str.IndexOf("(");
  6134. int eIndex = memo_str.IndexOf(")");
  6135. if (sIndex == -1 || eIndex == -1)
  6136. {
  6137. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6138. return;
  6139. }
  6140. string first = memo_str.Substring(0, sIndex + 1);
  6141. string memoCtid = newentity.OrderSn;
  6142. //if (memoCtid.IndexOf("C") != -1)
  6143. //{
  6144. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6145. //if (CIdx.IndexOf("+") != -1)
  6146. //{
  6147. //CIdx = "C" + CIdx.Split('+')[1];
  6148. //}
  6149. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6150. //}
  6151. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6152. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6153. string newMemo = first + memoCtid + last;
  6154. newentity.seller_memo = newMemo;
  6155. newentity.FinishPlaceTime = null;
  6156. newentity.UnusualTag = 0;
  6157. newentity.UnusualCon = "";
  6158. newentity.UnusualTime = null;
  6159. newentity.AfterSaleMemo = "";
  6160. newentity.AfterSaleMethod = afterMethod;
  6161. newentity.AfterSalePreTime = null;
  6162. newentity.AfterSaleReason = "";
  6163. newentity.AfterSaleResponsible = "";
  6164. newentity.AfterSaleState = 0;
  6165. newentity.AfterSaleTime = null;
  6166. newentity.AfterSaleUserId = 0;
  6167. newentity.AfterSaleSupplierState = 0;
  6168. newentity.LastBillWaybillCode = "";
  6169. newentity.LastBillCpCode = "";
  6170. newentity.FinishAfterSaleTime = null;
  6171. newentity.HandleTime = null;
  6172. newentity.IsSF = 0;
  6173. newentity.IsOldCustomer = 0;
  6174. newentity.UrgencyTime = null;
  6175. newentity.ResponsibleUserId = "";
  6176. newentity.IsVerifyToSupplier = false;
  6177. newentity.payment = 0;
  6178. newentity.CheckMemo = "";
  6179. newentity.OutSid = "";
  6180. newentity.CheckOrderTime = null;
  6181. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6182. }
  6183. newentity.isAfterSaleOrder = 1;
  6184. newentity.IsRefund = 0;
  6185. string receiveMobile = GetPostString("receiver_mobile");
  6186. if (receiveMobile.Length > 0)
  6187. {
  6188. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6189. if (trade != null)
  6190. {
  6191. trade.receiver_name = GetPostString("receiver_name");
  6192. trade.receiver_mobile = receiveMobile;
  6193. trade.receiver_state = GetPostString("receiver_state");
  6194. trade.receiver_city = GetPostString("receiver_city");
  6195. trade.receiver_district = GetPostString("receiver_district");
  6196. trade.receiver_address = GetPostString("receiver_address");
  6197. newentity.IsOffLineOrder = 1;
  6198. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6199. }
  6200. }
  6201. string st = GetPostString("ToState");
  6202. if (st.Length > 0)
  6203. {
  6204. if (newentity.OrderState <= 3)
  6205. {
  6206. newentity.WaitDesignTime = DateTime.Now;
  6207. newentity.StartDesignTime = null;
  6208. newentity.FinishDesignTime = null;
  6209. newentity.OrderState = 3;
  6210. if (st == "下单员")
  6211. {
  6212. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6213. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6214. {
  6215. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6216. }
  6217. }
  6218. else
  6219. {
  6220. newentity.WaitDesignTime = DateTime.Now;
  6221. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6222. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6223. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6224. {
  6225. DataRow user = dt1.Rows[0];
  6226. //找主管
  6227. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6228. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6229. if (dt != null && dt.Rows.Count > 0)
  6230. {
  6231. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6232. newentity.DesignUserId = designMr;
  6233. string key = "aftersale_order_" + designMr;
  6234. if (RedisHelper.HasKey(key))
  6235. {
  6236. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6237. list.Add(newentity.ctid);
  6238. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6239. }
  6240. }
  6241. //账号正常
  6242. if (user["State"].ToString() == "0")
  6243. {
  6244. newentity.DesignUserId = entity.DesignUserId;
  6245. string key = "aftersale_order_" + entity.DesignUserId;
  6246. if (RedisHelper.HasKey(key))
  6247. {
  6248. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6249. list.Add(newentity.ctid);
  6250. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6251. }
  6252. }
  6253. }
  6254. }
  6255. }
  6256. if (entity.IsXianHuo == 1)
  6257. {
  6258. newentity.OrderState = 6;
  6259. entity.FinishPlaceTime = DateTime.Now;
  6260. }
  6261. }
  6262. if (ishav)
  6263. {
  6264. newentity.Update();
  6265. }
  6266. else
  6267. {
  6268. newentity.Create();
  6269. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6270. newCellExtend.ctid = newentity.ctid;
  6271. newCellExtend.orderFrom = 20;
  6272. newCellExtend.orderType = 30;
  6273. if (st == "下单员")
  6274. {
  6275. }
  6276. else
  6277. {
  6278. newCellExtend.ReprintTime = DateTime.Now;
  6279. }
  6280. newCellExtend.Create();
  6281. }
  6282. if (st != "下单员")
  6283. {
  6284. designHelper.API_GetPrintData_CreateOrder(newentity);
  6285. }
  6286. }
  6287. //处理售后扩展
  6288. string resIdStr = GetPostString("ResponsibleUserId");
  6289. string refundFees = GetPostString("refundFrees");
  6290. int IsComplain = GetPostInt("isComplain");
  6291. int IsBad = GetPostInt("isBad");
  6292. string IsOriginal = GetPostString("isOriginal");
  6293. double diffResultPrice = GetPostDouble("diffResultPrice");
  6294. string textResult = GetPostString("textResult");
  6295. string supplierResponsible = GetPostString("supplierResponsible");
  6296. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6297. if (ceErpTradeAfterSaleExtend == null)
  6298. {
  6299. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6300. ceErpTradeAfterSaleExtend.tid = eid;
  6301. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6302. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6303. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6304. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6305. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6306. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6307. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6308. ceErpTradeAfterSaleExtend.Create();
  6309. }
  6310. else
  6311. {
  6312. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6313. {
  6314. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6315. }
  6316. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6317. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6318. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6319. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6320. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6321. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6322. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6323. ceErpTradeAfterSaleExtend.Update();
  6324. }
  6325. int gysid = GetPostInt("ResponsibleSupId");
  6326. if (entity.AfterSaleUserId == 0)
  6327. {
  6328. entity.AfterSaleUserId = CurrentUser.UserID;
  6329. }
  6330. entity.ResponsibleUserId = resIdStr;
  6331. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6332. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6333. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6334. {
  6335. CeErpTradeResponsible.DelByTid(eid, -1);
  6336. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6337. int backNum = 0;
  6338. if (number != null)
  6339. {
  6340. backNum = number.BackNum;
  6341. }
  6342. char[] separator = { ',' };
  6343. string[] sArray = resIdStr.Split(separator);
  6344. string[] refundFreeList = { };
  6345. if (refundFees.Length > 0)
  6346. {
  6347. refundFreeList = refundFees.Split(separator);
  6348. }
  6349. int index = -1;
  6350. foreach (string i in sArray)
  6351. {
  6352. index++;
  6353. if (i.Length <= 0) continue;
  6354. char[] separator2 = { '_' };
  6355. string idstr = i.Split(separator2)[0];
  6356. string idtype = i.Split(separator2)[1];
  6357. double refudFree = 0;
  6358. if (refundFreeList.Length > 0)
  6359. {
  6360. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6361. }
  6362. if (idtype == "s")
  6363. {
  6364. isDesign = true;
  6365. designFree = refudFree;
  6366. }
  6367. int userId = Convert.ToInt32(idstr);
  6368. int type = 0;
  6369. if (idtype == "g")
  6370. {
  6371. type = 1;
  6372. }
  6373. if (idtype == "w")
  6374. {
  6375. type = 2;
  6376. }
  6377. if (idtype == "t")
  6378. {
  6379. type = 3;
  6380. }
  6381. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6382. if (ceErpTradeResponsible == null)
  6383. {
  6384. ceErpTradeResponsible = new CeErpTradeResponsible();
  6385. ceErpTradeResponsible.tid = eid;
  6386. ceErpTradeResponsible.UserId = userId;
  6387. ceErpTradeResponsible.createdTime = DateTime.Now;
  6388. ceErpTradeResponsible.type = type;
  6389. if (type == 1)
  6390. {
  6391. ceErpTradeResponsible.IsSup = 1;
  6392. }
  6393. if (type == 2)
  6394. {
  6395. ceErpTradeResponsible.IsFlow = 1;
  6396. }
  6397. }
  6398. ceErpTradeResponsible.RefundFee = refudFree;
  6399. ceErpTradeResponsible.VerifyState = 0;
  6400. if (userId == 2125 || idtype == "w")
  6401. {
  6402. ceErpTradeResponsible.VerifyState = 1;
  6403. }
  6404. if (idtype == "w" && userId == 101)
  6405. {
  6406. ceErpTradeResponsible.VerifyState = 0;
  6407. }
  6408. if (ceErpTradeResponsible.ID > 0)
  6409. {
  6410. ceErpTradeResponsible.Update();
  6411. }
  6412. else
  6413. {
  6414. ceErpTradeResponsible.Create();
  6415. }
  6416. if (isDesign)
  6417. {
  6418. responsibleId = ceErpTradeResponsible.ID;
  6419. }
  6420. }
  6421. CeErpTradeResponsible.NumByTid(backNum, eid);
  6422. }
  6423. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6424. if (ceErpTradeCellExtend != null)
  6425. {
  6426. ceErpTradeCellExtend.returnVisit = 0;
  6427. ceErpTradeCellExtend.Update();
  6428. }
  6429. if (entity.HandleTime != null)
  6430. {
  6431. if (entity.AfterSaleState == 1)
  6432. {
  6433. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6434. }
  6435. else
  6436. {
  6437. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6438. }
  6439. }
  6440. else
  6441. {
  6442. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6443. entity.HandleTime = DateTime.Now;
  6444. }
  6445. bool isCompale = false;
  6446. if (entity.AfterSaleState == 5)
  6447. {
  6448. isCompale = true;
  6449. entity.AfterSaleState = 3;
  6450. }
  6451. entity.AfterSaleSupplierState = 0;
  6452. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6453. {
  6454. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6455. }
  6456. string sImgs = GetPostString("img");
  6457. entity.AfterSaleSupplierImg = sImgs;
  6458. entity.supRefundType = GetPostString("supRefundType");
  6459. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6460. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6461. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6462. entity.AfterSaleMemoType = GetPostString("MemoType");
  6463. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6464. {
  6465. //entity.AfterSaleSupplierState = 2;
  6466. }
  6467. string df = GetPostString("DeductFee");
  6468. if (df == "")
  6469. {
  6470. df = "0";
  6471. }
  6472. string rf = GetPostString("RefundFee");
  6473. if (rf == "")
  6474. {
  6475. rf = "0";
  6476. }
  6477. string pm = GetPostString("AfterSalePayment");
  6478. if (pm == "")
  6479. {
  6480. pm = "0";
  6481. }
  6482. entity.AfterSalePayment = Convert.ToDouble(pm);
  6483. entity.DeductFee = Convert.ToDouble(df);
  6484. entity.RefundFee = Convert.ToDouble(rf);
  6485. entity.Update();
  6486. string toState = GetPostString("ToState");
  6487. string original = GetPostString("isOriginal");
  6488. ApiVo apiVo = new ApiVo();
  6489. apiVo.orderNumber = entity.ctid;
  6490. apiVo.actionName = "afterDesign";
  6491. apiVo.orderRemarks = entity.AfterSaleMethod;
  6492. apiVo.reasonRemarks = entity.AfterSaleReason;
  6493. apiVo.isDesign = isDesign;
  6494. apiVo.designFree = designFree;
  6495. apiVo.responsibleId = responsibleId;
  6496. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6497. if (toState == "设计师")
  6498. {
  6499. apiVo.isOriginal = Convert.ToBoolean(original);
  6500. }
  6501. designHelper.API_WorkCore(apiVo);//afterDesign
  6502. CeErpMethod methodSql = new CeErpMethod();
  6503. methodSql.con = entity.AfterSaleMethod;
  6504. methodSql.addTime = DateTime.Now;
  6505. methodSql.Create();
  6506. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6507. CeErpMethod.ExecuteNonQuery(delsql);
  6508. if (isCompale)
  6509. {
  6510. aftersale_data_change(entity.ctid);
  6511. }
  6512. returnSuccessMsg("操作成功!");
  6513. return;
  6514. }
  6515. returnErrorMsg("找不到订单记录");
  6516. }
  6517. }
  6518. public void ins_erp_toresponsible()
  6519. {
  6520. if (UrlPostParmsCheck("ctid"))
  6521. {
  6522. string eid = GetPostString("ctid");
  6523. CeErpTradeCell entity = null;
  6524. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6525. if (entity != null)
  6526. {
  6527. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6528. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6529. {
  6530. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6531. return;
  6532. }
  6533. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6534. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6535. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6536. if (entity.AfterSalePreTime == null)
  6537. {
  6538. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6539. {
  6540. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6541. }
  6542. }
  6543. entity.AfterSalePreTime = DateTime.Now;
  6544. //预完成给售后主管审核客户问题直接完成
  6545. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6546. {
  6547. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6548. {
  6549. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6550. }
  6551. }
  6552. ceErpTradeAfterSaleExtend.Update();
  6553. entity.AfterSaleState = 2;
  6554. entity.Update();
  6555. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6556. aftersale_data_change(entity.ctid);
  6557. returnSuccessMsg("操作成功!");
  6558. return;
  6559. }
  6560. returnErrorMsg("找不到订单记录");
  6561. }
  6562. }
  6563. public void cancel_erp_aftersaleanddelnew()
  6564. {
  6565. if (UrlPostParmsCheck("ctid"))
  6566. {
  6567. string eid = GetPostString("ctid");
  6568. CeErpTradeCell entity = null;
  6569. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6570. if (entity != null)
  6571. {
  6572. entity.AfterSaleState = 0;
  6573. entity.AfterSaleReason = "";
  6574. entity.AfterSaleMethod = "";
  6575. entity.AfterSaleMemo = "";
  6576. entity.AfterSaleResponsible = "";
  6577. entity.ResponsibleUserId = "";
  6578. entity.DeductFee = 0;
  6579. entity.RefundFee = 0;
  6580. entity.IsArbitrate = 0;
  6581. CeErpTradeResponsible.DelByTid(eid, -1);
  6582. entity.Update();
  6583. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6584. if (after != null)
  6585. {
  6586. if (after.OrderState < 5)
  6587. CeErpTradeCell.DelByCtid("S_" + eid);
  6588. }
  6589. returnSuccessMsg("操作成功!");
  6590. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6591. return;
  6592. }
  6593. returnErrorMsg("找不到订单记录");
  6594. }
  6595. }
  6596. public void get_erp_aftersale_pregather()
  6597. {
  6598. List<string> lw = new List<string>();
  6599. int st = GetInt("st");
  6600. string tid = GetPostString("ctid");
  6601. if (tid.Length > 0) lw.Add(string.Format("(tid = '{0}' or ctid = '{0}' or orderSn = '{0}')", tid));
  6602. string shopname = GetPostString("shopname");
  6603. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6604. string buyernick = GetPostString("buyer_nick");
  6605. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6606. string sellermemo = GetPostString("seller_memo");
  6607. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6608. string orderState = GetPostString("orderState");
  6609. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6610. string reason = GetPostString("reason");
  6611. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6612. string method = GetPostString("method");
  6613. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6614. string handler = GetPostString("handler");
  6615. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6616. string handledate1 = GetPostString("handledate1");
  6617. string handledate2 = GetPostString("handledate2");
  6618. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6619. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6620. string supplier = GetPostString("supplier");
  6621. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6622. string responsible = GetPostString("responsibleman");
  6623. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6624. string customer = GetPostString("customer");
  6625. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6626. string design = GetPostString("design");
  6627. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6628. string afterMemoType = GetPostString("aftermemotype");
  6629. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6630. string afterSaleMemo = GetPostString("afterSaleMemo");
  6631. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6632. string afterresult = GetPostString("afterresult");
  6633. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6634. string poscode = CurrentUser.UserPost.Post.Code;
  6635. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6636. {
  6637. string shopid = CurrentUser.User.pemShop;
  6638. lw.Add(string.Format("shopId in ({0})", shopid));
  6639. }
  6640. var mainwhere = string.Join(" and ", lw.ToArray());
  6641. string ro_json = "";
  6642. string type = GetPostString("gather_type");
  6643. if (poscode == "AfterSale")
  6644. {
  6645. //处理中
  6646. if (type == "Handling")
  6647. {
  6648. 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) : ""));
  6649. DataTable dt = null;
  6650. try
  6651. {
  6652. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6653. }
  6654. catch (Exception e)
  6655. {
  6656. dt = new DataTable();
  6657. }
  6658. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6659. return;
  6660. }
  6661. if (type == "Wait")
  6662. {
  6663. //待处理
  6664. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6665. DataTable dt1 = null;
  6666. try
  6667. {
  6668. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6669. }
  6670. catch (Exception e)
  6671. {
  6672. dt1 = new DataTable();
  6673. }
  6674. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6675. return;
  6676. }
  6677. if (type == "back")
  6678. {
  6679. //打回
  6680. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6681. DataTable dt2 = null;
  6682. try
  6683. {
  6684. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6685. }
  6686. catch (Exception e)
  6687. {
  6688. dt2 = new DataTable();
  6689. }
  6690. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6691. return;
  6692. }
  6693. if (type == "preCompletion")
  6694. {
  6695. //预完成
  6696. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6697. DataTable dt3 = null;
  6698. try
  6699. {
  6700. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6701. }
  6702. catch (Exception e)
  6703. {
  6704. dt3 = new DataTable();
  6705. }
  6706. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6707. return;
  6708. }
  6709. if (type == "documentary")
  6710. {
  6711. //跟单中
  6712. 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) : ""));
  6713. DataTable dt4 = null;
  6714. try
  6715. {
  6716. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6717. }
  6718. catch (Exception e)
  6719. {
  6720. dt4 = new DataTable();
  6721. }
  6722. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6723. return;
  6724. }
  6725. if (type == "reBack")
  6726. {
  6727. //被打回
  6728. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6729. DataTable dt1 = null;
  6730. try
  6731. {
  6732. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6733. }
  6734. catch (Exception e)
  6735. {
  6736. dt1 = new DataTable();
  6737. }
  6738. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6739. return;
  6740. }
  6741. }
  6742. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6743. {
  6744. if (type == "puBack")
  6745. {
  6746. //退回
  6747. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6748. DataTable dt = null;
  6749. try
  6750. {
  6751. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6752. }
  6753. catch (Exception e)
  6754. {
  6755. dt = new DataTable();
  6756. }
  6757. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6758. return;
  6759. }
  6760. if (type == "reBack")
  6761. {
  6762. //打回
  6763. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6764. DataTable dt1 = null;
  6765. try
  6766. {
  6767. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6768. }
  6769. catch (Exception e)
  6770. {
  6771. dt1 = new DataTable();
  6772. }
  6773. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6774. return;
  6775. }
  6776. if (type == "examEd")
  6777. {
  6778. //已审核
  6779. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6780. DataTable dt2 = null;
  6781. try
  6782. {
  6783. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6784. }
  6785. catch (Exception e)
  6786. {
  6787. dt2 = new DataTable();
  6788. }
  6789. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6790. return;
  6791. }
  6792. if (type == "waitExam")
  6793. {
  6794. //待审核
  6795. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6796. DataTable dt3 = null;
  6797. try
  6798. {
  6799. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6800. }
  6801. catch (Exception e)
  6802. {
  6803. dt3 = new DataTable();
  6804. }
  6805. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6806. return;
  6807. }
  6808. if (type == "Handling")
  6809. {
  6810. //处理中
  6811. 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) : ""));
  6812. DataTable dt4 = null;
  6813. try
  6814. {
  6815. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6816. }
  6817. catch (Exception e)
  6818. {
  6819. dt4 = new DataTable();
  6820. }
  6821. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6822. return;
  6823. }
  6824. if (type == "Wait")
  6825. {
  6826. //待处理
  6827. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6828. DataTable dt5 = null;
  6829. try
  6830. {
  6831. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6832. }
  6833. catch (Exception e)
  6834. {
  6835. dt5 = new DataTable();
  6836. }
  6837. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6838. return;
  6839. }
  6840. if (type == "documentary")
  6841. {
  6842. //跟单中
  6843. 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) : ""));
  6844. DataTable dt6 = null;
  6845. try
  6846. {
  6847. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6848. }
  6849. catch (Exception e)
  6850. {
  6851. dt6 = new DataTable();
  6852. }
  6853. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6854. return;
  6855. }
  6856. }
  6857. returnSuccess(ro_json);
  6858. }
  6859. public void end_erp_aftersale()
  6860. {
  6861. if (UrlPostParmsCheck("ctid"))
  6862. {
  6863. string eid = GetPostString("ctid");
  6864. CeErpTradeCell entity = null;
  6865. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6866. if (entity != null)
  6867. {
  6868. string stype = GetPostString("stype");
  6869. string typeStr = stype;
  6870. entity.AfterSaleState = 4;
  6871. entity.FinishAfterSaleTime = DateTime.Now;
  6872. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6873. entity.Update();
  6874. ApiVo apiVo = new ApiVo();
  6875. apiVo.orderNumber = entity.ctid;
  6876. apiVo.actionName = "afterOver";
  6877. designHelper.API_WorkCore(apiVo); //afterOver
  6878. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6879. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6880. CeErpSukuraData.createInfo(entity.ctid, 8);
  6881. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6882. returnSuccessMsg("操作成功!");
  6883. return;
  6884. }
  6885. returnErrorMsg("找不到订单记录");
  6886. }
  6887. }
  6888. public void ins_erp_finishaftersale()
  6889. {
  6890. if (UrlPostParmsCheck("id"))
  6891. {
  6892. string eid = GetPostString("id");
  6893. CeErpTradeResponsible entity = null;
  6894. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6895. if (entity != null)
  6896. {
  6897. entity.VerifyState = 1;
  6898. entity.VerifyTime = DateTime.Now;
  6899. entity.Update();
  6900. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6901. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6902. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6903. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6904. if (dt.Rows.Count <= 0)
  6905. {
  6906. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6907. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6908. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6909. CeErpSukuraData.createInfo(entity.tid, 8);
  6910. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6911. {
  6912. CeErpDesignerBill.Del(entity.tid);
  6913. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6914. }
  6915. }
  6916. returnSuccessMsg("操作成功!");
  6917. return;
  6918. }
  6919. returnErrorMsg("找不到订单记录");
  6920. }
  6921. }
  6922. public void upd_erp_arbitrateaftersale()
  6923. {
  6924. if (UrlPostParmsCheck("id"))
  6925. {
  6926. string eid = GetPostString("id");
  6927. CeErpTradeResponsible entity = null;
  6928. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6929. if (entity != null)
  6930. {
  6931. entity.IsArbitrate = 1;
  6932. entity.ArbitradeMemo = GetPostString("reason");
  6933. entity.VerifyState = 2;
  6934. entity.Update();
  6935. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6936. if (tradecell != null)
  6937. {
  6938. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6939. tradecell.IsArbitrate = 1;
  6940. tradecell.Update();
  6941. }
  6942. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6943. returnSuccessMsg("操作成功!");
  6944. return;
  6945. }
  6946. returnErrorMsg("找不到订单记录");
  6947. }
  6948. }
  6949. public void upd_erp_backaftersale()
  6950. {
  6951. if (UrlPostParmsCheck("tid"))
  6952. {
  6953. string eid = GetPostString("tid");
  6954. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6955. int backNum = 0;
  6956. if (number != null)
  6957. {
  6958. backNum = number.BackNum;
  6959. }
  6960. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6961. CeErpTradeCell entity = null;
  6962. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6963. if (entity != null)
  6964. {
  6965. entity.AfterSaleBackReason = GetPostString("backreason");
  6966. entity.AfterSaleState = 1;
  6967. entity.AfterSaleSupplierState = 0;
  6968. entity.Update();
  6969. returnSuccessMsg("操作成功!");
  6970. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6971. return;
  6972. }
  6973. returnErrorMsg("找不到订单记录");
  6974. }
  6975. }
  6976. public void get_erp_supplieraftersalelist()
  6977. {
  6978. DataStruct dStruct = GetPostStruct();
  6979. List<string> lw = new List<string>();
  6980. string tid = GetPostString("ctid");
  6981. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6982. string shopname = GetPostString("shopname");
  6983. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6984. string buyernick = GetPostString("buyer_nick");
  6985. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6986. string sellermemo = GetPostString("seller_memo");
  6987. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6988. string orderState = GetPostString("orderState");
  6989. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6990. string afterState = GetPostString("afterstate");
  6991. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6992. string date1 = GetPostString("date1");
  6993. string date2 = GetPostString("date2");
  6994. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6995. if (dw.Length > 0) lw.Add(dw);
  6996. string price1 = GetPostString("price1");
  6997. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6998. string price2 = GetPostString("price2");
  6999. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7000. string reason = GetPostString("reason");
  7001. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7002. string method = GetPostString("method");
  7003. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7004. string handledate1 = GetPostString("handledate1");
  7005. string handledate2 = GetPostString("handledate2");
  7006. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7007. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7008. string handler = GetPostString("handler");
  7009. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7010. string afterdate1 = GetPostString("afterdate1");
  7011. string afterdate2 = GetPostString("afterdate2");
  7012. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7013. if (afterDate.Length > 0) lw.Add(afterDate);
  7014. string customer = GetPostString("customer");
  7015. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7016. string design = GetPostString("design");
  7017. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7018. string afterMemoType = GetPostString("aftermemotype");
  7019. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7020. string vstate = GetPostString("vstate");
  7021. if (vstate.Length > 0)
  7022. {
  7023. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7024. }
  7025. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7026. string supplier = GetPostString("supplier");
  7027. int supid = commonHelper.getSupplierIDByName(supplier);
  7028. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7029. string posCode = CurrentUser.UserPost.Post.Code;
  7030. if (posCode == "Supplier")
  7031. {
  7032. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7033. }
  7034. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7035. {
  7036. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7037. }
  7038. else
  7039. {
  7040. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7041. }
  7042. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7043. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7044. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7045. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7046. writeGridDataTableJson(dStruct.TotalCount, dt);
  7047. }
  7048. public void upd_erp_supverifyaftersale()
  7049. {
  7050. if (UrlPostParmsCheck("id"))
  7051. {
  7052. string id = GetPostString("id");
  7053. int st = GetPostInt("afterstate");
  7054. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7055. CeErpTradeCell entity = null;
  7056. if (ceErpTradeResponsible != null)
  7057. {
  7058. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7059. }
  7060. string afmemo = GetPostString("supmemo");
  7061. string image = GetPostString("image");
  7062. if (entity != null)
  7063. {
  7064. entity.AfterSaleSupplierState = st;
  7065. entity.AfterSaleSupplierMemo = afmemo;
  7066. if (st == 1)
  7067. {
  7068. ceErpTradeResponsible.VerifyState = 1;
  7069. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7070. ceErpTradeResponsible.Update();
  7071. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7072. if (isAll)
  7073. {
  7074. entity.AfterSaleState = 4;
  7075. entity.FinishAfterSaleTime = DateTime.Now;
  7076. }
  7077. }
  7078. else
  7079. {
  7080. CeErpTradeResponsible.dateByTid(entity.ctid);
  7081. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7082. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7083. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7084. if (num <= 1)
  7085. {
  7086. entity.AfterSaleState = 1;
  7087. }
  7088. else
  7089. {
  7090. entity.AfterSaleState = 5;
  7091. }
  7092. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7093. if (ceErpTradeAfterSaleExtend != null)
  7094. {
  7095. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7096. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7097. ceErpTradeAfterSaleExtend.Update();
  7098. }
  7099. else
  7100. {
  7101. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7102. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7103. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7104. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7105. ceErpTradeAfterSaleExtend.Create();
  7106. }
  7107. }
  7108. if (entity.AfterSaleState == 4)
  7109. {
  7110. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7111. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7112. {
  7113. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7114. }
  7115. ApiVo apiVo = new ApiVo();
  7116. apiVo.orderNumber = entity.ctid;
  7117. apiVo.actionName = "afterOver";
  7118. designHelper.API_WorkCore(apiVo); //afterOver
  7119. }
  7120. entity.Update();
  7121. returnSuccessMsg("操作成功!");
  7122. CeErpSukuraData.createInfo(entity.ctid, 8);
  7123. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7124. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7125. return;
  7126. }
  7127. returnErrorMsg("找不到订单记录");
  7128. }
  7129. }
  7130. public void upd_erp_masteraftersale()
  7131. {
  7132. if (UrlPostParmsCheck("id"))
  7133. {
  7134. string id = GetPostString("id");
  7135. int st = GetPostInt("afterstate");
  7136. string afmemo = GetPostString("supmemo");
  7137. string image = GetPostString("image");
  7138. string textResult = GetPostString("textResult");
  7139. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7140. if (ceErpTradeResponsible != null)
  7141. {
  7142. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7143. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7144. ceErpTradeResponsible.Update();
  7145. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7146. if (entity != null)
  7147. {
  7148. entity.AfterSaleSupplierState = st;
  7149. entity.AfterSaleSupplierMemo = afmemo;
  7150. if (st == 1)
  7151. {
  7152. }
  7153. else
  7154. {
  7155. CeErpTradeResponsible.dateByTid(entity.ctid);
  7156. //退回到售后
  7157. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7158. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7159. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7160. if (num <= 1)
  7161. {
  7162. entity.AfterSaleState = 1;
  7163. }
  7164. else
  7165. {
  7166. entity.AfterSaleState = 5;
  7167. }
  7168. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7169. if (ceErpTradeAfterSaleExtend != null)
  7170. {
  7171. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7172. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7173. ceErpTradeAfterSaleExtend.Update();
  7174. }
  7175. else
  7176. {
  7177. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7178. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7179. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7180. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7181. ceErpTradeAfterSaleExtend.Create();
  7182. }
  7183. }
  7184. entity.Update();
  7185. returnSuccessMsg("操作成功!");
  7186. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7187. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7188. return;
  7189. }
  7190. }
  7191. returnErrorMsg("找不到订单记录");
  7192. }
  7193. }
  7194. public void upd_erp_personaftersale()
  7195. {
  7196. if (UrlPostParmsCheck("id"))
  7197. {
  7198. string id = GetPostString("id");
  7199. int st = GetPostInt("afterstate");
  7200. string afmemo = GetPostString("supmemo");
  7201. string image = GetPostString("image");
  7202. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7203. if (ceErpTradeResponsible != null)
  7204. {
  7205. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7206. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7207. ceErpTradeResponsible.Update();
  7208. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7209. if (entity != null)
  7210. {
  7211. entity.AfterSaleSupplierMemo = afmemo;
  7212. entity.AfterSaleSupplierState = st;
  7213. if (st == 1)
  7214. {
  7215. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7216. if (isAll)
  7217. {
  7218. entity.AfterSaleState = 4;
  7219. entity.FinishAfterSaleTime = DateTime.Now;
  7220. }
  7221. }
  7222. else
  7223. {
  7224. CeErpTradeResponsible.dateByTid(entity.ctid);
  7225. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7226. if (ceErpTradeAfterSaleExtend != null)
  7227. {
  7228. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7229. ceErpTradeAfterSaleExtend.Update();
  7230. }
  7231. else
  7232. {
  7233. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7234. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7235. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7236. ceErpTradeAfterSaleExtend.Create();
  7237. }
  7238. //退回到主管
  7239. //entity.AfterSaleState = 2;
  7240. }
  7241. if (entity.AfterSaleState == 4)
  7242. {
  7243. ApiVo apiVo = new ApiVo();
  7244. apiVo.orderNumber = entity.ctid;
  7245. apiVo.actionName = "afterOver";
  7246. designHelper.API_WorkCore(apiVo); //afterOver
  7247. }
  7248. entity.Update();
  7249. returnSuccessMsg("操作成功!");
  7250. CeErpSukuraData.createInfo(entity.ctid, 8);
  7251. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7252. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7253. return;
  7254. }
  7255. }
  7256. returnErrorMsg("找不到订单记录");
  7257. }
  7258. }
  7259. public void set_erp_supplierrefundtag()
  7260. {
  7261. if (UrlPostParmsCheck("ctid"))
  7262. {
  7263. string eid = GetPostString("ctid");
  7264. CeErpTradeCell entity = null;
  7265. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7266. if (entity != null)
  7267. {
  7268. entity.IsSupplierRefund = GetPostInt("tag");
  7269. entity.Update();
  7270. returnSuccessMsg("操作成功!");
  7271. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7272. return;
  7273. }
  7274. returnErrorMsg("找不到订单记录");
  7275. }
  7276. }
  7277. public void get_erp_refundlist()
  7278. {
  7279. DataStruct dStruct = GetPostStruct();
  7280. List<string> lw = new List<string>();
  7281. string tid = GetPostString("tid");
  7282. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7283. //string rid = GetPostString("refund_id");
  7284. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7285. string shopname = GetPostString("shopname");
  7286. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7287. string buyernick = GetPostString("buyer_nick");
  7288. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7289. string customer = GetPostString("customer");
  7290. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7291. string design = GetPostString("design");
  7292. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7293. string sellermemo = GetPostString("seller_memo");
  7294. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7295. //string date1 = GetPostString("date1");
  7296. //string date2 = GetPostString("date2");
  7297. //string dateType = GetPostString("dateType");
  7298. //if (dateType.Length > 0)
  7299. //{
  7300. // if (dateType == "1001") dateType = "0";
  7301. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7302. // if (searchDT.Count == 2)
  7303. // {
  7304. // date1 = searchDT[0].ToString();
  7305. // date2 = searchDT[1].ToString();
  7306. // }
  7307. //}
  7308. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7309. //if (dw.Length > 0) lw.Add(dw);
  7310. string redate1 = GetPostString("refunddate1");
  7311. string redate2 = GetPostString("refunddate2");
  7312. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7313. if (dwdate.Length > 0) lw.Add(dwdate);
  7314. string price1 = GetPostString("price1");
  7315. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7316. string price2 = GetPostString("price2");
  7317. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7318. string ispartrefund = GetPostString("ispartrefund");
  7319. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7320. string refundState = GetPostString("refundvstate");
  7321. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7322. int st = GetInt("st");
  7323. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7324. {
  7325. string responsible = GetPostString("responsibleman");
  7326. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7327. lw.Add(string.Format("RefundState>={0}", st));
  7328. string code = CurrentUser.UserPost.Post.Code;
  7329. if (code == "CustomerService")
  7330. {
  7331. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7332. }
  7333. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7334. {
  7335. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7336. }
  7337. else if (code == "Place" || code == "PlaceMr")
  7338. {
  7339. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7340. }
  7341. dStruct.Order = "RefundState asc,created desc";
  7342. }
  7343. else if (st == 10)
  7344. {
  7345. string responsible = GetPostString("responsibleman");
  7346. if (responsible == "空白")
  7347. {
  7348. lw.Add(string.Format("ResponsibleUserName = ''"));
  7349. }
  7350. else if (responsible.Length > 0)
  7351. {
  7352. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7353. }
  7354. lw.Add(string.Format("RefundState>=0"));
  7355. dStruct.Order = "created desc";
  7356. }
  7357. else
  7358. {
  7359. string responsible = GetPostString("responsibleman");
  7360. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7361. lw.Add(string.Format("RefundState={0}", st));
  7362. dStruct.Order = "created desc";
  7363. }
  7364. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7365. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7366. dt.Columns.Add("refund_fees");
  7367. foreach (DataRow dr in dt.Rows)
  7368. {
  7369. String status = dr["status"].ToString();
  7370. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7371. {
  7372. dr["refund_fees"] = dr["refund_fee"];
  7373. }
  7374. else
  7375. {
  7376. dr["refund_fees"] = "0.0";
  7377. }
  7378. }
  7379. writeGridDataTableJson(dStruct.TotalCount, dt);
  7380. }
  7381. public void get_erp_refunddesignlist()
  7382. {
  7383. DataStruct dStruct = GetPostStruct();
  7384. List<string> lw = new List<string>();
  7385. string tid = GetPostString("tid");
  7386. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7387. string shopname = GetPostString("shopname");
  7388. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7389. string buyernick = GetPostString("buyer_nick");
  7390. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7391. string customer = GetPostString("customer");
  7392. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7393. string design = GetPostString("design");
  7394. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7395. string sellermemo = GetPostString("seller_memo");
  7396. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7397. string redate1 = GetPostString("refunddate1");
  7398. string redate2 = GetPostString("refunddate2");
  7399. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7400. if (dwdate.Length > 0) lw.Add(dwdate);
  7401. string price1 = GetPostString("price1");
  7402. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7403. string price2 = GetPostString("price2");
  7404. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7405. string ispartrefund = GetPostString("ispartrefund");
  7406. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7407. string designerorg = GetPostString("designerorg");
  7408. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7409. string refundState = GetPostString("refundState");
  7410. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7411. int myOrgid = CurrentUser.UserPost.OrgID;
  7412. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7413. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7414. {
  7415. if (CurrentUser.User.TeamIds.Length > 0)
  7416. {
  7417. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7418. }
  7419. else
  7420. {
  7421. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7422. }
  7423. }
  7424. else if ("SysAdmin".Equals(myOrgCode))
  7425. {
  7426. }
  7427. else
  7428. {
  7429. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7430. {
  7431. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7432. }
  7433. else
  7434. {
  7435. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7436. }
  7437. }
  7438. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7439. dStruct.Order = "created desc";
  7440. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7441. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7442. dt.Columns.Add("refund_fees");
  7443. foreach (DataRow dr in dt.Rows)
  7444. {
  7445. String status = dr["status"].ToString();
  7446. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7447. {
  7448. dr["refund_fees"] = dr["refund_fee"];
  7449. }
  7450. else
  7451. {
  7452. dr["refund_fees"] = "0.0";
  7453. }
  7454. }
  7455. writeGridDataTableJson(dStruct.TotalCount, dt);
  7456. }
  7457. public void handle_erp_refundtag()
  7458. {
  7459. if (UrlPostParmsCheck("refund_id"))
  7460. {
  7461. string eid = GetPostString("refund_id");
  7462. string respMan = GetPostString("ResponsibleName");
  7463. if (respMan.Length <= 0)
  7464. {
  7465. returnErrorMsg("责任人不能为空");
  7466. return;
  7467. }
  7468. CeErpTradeRefund entity = null;
  7469. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7470. if (entity != null)
  7471. {
  7472. entity.ResponsibleUserName = respMan;
  7473. string userid = GetPostString("ResponsibleUserId");
  7474. if (userid.Length > 0)
  7475. {
  7476. entity.ResponsibleUserId = userid;
  7477. }
  7478. entity.Memo = GetPostString("Memo");
  7479. if (respMan.IndexOf("客服") != -1 ||
  7480. respMan.IndexOf("设计师") != -1 ||
  7481. respMan.IndexOf("下单员") != -1)
  7482. {
  7483. entity.RefundState = 2;
  7484. }
  7485. else
  7486. {
  7487. entity.RefundState = 3;
  7488. }
  7489. entity.modified = DateTime.Now;
  7490. entity.Update();
  7491. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7492. returnSuccessMsg("操作成功!");
  7493. return;
  7494. }
  7495. returnErrorMsg("找不到订单记录");
  7496. }
  7497. }
  7498. public void handle_erp_designrefundtag()
  7499. {
  7500. if (UrlPostParmsCheck("refund_id"))
  7501. {
  7502. string eid = GetPostString("refund_id");
  7503. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7504. if (ceErpTradeCellExtend == null)
  7505. {
  7506. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7507. ceErpTradeCellExtend.ctid = eid;
  7508. }
  7509. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7510. if (ceErpTradeCellExtend.ID > 0)
  7511. {
  7512. ceErpTradeCellExtend.Update();
  7513. }
  7514. else
  7515. {
  7516. ceErpTradeCellExtend.Create();
  7517. }
  7518. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7519. returnSuccessMsg("操作成功!");
  7520. return;
  7521. }
  7522. returnErrorMsg("找不到订单记录");
  7523. }
  7524. public void upd_erp_refundverify()
  7525. {
  7526. if (UrlPostParmsCheck("refund_id"))
  7527. {
  7528. string eid = GetPostString("refund_id");
  7529. CeErpTradeRefund entity = null;
  7530. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7531. if (entity != null)
  7532. {
  7533. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7534. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7535. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7536. {
  7537. entity.RefundState = 2;
  7538. }
  7539. else
  7540. {
  7541. entity.RefundState = 3;
  7542. }
  7543. entity.Update();
  7544. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7545. returnSuccessMsg("操作成功!");
  7546. return;
  7547. }
  7548. returnErrorMsg("找不到订单记录");
  7549. }
  7550. }
  7551. public void upd_erp_refundapprove()
  7552. {
  7553. if (UrlPostParmsCheck("refund_id"))
  7554. {
  7555. string eid = GetPostString("refund_id");
  7556. CeErpTradeRefund entity = null;
  7557. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7558. if (entity != null)
  7559. {
  7560. int apr = GetPostInt("approve");
  7561. if (apr == 0)
  7562. {
  7563. entity.RefundState = 1;
  7564. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7565. }
  7566. else if (apr == 1)
  7567. {
  7568. entity.RefundState = 3;
  7569. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7570. }
  7571. entity.modified = DateTime.Now;
  7572. entity.Update();
  7573. returnSuccessMsg("操作成功!");
  7574. return;
  7575. }
  7576. returnErrorMsg("找不到订单记录");
  7577. }
  7578. }
  7579. public void get_erp_billlist()
  7580. {
  7581. DataStruct dStruct = GetPostStruct();
  7582. List<string> lw = new List<string>();
  7583. string title = GetPostString("title");
  7584. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7585. string tid = GetPostString("tid");
  7586. string tids = GetPostString("tids");
  7587. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7588. if (tids.Length > 0)
  7589. {
  7590. tids = "'" + tids + "'";
  7591. tids = tids.Replace(",", "','");
  7592. lw.Add(string.Format("tid in ({0})", tids));
  7593. }
  7594. string shopname = GetPostString("shopname");
  7595. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7596. string buyernick = GetPostString("buyer_nick");
  7597. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7598. string customer = GetPostString("customer");
  7599. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7600. string date1 = GetPostString("date1");
  7601. string date2 = GetPostString("date2");
  7602. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7603. if (dw.Length > 0) lw.Add(dw);
  7604. string price1 = GetPostString("price1");
  7605. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7606. string price2 = GetPostString("price2");
  7607. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7608. string returndate1 = GetPostString("returndate1");
  7609. string returndate2 = GetPostString("returndate2");
  7610. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7611. if (dw1.Length > 0) lw.Add(dw1);
  7612. string billtype = GetPostString("billtype");
  7613. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7614. string billstate = GetPostString("billstate");
  7615. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7616. string usershop = CurrentUser.User.pemShop;
  7617. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7618. dStruct.Order = "createTime desc";
  7619. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7620. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7621. //foreach (DataRow dr in dt.Rows)
  7622. //{
  7623. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7624. //}
  7625. writeGridDataTableJson(dStruct.TotalCount, dt);
  7626. }
  7627. public void modify_erp_billinfo()
  7628. {
  7629. if (UrlPostParmsCheck("ID"))
  7630. {
  7631. string eid = GetPostString("ID");
  7632. CeErpBill bill_entity = null;
  7633. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7634. if (bill_entity != null)
  7635. {
  7636. bill_entity.tid = GetPostString("tid");
  7637. bill_entity.title = GetPostString("title");
  7638. bill_entity.tax = GetPostString("tax");
  7639. bill_entity.bank = GetPostString("bank");
  7640. bill_entity.bankac = GetPostString("bankac");
  7641. bill_entity.address = GetPostString("address");
  7642. bill_entity.phone = GetPostString("phone");
  7643. bill_entity.price = GetPostString("price");
  7644. bill_entity.productId = GetPostInt("ProductName");
  7645. bill_entity.num = GetPostInt("num");
  7646. bill_entity.unit = GetPostString("unit");
  7647. bill_entity.type = GetPostString("type");
  7648. bill_entity.sendType = GetPostString("SendType");
  7649. bill_entity.email = GetPostString("email");
  7650. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7651. bill_entity.shopName = GetPostString("ShopName");
  7652. bill_entity.applymemo = GetPostString("applymemo");
  7653. bill_entity.modifyTime = DateTime.Now;
  7654. bill_entity.createTime = DateTime.Now;
  7655. bill_entity.state = 0;
  7656. bill_entity.Update();
  7657. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7658. returnSuccessMsg("发票修改成功!");
  7659. return;
  7660. }
  7661. returnErrorMsg("找不到对应记录");
  7662. }
  7663. }
  7664. public void set_erp_invoicing()
  7665. {
  7666. if (UrlPostParmsCheck("id"))
  7667. {
  7668. try
  7669. {
  7670. string eid = GetPostString("id");
  7671. CeErpBill bill_entity = null;
  7672. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7673. if (bill_entity != null)
  7674. {
  7675. int ComId = GetPostInt("ComId");
  7676. //string memo = GetPostString("Memo");
  7677. int allInfo = GetPostInt("allinfo");
  7678. string clert = CurrentUser.User.Name;
  7679. //string detailValue = GetPostString("detailvalue");
  7680. string billId = bill_entity.billOrderId;
  7681. string[] billIdList = billId.Split(',');
  7682. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7683. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7684. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7685. {
  7686. billCount += 1;
  7687. }
  7688. if (billId.Length <= 0 || billIdList.Length != billCount)
  7689. {
  7690. bill_entity.billOrderId = "";
  7691. string prebill = "ltb";
  7692. for (int idx = 1; idx <= billCount; idx++)
  7693. {
  7694. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7695. string billoid = prebill + idx + dtstr;
  7696. bill_entity.billOrderId += billoid;
  7697. if (idx < billCount)
  7698. {
  7699. bill_entity.billOrderId += ",";
  7700. }
  7701. }
  7702. }
  7703. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7704. if (bill_entity.state == 5)
  7705. {
  7706. string errMsg = bill_entity.failerror;
  7707. string[] errlist = errMsg.Split('|');
  7708. string[] errTags = new string[errlist.Length];
  7709. for (int itag = 0; itag < errlist.Length; itag++)
  7710. {
  7711. if (errlist[itag].Length <= 0) continue;
  7712. errTags[itag] = errlist[itag].Split('&')[0];
  7713. }
  7714. for (int iii = 0; iii < errTags.Length; iii++)
  7715. {
  7716. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7717. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7718. if (billOrderList.Length >= erroBillOrderTag)
  7719. {
  7720. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7721. if (needModifyBillId.Length <= 19)
  7722. {
  7723. needModifyBillId = needModifyBillId + "1";
  7724. }
  7725. else
  7726. {
  7727. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7728. last = last + 1;
  7729. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7730. }
  7731. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7732. }
  7733. }
  7734. }
  7735. bool isHaveBillSucces = false;
  7736. string totalRes = "";
  7737. bill_entity.failerror = "";
  7738. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7739. {
  7740. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7741. totalRes += res;
  7742. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7743. {
  7744. isHaveBillSucces = true;
  7745. bill_entity.comId = ComId;
  7746. bill_entity.state = 1;
  7747. bill_entity.executeTime = DateTime.Now;
  7748. bill_entity.executeUser = clert;
  7749. }
  7750. else
  7751. {
  7752. bill_entity.state = 5;
  7753. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7754. }
  7755. }
  7756. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7757. bill_entity.Update();
  7758. if (isHaveBillSucces)
  7759. {
  7760. StringBuilder sql = new StringBuilder();
  7761. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7762. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7763. }
  7764. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7765. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7766. {
  7767. returnErrorMsg("开票失败");
  7768. }
  7769. else
  7770. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7771. return;
  7772. }
  7773. returnErrorMsg("找不到对应记录");
  7774. }
  7775. catch (Exception ex)
  7776. {
  7777. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7778. returnErrorMsg("操作失败");
  7779. }
  7780. }
  7781. }
  7782. public void get_erp_invoicing_back()
  7783. {
  7784. if (UrlPostParmsCheck("id"))
  7785. {
  7786. try
  7787. {
  7788. string id = GetPostString("id");
  7789. CeErpBill entiy = CeErpBill.Get(id);
  7790. if (entiy != null)
  7791. {
  7792. if (entiy.state == 0)
  7793. {
  7794. returnErrorMsg("发票还未开具");
  7795. return;
  7796. }
  7797. string[] billOrderList = entiy.billOrderId.Split(',');
  7798. int iTag = 0;
  7799. entiy.fplsh = "";
  7800. entiy.fpdm = "";
  7801. entiy.fphm = "";
  7802. foreach (string billOrderId in billOrderList)
  7803. {
  7804. iTag++;
  7805. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7806. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7807. {
  7808. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7809. try
  7810. {
  7811. Invoicing_get_response_Obj iObj = null;
  7812. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7813. if (iObj != null)
  7814. {
  7815. entiy.state = 2;
  7816. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7817. entiy.fpdm += iObj.list[0].c_fpdm;
  7818. entiy.fphm += iObj.list[0].c_fphm;
  7819. if (iTag < billOrderList.Length)
  7820. {
  7821. entiy.fplsh += ",";
  7822. entiy.fpdm += ",";
  7823. entiy.fphm += ",";
  7824. }
  7825. entiy.Update();
  7826. }
  7827. StringBuilder sql = new StringBuilder();
  7828. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7829. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7830. returnSuccessMsg("开票成功");
  7831. }
  7832. catch (Exception ex)
  7833. {
  7834. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7835. }
  7836. return;
  7837. }
  7838. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7839. {
  7840. var res_obj = new
  7841. {
  7842. data = "开票中"
  7843. };
  7844. string ro_json = JsonConvert.SerializeObject(res_obj);
  7845. returnSuccess(ro_json);
  7846. return;
  7847. }
  7848. else
  7849. {
  7850. int eidx = res.IndexOf("c_resultmsg");
  7851. int lidx = res.IndexOf("c_status");
  7852. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7853. entiy.state = 5;
  7854. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7855. entiy.Update();
  7856. returnErrorMsg("开票失败");
  7857. return;
  7858. }
  7859. }
  7860. }
  7861. }
  7862. catch (Exception ex)
  7863. {
  7864. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7865. }
  7866. return;
  7867. }
  7868. }
  7869. public void get_erp_invoicing()
  7870. {
  7871. if (UrlPostParmsCheck("id"))
  7872. {
  7873. try
  7874. {
  7875. string id = GetPostString("id");
  7876. CeErpBill entiy = CeErpBill.Get(id);
  7877. if (entiy != null)
  7878. {
  7879. if (entiy.state == 0)
  7880. {
  7881. returnErrorMsg("发票还未开具");
  7882. return;
  7883. }
  7884. if (entiy.sendType == "纸质发票")
  7885. {
  7886. if (entiy.img.Length <= 0)
  7887. {
  7888. returnErrorMsg("查无纸质发票");
  7889. return;
  7890. }
  7891. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7892. returnSuccess(returnres);
  7893. return;
  7894. }
  7895. string[] billOrderList = entiy.billOrderId.Split(',');
  7896. int iTag = 0;
  7897. string fpUrl = "";
  7898. entiy.fplsh = "";
  7899. entiy.fpdm = "";
  7900. entiy.fphm = "";
  7901. foreach (string billOrderId in billOrderList)
  7902. {
  7903. iTag++;
  7904. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7905. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7906. {
  7907. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7908. Invoicing_get_response_Obj iObj = null;
  7909. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7910. if (iObj != null)
  7911. {
  7912. //entiy.state = 2;
  7913. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7914. entiy.fpdm += iObj.list[0].c_fpdm;
  7915. entiy.fphm += iObj.list[0].c_fphm;
  7916. if (iTag < billOrderList.Length)
  7917. {
  7918. entiy.fplsh += ",";
  7919. entiy.fpdm += ",";
  7920. entiy.fphm += ",";
  7921. }
  7922. entiy.Update();
  7923. fpUrl += iObj.list[0].c_url + ",";
  7924. }
  7925. //returnSuccess(res);
  7926. StringBuilder sql = new StringBuilder();
  7927. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7928. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7929. }
  7930. else
  7931. {
  7932. int eidx = res.IndexOf("c_resultmsg");
  7933. //int lidx = res.IndexOf("c_status");
  7934. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7935. //开票失败
  7936. entiy.state = 5;
  7937. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7938. entiy.Update();
  7939. returnErrorMsg("开票失败");
  7940. return;
  7941. }
  7942. }
  7943. var returnObj = new
  7944. {
  7945. data = fpUrl
  7946. };
  7947. string ro_json = JsonConvert.SerializeObject(returnObj);
  7948. returnSuccess(ro_json);
  7949. }
  7950. }
  7951. catch (Exception ex)
  7952. {
  7953. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7954. }
  7955. return;
  7956. }
  7957. }
  7958. public void save_erp_billimg()
  7959. {
  7960. if (UrlPostParmsCheck("id"))
  7961. {
  7962. string eid = GetPostString("id");
  7963. CeErpBill bill_entity = null;
  7964. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7965. if (bill_entity != null)
  7966. {
  7967. bill_entity.img = GetPostString("img");
  7968. bill_entity.executeTime = DateTime.Now;
  7969. bill_entity.state = 2;
  7970. bill_entity.Update();
  7971. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7972. returnSuccessMsg("保存成功");
  7973. }
  7974. return;
  7975. }
  7976. }
  7977. public void upd_erp_billreturnback()
  7978. {
  7979. if (UrlPostParmsCheck("id"))
  7980. {
  7981. int eid = GetPostInt("id");
  7982. CeErpBill bill_entity = null;
  7983. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7984. if (bill_entity != null)
  7985. {
  7986. bill_entity.state = 3;
  7987. bill_entity.returnReason = GetPostString("reason");
  7988. bill_entity.Update();
  7989. returnSuccessMsg("驳回成功!");
  7990. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7991. }
  7992. return;
  7993. }
  7994. }
  7995. public void cancel_erp_bill()
  7996. {
  7997. if (UrlPostParmsCheck("id"))
  7998. {
  7999. int eid = GetPostInt("id");
  8000. int detailValue = GetPostInt("detailvalue");
  8001. CeErpBill bill_entity = null;
  8002. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8003. string cres = "";
  8004. string gres = "";
  8005. if (bill_entity != null)
  8006. {
  8007. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8008. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8009. {
  8010. int iTag = 0;
  8011. bill_entity.fplsh = "";
  8012. bill_entity.fpdm = "";
  8013. bill_entity.fphm = "";
  8014. foreach (string billOrderId in billOrderList)
  8015. {
  8016. iTag++;
  8017. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8018. if (gres.IndexOf("success") != -1)
  8019. {
  8020. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8021. Invoicing_get_response_Obj iObj = null;
  8022. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8023. if (iObj != null)
  8024. {
  8025. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8026. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8027. bill_entity.fphm += iObj.list[0].c_fphm;
  8028. if (iTag < billOrderList.Length)
  8029. {
  8030. bill_entity.fplsh += ",";
  8031. bill_entity.fpdm += ",";
  8032. bill_entity.fphm += ",";
  8033. }
  8034. bill_entity.Update();
  8035. }
  8036. }
  8037. else
  8038. {
  8039. returnErrorMsg(gres);
  8040. return;
  8041. }
  8042. }
  8043. }
  8044. if (bill_entity.sendType == "纸质发票")
  8045. {
  8046. //作废
  8047. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8048. //if (DateTime.Now.Month == extime.Month)
  8049. //{
  8050. //cres = taobaoHelper.cancel_invoicing(eid);
  8051. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8052. //{
  8053. bill_entity.state = 4;//已作废
  8054. bill_entity.Update();
  8055. returnSuccessMsg("发票已作废");
  8056. return;
  8057. //}
  8058. //else
  8059. //{
  8060. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8061. // bill_entity.Update();
  8062. // returnErrorMsg(cres);
  8063. // return;
  8064. //}
  8065. //}
  8066. //else
  8067. //{
  8068. // returnErrorMsg("纸质发票只能作废本月的发票");
  8069. // return;
  8070. //}
  8071. }
  8072. //红冲
  8073. int redTag = 0;
  8074. string[] fpdmList = bill_entity.fpdm.Split(',');
  8075. string[] fphmList = bill_entity.fphm.Split(',');
  8076. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8077. {
  8078. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8079. return;
  8080. }
  8081. foreach (string billOrderId in billOrderList)
  8082. {
  8083. redTag++;
  8084. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8085. cres += onecres;
  8086. cres += ",";
  8087. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8088. {
  8089. bill_entity.state = 4;//已作废
  8090. //bill_entity.Update();
  8091. //returnSuccessMsg("发票已红冲");
  8092. }
  8093. else if (onecres.IndexOf("重复冲红") != -1)
  8094. {
  8095. bill_entity.state = 4;//已作废
  8096. //bill_entity.Update();
  8097. //returnSuccessMsg("发票已红冲");
  8098. }
  8099. else
  8100. {
  8101. string errmsg = commonHelper.KeepChinese(onecres);
  8102. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8103. }
  8104. }
  8105. bill_entity.Update();
  8106. if (cres.IndexOf("失败") != -1)
  8107. returnErrorMsg("红冲失败");
  8108. else
  8109. returnSuccessMsg("发票已红冲");
  8110. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8111. return;
  8112. }
  8113. return;
  8114. }
  8115. }
  8116. public void del_erp_billorder()
  8117. {
  8118. if (UrlPostParmsCheck("id"))
  8119. {
  8120. string eid = GetPostString("id");
  8121. CeErpBill.Del(eid);
  8122. CeErpBill bill = CeErpBill.Get(eid);
  8123. if (bill != null)
  8124. {
  8125. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8126. }
  8127. returnSuccessMsg("删除成功");
  8128. }
  8129. }
  8130. public void finish_erp_bill()
  8131. {
  8132. if (UrlPostParmsCheck("ids"))
  8133. {
  8134. string eids = GetPostString("ids");
  8135. string[] list = eids.Split(',');
  8136. foreach (string eid in list)
  8137. {
  8138. CeErpBill bill = CeErpBill.Get(eid);
  8139. if (bill != null)
  8140. {
  8141. bill.state = 2;
  8142. bill.Update();
  8143. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8144. }
  8145. }
  8146. returnSuccessMsg("操作成功");
  8147. }
  8148. }
  8149. public void get_erp_returncash()
  8150. {
  8151. DataStruct dStruct = GetPostStruct();
  8152. List<string> lw = new List<string>();
  8153. string tid = GetPostString("tid");
  8154. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8155. string shopname = GetPostString("shopname");
  8156. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8157. string buyernick = GetPostString("buyer_nick");
  8158. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8159. string customer = GetPostString("customer");
  8160. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8161. string returndate1 = GetPostString("returndate1");
  8162. string returndate2 = GetPostString("returndate2");
  8163. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8164. if (dw.Length > 0) lw.Add(dw);
  8165. string finishDate1 = GetPostString("finishdate1");
  8166. string finishDate2 = GetPostString("finishdate2");
  8167. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8168. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8169. string returntype = GetPostString("returntype");
  8170. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8171. string returnvstate = GetPostString("returnvstate");
  8172. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8173. dStruct.Order = "created desc";
  8174. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8175. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8176. writeGridDataTableJson(dStruct.TotalCount, dt);
  8177. }
  8178. public void get_erp_staygoods()
  8179. {
  8180. DataStruct dStruct = GetPostStruct();
  8181. List<string> lw = new List<string>();
  8182. string tid = GetPostString("tid");
  8183. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8184. string shopname = GetPostString("shopname");
  8185. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8186. string wangwang = GetPostString("wangwang");
  8187. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8188. string customer = GetPostString("customer");
  8189. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8190. string returndate1 = GetPostString("returndate1");
  8191. string returndate2 = GetPostString("returndate2");
  8192. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8193. if (dw.Length > 0) lw.Add(dw);
  8194. string finishDate1 = GetPostString("finishdate1");
  8195. string finishDate2 = GetPostString("finishdate2");
  8196. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8197. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8198. string returnvstate = GetPostString("returnvstate");
  8199. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8200. string persuadetype = GetPostString("persuadetype");
  8201. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8202. string customerOrg = GetPostString("customerOrg");
  8203. if (customerOrg.Length > 0)
  8204. {
  8205. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8206. }
  8207. dStruct.Order = "creata_time desc";
  8208. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8209. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8210. writeGridDataTableJson(dStruct.TotalCount, dt);
  8211. }
  8212. public void upd_erp_staygoods()
  8213. {
  8214. if (UrlPostParmsCheck("id"))
  8215. {
  8216. int eid = GetPostInt("id");
  8217. CeErpStayGoods entity = null;
  8218. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8219. if (entity != null)
  8220. {
  8221. entity.audit_type = 1;
  8222. entity.audit_time = DateTime.Now;
  8223. entity.audit_u_id = CurrentUser.UserID;
  8224. entity.audit_u_name = CurrentUser.UserName;
  8225. entity.Update();
  8226. returnSuccessMsg("审核成功!");
  8227. return;
  8228. }
  8229. returnErrorMsg("找不到订单记录");
  8230. }
  8231. }
  8232. public void upd_erp_stayGoodsback()
  8233. {
  8234. if (UrlPostParmsCheck("id"))
  8235. {
  8236. int eid = GetPostInt("id");
  8237. CeErpStayGoods entity = null;
  8238. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8239. if (entity != null)
  8240. {
  8241. entity.audit_text = GetPostString("reason");
  8242. entity.audit_type = 2;
  8243. entity.audit_time = DateTime.Now;
  8244. entity.audit_u_id = CurrentUser.UserID;
  8245. entity.audit_u_name = CurrentUser.UserName;
  8246. entity.Update();
  8247. returnSuccessMsg("退回成功!");
  8248. return;
  8249. }
  8250. returnErrorMsg("找不到订单记录");
  8251. }
  8252. }
  8253. public void upd_erp_returncashverify()
  8254. {
  8255. if (UrlPostParmsCheck("ID"))
  8256. {
  8257. int eid = GetPostInt("ID");
  8258. CeErpReturnCash entity = null;
  8259. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8260. if (entity != null)
  8261. {
  8262. entity.cashstate = 1;
  8263. entity.verifytime = DateTime.Now;
  8264. entity.verifyuserid = CurrentUser.UserID;
  8265. entity.Update();
  8266. returnSuccessMsg("审核成功!");
  8267. return;
  8268. }
  8269. returnErrorMsg("找不到订单记录");
  8270. }
  8271. }
  8272. public void upd_all_erp_returncashverify()
  8273. {
  8274. if (UrlPostParmsCheck("ID"))
  8275. {
  8276. String[] list = GetPostString("ID").Split(',');
  8277. CeErpReturnCash entity = null;
  8278. for (int i = 0; i < list.Length; i++)
  8279. {
  8280. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8281. if (entity != null)
  8282. {
  8283. if (entity.cashstate == 1)
  8284. {
  8285. returnErrorMsg("已审核过的订单不需要在审核!");
  8286. return;
  8287. }
  8288. entity.cashstate = 1;
  8289. entity.verifytime = DateTime.Now;
  8290. entity.verifyuserid = CurrentUser.UserID;
  8291. entity.Update();
  8292. }
  8293. }
  8294. returnSuccessMsg("审核成功!");
  8295. return;
  8296. }
  8297. }
  8298. public void upd_erp_returncashback()
  8299. {
  8300. if (UrlPostParmsCheck("ID"))
  8301. {
  8302. int eid = GetPostInt("ID");
  8303. CeErpReturnCash entity = null;
  8304. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8305. if (entity != null)
  8306. {
  8307. entity.backreason = GetPostString("reason");
  8308. entity.cashstate = 2;
  8309. entity.verifytime = DateTime.Now;
  8310. entity.verifyuserid = CurrentUser.UserID;
  8311. entity.Update();
  8312. returnSuccessMsg("退回成功!");
  8313. return;
  8314. }
  8315. returnErrorMsg("找不到订单记录");
  8316. }
  8317. }
  8318. public void upd_erp_returnprice()
  8319. {
  8320. if (UrlPostParmsCheck("ID"))
  8321. {
  8322. int eid = GetPostInt("ID");
  8323. CeErpReturnCash entity = null;
  8324. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8325. if (entity != null)
  8326. {
  8327. if (entity.cashstate == 1)
  8328. {
  8329. returnErrorMsg("审核通过了不能改");
  8330. return;
  8331. }
  8332. entity.returnprice = GetPostDouble("returnprice");
  8333. entity.Update();
  8334. returnSuccessMsg("修改成功!");
  8335. return;
  8336. }
  8337. returnErrorMsg("找不到订单记录");
  8338. }
  8339. }
  8340. public void del_erp_returncash()
  8341. {
  8342. if (UrlPostParmsCheck("ID"))
  8343. {
  8344. int eid = GetPostInt("ID");
  8345. CeErpReturnCash.Del(eid);
  8346. returnSuccessMsg("操作成功");
  8347. return;
  8348. }
  8349. }
  8350. public void test_for_do_sql()
  8351. {
  8352. string sql = GetPostString("sqlstr");
  8353. if (sql.Length > 0)
  8354. {
  8355. try
  8356. {
  8357. DbHelper.DbConn.ExecuteNonQuery(sql);
  8358. var res_obj = new
  8359. {
  8360. data = "成功",
  8361. };
  8362. string ro_json = JsonConvert.SerializeObject(res_obj);
  8363. returnSuccess(ro_json);
  8364. }
  8365. catch (Exception ex)
  8366. {
  8367. var res_obj = new
  8368. {
  8369. data = ex.Message,
  8370. };
  8371. string ro_json = JsonConvert.SerializeObject(res_obj);
  8372. returnSuccess(ro_json);
  8373. }
  8374. }
  8375. }
  8376. public void get_user_info()
  8377. {
  8378. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8379. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8380. }
  8381. public void get_total_data()
  8382. {
  8383. int userId = CurrentUser.UserID;
  8384. string sql = "";
  8385. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8386. {
  8387. 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);
  8388. }
  8389. else
  8390. {
  8391. 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 " +
  8392. "(select ID from CE_ErpUser where ID = {0}) d " +
  8393. "left join " +
  8394. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8395. ") a on d.ID = a.id left join " +
  8396. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8397. ") b on a.id = b.id1 left join" +
  8398. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8399. ") c on a.id = c.id2;", userId);
  8400. }
  8401. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8402. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8403. }
  8404. public void get_date_area_total_data2()
  8405. {
  8406. int userId = CurrentUser.UserID;
  8407. string date_type = GetPostString("timetype");
  8408. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8409. string sql = "";
  8410. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8411. {
  8412. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8413. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8414. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8415. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8416. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8417. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8418. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8419. ") a on e.ID = a.id left join " +
  8420. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8421. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8422. ") b on a.id = b.id1 " +
  8423. "left join " +
  8424. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8425. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8426. ") c on a.id = c.id2 " +
  8427. "left join " +
  8428. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8429. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8430. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8431. }
  8432. else
  8433. {
  8434. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8435. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8436. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8437. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8438. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8439. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8440. ") a on e.ID = a.id left join " +
  8441. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8442. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8443. ") c on a.id = c.id2 " +
  8444. "left join " +
  8445. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8446. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8447. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8448. }
  8449. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8450. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8451. }
  8452. public void get_date_area_total_data()
  8453. {
  8454. int userId = CurrentUser.UserID;
  8455. string date_type = GetPostString("timetype");
  8456. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8457. string date1 = searchDT[0].ToString();
  8458. string date2 = searchDT[1].ToString();
  8459. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8460. {
  8461. SqlParameter[] sqlParameter ={
  8462. new SqlParameter("@userId", SqlDbType.Int,4),
  8463. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8464. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8465. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8466. };
  8467. sqlParameter[0].Value = userId;
  8468. sqlParameter[1].Value = date1;
  8469. sqlParameter[2].Value = date2;
  8470. sqlParameter[3].Direction = ParameterDirection.Output;
  8471. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8472. string res = sqlParameter[3].Value.ToString();
  8473. var res_obj = new
  8474. {
  8475. data = res
  8476. };
  8477. string ro_json = JsonConvert.SerializeObject(res_obj);
  8478. returnSuccess(ro_json);
  8479. }
  8480. else
  8481. {
  8482. SqlParameter[] sqlParameter ={
  8483. new SqlParameter("@userId", SqlDbType.Int,4),
  8484. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8485. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8486. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8487. };
  8488. sqlParameter[0].Value = userId;
  8489. sqlParameter[1].Value = date1;
  8490. sqlParameter[2].Value = date2;
  8491. sqlParameter[3].Direction = ParameterDirection.Output;
  8492. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8493. string res = sqlParameter[3].Value.ToString();
  8494. var res_obj = new
  8495. {
  8496. data = res
  8497. };
  8498. string ro_json = JsonConvert.SerializeObject(res_obj);
  8499. returnSuccess(ro_json);
  8500. }
  8501. //writeGridDataViewJson(dt.Rows.Count, dv);
  8502. }
  8503. public void get_order_list()
  8504. {
  8505. string strFields = GetPostString("paraFields");
  8506. string strOrder = GetPostString("paraOrder");
  8507. string strWhere = GetPostString("paraWhere");
  8508. string strPageSize = GetPostString("paraPageSize");
  8509. DataStruct dStruct = GetPostStruct();
  8510. dStruct.PageSize = int.Parse(strPageSize);
  8511. dStruct.Fileds = strFields;
  8512. dStruct.Order = strOrder;
  8513. dStruct.MainWhere = strWhere;
  8514. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8515. writeGridDataTableJson(dStruct.TotalCount, dt);
  8516. }
  8517. ////获取待开始订单列表
  8518. //public void get_wait_design_order_list()
  8519. //{
  8520. // string date_type = GetPostString("date_type");
  8521. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8522. // DataStruct dStruct = GetPostStruct();
  8523. // dStruct.PageSize = 1000;
  8524. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8525. // List<string> lw = new List<string>();
  8526. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8527. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8528. // dStruct.Order = "WaitDesignTime asc";
  8529. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8530. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8531. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8532. //}
  8533. //获取完成单量排名
  8534. public void get_finish_order_count_ranking()
  8535. {
  8536. /* string date_type = GetPostString("date_type");
  8537. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8538. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8539. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8540. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8541. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8542. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8543. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8544. writeGridDataTableJson(0, new DataTable());
  8545. }
  8546. public void get_finish_order_amount_ranking()
  8547. {
  8548. /*string date_type = GetPostString("date_type");
  8549. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8550. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8551. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8552. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8553. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8554. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8555. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8556. writeGridDataTableJson(0, new DataTable());
  8557. }
  8558. public void get_finish_refund_count_ranking()
  8559. {
  8560. string date_type = GetPostString("date_type");
  8561. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8562. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8563. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8564. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8565. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8566. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8567. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8568. writeGridDataTableJson(dt.Rows.Count, dt);
  8569. }
  8570. public void get_finish_refund_amount_ranking()
  8571. {
  8572. string date_type = GetPostString("date_type");
  8573. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8574. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8575. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8576. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8577. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8578. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8579. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8580. writeGridDataTableJson(dt.Rows.Count, dt);
  8581. }
  8582. public void set_erp_finishorder_director()
  8583. {
  8584. if (UrlPostParmsCheck("ctid"))
  8585. {
  8586. string eid = GetPostString("ctid");
  8587. CeErpTradeCell entity = null;
  8588. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8589. if (entity != null)
  8590. {
  8591. entity.OrderState = 8;
  8592. entity.Update();
  8593. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8594. returnSuccessMsg("操作成功!");
  8595. return;
  8596. }
  8597. returnErrorMsg("找不到记录");
  8598. }
  8599. }
  8600. public void get_erp_placeregistlist()
  8601. {
  8602. DataStruct dStruct = GetPostStruct();
  8603. List<string> lw = new List<string>();
  8604. string outsid = GetPostString("outsid");
  8605. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8606. string memo = GetPostString("memo");
  8607. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8608. string filename = GetPostString("filename");
  8609. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8610. string islate = GetPostString("islate");
  8611. if (islate.Length > 0)
  8612. {
  8613. if (islate == "1")
  8614. lw.Add(string.Format("OutLate>0"));
  8615. else
  8616. lw.Add(string.Format("OutLate=0"));
  8617. }
  8618. string placedate1 = GetPostString("placedate1");
  8619. string placedate2 = GetPostString("placedate2");
  8620. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8621. if (dw.Length > 0) lw.Add(dw);
  8622. string deliveryDate1 = GetPostString("deliverydate1");
  8623. string deliveryDate2 = GetPostString("deliverydate2");
  8624. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8625. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8626. dStruct.Order = "ID desc";
  8627. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8628. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8629. writeGridDataTableJson(dStruct.TotalCount, dt);
  8630. }
  8631. public void ins_erp_placeregist()
  8632. {
  8633. if (UrlPostParmsCheck("id"))
  8634. {
  8635. string eid = GetPostString("id");
  8636. CeErpPlaceRegister entity = null;
  8637. if (eid == "0")//新增
  8638. {
  8639. entity = new CeErpPlaceRegister();
  8640. string xdTime = GetPostString("placeTime");
  8641. if (xdTime.Length > 0)
  8642. {
  8643. entity.PlactTime = Convert.ToDateTime(xdTime);
  8644. }
  8645. string fhTime = GetPostString("deliveryTime");
  8646. if (fhTime.Length > 0)
  8647. {
  8648. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8649. }
  8650. string preTime = GetPostString("preOutTime");
  8651. if (preTime.Length > 0)
  8652. {
  8653. entity.PreOutTime = Convert.ToDateTime(preTime);
  8654. }
  8655. entity.DeliveryCount = GetPostInt("deliveryCount");
  8656. entity.ReceiveCount = GetPostInt("receiveCount");
  8657. entity.OutSid = GetPostString("outSid");
  8658. entity.FileName = GetPostString("fileName");
  8659. entity.Memo = GetPostString("memo");
  8660. entity.AddUserId = CurrentUser.UserID;
  8661. entity.CreateTime = DateTime.Now;
  8662. entity.Img = GetPostString("img");
  8663. entity.Supplier = GetPostInt("supplier");
  8664. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8665. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8666. {
  8667. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8668. DateTime dt2 = (DateTime)entity.PreOutTime;
  8669. TimeSpan span = dt1.Subtract(dt2);
  8670. if (span.Days > 0)
  8671. {
  8672. entity.OutLate = span.Days;
  8673. }
  8674. }
  8675. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8676. entity.Create();
  8677. returnSuccessMsg("添加成功!");
  8678. return;
  8679. }
  8680. else //修改
  8681. {
  8682. entity = CeErpPlaceRegister.Get(eid);
  8683. if (entity != null)
  8684. {
  8685. string xdTime = GetPostString("placeTime");
  8686. if (xdTime.Length > 0)
  8687. {
  8688. entity.PlactTime = Convert.ToDateTime(xdTime);
  8689. }
  8690. string fhTime = GetPostString("deliveryTime");
  8691. if (fhTime.Length > 0)
  8692. {
  8693. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8694. }
  8695. string preTime = GetPostString("preOutTime");
  8696. if (preTime.Length > 0)
  8697. {
  8698. entity.PreOutTime = Convert.ToDateTime(preTime);
  8699. }
  8700. entity.DeliveryCount = GetPostInt("deliveryCount");
  8701. entity.ReceiveCount = GetPostInt("receiveCount");
  8702. if (entity.DeliveryCount == entity.ReceiveCount)
  8703. {
  8704. entity.CurState = "已完成";
  8705. }
  8706. else
  8707. {
  8708. entity.CurState = "未完成";
  8709. }
  8710. entity.OutSid = GetPostString("outSid");
  8711. entity.FileName = GetPostString("fileName");
  8712. entity.Memo = GetPostString("memo");
  8713. entity.Img = GetPostString("img");
  8714. entity.Supplier = GetPostInt("supplier");
  8715. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8716. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8717. {
  8718. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8719. DateTime dt2 = (DateTime)entity.PreOutTime;
  8720. TimeSpan span = dt1.Subtract(dt2);
  8721. if (span.Days > 0)
  8722. {
  8723. entity.OutLate = span.Days;
  8724. }
  8725. }
  8726. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8727. entity.Update();
  8728. returnSuccessMsg("修改成功");
  8729. return;
  8730. }
  8731. returnErrorMsg("找不到对应的记录");
  8732. return;
  8733. }
  8734. }
  8735. returnErrorMsg("缺少必要参数");
  8736. }
  8737. public void del_erp_placeregist()
  8738. {
  8739. string eid = GetPostString("id");
  8740. CeErpPlaceRegister.Del(eid);
  8741. returnSuccessMsg("删除成功!");
  8742. return;
  8743. }
  8744. public void ins_erp_placeregistbyorder()
  8745. {
  8746. string ctid = GetPostString("ctid");
  8747. if (ctid.Length > 0)
  8748. {
  8749. StringBuilder sql = new StringBuilder();
  8750. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8751. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8752. if (dt.Rows.Count > 0)
  8753. {
  8754. foreach (DataRow dr in dt.Rows)
  8755. {
  8756. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8757. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8758. entity.AddUserId = CurrentUser.UserID;
  8759. entity.tid = dr["tid"].ToString();
  8760. entity.Did = Convert.ToString(dr["ctid"]);
  8761. entity.splitTag = dr["SplitTag"].ToString();
  8762. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8763. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8764. if (pre_ctid.Length > 0)
  8765. {
  8766. sellmemo = sellmemo.Replace(pre_ctid, "");
  8767. }
  8768. sellmemo = sellmemo.Replace("[", "");
  8769. sellmemo = sellmemo.Replace("]", "");
  8770. entity.FileName = sellmemo;
  8771. string count = dr["ProductCount"].ToString();
  8772. int usecount = commonHelper.getIntCountFromString(count);
  8773. entity.DeliveryCount = usecount;
  8774. entity.CurState = "未完成";
  8775. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8776. {
  8777. entity.Supplier = 24;//dl手提袋定制
  8778. }
  8779. else
  8780. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8781. entity.CreateTime = DateTime.Now;
  8782. entity.Create();
  8783. }
  8784. returnSuccessMsg("操作成功");
  8785. return;
  8786. }
  8787. returnErrorMsg("没有找到对应订单");
  8788. return;
  8789. }
  8790. returnErrorMsg("缺少订单编号");
  8791. return;
  8792. }
  8793. public void get_erp_persuadelist()
  8794. {
  8795. DataStruct dStruct = GetPostStruct();
  8796. List<string> lw = new List<string>();
  8797. string ctid = GetPostString("ctid");
  8798. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8799. string shopname = GetPostString("shopname");
  8800. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8801. string buyernick = GetPostString("buyer_nick");
  8802. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8803. string customer = GetPostString("customer");
  8804. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8805. string returndate1 = GetPostString("returndate1");
  8806. string returndate2 = GetPostString("returndate2");
  8807. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8808. if (dw.Length > 0) lw.Add(dw);
  8809. string finishDate1 = GetPostString("finishdate1");
  8810. string finishDate2 = GetPostString("finishdate2");
  8811. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8812. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8813. string persuadetype = GetPostString("persuadetype");
  8814. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8815. string returnvstate = GetPostString("returnvstate");
  8816. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8817. dStruct.Order = "created desc";
  8818. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8819. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8820. writeGridDataTableJson(dStruct.TotalCount, dt);
  8821. }
  8822. public void upd_erp_returnpersuadeback()
  8823. {
  8824. if (UrlPostParmsCheck("ID"))
  8825. {
  8826. int eid = GetPostInt("ID");
  8827. CeErpPersuade entity = null;
  8828. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8829. if (entity != null)
  8830. {
  8831. entity.backreason = GetPostString("reason");
  8832. entity.pstate = 2;
  8833. entity.verifytime = DateTime.Now;
  8834. entity.verifyuserid = CurrentUser.UserID;
  8835. entity.Update();
  8836. returnSuccessMsg("退回成功!");
  8837. return;
  8838. }
  8839. returnErrorMsg("找不到订单记录");
  8840. }
  8841. }
  8842. public void upd_erp_returnpersuadeverify()
  8843. {
  8844. if (UrlPostParmsCheck("ID"))
  8845. {
  8846. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8847. {
  8848. returnErrorMsg("暂无权限审核");
  8849. return;
  8850. }
  8851. int eid = GetPostInt("ID");
  8852. CeErpPersuade entity = null;
  8853. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8854. if (entity != null)
  8855. {
  8856. entity.pstate = 1;
  8857. entity.verifytime = DateTime.Now;
  8858. entity.verifyuserid = CurrentUser.UserID;
  8859. entity.Update();
  8860. returnSuccessMsg("审核成功!");
  8861. return;
  8862. }
  8863. returnErrorMsg("找不到订单记录");
  8864. }
  8865. }
  8866. public void del_erp_persuade()
  8867. {
  8868. if (UrlPostParmsCheck("ID"))
  8869. {
  8870. int eid = GetPostInt("ID");
  8871. CeErpPersuade.Del(eid);
  8872. returnSuccessMsg("操作成功");
  8873. return;
  8874. }
  8875. }
  8876. public void get_erp_oldcustoupload()
  8877. {
  8878. DataStruct dStruct = GetPostStruct();
  8879. List<string> lw = new List<string>();
  8880. string buyernick = GetPostString("buyer_nick");
  8881. if (buyernick.Length > 0)
  8882. {
  8883. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8884. }
  8885. else
  8886. return;
  8887. dStruct.Order = "pay_time desc";
  8888. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8889. DataTable dt = null;
  8890. dt = WebCache.GetData("view_erptradecell", dStruct);
  8891. writeGridDataTableJson(dStruct.TotalCount, dt);
  8892. }
  8893. public void get_erp_checkorderlist()
  8894. {
  8895. DataStruct dStruct = GetPostStruct();
  8896. List<string> lw = new List<string>();
  8897. string tid = GetPostString("ctid");
  8898. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8899. string shopname = GetPostString("shopname");
  8900. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8901. string buyernick = GetPostString("buyer_nick");
  8902. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8903. string customer = GetPostString("customer");
  8904. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8905. string design = GetPostString("design");
  8906. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8907. string orderState = GetPostString("orderState");
  8908. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8909. string address = GetPostString("address");
  8910. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8911. string sellermemo = GetPostString("seller_memo");
  8912. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8913. string supplier = GetPostString("supplier");
  8914. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8915. {
  8916. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8917. }
  8918. else
  8919. {
  8920. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8921. }
  8922. string date1 = GetPostString("date1");
  8923. string date2 = GetPostString("date2");
  8924. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8925. if (dw.Length > 0) lw.Add(dw);
  8926. string placedate1 = GetPostString("placedate1");
  8927. string placedate2 = GetPostString("placedate2");
  8928. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8929. if (fdw.Length > 0) lw.Add(fdw);
  8930. string price1 = GetPostString("price1");
  8931. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8932. string price2 = GetPostString("price2");
  8933. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8934. string checkst = GetPostString("checkstate");
  8935. if (checkst.Length > 0 && "10".Equals(checkst))
  8936. {
  8937. lw.Add(string.Format("CheckOut>0"));
  8938. }
  8939. else
  8940. {
  8941. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8942. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8943. }
  8944. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8945. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8946. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8947. writeGridDataTableJson(dStruct.TotalCount, dt);
  8948. }
  8949. public void ins_erp_startCheck()
  8950. {
  8951. if (UrlPostParmsCheck("ctid"))
  8952. {
  8953. string eid = GetPostString("ctid");
  8954. CeErpTradeCell entity = null;
  8955. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8956. if (entity != null)
  8957. {
  8958. entity.MemoOpt = 4;
  8959. entity.Update();
  8960. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8961. CeErpSukuraData.createInfo(entity.ctid, 6);
  8962. returnSuccessMsg("操作成功!");
  8963. return;
  8964. }
  8965. returnErrorMsg("找不到记录");
  8966. }
  8967. }
  8968. public void upd_erp_sendXlw()
  8969. {
  8970. if (UrlPostParmsCheck("ctid"))
  8971. {
  8972. string eid = GetPostString("ctid");
  8973. CeErpTradeCell entity = null;
  8974. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8975. if (entity != null)
  8976. {
  8977. if (entity.IsSendGift == 1)
  8978. {
  8979. returnErrorMsg("请勿重复标记");
  8980. return;
  8981. }
  8982. entity.IsSendGift = 1;
  8983. entity.Update();
  8984. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8985. returnSuccessMsg("操作成功!");
  8986. return;
  8987. }
  8988. returnErrorMsg("找不到记录");
  8989. }
  8990. }
  8991. public void cancel_sendXlw()
  8992. {
  8993. if (UrlPostParmsCheck("ctid"))
  8994. {
  8995. string eid = GetPostString("ctid");
  8996. CeErpTradeCell entity = null;
  8997. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8998. if (entity != null)
  8999. {
  9000. if (entity.IsSendGift == 0)
  9001. {
  9002. returnErrorMsg("未标记小礼物");
  9003. return;
  9004. }
  9005. entity.IsSendGift = 0;
  9006. entity.Update();
  9007. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9008. returnSuccessMsg("操作成功!");
  9009. return;
  9010. }
  9011. returnErrorMsg("找不到记录");
  9012. }
  9013. }
  9014. public void get_erp_designbill()
  9015. {
  9016. DataStruct dStruct = GetPostStruct();
  9017. List<string> lw = new List<string>();
  9018. int isMy = GetInt("my");
  9019. if (isMy == 1)
  9020. {
  9021. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9022. }
  9023. string tid = GetPostString("tid");
  9024. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9025. string userName = GetPostString("design");
  9026. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9027. string price1 = GetPostString("price1");
  9028. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9029. string price2 = GetPostString("price2");
  9030. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9031. string rePrice1 = GetPostString("rePrice1");
  9032. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9033. string rePrice2 = GetPostString("rePrice2");
  9034. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9035. string designerType = GetPostString("designerType");
  9036. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9037. string orderState = GetPostString("orderState");
  9038. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9039. string endTime1 = GetPostString("endTime1");
  9040. string endTime2 = GetPostString("endTime2");
  9041. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9042. if (dw.Length > 0) lw.Add(dw);
  9043. string isDk = GetPostString("isDk");
  9044. if (isDk == "1")
  9045. {
  9046. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9047. }
  9048. else if (isDk == "0")
  9049. {
  9050. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9051. }
  9052. dStruct.Order = "oid, create_time desc";
  9053. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9054. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9055. writeGridDataTableJson(dStruct.TotalCount, dt);
  9056. }
  9057. public void upd_erp_designerbill()
  9058. {
  9059. if (UrlPostParmsCheck("ID"))
  9060. {
  9061. string eid = GetPostString("ID");
  9062. CeErpDesignerBill entity = null;
  9063. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9064. if (entity != null)
  9065. {
  9066. if (GetPostDouble("designerpirce") > 0)
  9067. {
  9068. entity.realPrice = GetPostDouble("designerpirce");
  9069. entity.update_time = DateTime.Now;
  9070. entity.update_u_id = CurrentUser.UserID;
  9071. entity.update_u_name = CurrentUser.UserName;
  9072. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9073. entity.Update();
  9074. returnSuccessMsg("操作成功!");
  9075. return;
  9076. }
  9077. else
  9078. {
  9079. entity.price = GetPostDouble("price");
  9080. entity.update_time = DateTime.Now;
  9081. entity.update_u_id = CurrentUser.UserID;
  9082. entity.update_u_name = CurrentUser.UserName;
  9083. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9084. entity.Update();
  9085. returnSuccessMsg("操作成功!");
  9086. return;
  9087. }
  9088. }
  9089. returnErrorMsg("找不到记录");
  9090. }
  9091. }
  9092. public void audit_erp_designerbill()
  9093. {
  9094. if (UrlPostParmsCheck("ID"))
  9095. {
  9096. string eid = GetPostString("ID");
  9097. CeErpDesignerBill entity = null;
  9098. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9099. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9100. if (entity != null)
  9101. {
  9102. entity.realPrice = GetPostDouble("designerpirce");
  9103. entity.update_time = DateTime.Now;
  9104. entity.update_u_id = CurrentUser.UserID;
  9105. entity.update_u_name = CurrentUser.UserName;
  9106. entity.isAudit = 1;
  9107. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9108. entity.Update();
  9109. if (orderEntity != null)
  9110. {
  9111. orderEntity.IsReadTag = 3;
  9112. orderEntity.Update();
  9113. }
  9114. returnSuccessMsg("操作成功!");
  9115. return;
  9116. }
  9117. returnErrorMsg("找不到记录");
  9118. }
  9119. }
  9120. public void all_audit_erp_designerbill()
  9121. {
  9122. if (UrlPostParmsCheck("idList"))
  9123. {
  9124. string[] list = GetPostString("idList").Split(',');
  9125. CeErpDesignerBill entity = null;
  9126. for (int i = 0; i < list.Length; i++)
  9127. {
  9128. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9129. if (entity == null) return;
  9130. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9131. if (orderEntity == null) return;
  9132. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9133. entity.update_time = DateTime.Now;
  9134. entity.update_u_id = CurrentUser.UserID;
  9135. entity.update_u_name = CurrentUser.UserName;
  9136. entity.isAudit = 1;
  9137. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9138. entity.Update();
  9139. orderEntity.IsReadTag = 3;
  9140. orderEntity.Update();
  9141. }
  9142. returnSuccessMsg("操作成功!");
  9143. return;
  9144. }
  9145. }
  9146. public void get_erp_sameorders()
  9147. {
  9148. if (UrlPostParmsCheck("ctid"))
  9149. {
  9150. string eid = GetPostString("ctid");
  9151. CeErpTradeCell entity = null;
  9152. entity = CeErpTradeCell.GetByCtid(eid);
  9153. if (entity != null)
  9154. {
  9155. StringBuilder sql = new StringBuilder();
  9156. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9157. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9158. var res = new
  9159. {
  9160. data = dt.Rows.Count
  9161. };
  9162. string ro_jsond = JsonConvert.SerializeObject(res);
  9163. returnSuccess(ro_jsond);
  9164. return;
  9165. }
  9166. returnErrorMsg("未找到订单");
  9167. return;
  9168. }
  9169. returnErrorMsg("缺少必要的参数");
  9170. }
  9171. public void get_erp_islasthavesameorder()
  9172. {
  9173. if (UrlPostParmsCheck("ctid"))
  9174. {
  9175. string eid = GetPostString("ctid");
  9176. string[] ctidList = eid.Split(',');
  9177. StringBuilder sql = new StringBuilder();
  9178. string tisCtid = "";
  9179. foreach (string ctid in ctidList)
  9180. {
  9181. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9182. if (entity != null)
  9183. {
  9184. sql = new StringBuilder();
  9185. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9186. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9187. if (dth.Rows.Count > 0)
  9188. {
  9189. tisCtid += entity.ctid;
  9190. tisCtid += ",";
  9191. }
  9192. }
  9193. }
  9194. if (tisCtid.Length > 0)
  9195. {
  9196. var res = new
  9197. {
  9198. data = tisCtid
  9199. };
  9200. string ro_jsond = JsonConvert.SerializeObject(res);
  9201. returnSuccess(ro_jsond);
  9202. }
  9203. else
  9204. {
  9205. var res = new
  9206. {
  9207. data = ""
  9208. };
  9209. string ro_jsond = JsonConvert.SerializeObject(res);
  9210. returnSuccess(ro_jsond);
  9211. }
  9212. return;
  9213. }
  9214. returnErrorMsg("缺少必要的参数");
  9215. }
  9216. public void file_client_down_url()
  9217. {
  9218. if (!UrlPostParmsCheck("userId"))
  9219. {
  9220. returnErrorMsg("缺少必要的参数");
  9221. }
  9222. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9223. }
  9224. public void checkout_form_data()
  9225. {
  9226. if (!UrlPostParmsCheck("tid"))
  9227. {
  9228. returnErrorMsg("缺少必要的参数");
  9229. }
  9230. string tid = GetPostString("tid");
  9231. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9232. if (ceErpOrderFormData != null)
  9233. {
  9234. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9235. returnSuccess(ro_jsond);
  9236. return;
  9237. }
  9238. returnErrorMsg("尚未有文件!");
  9239. }
  9240. public void back_supplier_audit()
  9241. {
  9242. int userId = CurrentUser.UserID;
  9243. StringBuilder sql = new StringBuilder();
  9244. 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);
  9245. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9246. if (dt.Rows.Count > 0)
  9247. {
  9248. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9249. }
  9250. else
  9251. {
  9252. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9253. }
  9254. }
  9255. public void back_supplier_query()
  9256. {
  9257. string eid = GetPostString("ctid");
  9258. if (eid != "")
  9259. {
  9260. StringBuilder sql = new StringBuilder();
  9261. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9262. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9263. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9264. }
  9265. else
  9266. {
  9267. returnErrorMsg("找不到订单记录");
  9268. return;
  9269. }
  9270. }
  9271. public void verified_to_order()
  9272. {
  9273. int userId = CurrentUser.UserID;
  9274. StringBuilder sql = new StringBuilder();
  9275. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9276. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9277. if (dt.Rows.Count > 0)
  9278. {
  9279. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9280. }
  9281. else
  9282. {
  9283. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9284. }
  9285. }
  9286. public void upd_supplier_audit()
  9287. {
  9288. if (UrlPostParmsCheck("ctid"))
  9289. {
  9290. string eid = GetPostString("ctid");
  9291. string reason = GetPostString("returnreason");
  9292. CeErpTradeCell entity = null;
  9293. CeWithdraw withdraw = null;
  9294. withdraw = CeWithdraw.GetByTid(eid);
  9295. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9296. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9297. {
  9298. if (withdraw != null)
  9299. {
  9300. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9301. {
  9302. returnSuccessMsg("您没有权限操作!");
  9303. return;
  9304. }
  9305. else
  9306. {
  9307. if (reason.Equals("1"))
  9308. {
  9309. if (entity.OrderState == -1)
  9310. {
  9311. if (entity.FinishPlaceTime == null)
  9312. {
  9313. entity.OrderState = 2;
  9314. }
  9315. else
  9316. {
  9317. entity.OrderState = 6;
  9318. }
  9319. }
  9320. entity.Update();
  9321. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9322. if (withdraw != null)
  9323. {
  9324. withdraw.status = int.Parse(reason);
  9325. withdraw.Update();
  9326. }
  9327. returnSuccessMsg("操作成功!");
  9328. return;
  9329. }
  9330. else
  9331. {
  9332. withdraw.status = int.Parse(reason);
  9333. withdraw.acknowledgingtime = DateTime.Now;
  9334. withdraw.Update();
  9335. returnSuccessMsg("查看详细请点击线下订单查询");
  9336. return;
  9337. }
  9338. }
  9339. }
  9340. // 第一个字符是 'N'
  9341. }
  9342. if (eid[0] != 'N')
  9343. {
  9344. }
  9345. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9346. {
  9347. entity.IsVerifyToSupplier = false;
  9348. entity.IsReturn = 1;
  9349. entity.ReturnTime = DateTime.Now;
  9350. entity.ReturnReason = reason;
  9351. if (entity.OrderState == 6)
  9352. {
  9353. entity.OrderState = 5;
  9354. }
  9355. entity.Update();
  9356. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9357. if (withdraw != null)
  9358. {
  9359. withdraw.status = int.Parse(reason);
  9360. withdraw.Update();
  9361. }
  9362. returnSuccessMsg("操作成功!");
  9363. return;
  9364. }
  9365. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9366. {
  9367. ;
  9368. if (withdraw != null)
  9369. {
  9370. withdraw.status = int.Parse(reason);
  9371. withdraw.acknowledgingtime = DateTime.Now;
  9372. withdraw.Update();
  9373. returnSuccessMsg("供应商取消撤回!");
  9374. return;
  9375. }
  9376. }
  9377. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9378. {
  9379. if (entity.OrderState == -1)
  9380. {
  9381. if (entity.FinishPlaceTime == null)
  9382. {
  9383. entity.OrderState = 2;
  9384. }
  9385. else
  9386. {
  9387. entity.OrderState = 3;
  9388. }
  9389. commonHelper.getCytPrice(entity);
  9390. }
  9391. entity.Update();
  9392. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9393. if (withdraw != null)
  9394. {
  9395. withdraw.status = int.Parse(reason);
  9396. withdraw.Update();
  9397. }
  9398. returnSuccessMsg("操作成功!");
  9399. return;
  9400. }
  9401. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9402. {
  9403. if (withdraw == null)
  9404. {
  9405. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9406. return;
  9407. }
  9408. }
  9409. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9410. {
  9411. if (withdraw != null)
  9412. {
  9413. withdraw.status = int.Parse(reason);
  9414. withdraw.acknowledgingtime = DateTime.Now;
  9415. withdraw.Update();
  9416. returnSuccessMsg("查看详细请点击线下订单查询");
  9417. return;
  9418. }
  9419. }
  9420. return;
  9421. }
  9422. }
  9423. //校验报价
  9424. public void refund_order_tip()
  9425. {
  9426. int userid = CurrentUser.UserID;
  9427. int sectionId = CurrentUser.UserPost.OrgID;
  9428. StringBuilder sql = new StringBuilder();
  9429. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9430. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9431. List<string> ids = new List<string>();
  9432. if (dth.Rows.Count > 0)
  9433. {
  9434. foreach (DataRow dr in dth.Rows)
  9435. {
  9436. ids.Add(dr["ID"].ToString());
  9437. }
  9438. try
  9439. {
  9440. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9441. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9442. }
  9443. catch (Exception ex)
  9444. {
  9445. }
  9446. }
  9447. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9448. }
  9449. public void refund_order_Design()
  9450. {
  9451. int userid = CurrentUser.UserID;
  9452. int sectionId = CurrentUser.UserPost.OrgID;
  9453. StringBuilder sql = new StringBuilder();
  9454. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9455. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9456. List<string> ids = new List<string>();
  9457. if (dth.Rows.Count > 0)
  9458. {
  9459. foreach (DataRow dr in dth.Rows)
  9460. {
  9461. ids.Add(dr["ID"].ToString());
  9462. }
  9463. try
  9464. {
  9465. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9466. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9467. }
  9468. catch (Exception ex)
  9469. {
  9470. }
  9471. }
  9472. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9473. }
  9474. public void change_order_info()
  9475. {
  9476. int userid = CurrentUser.UserID;
  9477. StringBuilder sql = new StringBuilder();
  9478. 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);
  9479. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9480. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9481. }
  9482. public void change_win_mome()
  9483. {
  9484. if (UrlPostParmsCheck("id,ctid"))
  9485. {
  9486. string id = GetPostString("id");
  9487. string ctid = GetPostString("ctid");
  9488. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9489. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9490. if (ce == null || ceErpMessageTip == null)
  9491. {
  9492. returnSuccessMsg("未找到对应的订单!");
  9493. return;
  9494. }
  9495. int type = GetPostInt("type");
  9496. string content = GetPostString("content");
  9497. if (type == 0)
  9498. {
  9499. content = content.Replace("(", "(");
  9500. content = content.Replace(")", ")");
  9501. string check = MidStrEx(content, "(", ")").Trim();
  9502. if (string.IsNullOrEmpty(check))
  9503. {
  9504. returnSuccessMsg("文件名格式不正确");
  9505. return;
  9506. }
  9507. }
  9508. ce.seller_memo = content;
  9509. ce.Update();
  9510. ceErpMessageTip.isVisit = true;
  9511. ceErpMessageTip.Update();
  9512. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9513. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9514. ApiVo apiVo = new ApiVo();
  9515. apiVo.orderNumber = ce.ctid;
  9516. apiVo.actionName = "demandDesign";
  9517. apiVo.orderRemarks = content;
  9518. apiVo.demandExamine = type + 1;
  9519. designHelper.API_WorkCore(apiVo);//demandDesign
  9520. returnSuccessMsg("修改成功!");
  9521. }
  9522. }
  9523. public static string MidStrEx(string sourse, string startstr, string endstr)
  9524. {
  9525. string result = string.Empty;
  9526. int startindex, endindex;
  9527. try
  9528. {
  9529. startindex = sourse.IndexOf(startstr);
  9530. if (startindex == -1)
  9531. return result;
  9532. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9533. endindex = tmpstr.IndexOf(endstr);
  9534. if (endindex == -1)
  9535. return result;
  9536. result = tmpstr.Remove(endindex);
  9537. }
  9538. catch (Exception ex)
  9539. {
  9540. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9541. }
  9542. return result;
  9543. }
  9544. public void refund_order_list()
  9545. {
  9546. int userid = CurrentUser.UserID;
  9547. int sectionId = CurrentUser.UserPost.OrgID;
  9548. StringBuilder sql = new StringBuilder();
  9549. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9550. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9551. DataStruct dStruct = GetPostStruct();
  9552. DataTable dt = null;
  9553. List<string> ids = new List<string>();
  9554. List<string> tids = new List<string>();
  9555. if (dth.Rows.Count > 0)
  9556. {
  9557. foreach (DataRow dr in dth.Rows)
  9558. {
  9559. tids.Add("'" + dr["tid"].ToString() + "'");
  9560. ids.Add(dr["id"].ToString());
  9561. }
  9562. try
  9563. {
  9564. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9565. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9566. List<string> lw = new List<string>();
  9567. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9568. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9569. dt = WebCache.GetData("view_orderlist", dStruct);
  9570. }
  9571. catch (Exception ex)
  9572. {
  9573. }
  9574. }
  9575. writeGridDataTableJson(dStruct.TotalCount, dt);
  9576. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9577. }
  9578. //新增
  9579. public void order_batch_downloads()
  9580. {
  9581. string ceid = GetPostString("tid");
  9582. String[] tid = ceid.Split(',');
  9583. order_batch_caiyingtong(tid);
  9584. /* (string success, string errors) = UploadFiles(tid);
  9585. returnSuccessMsg(success + errors);*/
  9586. return;
  9587. }
  9588. //报价接口
  9589. public void Get_To_Quote()
  9590. {
  9591. string ceid = GetPostString("ctid");
  9592. if (ceid != null)
  9593. {
  9594. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9595. if (entity != null)
  9596. {
  9597. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9598. {
  9599. return;
  9600. }
  9601. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9602. double price = 0;
  9603. if (cp == null)
  9604. {
  9605. JObject jsonObject12 = new JObject
  9606. {
  9607. { "UserId", "77886" },
  9608. { "Pwd", "lt666888" },
  9609. { "Filename", entity.seller_memo }
  9610. };
  9611. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9612. JObject jsonObjects1 = JObject.Parse(response1);
  9613. string ms1g = (string)jsonObjects1["msg"];
  9614. if (ms1g == "报价成功")
  9615. {
  9616. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9617. string data = (string)jsonObject1["price"];
  9618. 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 + "');";
  9619. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9620. returnSuccessMsg("获取报价成功:" + data);
  9621. price = Convert.ToDouble(data);
  9622. }
  9623. else
  9624. {
  9625. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9626. return;
  9627. }
  9628. }
  9629. String[] beizhu = entity.seller_memo.Split('-');
  9630. String chanp = "";
  9631. if (beizhu.Length > 0)
  9632. {
  9633. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9634. }
  9635. else
  9636. {
  9637. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9638. }
  9639. JObject jsonObject = new JObject
  9640. {
  9641. { "UserId", "77886" },
  9642. { "Pwd", "lt666888" },
  9643. { "Filename", chanp }
  9644. };
  9645. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9646. JObject jsonObjects = JObject.Parse(response);
  9647. string msg = (string)jsonObjects["msg"];
  9648. if (msg == "报价成功")
  9649. {
  9650. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9651. string data = (string)jsonObject1["price"];
  9652. 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 + "');";
  9653. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9654. returnSuccessMsg("获取报价成功:" + data);
  9655. price = Convert.ToDouble(data);
  9656. }
  9657. else
  9658. {
  9659. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9660. return;
  9661. }
  9662. if (price > 0)
  9663. {
  9664. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9665. if (ceErpTradeCellExtend == null)
  9666. {
  9667. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9668. ceErpTradeCellExtend.ctid = entity.ctid;
  9669. ceErpTradeCellExtend.payment_cyt = price;
  9670. ceErpTradeCellExtend.Create();
  9671. }
  9672. else
  9673. {
  9674. ceErpTradeCellExtend.payment_cyt = price;
  9675. ceErpTradeCellExtend.Update();
  9676. }
  9677. }
  9678. return;
  9679. }
  9680. }
  9681. else
  9682. {
  9683. returnErrorMsg("请至少选择一条数据");
  9684. return;
  9685. }
  9686. }
  9687. //新增
  9688. public void order_To_Supplier()
  9689. {
  9690. string ceid = GetPostString("tid");
  9691. String[] tid = ceid.Split(',');
  9692. if (tid.Length > 0)
  9693. {
  9694. try
  9695. {
  9696. for (int i = 0; i < tid.Length; i++)
  9697. {
  9698. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9699. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9700. entity.SupplierId = suid;
  9701. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9702. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9703. entity.Update();
  9704. }
  9705. }
  9706. catch (Exception ex)
  9707. {
  9708. returnErrorMsg("自动匹配供应商失败");
  9709. return;
  9710. }
  9711. }
  9712. else
  9713. {
  9714. returnErrorMsg("请至少选择一条数据");
  9715. return;
  9716. }
  9717. returnSuccessMsg("自动匹配供应商成功");
  9718. return;
  9719. }
  9720. public (string, string) UploadFiles(string[] urls)
  9721. {
  9722. string success = "";
  9723. string errors = "";
  9724. int userid = CurrentUser.UserID;
  9725. foreach (string url in urls)
  9726. {
  9727. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9728. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9729. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9730. {
  9731. JObject jsonObject = new JObject
  9732. {
  9733. { "Userid", "77886" },
  9734. { "pwd", "cyt86435015" },
  9735. { "content", base64FileContent },
  9736. { "ext", Path.GetExtension(fileName) }
  9737. };
  9738. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9739. JObject jsonObjects = JObject.Parse(response);
  9740. string msg = (string)jsonObjects["msg"];
  9741. if (msg.Equals("上传成功"))
  9742. {
  9743. success += url + " 上传成功";
  9744. }
  9745. else
  9746. {
  9747. errors += url + " 上传失败";
  9748. }
  9749. }
  9750. else
  9751. {
  9752. errors += url + " 格式出现问题";
  9753. }
  9754. }
  9755. if (urls.Length == 0)
  9756. {
  9757. return (success, errors);
  9758. }
  9759. return (success, errors);
  9760. }
  9761. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9762. {
  9763. return true; //总是接受
  9764. }
  9765. public static string HttpPost(string url, string param = null)
  9766. {
  9767. HttpWebRequest request;
  9768. //如果是发送HTTPS请求
  9769. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9770. {
  9771. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9772. request = WebRequest.Create(url) as HttpWebRequest;
  9773. request.ProtocolVersion = HttpVersion.Version10;
  9774. }
  9775. else
  9776. {
  9777. request = WebRequest.Create(url) as HttpWebRequest;
  9778. }
  9779. request.Method = "POST";
  9780. request.ContentType = "application/json";
  9781. request.Accept = "*/*";
  9782. request.Timeout = 120000;
  9783. request.AllowAutoRedirect = false;
  9784. StreamWriter requestStream = null;
  9785. WebResponse response = null;
  9786. string responseStr = null;
  9787. try
  9788. {
  9789. requestStream = new StreamWriter(request.GetRequestStream());
  9790. requestStream.Write(param);
  9791. requestStream.Close();
  9792. response = request.GetResponse();
  9793. if (response != null)
  9794. {
  9795. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9796. responseStr = reader.ReadToEnd();
  9797. reader.Close();
  9798. }
  9799. }
  9800. catch (Exception ex)
  9801. {
  9802. return ex.Message;
  9803. }
  9804. finally
  9805. {
  9806. request = null;
  9807. requestStream = null;
  9808. response = null;
  9809. }
  9810. return responseStr;
  9811. }
  9812. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9813. {
  9814. string base64FileContent;
  9815. string fileName;
  9816. using (WebClient webClient = new WebClient())
  9817. {
  9818. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9819. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9820. {
  9821. using (Stream stream = response.GetResponseStream())
  9822. {
  9823. using (MemoryStream memoryStream = new MemoryStream())
  9824. {
  9825. stream.CopyTo(memoryStream);
  9826. byte[] fileBytes = memoryStream.ToArray();
  9827. base64FileContent = Convert.ToBase64String(fileBytes);
  9828. fileName = response.Headers["Content-Disposition"];
  9829. if (!string.IsNullOrEmpty(fileName))
  9830. {
  9831. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9832. if (index >= 0)
  9833. {
  9834. fileName = fileName.Substring(index + 9).Trim('\"');
  9835. }
  9836. }
  9837. else
  9838. {
  9839. fileName = Path.GetFileName(downloadUrl);
  9840. }
  9841. }
  9842. }
  9843. }
  9844. }
  9845. return (fileName, base64FileContent);
  9846. }
  9847. //新增
  9848. public void order_batch_caiyingtong(string[] downloadUrls)
  9849. {
  9850. try
  9851. {
  9852. //遍历文件
  9853. DataStruct dStruct = GetPostStruct();
  9854. DataTable dt = null;
  9855. int userid = CurrentUser.UserID;
  9856. List<string> ids = new List<string>();//失败组
  9857. List<string> tids = new List<string>();
  9858. using (WebClient webClient = new WebClient())
  9859. {
  9860. foreach (var url in downloadUrls)
  9861. {
  9862. try
  9863. {
  9864. tids.Add("'" + url + "'");
  9865. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9866. if (entity != null)
  9867. {
  9868. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9869. if (cp == null)
  9870. {
  9871. JObject jsonObject = new JObject
  9872. {
  9873. { "Userid", "77886" },
  9874. { "pwd", "lt666888" },
  9875. { "Filename",entity.seller_memo }
  9876. };
  9877. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9878. JObject jsonObjects = JObject.Parse(response);
  9879. string msg = (string)jsonObjects["msg"];
  9880. if (msg == "报价成功")
  9881. {
  9882. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9883. DownloadAndConvertToBase64(url1);
  9884. }
  9885. else
  9886. {
  9887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9888. }
  9889. }
  9890. else
  9891. {
  9892. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9893. JObject jsonObject = new JObject
  9894. {
  9895. { "Userid", "77886" },
  9896. { "pwd", "lt666888" },
  9897. { "Filename",chanp }
  9898. };
  9899. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9900. JObject jsonObjects = JObject.Parse(response);
  9901. string msg = (string)jsonObjects["msg"];
  9902. if (msg == "报价成功")
  9903. {
  9904. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9905. DownloadAndConvertToBase64(url1);
  9906. }
  9907. else
  9908. {
  9909. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9910. }
  9911. }
  9912. }
  9913. // 上传文件到FTP
  9914. }
  9915. catch (Exception ex)
  9916. {
  9917. Console.WriteLine($"An error occurred: {ex.Message}");
  9918. }
  9919. }
  9920. List<string> lw = new List<string>();
  9921. lw.Add(string.Format("( OrderState < 6 )"));
  9922. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9923. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9924. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9925. if (dt.Rows.Count > 0)
  9926. {
  9927. foreach (DataRow dr in dt.Rows)
  9928. {
  9929. ids.Add(dr["ctid"].ToString());
  9930. }
  9931. }
  9932. String ErrorMsgs = "";
  9933. foreach (String id in ids)
  9934. {
  9935. ErrorMsgs += id + ",";
  9936. }
  9937. if (ErrorMsgs.Length > 1)
  9938. {
  9939. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9940. }
  9941. if (ErrorMsgs.Length < 1)
  9942. {
  9943. ErrorMsgs = "上传成功";
  9944. returnSuccessMsg(ErrorMsgs);
  9945. }
  9946. else
  9947. {
  9948. returnErrorMsg("以下订单" + ErrorMsgs);
  9949. }
  9950. }
  9951. // 删除文件夹及其内容
  9952. /* Directory.Delete(localDirectory, true);*/
  9953. }
  9954. catch { }
  9955. }
  9956. public void get_center_data()
  9957. {
  9958. int userId = CurrentUser.UserID;
  9959. string postCode = CurrentUser.UserPost.Post.Code;
  9960. List<string> lw = new List<string>();
  9961. List<string> ww = new List<string>();
  9962. DateTime currentTime = DateTime.Now;
  9963. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9964. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9965. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9966. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9967. string sql = " SELECT ";
  9968. string startTime = "2023-10-01 11:22:31";
  9969. //设计
  9970. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9971. {
  9972. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9973. 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));
  9974. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9975. 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));
  9976. }
  9977. //客服
  9978. else if (postCode == "CustomerService" || postCode == "Director")
  9979. {
  9980. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9981. 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));
  9982. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9983. 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));
  9984. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9985. 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));
  9986. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9987. 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));
  9988. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9989. 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));
  9990. }
  9991. //售后
  9992. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9993. {
  9994. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9995. 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));
  9996. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9997. 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));
  9998. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9999. 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));
  10000. }
  10001. //下单部
  10002. else if (postCode == "Place" || postCode == "PlaceMr")
  10003. {
  10004. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10005. 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));
  10006. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10007. 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));
  10008. }
  10009. //车间
  10010. else if (postCode == "Supplier")
  10011. {
  10012. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10013. 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));
  10014. }
  10015. DataTable dt = new DataTable();
  10016. if (lw.Count > 0)
  10017. {
  10018. sql += string.Join(" , ", lw);
  10019. sql += " FROM ";
  10020. sql += string.Join(" , ", ww);
  10021. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10022. }
  10023. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10024. }
  10025. public void get_center_data_list()
  10026. {
  10027. int userId = CurrentUser.UserID;
  10028. string postCode = CurrentUser.UserPost.Post.Code;
  10029. string shopIds = CurrentUser.User.pemShop;
  10030. DataStruct dStruct = GetPostStruct();
  10031. List<string> lw = new List<string>();
  10032. DateTime currentTime = DateTime.Now;
  10033. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10034. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10035. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10036. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10037. string startTime = "2023-10-01 11:22:31";
  10038. int order_type = GetPostInt("order_type");
  10039. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10040. {
  10041. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10042. if (order_type == 0)
  10043. {
  10044. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10045. }
  10046. else if (order_type == 3)
  10047. {
  10048. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10049. }
  10050. else
  10051. {
  10052. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10053. }
  10054. }
  10055. //客服
  10056. if (postCode == "CustomerService" || postCode == "Director")
  10057. {
  10058. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10059. if (order_type == 0)
  10060. {
  10061. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10062. }
  10063. else if (order_type == 1)
  10064. {
  10065. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10066. }
  10067. else if (order_type == 2)
  10068. {
  10069. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10070. }
  10071. else if (order_type == 3)
  10072. {
  10073. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10074. }
  10075. else if (order_type == 4)
  10076. {
  10077. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10078. }
  10079. else
  10080. {
  10081. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10082. }
  10083. }
  10084. //售后
  10085. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10086. {
  10087. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10088. if (shopIds != "")
  10089. {
  10090. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10091. }
  10092. if (order_type == 2)
  10093. {
  10094. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10095. }
  10096. else if (order_type == 4)
  10097. {
  10098. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10099. }
  10100. else if (order_type == 5)
  10101. {
  10102. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10103. }
  10104. else
  10105. {
  10106. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10107. }
  10108. }
  10109. //下单部
  10110. if (postCode == "Place" || postCode == "PlaceMr")
  10111. {
  10112. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10113. if (shopIds != "")
  10114. {
  10115. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10116. }
  10117. else if (order_type == 1)
  10118. {
  10119. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10120. }
  10121. else if (order_type == 2)
  10122. {
  10123. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10124. }
  10125. else
  10126. {
  10127. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10128. }
  10129. }
  10130. //车间
  10131. if (postCode == "Supplier")
  10132. {
  10133. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10134. if (order_type == 5)
  10135. {
  10136. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10137. }
  10138. else
  10139. {
  10140. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10141. }
  10142. }
  10143. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10144. dStruct.Fileds = "tid,ctid";
  10145. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10146. writeGridDataTableJson(dStruct.TotalCount, dt);
  10147. }
  10148. public void aftersale_audit_master()
  10149. {
  10150. if (UrlPostParmsCheck("ctid"))
  10151. {
  10152. string ctid = GetPostString("ctid");
  10153. if (ctid.Length > 0)
  10154. {
  10155. bool result = aftersale_data_change(ctid);
  10156. if (result)
  10157. {
  10158. returnSuccessMsg("修改成功!");
  10159. return;
  10160. }
  10161. }
  10162. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10163. }
  10164. }
  10165. public void aftersale_batch_audit_master()
  10166. {
  10167. if (UrlPostParmsCheck("ctids"))
  10168. {
  10169. string ctids = GetPostString("ctids");
  10170. if (ctids.Length > 0)
  10171. {
  10172. List<string> list = new List<string>();
  10173. string[] ctid_list = ctids.Split(',');
  10174. foreach (var item in ctid_list)
  10175. {
  10176. bool result = aftersale_data_change(item);
  10177. if (!result)
  10178. {
  10179. list.Add(item);
  10180. }
  10181. }
  10182. if (list.Count > 0)
  10183. {
  10184. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10185. return;
  10186. }
  10187. returnSuccessMsg("修改成功!");
  10188. return;
  10189. }
  10190. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10191. }
  10192. }
  10193. public bool aftersale_data_change(string ctid)
  10194. {
  10195. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10196. if (ceErpTradeCell != null)
  10197. {
  10198. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10199. ceErpTradeCell.AfterSaleSupplierState = 0;
  10200. StringBuilder sql = new StringBuilder();
  10201. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10202. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10203. CeErpTradeResponsible.DelByTid(ctid, 0);
  10204. 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 == "不理赔")
  10205. {
  10206. CeErpTradeResponsible.DelByTid(ctid, 1);
  10207. ceErpTradeCell.AfterSaleSupplierState = 1;
  10208. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10209. ceErpTradeCell.AfterSaleState = 4;
  10210. }
  10211. else
  10212. {
  10213. ceErpTradeCell.AfterSaleState = 3;
  10214. }
  10215. bool needCyt = false;
  10216. if (dt != null)
  10217. {
  10218. if (dt.Rows.Count == 1)
  10219. {
  10220. bool isEnd = false;
  10221. foreach (DataRow dr in dt.Rows)
  10222. {
  10223. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10224. {
  10225. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10226. isEnd = true;
  10227. }
  10228. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10229. {
  10230. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10231. isEnd = true;
  10232. }
  10233. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10234. {
  10235. needCyt = true;
  10236. }
  10237. }
  10238. if (isEnd)
  10239. {
  10240. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10241. ceErpTradeCell.AfterSaleState = 4;
  10242. ceErpTradeCell.AfterSaleSupplierState = 1;
  10243. }
  10244. }
  10245. else
  10246. {
  10247. bool isAll = true;
  10248. foreach (DataRow dr in dt.Rows)
  10249. {
  10250. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10251. {
  10252. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10253. continue;
  10254. }
  10255. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10256. {
  10257. string path = "";
  10258. int OrgID = 0;
  10259. if (!Convert.IsDBNull(dr["OrgPath"]))
  10260. {
  10261. path = dr["OrgPath"].ToString();
  10262. }
  10263. if (!Convert.IsDBNull(dr["OrgID"]))
  10264. {
  10265. OrgID = Convert.ToInt32(dr["OrgID"]);
  10266. }
  10267. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10268. {
  10269. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10270. continue;
  10271. }
  10272. }
  10273. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10274. {
  10275. needCyt = true;
  10276. }
  10277. isAll = false;
  10278. }
  10279. if (isAll)
  10280. {
  10281. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10282. ceErpTradeCell.AfterSaleState = 4;
  10283. ceErpTradeCell.AfterSaleSupplierState = 1;
  10284. }
  10285. }
  10286. }
  10287. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10288. {
  10289. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10290. }
  10291. if (ceErpTradeCell.AfterSaleState == 4)
  10292. {
  10293. ApiVo apiVo = new ApiVo();
  10294. apiVo.orderNumber = ceErpTradeCell.ctid;
  10295. apiVo.actionName = "afterOver";
  10296. designHelper.API_WorkCore(apiVo); //afterOver
  10297. }
  10298. ceErpTradeCell.Update();
  10299. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10300. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10301. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10302. return true;
  10303. }
  10304. return false;
  10305. }
  10306. public void get_erp_wechatorder()
  10307. {
  10308. DataStruct dStruct = GetPostStruct();
  10309. List<string> lw = new List<string>();
  10310. string tid = GetPostString("tid");
  10311. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10312. string shopname = GetPostString("shopname");
  10313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10314. string buyernick = GetPostString("buyer_nick");
  10315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10316. string customer = GetPostString("customer");
  10317. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10318. string returndate1 = GetPostString("returndate1");
  10319. string returndate2 = GetPostString("returndate2");
  10320. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10321. if (dw.Length > 0) lw.Add(dw);
  10322. string finishDate1 = GetPostString("finishdate1");
  10323. string finishDate2 = GetPostString("finishdate2");
  10324. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10325. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10326. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10327. dStruct.Order = "created desc";
  10328. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10329. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10330. writeGridDataTableJson(dStruct.TotalCount, dt);
  10331. }
  10332. public void get_erp_wechatlist_sumprice()
  10333. {
  10334. DataStruct dStruct = GetPostStruct();
  10335. List<string> lw = new List<string>();
  10336. string tid = GetPostString("tid");
  10337. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10338. string shopname = GetPostString("shopname");
  10339. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10340. string buyernick = GetPostString("buyer_nick");
  10341. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10342. string customer = GetPostString("customer");
  10343. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10344. string returndate1 = GetPostString("returndate1");
  10345. string returndate2 = GetPostString("returndate2");
  10346. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10347. if (dw.Length > 0) lw.Add(dw);
  10348. string finishDate1 = GetPostString("finishdate1");
  10349. string finishDate2 = GetPostString("finishdate2");
  10350. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10351. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10352. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10353. string mainWhere = string.Join(" and ", lw.ToArray());
  10354. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10355. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10356. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10357. decimal total = 0;
  10358. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10359. {
  10360. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10361. }
  10362. var res = new
  10363. {
  10364. data = total
  10365. };
  10366. string ro_jsond = JsonConvert.SerializeObject(res);
  10367. returnSuccess(ro_jsond);
  10368. return;
  10369. }
  10370. public void get_erp_qr_waitdeliverylist()
  10371. {
  10372. DataStruct dStruct = GetPostStruct();
  10373. List<string> lw = new List<string>();
  10374. string tid = GetPostString("ctid");
  10375. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10376. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10377. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10378. var res_objz = new
  10379. {
  10380. restype = 1,
  10381. data = dt
  10382. };
  10383. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10384. returnSuccess(ro_jsonz);
  10385. }
  10386. public void get_erp_yield_list()
  10387. {
  10388. DataStruct dStruct = GetPostStruct();
  10389. List<string> lw = new List<string>();
  10390. string tid = GetPostString("ctid");
  10391. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10392. string shopname = GetPostString("shopname");
  10393. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10394. string buyernick = GetPostString("buyer_nick");
  10395. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10396. //if (tid.Length == 0 && buyernick.Length == 0)
  10397. //{
  10398. // lw.Add(string.Format("IsRefund<={0}", 1));
  10399. //}
  10400. string customer = GetPostString("customer");
  10401. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10402. string design = GetPostString("design");
  10403. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10404. string orderState = GetPostString("orderState");
  10405. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10406. string address = GetPostString("address");
  10407. 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));
  10408. string sellermemo = GetPostString("seller_memo");
  10409. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10410. string supplier = GetPostString("supplier");
  10411. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10412. string OrderArea = GetPostString("order_area");
  10413. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10414. string placedate1 = GetPostString("placedate1");
  10415. string placedate2 = GetPostString("placedate2");
  10416. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10417. if (fdw.Length > 0) lw.Add(fdw);
  10418. string price1 = GetPostString("price1");
  10419. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10420. string price2 = GetPostString("price2");
  10421. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10422. string unusualCon = GetPostString("unusualcon");
  10423. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10424. string posTag = CurrentUser.UserPost.Post.Code;
  10425. if (posTag == "Supplier")
  10426. {
  10427. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10428. }
  10429. lw.Add(string.Format("OrderState = 6 "));
  10430. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10431. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10432. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10433. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10434. writeGridDataTableJson(dStruct.TotalCount, dt);
  10435. }
  10436. public void change_erp_sup_state()
  10437. {
  10438. if (UrlPostParmsCheck("ctid"))
  10439. {
  10440. string ctid = GetPostString("ctid");
  10441. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10442. if (ceErpTradeCell != null)
  10443. {
  10444. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10445. if (ceErpTradeCellExtend == null)
  10446. {
  10447. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10448. ceErpTradeCellExtend.ctid = ctid;
  10449. ceErpTradeCellExtend.SupState = 1;
  10450. ceErpTradeCellExtend.Create();
  10451. }
  10452. else
  10453. {
  10454. ceErpTradeCellExtend.SupState = 1;
  10455. ceErpTradeCellExtend.Update();
  10456. }
  10457. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10458. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10459. return;
  10460. }
  10461. returnErrorMsg("找不到订单");
  10462. }
  10463. }
  10464. public void supplier_all_downs()
  10465. {
  10466. if (UrlPostParmsCheck("tids"))
  10467. {
  10468. string tids = GetPostString("tids");
  10469. if (tids != null && tids.Length > 0)
  10470. {
  10471. StringBuilder sql = new StringBuilder();
  10472. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10473. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10474. sql = new StringBuilder();
  10475. 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, "下载设计文件");
  10476. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10477. string[] list = tids.Split(',');
  10478. foreach (string ctid in list)
  10479. {
  10480. CeErpSukuraData.createInfo(ctid, 3);
  10481. }
  10482. designHelper.api_approveDesign(tids); //approveDesign
  10483. returnSuccessMsg("下载成功!");
  10484. return;
  10485. }
  10486. returnErrorMsg("下载订单更新失败");
  10487. }
  10488. }
  10489. public void uploaderFileSuccess()
  10490. {
  10491. if (UrlPostParmsCheck("fileName"))
  10492. {
  10493. string fileName = GetPostString("fileName");
  10494. ApiVo apiVo = new ApiVo();
  10495. apiVo.orderNumber = fileName;
  10496. apiVo.actionName = "finishDesign";
  10497. designHelper.API_WorkCore(apiVo);//finishDesign
  10498. returnSuccessMsg("");
  10499. }
  10500. }
  10501. public void get_sample2_order()
  10502. {
  10503. if (UrlPostParmsCheck("ctid"))
  10504. {
  10505. string ctid = GetPostString("ctid");
  10506. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10507. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10508. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10509. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10510. double total = 0.0;
  10511. double order_price = 0.0;
  10512. if (dt_bu.Rows.Count > 0)
  10513. {
  10514. foreach (DataRow dr in dt_bu.Rows)
  10515. {
  10516. total += Convert.ToDouble(dr["payment"]);
  10517. }
  10518. }
  10519. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10520. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10521. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10522. string tid = ctid.Replace("S_", "");
  10523. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10524. double paymant = 0.0;
  10525. if (entity != null)
  10526. {
  10527. paymant = entity.payment;
  10528. }
  10529. string return_reason = "";
  10530. if (dt_after != null && dt_after.Rows.Count > 0)
  10531. {
  10532. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10533. }
  10534. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10535. }
  10536. }
  10537. public void get_erp_design_status()
  10538. {
  10539. string designName = GetPostString("designName");
  10540. DataStruct dStruct = GetPostStruct();
  10541. if (designName.Length > 0)
  10542. {
  10543. 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";
  10544. sql_user += " and Name like '%" + designName + "%'";
  10545. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10546. List<string> ids_list = new List<string>();
  10547. if (user_table.Rows.Count > 0)
  10548. {
  10549. foreach (DataRow item in user_table.Rows)
  10550. {
  10551. ids_list.Add(item["id"].ToString());
  10552. string ids_s = item["TeamIds"].ToString();
  10553. if (ids_s.Length > 0)
  10554. {
  10555. ids_list.AddRange(ids_s.Split(','));
  10556. }
  10557. }
  10558. }
  10559. HashSet<string> set = new HashSet<string>(ids_list);
  10560. ids_list = set.ToList();
  10561. if (ids_list.Count > 0)
  10562. {
  10563. 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));
  10564. dStruct.MainWhere = sql;
  10565. DataTable dt = null;
  10566. dt = WebCache.GetData("view_ErpUser", dStruct);
  10567. writeGridDataTableJson(dStruct.TotalCount, dt);
  10568. }
  10569. }
  10570. }
  10571. public void change_erp_order_price()
  10572. {
  10573. string ctid = GetPostString("ctid");
  10574. double price = GetPostDouble("price");
  10575. if (ctid.Length > 0)
  10576. {
  10577. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10578. if (ceErpTradeCellExtend == null)
  10579. {
  10580. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10581. ceErpTradeCellExtend.ctid = ctid;
  10582. ceErpTradeCellExtend.payment_cyt = price;
  10583. ceErpTradeCellExtend.Create();
  10584. }
  10585. else
  10586. {
  10587. ceErpTradeCellExtend.payment_cyt = price;
  10588. ceErpTradeCellExtend.Update();
  10589. }
  10590. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10591. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10592. {
  10593. ceErpDataSendOrderInfo.isSync = false;
  10594. ceErpDataSendOrderInfo.Update();
  10595. }
  10596. if (ceErpDataSendOrderInfo == null)
  10597. {
  10598. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10599. ceErpDataSendOrderInfo.isSync = false;
  10600. ceErpDataSendOrderInfo.ctid = ctid;
  10601. ceErpDataSendOrderInfo.Create();
  10602. }
  10603. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10604. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10605. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10606. if (dth != null && dth.Rows.Count > 0)
  10607. {
  10608. dataSendOrderBean dataSendOrderBean = null;
  10609. foreach (DataRow item in dth.Rows)
  10610. {
  10611. try
  10612. {
  10613. dataSendOrderBean = new dataSendOrderBean();
  10614. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10615. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10616. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10617. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10618. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10619. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10620. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10621. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10622. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10623. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10624. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10625. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10626. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10627. if (result != null)
  10628. {
  10629. if ("0".Equals(result.errcode))
  10630. {
  10631. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10632. }
  10633. else
  10634. {
  10635. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10636. }
  10637. }
  10638. }
  10639. catch (Exception ex)
  10640. {
  10641. }
  10642. }
  10643. }
  10644. returnSuccessMsg("修改成功!");
  10645. return;
  10646. }
  10647. returnErrorMsg("找不到订单");
  10648. }
  10649. public void find_he_together()
  10650. {
  10651. string ctid = GetPostString("ctid");
  10652. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10653. List<string> list = new List<string>();
  10654. if (ceErpTradeCell != null)
  10655. {
  10656. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10657. {
  10658. 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);
  10659. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10660. if (table != null && table.Rows.Count > 0)
  10661. {
  10662. foreach (TableRow row in table.Rows)
  10663. {
  10664. }
  10665. }
  10666. }
  10667. }
  10668. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10669. }
  10670. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10671. {
  10672. //chy----19
  10673. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10674. //GD-CYT-----64
  10675. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10676. //ZHX----3
  10677. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10678. //JK----97
  10679. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10680. //ZT----70
  10681. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10682. //LHCY-----98
  10683. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10684. //XD-----90
  10685. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10686. //CYCY-----14
  10687. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10688. };
  10689. //其他改名
  10690. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10691. {
  10692. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10693. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10694. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10695. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10696. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10697. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10698. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10699. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10700. };
  10701. //不统计
  10702. List<int> no_suppliers = new List<int>()
  10703. {
  10704. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10705. };
  10706. //配件单
  10707. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10708. {
  10709. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10710. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10711. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10712. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10713. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10714. {"旗杆",new List<string>(){ "班旗" } },
  10715. {"牙签",new List<string>(){ "不干胶" } }
  10716. };
  10717. public void get_place_order_data()
  10718. {
  10719. string date1 = GetPostString("date1");
  10720. string date2 = GetPostString("date2");
  10721. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10722. DateTime start = DateTime.Parse(starttime);
  10723. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10724. DateTime end = DateTime.Parse(endtime);
  10725. if (date1 != null && date1.Length > 0)
  10726. {
  10727. DateTime dateTime = DateTime.Parse(date1);
  10728. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10729. start = DateTime.Parse(starttime);
  10730. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10731. end = DateTime.Parse(endtime);
  10732. }
  10733. if (date2 != null && date2.Length > 0)
  10734. {
  10735. DateTime dateTime = DateTime.Parse(date2);
  10736. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10737. end = DateTime.Parse(endtime);
  10738. }
  10739. 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);
  10740. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10741. //不干胶-----1,卡片-----29
  10742. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10743. foreach (DataRow row in data.Rows)
  10744. {
  10745. int productId = Convert.ToInt32(row["ProductId"]);
  10746. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10747. if (no_suppliers.Contains(supplierId))
  10748. {
  10749. continue;
  10750. }
  10751. string seller_memo = row["seller_memo"].ToString();
  10752. bool ispj = false;//是否配件单
  10753. bool isfirst = true;//第一个配
  10754. maps.Keys.ForEach(key =>
  10755. {
  10756. //备注包含配件
  10757. if (seller_memo.Contains(key) && isfirst)
  10758. {
  10759. List<string> list = maps[key];
  10760. ispj = true;
  10761. isfirst = false;
  10762. for (int i = 0; i < list.Count; i++)
  10763. {
  10764. if (seller_memo.Contains(list[i]))
  10765. {
  10766. ispj = false;
  10767. break;
  10768. }
  10769. }
  10770. }
  10771. });
  10772. if (ispj)
  10773. {
  10774. continue;
  10775. }
  10776. seller_memo = seller_memo.Replace("UV", "uv");
  10777. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10778. //吊牌归到卡片
  10779. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10780. seller_memo = seller_memo.Replace("卡套", "卡片");
  10781. seller_memo = seller_memo.Replace("封套", "卡片");
  10782. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10783. seller_memo = seller_memo.Replace("腰封", "卡片");
  10784. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10785. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10786. seller_memo = seller_memo.Replace("横幅", "条幅");
  10787. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10788. string map_key = "";
  10789. string type = "";
  10790. if (supplierMap.ContainsKey(supplierId))
  10791. {
  10792. foreach (var kvp in supplierMap[supplierId])
  10793. {
  10794. if (seller_memo.Contains(kvp.Key))
  10795. {
  10796. map_key = kvp.Value;
  10797. type = kvp.Value;
  10798. break;
  10799. }
  10800. }
  10801. }
  10802. if (map_key == "")
  10803. {
  10804. type = "其他";
  10805. map_key = "其他";
  10806. }
  10807. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10808. {
  10809. map_key = suppliers[supplierId];
  10810. }
  10811. if (supplierId == 70)
  10812. {
  10813. supplierId = 70;
  10814. }
  10815. map_key += "_" + row["SupplierName"].ToString();
  10816. Dictionary<string, int> map = null;
  10817. if (other_map.ContainsKey(map_key))
  10818. {
  10819. other_map.TryGetValue(map_key, out map);
  10820. }
  10821. else
  10822. {
  10823. map = new Dictionary<string, int>();
  10824. map.Add("dayDev", 0);//当天出货
  10825. map.Add("dayTotal", 0);//下单总数
  10826. map.Add("payTotal", 0);//500以上
  10827. map.Add("today", 0);//当天出货数量
  10828. map.Add("unusua", 0);//异常数
  10829. other_map.Add(map_key, map);
  10830. other_map.TryGetValue(map_key, out map);
  10831. }
  10832. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10833. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10834. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10835. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  10836. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10837. {
  10838. map["dayTotal"]++;
  10839. if (supplierId == 97)
  10840. {
  10841. supplierId = 97;
  10842. }
  10843. }
  10844. if (Convert.ToDecimal(row["payment"]) >= 500)
  10845. {
  10846. map["payTotal"]++;
  10847. }
  10848. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10849. {
  10850. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10851. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10852. {
  10853. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  10854. {
  10855. map["today"]++;
  10856. }
  10857. }
  10858. else
  10859. {
  10860. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10861. {
  10862. map["today"]++;
  10863. }
  10864. }
  10865. }
  10866. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10867. {
  10868. map["unusua"]++;
  10869. }
  10870. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10871. //GD-CYT-----64
  10872. DateTime two = palceTimeStart.AddHours(14);
  10873. DateTime three = palceTimeStart.AddHours(15);
  10874. DateTime four = palceTimeStart.AddHours(16);
  10875. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10876. {
  10877. //下午四点前 500-1000
  10878. string count = row["ProductCount"].ToString();
  10879. if (count != null && count.Length > 0)
  10880. {
  10881. int productCount = commonHelper.getPlaceProductCount(count);
  10882. if (productCount >= 500 && productCount <= 1000)
  10883. {
  10884. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10885. {
  10886. map["dayDev"]++;
  10887. }
  10888. }
  10889. }
  10890. }
  10891. //UV
  10892. else if ("uv".Equals(type))
  10893. {
  10894. //ZT----70
  10895. //ZHX----3
  10896. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10897. {
  10898. map["dayDev"]++;
  10899. }
  10900. //JK----97
  10901. //HZX----105
  10902. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10903. {
  10904. map["dayDev"]++;
  10905. if (supplierId == 97)
  10906. {
  10907. supplierId = 97;
  10908. }
  10909. }
  10910. }
  10911. //帆布---52|条幅---27
  10912. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10913. {
  10914. //LHCY-----98
  10915. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10916. {
  10917. map["dayDev"]++;
  10918. }
  10919. }
  10920. //条幅
  10921. else if ("条幅".Equals(type))
  10922. {
  10923. //XD-----90
  10924. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10925. {
  10926. map["dayDev"]++;
  10927. }
  10928. }
  10929. //桌布
  10930. else if ("桌布".Equals(type))
  10931. {
  10932. //XD-----90
  10933. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10934. {
  10935. map["dayDev"]++;
  10936. }
  10937. }
  10938. //DL---10
  10939. //AYTW---119
  10940. //FS-CYT-DY ----80
  10941. //JK----97
  10942. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10943. {
  10944. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10945. {
  10946. map["dayDev"]++;
  10947. }
  10948. }
  10949. }
  10950. DataTable dt = new DataTable();
  10951. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10952. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10953. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10954. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10955. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10956. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10957. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10958. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10959. other_map.Keys.ForEach(key =>
  10960. {
  10961. DataRow dr = dt.NewRow();
  10962. Dictionary<string, int> map = other_map[key];
  10963. string[] key_list = key.Split('_');
  10964. dr[0] = key_list[0];
  10965. dr[1] = key_list[1];
  10966. if (key_list.Length > 2)
  10967. {
  10968. dr[1] += "(" + key_list[2] + ")";
  10969. }
  10970. dr[2] = map["dayTotal"];
  10971. dr[3] = map["payTotal"];
  10972. dr[4] = map["today"];
  10973. dr[5] = map["unusua"];
  10974. dr[6] = map["dayDev"];
  10975. double rate = 0.00;
  10976. if (map["dayDev"] > 0)
  10977. {
  10978. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10979. }
  10980. dr[7] = rate.ToString();
  10981. dt.Rows.Add(dr);
  10982. });
  10983. DataView dv = new DataView(dt);
  10984. dv.Sort = "SupplierName";
  10985. //dv.Sort = "AllOrder desc";
  10986. DataTable dtNew = dv.ToTable();
  10987. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10988. }
  10989. public void check_order_desing_info()
  10990. {
  10991. string ctid = GetPostString("ctid");
  10992. if (!string.IsNullOrEmpty(ctid))
  10993. {
  10994. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10995. if (ceErpTradeCell != null)
  10996. {
  10997. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10998. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10999. return;
  11000. }
  11001. returnErrorMsg("找不到订单");
  11002. return;
  11003. }
  11004. returnErrorMsg("找不到订单");
  11005. }
  11006. public void get_timeout_detail()
  11007. {
  11008. string poscode = CurrentUser.UserPost.Post.Code;
  11009. DataStruct dStruct = GetPostStruct();
  11010. List<string> lw = new List<string>();
  11011. string id = GetPostString("id");
  11012. string pay_date1 = GetPostString("pay_date1");
  11013. string pay_date2 = GetPostString("pay_date2");
  11014. int type = GetPostInt("type");
  11015. if (type == 0)
  11016. {
  11017. if (pay_date1.Length > 0)
  11018. {
  11019. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11020. }
  11021. if (pay_date2.Length > 0)
  11022. {
  11023. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11024. }
  11025. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11026. }
  11027. if (type == 1)
  11028. {
  11029. if (pay_date1.Length > 0)
  11030. {
  11031. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11032. }
  11033. if (pay_date2.Length > 0)
  11034. {
  11035. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11036. }
  11037. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11038. }
  11039. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11040. DataTable dt = null;
  11041. dt = WebCache.GetData("view_orderlist", dStruct);
  11042. writeGridDataTableJson(dStruct.TotalCount, dt);
  11043. }
  11044. public void saveUrgentChargePrice()
  11045. {
  11046. string ctid = GetPostString("ctid");
  11047. if (!string.IsNullOrEmpty(ctid))
  11048. {
  11049. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11050. if (ceErpTradeCell != null)
  11051. {
  11052. double price = GetPostDouble("price");
  11053. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11054. if (ceErpTradeCellExtend == null)
  11055. {
  11056. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11057. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11058. }
  11059. ceErpTradeCellExtend.urgentCharge = price;
  11060. if (ceErpTradeCellExtend.ID > 0)
  11061. {
  11062. ceErpTradeCellExtend.Update();
  11063. }
  11064. else
  11065. {
  11066. ceErpTradeCellExtend.Save();
  11067. }
  11068. returnSuccessMsg("修改成功!");
  11069. return;
  11070. }
  11071. returnErrorMsg("找不到订单");
  11072. return;
  11073. }
  11074. returnErrorMsg("找不到订单");
  11075. }
  11076. public void finish_erp_order()
  11077. {
  11078. string ctid = GetPostString("ctid");
  11079. if (!string.IsNullOrEmpty(ctid))
  11080. {
  11081. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11082. {
  11083. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11084. if (ceErpTradeCell != null)
  11085. {
  11086. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11087. ceErpTradeCell.Update();
  11088. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11089. returnSuccessMsg("修改成功!");
  11090. return;
  11091. }
  11092. }
  11093. }
  11094. returnErrorMsg("找不到订单");
  11095. }
  11096. public void get_trade_order_list()
  11097. {
  11098. string tid = GetPostString("tid");
  11099. if (!string.IsNullOrEmpty(tid))
  11100. {
  11101. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11102. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11103. writeGridDataTableJson(data.Rows.Count, data);
  11104. return;
  11105. }
  11106. returnErrorMsg("找不到订单");
  11107. }
  11108. public void save_cell_spu()
  11109. {
  11110. string ctid = GetPostString("ctid");
  11111. string spu_id = GetPostString("spu_id");
  11112. if (!string.IsNullOrEmpty(ctid))
  11113. {
  11114. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11115. if (ceErpTradeCellExtend == null)
  11116. {
  11117. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11118. ceErpTradeCellExtend.ctid = ctid;
  11119. }
  11120. ceErpTradeCellExtend.spu_id = spu_id;
  11121. if (ceErpTradeCellExtend.ID == 0)
  11122. {
  11123. ceErpTradeCellExtend.Create();
  11124. }
  11125. else
  11126. {
  11127. ceErpTradeCellExtend.Update();
  11128. }
  11129. returnSuccessMsg("修改成功!");
  11130. return;
  11131. }
  11132. returnErrorMsg("找不到订单");
  11133. }
  11134. public void change_express_info()
  11135. {
  11136. string ctid = GetPostString("ctid");
  11137. string transNo = GetPostString("transNo");
  11138. string transCom = GetPostString("transCom");
  11139. if (!string.IsNullOrEmpty(ctid))
  11140. {
  11141. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11142. if (ceErpTradeCellExtend == null)
  11143. {
  11144. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11145. ceErpTradeCellExtend.ctid = ctid;
  11146. }
  11147. ceErpTradeCellExtend.modExpressNo = transNo;
  11148. ceErpTradeCellExtend.modExpressCom = transCom;
  11149. ceErpTradeCellExtend.readMod = 2;
  11150. if (ceErpTradeCellExtend.ID == 0)
  11151. {
  11152. ceErpTradeCellExtend.Create();
  11153. }
  11154. else
  11155. {
  11156. ceErpTradeCellExtend.Update();
  11157. }
  11158. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11159. returnSuccessMsg("修改成功!");
  11160. return;
  11161. }
  11162. returnErrorMsg("找不到订单");
  11163. }
  11164. public void get_change_express_list()
  11165. {
  11166. DataStruct dStruct = GetPostStruct();
  11167. List<string> lw = new List<string>();
  11168. int st = 2;
  11169. string tid = GetPostString("ctid");
  11170. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11171. string shopname = GetPostString("shopname");
  11172. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11173. string buyernick = GetPostString("buyer_nick");
  11174. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11175. string sellermemo = GetPostString("seller_memo");
  11176. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11177. string supplier = GetPostString("supplier");
  11178. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11179. string customer = GetPostString("customer");
  11180. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11181. string design = GetPostString("design");
  11182. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11183. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11184. string poscode = CurrentUser.UserPost.Post.Code;
  11185. if (poscode != "SysAdmin")
  11186. {
  11187. string shopid = CurrentUser.User.pemShop;
  11188. lw.Add(string.Format("shopId in ({0})", shopid));
  11189. }
  11190. lw.Add("readMod = 2");
  11191. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11192. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11193. writeGridDataTableJson(dStruct.TotalCount, dt);
  11194. }
  11195. public void deal_express_complete()
  11196. {
  11197. string ctid = GetPostString("ctid");
  11198. if (!string.IsNullOrEmpty(ctid))
  11199. {
  11200. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11201. if (ceErpTradeCellExtend == null)
  11202. {
  11203. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11204. ceErpTradeCellExtend.ctid = ctid;
  11205. }
  11206. ceErpTradeCellExtend.readMod = 1;
  11207. if (ceErpTradeCellExtend.ID == 0)
  11208. {
  11209. ceErpTradeCellExtend.Create();
  11210. }
  11211. else
  11212. {
  11213. ceErpTradeCellExtend.Update();
  11214. }
  11215. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11216. returnSuccessMsg("修改成功!");
  11217. return;
  11218. }
  11219. returnErrorMsg("找不到订单");
  11220. }
  11221. public void aftersale_return_visit()
  11222. {
  11223. string ctid = GetPostString("ctid");
  11224. if (!string.IsNullOrEmpty(ctid))
  11225. {
  11226. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11227. if (ceErpTradeCellExtend == null)
  11228. {
  11229. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11230. ceErpTradeCellExtend.ctid = ctid;
  11231. }
  11232. ceErpTradeCellExtend.returnVisit = 1;
  11233. if (ceErpTradeCellExtend.ID == 0)
  11234. {
  11235. ceErpTradeCellExtend.Create();
  11236. }
  11237. else
  11238. {
  11239. ceErpTradeCellExtend.Update();
  11240. }
  11241. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11242. if (ceErpTradeAfterSaleExtend != null)
  11243. {
  11244. ceErpTradeAfterSaleExtend.TextResult = "";
  11245. ceErpTradeAfterSaleExtend.Update();
  11246. }
  11247. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11248. returnSuccessMsg("修改成功!");
  11249. return;
  11250. }
  11251. returnErrorMsg("找不到订单");
  11252. }
  11253. public void orderPlaceInfo()
  11254. {
  11255. string ctids = GetPostString("ctids");
  11256. string[] list = ctids.Split(',');
  11257. foreach (string ctid in list)
  11258. {
  11259. CeErpSukuraData.createInfo(ctid, 3);
  11260. }
  11261. designHelper.api_approveDesign(ctids); //approveDesign
  11262. returnSuccessMsg("");
  11263. }
  11264. public void get_issue_list()
  11265. {
  11266. DataStruct dStruct = GetPostStruct();
  11267. List<string> lw = new List<string>();
  11268. int st = 2;
  11269. string tid = GetPostString("ctid");
  11270. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11271. string shopname = GetPostString("shopname");
  11272. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11273. string buyernick = GetPostString("buyer_nick");
  11274. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11275. string sellermemo = GetPostString("seller_memo");
  11276. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11277. string supplier = GetPostString("supplier");
  11278. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11279. string customer = GetPostString("customer");
  11280. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11281. string design = GetPostString("design");
  11282. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11283. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11284. string poscode = CurrentUser.UserPost.Post.Code;
  11285. if (poscode != "SysAdmin")
  11286. {
  11287. string shopid = CurrentUser.User.pemShop;
  11288. lw.Add(string.Format("shopId in ({0})", shopid));
  11289. }
  11290. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11291. {
  11292. lw.Add("IssueState = 1");
  11293. }
  11294. lw.Add("IssueState > 0");
  11295. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11296. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11297. writeGridDataTableJson(dStruct.TotalCount, dt);
  11298. }
  11299. public void saveIssueContent()
  11300. {
  11301. string ctid = GetPostString("ctid");
  11302. if (!string.IsNullOrEmpty(ctid))
  11303. {
  11304. string content = GetPostString("content");
  11305. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11306. if (ceErpTradeAfterSaleExtend == null)
  11307. {
  11308. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11309. ceErpTradeAfterSaleExtend.tid = ctid;
  11310. }
  11311. ceErpTradeAfterSaleExtend.IssueContent = content;
  11312. ceErpTradeAfterSaleExtend.IssueState = 1;
  11313. if (ceErpTradeAfterSaleExtend.ID > 0)
  11314. {
  11315. ceErpTradeAfterSaleExtend.Update();
  11316. }
  11317. else
  11318. {
  11319. ceErpTradeAfterSaleExtend.Create();
  11320. }
  11321. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11322. returnSuccessMsg("添加成功!");
  11323. return;
  11324. }
  11325. returnErrorMsg("找不到订单");
  11326. }
  11327. public void dealIssueContent()
  11328. {
  11329. string ctid = GetPostString("ctid");
  11330. if (!string.IsNullOrEmpty(ctid))
  11331. {
  11332. string content = GetPostString("content");
  11333. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11334. if (ceErpTradeAfterSaleExtend != null)
  11335. {
  11336. ceErpTradeAfterSaleExtend.IssueState = 2;
  11337. ceErpTradeAfterSaleExtend.Update();
  11338. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11339. returnSuccessMsg("修改完成!");
  11340. return;
  11341. }
  11342. }
  11343. returnErrorMsg("找不到订单");
  11344. }
  11345. public void set_tid_attachments()
  11346. {
  11347. string tid = GetPostString("tid");
  11348. string atta = GetPostString("atta");
  11349. if (!string.IsNullOrEmpty(tid))
  11350. {
  11351. if (string.IsNullOrEmpty(atta))
  11352. {
  11353. returnErrorMsg("文件地址为空");
  11354. return;
  11355. }
  11356. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  11357. if (ceErpTrade == null)
  11358. {
  11359. returnErrorMsg("找不到订单");
  11360. return;
  11361. }
  11362. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", tid)).Tables[0];
  11363. bool isSend = false;
  11364. if (dt != null && dt.Rows.Count > 0)
  11365. {
  11366. foreach (DataRow row in dt.Rows)
  11367. {
  11368. if (Convert.ToInt16(row["OrderState"]) > 6)
  11369. {
  11370. isSend = true;
  11371. }
  11372. }
  11373. if (isSend)
  11374. {
  11375. returnErrorMsg("已发货无法修改");
  11376. return;
  11377. }
  11378. ceErpTrade.Attachments = atta;
  11379. ceErpTrade.Update();
  11380. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11381. returnSuccessMsg("上传成功!");
  11382. return;
  11383. }
  11384. }
  11385. returnErrorMsg("找不到订单");
  11386. }
  11387. public void get_tid_attachments()
  11388. {
  11389. string tid = GetPostString("tid");
  11390. if (!string.IsNullOrEmpty(tid))
  11391. {
  11392. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  11393. if (ceErpTrade == null)
  11394. {
  11395. returnErrorMsg("找不到订单");
  11396. }
  11397. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11398. return;
  11399. }
  11400. returnErrorMsg("找不到订单");
  11401. }
  11402. }
  11403. }