sync.order.cs 587 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //apiHelper.Api_SyncOrderByTime("598825");
  55. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  56. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  57. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  58. //banniuApiHelper.sendLogisticsInfo(null);
  59. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  60. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  61. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  62. //int sid = commonHelper.autoDistributeToSupplier(entity);
  63. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  64. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1742461349000,\"deliveryType\":\"OFFLINE\",\"discountFee\":3.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1743325347000,\"lines\":[{\"mark2\":[],\"num\":31,\"outerId\":\"JSBHUVZYT\",\"payment\":1547.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2200806677467/O1CN01aEDI6s251wFlRwWHL_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4271229037819075415\",\"refSkuId\":\"0\",\"refSpuId\":\"620901028368\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":49.9032,\"singleFee\":49.9,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"水晶标贴金属标签LOGO贴纸定制车热uv转印贴透明商标打印移丝印广告自粘刻字烫金定做公司标志防水不干胶印刷\",\"totalFee\":1547.0,\"totalPrice\":1550.0,\"totalSellPrice\":1547.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1742464167000,\"openBuyerId\":\"AAELRHraABkUZRPgSx2KM2Bx\",\"openBuyerNick\":\"美**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1742461325000,\"payTime\":1742461347000,\"payment\":1547.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"长沙市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"岳麓区\",\"receiverId\":\"ae45da4cb4cce6519f6bc00bdc10208b$\",\"receiverState\":\"湖南省\",\"receiverTown\":\"天顶街道\",\"refOid\":\"4271229037819075415\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"90x60mm-3000张-插旗-250克白卡纸对裱-覆哑膜模切-美美de二胖-小白-(粘牙签12cm)-老客户改稿\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":1547.0,\"totalPrice\":1550.0,\"totalSellPrice\":1547.0,\"type\":\"SALE\"}}");
  65. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  110. }
  111. if (buyernick.Length > 0)
  112. {
  113. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  114. }
  115. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  116. if (dw.Length > 0)
  117. {
  118. lw.Add(dw);
  119. }
  120. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  121. {
  122. string usershop = CurrentUser.User.pemShop;
  123. lw.Add(string.Format("ShopId in ({0})", usershop));
  124. }
  125. }
  126. else
  127. {
  128. if (ex_psize == 0)
  129. {
  130. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  131. }
  132. if (PKey != "admin")
  133. {
  134. string usershop = CurrentUser.User.pemShop;
  135. lw.Add(string.Format("ShopId in ({0})", usershop));
  136. paramsCount++;
  137. }
  138. }
  139. string uploaddate1 = GetPostString("uploaddate1");
  140. string uploaddate2 = GetPostString("uploaddate2");
  141. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  142. if (update.Length > 0) lw.Add(update);
  143. string deliverydate1 = GetPostString("deliverydate1");
  144. string deliverydate2 = GetPostString("deliverydate2");
  145. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  146. if (deliverydate.Length > 0)
  147. {
  148. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  149. };
  150. string shopname = GetPostString("shopname");
  151. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  152. string addwechat = GetPostString("addwechat");
  153. if (addwechat.Length > 0)
  154. {
  155. int addWt = Convert.ToInt32(addwechat);
  156. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  157. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  158. }
  159. string customer = GetPostString("customer");
  160. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  161. string design = GetPostString("design");
  162. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  163. string orderState = GetPostString("orderState");
  164. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  165. string address = GetPostString("address");
  166. 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));
  167. string sellermemo = GetPostString("seller_memo");
  168. if (sellermemo.Length > 0)
  169. {
  170. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  171. }
  172. string backReason = GetPostString("backReason");
  173. if (backReason.Length > 0)
  174. {
  175. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  176. }
  177. string apdate1 = GetPostString("apdate1");
  178. string apdate2 = GetPostString("apdate2");
  179. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  180. if (dwap.Length > 0) lw.Add(dwap);
  181. string price1 = GetPostString("price1");
  182. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  183. string price2 = GetPostString("price2");
  184. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  185. string isoldcustomer = GetPostString("isoldcus");
  186. string finishdate1 = GetPostString("finishdate1");
  187. string finishdate2 = GetPostString("finishdate2");
  188. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  189. bool isFinish = false;
  190. if (finishdate.Length > 0)
  191. {
  192. lw.Add(finishdate);
  193. isFinish = true;
  194. paramsCount++;
  195. }
  196. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  197. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  198. if (ex_psize > 0)
  199. {
  200. int UserID = CurrentUser.UserID;
  201. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  202. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  203. {
  204. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  205. }
  206. dStruct.Order = "pay_time desc";
  207. }
  208. string isNew = GetPostString("isNew");
  209. if (isNew == "true")
  210. {
  211. lw.Add(string.Format("IsNew = {0}", 1));
  212. }
  213. string overtime = GetPostString("overtime");
  214. if (overtime == "1")
  215. {
  216. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  217. }
  218. String usePost = CurrentUser.UserPost.Post.Code;
  219. if (usePost.Equals("Operation") == true)
  220. {
  221. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  222. }
  223. else
  224. {
  225. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  226. }
  227. //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";
  228. if (dStruct.PageSize == 100000)
  229. {
  230. dStruct.Order = "";
  231. }
  232. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  233. DataTable dt = null;
  234. string tablename = "view_orderlist";
  235. if (isFinish)
  236. {
  237. tablename = "view_orderlist_end";
  238. }
  239. dt = WebCache.GetData(tablename, dStruct);
  240. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  241. if (dt != null && dt.Rows.Count > 0)
  242. {
  243. foreach (DataRow dr in dt.Rows)
  244. {
  245. try
  246. {
  247. if (dr["refund_fees"] != null)
  248. {
  249. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  250. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  251. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  252. if (payment == refund_fees)
  253. {
  254. dr["refund_fees"] = Math.Round(refund_fees, 2);
  255. }
  256. else if (refund_fees == total_fee)
  257. {
  258. dr["refund_fees"] = payment;
  259. }
  260. else
  261. {
  262. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  263. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  264. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  265. }
  266. }
  267. // 对象操作
  268. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  269. ceErpTradeCell.ctid = dr["ctid"].ToString();
  270. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  271. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  272. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  273. if (dStruct.PageSize != 100000)
  274. {
  275. if (dr["DispatchSort"].ToString() == "2")
  276. {
  277. dr["gongchuang"] = 200;
  278. }
  279. else
  280. {
  281. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  282. dr["gongchuang"] = response.code;
  283. }
  284. }
  285. }
  286. catch (NullReferenceException ex)
  287. {
  288. // 处理空引用异常
  289. dr["refund_fees"] = "0.00";
  290. }
  291. }
  292. }
  293. writeGridDataTableJson(dStruct.TotalCount, dt);
  294. }
  295. public void get_erp_orderlist_sumprice()
  296. {
  297. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  298. return;
  299. List<string> lw = new List<string>();
  300. string tid = GetPostString("ctid");
  301. string date1 = GetPostString("date1");
  302. string date2 = GetPostString("date2");
  303. if (tid.Length > 0 || date1.Length > 0)
  304. {
  305. lw.Add(string.Format("ctid like '%{0}%'", tid));
  306. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  307. if (dw.Length > 0) lw.Add(dw);
  308. }
  309. else
  310. {
  311. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  312. }
  313. string shopname = GetPostString("shopname");
  314. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  315. string buyernick = GetPostString("buyer_nick");
  316. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  317. string customer = GetPostString("customer");
  318. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  319. string design = GetPostString("design");
  320. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  321. string orderState = GetPostString("orderState");
  322. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  323. string address = GetPostString("address");
  324. 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));
  325. string sellermemo = GetPostString("seller_memo");
  326. if (sellermemo.Length > 0)
  327. {
  328. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  329. }
  330. string apdate1 = GetPostString("apdate1");
  331. string apdate2 = GetPostString("apdate2");
  332. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  333. if (dwap.Length > 0) lw.Add(dwap);
  334. string price1 = GetPostString("price1");
  335. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  336. string price2 = GetPostString("price2");
  337. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  338. string isoldcustomer = GetPostString("isoldcus");
  339. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  340. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  341. if (PKey != "admin")
  342. {
  343. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  344. lw.Add(string.Format("shopId in ({0})", usershop));
  345. }
  346. //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";
  347. string mainWhere = string.Join(" and ", lw.ToArray());
  348. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  349. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  350. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  351. decimal total = 0;
  352. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  353. {
  354. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  355. }
  356. var res = new
  357. {
  358. data = total
  359. };
  360. string ro_jsond = JsonConvert.SerializeObject(res);
  361. returnSuccess(ro_jsond);
  362. return;
  363. }
  364. public void get_erp_CustomerServiceGather()
  365. {
  366. string userWhere = "", orderWhere = "";
  367. List<string> lw = new List<string>();
  368. string customer = GetPostString("customer");
  369. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  370. string shopname = GetPostString("shopname");
  371. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  372. string date1 = GetPostString("date1");
  373. string date2 = GetPostString("date2");
  374. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  375. if (dw.Length > 0) lw.Add(dw);
  376. orderWhere = string.Join(" and ", lw.ToArray());
  377. 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 " +
  378. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  379. "left join " +
  380. "( " +
  381. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  382. ") as b on a.ID = b.CustomerUserId " +
  383. "left join " +
  384. "( " +
  385. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  386. ") as d on a.ID = d.CustomerUserId " +
  387. "left join " +
  388. "( " +
  389. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  390. ") as e on a.ID = e.CustomerUserId " +
  391. "left join " +
  392. "( " +
  393. " select CustomerUserId, RefundCount, RefundSum from " +
  394. " ( " +
  395. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  396. " from CE_ErpTradeRefund a " +
  397. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  398. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  399. " group by CustomerUserId " +
  400. " ) as a " +
  401. ") as f on a.ID = f.CustomerUserId " +
  402. "where a.PostCode = 'CustomerService'",
  403. userWhere, orderWhere);
  404. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  405. writeGridDataTableJson(dt.Rows.Count, dt);
  406. //writeGridDataTableJson(dt.Rows.Count, dt);
  407. }
  408. //设计汇总
  409. public void get_erp_DesignerGather()
  410. {
  411. string userWhere = "", orderWhere = "";
  412. List<string> lw = new List<string>();
  413. string Designer = GetPostString("designer");
  414. int org = GetPostInt("org");
  415. if (Designer.Length > 0)
  416. {
  417. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  418. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  419. }
  420. else if (org > 0)
  421. {
  422. userWhere = string.Format(" where OrgID ={0}", org);
  423. }
  424. string shopname = GetPostString("shopname");
  425. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  426. string state = GetPostString("state");
  427. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  428. string OrderArea = GetPostString("order_area");
  429. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  430. string date1 = GetPostString("date1");
  431. string date2 = GetPostString("date2");
  432. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  433. if (dw.Length > 0) lw.Add(dw);
  434. string UpDate1 = GetPostString("UpDate1");
  435. string UpDate2 = GetPostString("UpDate2");
  436. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  437. if (dw.Length > 0) lw.Add(dw);
  438. orderWhere = string.Join(" and ", lw.ToArray());
  439. 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 (" +
  440. "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 " +
  441. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  442. "left join " +
  443. "( " +
  444. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  445. ") as b on a.ID = b.DesignUserId " +
  446. "left join " +
  447. "( " +
  448. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  449. ") as d on a.ID = d.DesignUserId " +
  450. "left join " +
  451. "( " +
  452. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  453. ") as e on a.ID = e.DesignUserId " +
  454. "left join " +
  455. "( " +
  456. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  457. ") as g on a.ID = g.DesignUserId " +
  458. "left join " +
  459. "( " +
  460. " select CustomerUserId, RefundCount, RefundSum from " +
  461. " ( " +
  462. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  463. " from CE_ErpTradeRefund a " +
  464. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  465. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  466. " group by CustomerUserId " +
  467. " ) as a " +
  468. ") as f on a.ID = f.CustomerUserId " +
  469. "where a.PostCode = 'Designer') as z",
  470. userWhere, orderWhere);
  471. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  472. writeGridDataTableJson(dt.Rows.Count, dt);
  473. }
  474. //删除tradecell的订单
  475. public void del_erp_cellorder()
  476. {
  477. if (UrlPostParmsCheck("ctid"))
  478. {
  479. string eid = GetPostString("ctid");
  480. CeErpTradeCell.DelByCtid(eid);
  481. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  482. returnSuccessMsg("删除成功");
  483. }
  484. }
  485. public void clear_erp_refundstate()
  486. {
  487. if (UrlPostParmsCheck("ids"))
  488. {
  489. string eids = GetPostString("ids");
  490. string[] ctidList = eids.Split(',');
  491. foreach (string ctid in ctidList)
  492. {
  493. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  494. if (entity != null)
  495. {
  496. entity.IsRefund = 0;
  497. entity.Update();
  498. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  499. }
  500. else
  501. continue;
  502. }
  503. returnSuccessMsg("操作成功");
  504. return;
  505. }
  506. returnErrorMsg("缺少必要参数");
  507. }
  508. public void set_erp_urgency()
  509. {
  510. if (UrlPostParmsCheck("ctid"))
  511. {
  512. string eid = GetPostString("ctid");
  513. CeErpTradeCell entity = null;
  514. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  515. if (entity != null)
  516. {
  517. string utime = GetPostString("urgencytime");
  518. if (utime.Length > 0)
  519. {
  520. entity.UrgencyTime = Convert.ToDateTime(utime);
  521. }
  522. else
  523. {
  524. returnErrorMsg("请选择加急时间");
  525. return;
  526. }
  527. if (entity.OrderState <= 4)
  528. {
  529. //entity.seller_memo = entity.seller_memo + "-加急";
  530. string smemo = entity.seller_memo;
  531. int kindex = smemo.IndexOf(")");
  532. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  533. if (lastoneStr != "-")
  534. {
  535. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  536. }
  537. string prememo = smemo.Substring(0, kindex + 2);
  538. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  539. int lastkindex = lastmemo.IndexOf("(");
  540. DateTime urgtime = Convert.ToDateTime(utime);
  541. string newlastmemo = "";
  542. if (lastkindex == 0)
  543. {
  544. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  545. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  546. }
  547. else
  548. {
  549. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  550. }
  551. entity.seller_memo = prememo + newlastmemo;
  552. }
  553. entity.IsUrgency = true;
  554. entity.Update();
  555. ApiVo apiVo = new ApiVo();
  556. apiVo.orderNumber = entity.ctid;
  557. apiVo.actionName = "changeDesign";
  558. apiVo.orderRemarks = entity.seller_memo;
  559. apiVo.remarkSign = 3;
  560. designHelper.API_WorkCore(apiVo); //changeDesign
  561. CeErpSukuraData.createInfo(entity.ctid, 7);
  562. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  563. returnSuccessMsg("设置成功!");
  564. return;
  565. }
  566. returnErrorMsg("找不到记录");
  567. }
  568. }
  569. public void set_erp_reset()
  570. {
  571. if (UrlPostParmsCheck("ctid"))
  572. {
  573. string eid = GetPostString("ctid");
  574. CeErpTradeCell entity = null;
  575. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  576. if (entity != null)
  577. {
  578. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  579. {
  580. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  581. {
  582. returnErrorMsg("财务要求已下单已发货无法重置");
  583. return;
  584. }
  585. }
  586. entity.IsUrgency = false;
  587. entity.seller_memo = "";
  588. entity.OtherMemo = "";
  589. entity.OrderState = 0;
  590. entity.IsReturn = 0;
  591. //entity.IsRefund = 0;
  592. entity.MemoOpt = 0;
  593. entity.AfterSaleState = 0;
  594. entity.AfterSaleResponsible = "";
  595. entity.AfterSaleUserId = 0;
  596. entity.IsNeedBill = 0;
  597. entity.CustomerUserId = 0;
  598. entity.DesignUserId = 0;
  599. entity.SupplierId = 0;
  600. entity.PlaceUserId = 0;
  601. entity.ptid = "";
  602. entity.IsSample = 0;
  603. entity.IsXianHuo = 0;
  604. entity.isDianziOrder = 0;
  605. entity.DispatchSort = 0;
  606. entity.FinishPlaceTime = null;
  607. entity.Update();
  608. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  609. if (trade != null)
  610. {
  611. trade.seller_memo = "";
  612. trade.Update();
  613. }
  614. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  615. returnSuccessMsg("重置成功!");
  616. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  617. if (desginBill != null)
  618. {
  619. desginBill.isDel = 1;
  620. desginBill.Update();
  621. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  622. }
  623. ApiVo apiVo = new ApiVo();
  624. apiVo.orderNumber = entity.ctid;
  625. apiVo.actionName = "resetDesign";
  626. designHelper.API_WorkCore(apiVo);//resetDesign
  627. return;
  628. }
  629. returnErrorMsg("找不到记录");
  630. }
  631. }
  632. public void save_erp_sellermemo()
  633. {
  634. if (UrlPostParmsCheck("ctid"))
  635. {
  636. string ctid = GetPostString("ctid");
  637. CeErpTradeCell entity = null;
  638. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  639. if (entity != null)
  640. {
  641. string memo = GetPostString("seller_memo");
  642. memo = memo.Replace(" ", "");
  643. if (memo.Contains("补差"))
  644. {
  645. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  646. return;
  647. }
  648. if (entity.seller_memo != memo)
  649. {
  650. if (entity.IsSample == 2)
  651. {
  652. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  653. return;
  654. }
  655. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  656. {
  657. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  658. {
  659. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  660. return;
  661. }
  662. }
  663. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  664. }
  665. commonHelper.getCytPrice(entity);
  666. int memoopt = GetPostInt("MemoOpt");
  667. Boolean ismemoopt = false;
  668. if (memoopt > 0)
  669. {
  670. string stropt = "";
  671. if (memoopt == 1)
  672. {
  673. stropt = "“改稿”";
  674. ismemoopt = true;
  675. }
  676. else if (memoopt == 2)
  677. {
  678. stropt = "“定稿”";
  679. }
  680. else if (memoopt == 3)
  681. {
  682. stropt = "“查货”";
  683. CeErpSukuraData.createInfo(entity.ctid, 6);
  684. }
  685. entity.MemoOpt = Convert.ToInt32(memoopt);
  686. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  687. }
  688. if (entity.OrderState < 5)
  689. {
  690. memo = memo.Replace("(", "(");
  691. memo = memo.Replace(")", ")");
  692. }
  693. entity.seller_memo = memo;
  694. entity.Update();
  695. ApiVo apiVo = new ApiVo();
  696. apiVo.orderNumber = entity.ctid;
  697. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  698. apiVo.orderRemarks = memo;
  699. apiVo.remarkSign = memoopt;
  700. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  701. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  702. returnSuccessMsg("保存成功!");
  703. return;
  704. }
  705. returnErrorMsg("找不到记录");
  706. }
  707. }
  708. public void ins_erp_checkorder()
  709. {
  710. if (UrlPostParmsCheck("ctid"))
  711. {
  712. string ctid = GetPostString("ctid");
  713. CeErpTradeCell entity = null;
  714. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  715. if (entity != null)
  716. {
  717. if (entity.OrderState < 6)
  718. {
  719. returnErrorMsg("下单完成后才可查货");
  720. return;
  721. }
  722. /*if (entity.OrderState > 6)
  723. {
  724. returnErrorMsg("订单已发货");
  725. return;
  726. }*/
  727. if (entity.FinishPlaceTime != null)
  728. {
  729. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  730. {
  731. returnErrorMsg("下单时间不足,无法查货");
  732. return;
  733. }
  734. }
  735. entity.MemoOpt = 3;
  736. entity.CheckOrderTime = DateTime.Now;
  737. entity.Update();
  738. CeErpSukuraData.createInfo(entity.ctid, 6);
  739. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  740. returnSuccessMsg("操作成功!");
  741. return;
  742. }
  743. returnErrorMsg("找不到记录");
  744. }
  745. }
  746. public void save_erp_othermemo()
  747. {
  748. if (UrlPostParmsCheck("ctid"))
  749. {
  750. string ctid = GetPostString("ctid");
  751. CeErpTradeCell entity = null;
  752. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  753. if (entity != null)
  754. {
  755. entity.OtherMemo = GetPostString("otherMemo");
  756. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  757. {
  758. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  759. StringBuilder sql = new StringBuilder();
  760. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  761. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  762. if (dt != null && dt.Rows.Count > 0)
  763. {
  764. foreach (DataRow dr in dt.Rows)
  765. {
  766. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  767. {
  768. //品类一直
  769. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  770. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  771. if (ceErpSampleCustomer == null)
  772. {
  773. ceErpSampleCustomer = new CeErpSampleCustomer();
  774. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  775. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  776. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  777. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  778. ceErpSampleCustomer.shopId = entity.ShopId;
  779. }
  780. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  781. ceErpSampleCustomer.lastTid = entity.tid;
  782. if (ceErpSampleCustomer.ID > 0)
  783. {
  784. ceErpSampleCustomer.Update();
  785. }
  786. else
  787. {
  788. ceErpSampleCustomer.Create();
  789. }
  790. }
  791. }
  792. }
  793. }
  794. //if (entity.IsOldCustomer == 1)
  795. //{
  796. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  797. //{
  798. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  799. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  800. //}
  801. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  802. //{
  803. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  804. // {
  805. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  806. // {
  807. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  808. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  809. // }
  810. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  811. // {
  812. // entity.OrderState = 2;
  813. // entity.DesignUserId = 0;
  814. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  815. // }
  816. // else
  817. // {
  818. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  819. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  820. // }
  821. // }
  822. //}
  823. //}
  824. entity.Update();
  825. returnSuccessMsg("保存成功!");
  826. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  827. return;
  828. }
  829. returnErrorMsg("找不到记录");
  830. }
  831. }
  832. public void save_erp_customermemo()
  833. {
  834. if (UrlPostParmsCheck("ctid"))
  835. {
  836. string ctid = GetPostString("ctid");
  837. CeErpTradeCell entity = null;
  838. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  839. if (entity != null)
  840. {
  841. entity.CustomerMemo = GetPostString("CustomerMemo");
  842. entity.Update();
  843. ApiVo apiVo = new ApiVo();
  844. apiVo.orderNumber = entity.ctid;
  845. apiVo.actionName = "followRemarks";
  846. apiVo.orderRemarks = entity.CustomerMemo;
  847. designHelper.API_WorkCore(apiVo);//followRemarks
  848. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  849. returnSuccessMsg("保存成功!");
  850. return;
  851. }
  852. returnErrorMsg("找不到记录");
  853. }
  854. }
  855. public void upd_erp_addmemotag()
  856. {
  857. if (UrlPostParmsCheck("ctid"))
  858. {
  859. ;
  860. string eid = GetPostString("ctid");
  861. string sfTagstr = GetPostString("memotag");
  862. CeErpTradeCell entity = null;
  863. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  864. if (entity != null)
  865. {
  866. if (entity.OrderState == 0)
  867. {
  868. returnErrorMsg("请先领单");
  869. return;
  870. }
  871. //撤销顺丰
  872. if (sfTagstr == "撤销顺丰")
  873. {
  874. entity.IsSF = 0;
  875. string reMsg = "";
  876. string oldmemo = entity.seller_memo;
  877. if (entity.OrderState < 5)
  878. {
  879. oldmemo = oldmemo.Replace("顺丰到付", "");
  880. oldmemo = oldmemo.Replace("顺丰寄付", "");
  881. entity.seller_memo = oldmemo;
  882. }
  883. else
  884. {
  885. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  886. {
  887. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  888. }
  889. }
  890. entity.Update();
  891. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  892. api.orderNumber = entity.ctid;
  893. api.actionName = "followRemarks";
  894. api.orderRemarks = entity.seller_memo;
  895. api.isSf = entity.IsSF.ToString();
  896. designHelper.API_WorkCore(api);//followRemarks
  897. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  898. returnSuccessMsg("撤销成功!" + reMsg);
  899. return;
  900. }
  901. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  902. {
  903. //string oldmemo = entity.seller_memo;
  904. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  905. string sfStr = GetPostString("memotag");
  906. string smemo = entity.seller_memo;
  907. int kindex = smemo.IndexOf(")");
  908. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  909. if (lastoneStr != "-")
  910. {
  911. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  912. }
  913. string prememo = smemo.Substring(0, kindex + 2);
  914. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  915. int lastkindex = lastmemo.IndexOf("(");
  916. string newlastmemo = "";
  917. if (lastkindex == 0)
  918. {
  919. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  920. newlastmemo = "(" + sfStr + "." + useLastmemo;
  921. }
  922. else
  923. {
  924. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  925. }
  926. entity.seller_memo = prememo + newlastmemo;
  927. }
  928. string sfTagMSg = "";
  929. if (sfTagstr == "顺丰寄付")
  930. {
  931. entity.IsSF = 1;
  932. sfTagMSg = "顺丰寄付";
  933. }
  934. else if (sfTagstr == "顺丰到付")
  935. {
  936. entity.IsSF = 2;
  937. sfTagMSg = "顺丰到付";
  938. }
  939. entity.Update();
  940. ApiVo apiVo = new ApiVo();
  941. apiVo.orderNumber = entity.ctid;
  942. apiVo.actionName = "orderRemarks";
  943. apiVo.orderRemarks = entity.seller_memo;
  944. apiVo.isSf = entity.IsSF.ToString();
  945. designHelper.API_WorkCore(apiVo);//orderRemarks
  946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  947. returnSuccessMsg("标记成功!");
  948. return;
  949. }
  950. returnErrorMsg("找不到记录");
  951. }
  952. }
  953. public void upd_erp_ordertag()
  954. {
  955. if (UrlPostParmsCheck("ctid"))
  956. {
  957. string eid = GetPostString("ctid");
  958. CeErpTradeCell entity = null;
  959. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  960. if (entity != null)
  961. {
  962. int tag = GetPostInt("wechattag");
  963. //if(tag==4 && entity.IsSample == 2)
  964. //{
  965. // returnErrorMsg("补差价单不能标记微信单");
  966. // return;
  967. //}
  968. entity.wechatTag = tag;
  969. entity.Update();
  970. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  971. if (tag == 1)
  972. {
  973. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  974. if (cash == null)
  975. {
  976. CeErpTrade main = CeErpTrade.Get(entity.tid);
  977. cash = new CeErpReturnCash();
  978. cash.tid = entity.tid;
  979. cash.seller_nick = main.seller_nick;
  980. cash.payment = trade.payment;
  981. cash.buyer_nick = main.buyer_nick;
  982. cash.cashstate = 0;
  983. cash.rtype = "微信返现";
  984. cash.returnprice = 0;
  985. cash.created = DateTime.Now;
  986. cash.con = "订单标记微信单";
  987. cash.img = "";
  988. cash.applyuserid = CurrentUser.UserID;
  989. cash.Create();
  990. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  991. }
  992. else
  993. {
  994. cash.cashstate = 0;
  995. cash.Update();
  996. }
  997. CeErpSukuraData.createInfo(entity.ctid, 9);
  998. }
  999. else if (tag == 2)
  1000. {
  1001. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1002. if (cash == null)
  1003. {
  1004. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1005. cash = new CeErpReturnCash();
  1006. cash.tid = entity.tid;
  1007. cash.seller_nick = main.seller_nick;
  1008. cash.payment = trade.payment;
  1009. cash.buyer_nick = main.buyer_nick;
  1010. cash.cashstate = 0;
  1011. cash.rtype = "推购返现";
  1012. cash.returnprice = 5;
  1013. cash.created = DateTime.Now;
  1014. cash.con = "订单标记推购单";
  1015. cash.img = "";
  1016. cash.applyuserid = CurrentUser.UserID;
  1017. cash.Create();
  1018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1019. }
  1020. else
  1021. {
  1022. cash.cashstate = 0;
  1023. cash.Update();
  1024. }
  1025. CeErpSukuraData.createInfo(entity.ctid, 9);
  1026. }
  1027. else if (tag == 3)
  1028. {
  1029. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1030. if (pers == null)
  1031. {
  1032. pers = new CeErpPersuade();
  1033. pers.ctid = entity.ctid;
  1034. pers.pstate = 0;
  1035. pers.created = DateTime.Now;
  1036. pers.applyuserid = CurrentUser.UserID;
  1037. pers.Create();
  1038. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1039. }
  1040. else
  1041. {
  1042. pers.pstate = 0;
  1043. pers.Update();
  1044. }
  1045. }
  1046. else if (tag == 4 || tag == 5)
  1047. {
  1048. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1049. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1050. if (pers == null)
  1051. {
  1052. pers = new CeErpStayGoods();
  1053. pers.t_id = entity.tid;
  1054. pers.status = "待审核";
  1055. pers.audit_type = 0;
  1056. if (tag == 4)
  1057. {
  1058. pers.stay_type = "微信推购";
  1059. }
  1060. else
  1061. {
  1062. pers.stay_type = "旺旺推购";
  1063. }
  1064. if (entity.IsXianHuo == 0)
  1065. {
  1066. pers.product_id = entity.ProductId;
  1067. }
  1068. pers.wangwang = main.buyer_nick;
  1069. pers.shop_name = main.seller_nick;
  1070. pers.creata_time = DateTime.Now;
  1071. pers.create_u_id = CurrentUser.UserID;
  1072. pers.create_u_name = CurrentUser.UserName;
  1073. pers.Create();
  1074. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1075. }
  1076. else
  1077. {
  1078. pers.audit_type = 0;
  1079. pers.Update();
  1080. }
  1081. CeErpSukuraData.createInfo(entity.ctid, 10);
  1082. }
  1083. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1084. returnSuccessMsg("标记成功!");
  1085. return;
  1086. }
  1087. returnErrorMsg("找不到记录");
  1088. }
  1089. }
  1090. public void upd_erp_ordertag_cancel()
  1091. {
  1092. if (UrlPostParmsCheck("ctid"))
  1093. {
  1094. string eid = GetPostString("ctid");
  1095. CeErpTradeCell entity = null;
  1096. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1097. if (entity != null)
  1098. {
  1099. entity.wechatTag = 0;
  1100. entity.Update();
  1101. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1102. if (pers != null)
  1103. {
  1104. pers.status = "取消推购";
  1105. pers.audit_type = 3;
  1106. pers.Update();
  1107. }
  1108. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1109. returnSuccessMsg("标记成功!");
  1110. return;
  1111. }
  1112. returnErrorMsg("找不到记录");
  1113. }
  1114. }
  1115. public void upd_erp_addweichattag()
  1116. {
  1117. if (UrlPostParmsCheck("ctid"))
  1118. {
  1119. ;
  1120. string eid = GetPostString("ctid");
  1121. CeErpTradeCell entity = null;
  1122. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1123. if (entity != null)
  1124. {
  1125. if (entity.IsAddWechat > 0)
  1126. {
  1127. returnErrorMsg("此单已经标记过了");
  1128. return;
  1129. }
  1130. 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);
  1131. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1132. if (dt.Rows.Count > 0)
  1133. {
  1134. entity.IsAddWechat = 2;
  1135. }
  1136. else
  1137. {
  1138. entity.IsAddWechat = 1;
  1139. }
  1140. entity.Update();
  1141. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1142. returnSuccessMsg("标记成功!");
  1143. return;
  1144. }
  1145. returnErrorMsg("找不到记录");
  1146. }
  1147. }
  1148. public void upd_erp_getmyorder()
  1149. {
  1150. if (UrlPostParmsCheck("ctid"))
  1151. {
  1152. ;
  1153. string eid = GetPostString("ctid");
  1154. CeErpTradeCell entity = null;
  1155. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1156. if (entity != null)
  1157. {
  1158. if (entity.ctid.IndexOf("C") != -1)
  1159. {
  1160. StringBuilder sql = new StringBuilder();
  1161. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1162. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1163. if (dt.Rows.Count > 0)
  1164. {
  1165. decimal total = 0;
  1166. foreach (DataRow dr in dt.Rows)
  1167. {
  1168. total += Convert.ToDecimal(dr["payment"]);
  1169. }
  1170. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1171. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1172. {
  1173. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1174. return;
  1175. }
  1176. }
  1177. }
  1178. entity.CustomerUserId = CurrentUser.UserID;
  1179. if (entity.OrderState < 2)
  1180. {
  1181. entity.OrderState = 2;
  1182. if (entity.ShopId != 0)
  1183. {
  1184. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1185. }
  1186. }
  1187. entity.Update();
  1188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1189. returnSuccessMsg("领单成功!");
  1190. return;
  1191. }
  1192. returnErrorMsg("找不到记录");
  1193. }
  1194. }
  1195. public void getmyorder_from_init()
  1196. {
  1197. if (UrlPostParmsCheck("ctid"))
  1198. {
  1199. string eid = GetPostString("ctid");
  1200. CeErpTradeCell entity = null;
  1201. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1202. if (entity != null)
  1203. {
  1204. string sellerMemo = GetPostString("sellerMemo");
  1205. if (sellerMemo.Length > 0)
  1206. {
  1207. entity.seller_memo = sellerMemo;
  1208. }
  1209. string oterhMemo = GetPostString("otherMemo");
  1210. if (oterhMemo.Length > 0)
  1211. {
  1212. entity.OtherMemo = oterhMemo;
  1213. }
  1214. int urg = GetPostInt("urgency");
  1215. entity.IsUrgency = (urg == 1 ? true : false);
  1216. int wechat = GetPostInt("wechat");
  1217. int command = GetPostInt("command");
  1218. if (wechat == 1)
  1219. {
  1220. entity.wechatTag = 1;
  1221. }
  1222. if (command == 1)
  1223. {
  1224. entity.wechatTag = 2;
  1225. }
  1226. string pPro = GetPostString("pprofession");
  1227. if (pPro.Length > 0)
  1228. {
  1229. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1230. string spro = GetPostString("profession");
  1231. if (spro.Length > 0)
  1232. {
  1233. entity.ProfessionId = Convert.ToInt32(spro);
  1234. }
  1235. }
  1236. string proId = GetPostString("productId");
  1237. if (proId.Length > 0)
  1238. {
  1239. entity.ProductId = Convert.ToInt32(proId);
  1240. }
  1241. entity.Material = GetPostString("material");
  1242. entity.Craft = GetPostString("craft");
  1243. entity.CustomerUserId = CurrentUser.UserID;
  1244. if (entity.OrderState < 2)
  1245. {
  1246. entity.OrderState = 2;
  1247. if (entity.ShopId != 0)
  1248. {
  1249. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1250. }
  1251. }
  1252. entity.Update();
  1253. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1254. returnSuccessMsg("领单成功!");
  1255. return;
  1256. }
  1257. returnErrorMsg("找不到记录");
  1258. }
  1259. }
  1260. public void upd_erp_setrelationorder()
  1261. {
  1262. if (UrlPostParmsCheck("ctid"))
  1263. {
  1264. ;
  1265. string eid = GetPostString("ctid");
  1266. string ftid = GetPostString("ftid");
  1267. CeErpTradeCell entity = null;
  1268. CeErpTradeCell fentity = null;
  1269. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1270. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1271. if (fentity == null)
  1272. {
  1273. returnErrorMsg("找不到关联的主订单");
  1274. return;
  1275. }
  1276. if (entity != null)
  1277. {
  1278. if (entity.OrderState >= 5)
  1279. {
  1280. returnErrorMsg("本单已经设计完成无法关联");
  1281. return;
  1282. }
  1283. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1284. {
  1285. returnErrorMsg("线下单续审核后才能关联!");
  1286. return;
  1287. }
  1288. entity.ptid = ftid;
  1289. entity.OrderState = fentity.OrderState;
  1290. //entity.status = fentity.status;
  1291. entity.CustomerUserId = fentity.CustomerUserId;
  1292. entity.DesignUserId = fentity.DesignUserId;
  1293. entity.seller_memo = "补差价单:" + ftid;
  1294. entity.IsSample = 2;
  1295. entity.Update();
  1296. ApiVo apiVo = new ApiVo();
  1297. apiVo.orderNumber = ftid;
  1298. apiVo.payment = entity.payment;
  1299. apiVo.actionName = "repairDesign";
  1300. designHelper.API_WorkCore(apiVo);//repairDesign
  1301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1302. returnSuccessMsg("关联成功!");
  1303. return;
  1304. }
  1305. else
  1306. returnErrorMsg("找不到记录");
  1307. }
  1308. }
  1309. public void download_erp_neworder()
  1310. {
  1311. string seller = GetPostString("seller_nick");
  1312. string tid = GetPostString("tid");
  1313. if (seller.Length <= 0 || tid.Length <= 0)
  1314. {
  1315. returnErrorMsg("数据错误");
  1316. }
  1317. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1318. //{
  1319. // returnErrorMsg("找不到店铺Sessionkey");
  1320. //}
  1321. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1322. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1323. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1324. if (res.IndexOf("refOid") == -1)
  1325. {
  1326. returnErrorMsg("下载订单数据失败");
  1327. return;
  1328. }
  1329. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1330. returnSuccessMsg("下载完成");
  1331. //tmcHelper.createNewOrder(res);
  1332. //CeErpTrade entr = null;
  1333. //entr = CeErpTrade.Get(tid);
  1334. //if (entr != null)
  1335. //{
  1336. // returnSuccess("下载成功");
  1337. // //下载成功之后,Cell表生成对应的订单;
  1338. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1339. //}
  1340. //else
  1341. //{
  1342. // returnErrorMsg("下载失败或者创建订单失败");
  1343. //}
  1344. }
  1345. public void set_erp_atersale()
  1346. {
  1347. if (UrlPostParmsCheck("ctid"))
  1348. {
  1349. string eid = GetPostString("ctid");
  1350. string reason = GetPostString("AfterSaleReason");
  1351. CeErpTradeCell entity = null;
  1352. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1353. if (entity != null)
  1354. {
  1355. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1356. {
  1357. returnErrorMsg("此订单已经在售后");
  1358. return;
  1359. }
  1360. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1361. //entity.AfterSaleReason = reason;
  1362. entity.AfterSaleTime = DateTime.Now;
  1363. entity.Update();
  1364. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1365. returnSuccessMsg("转售后成功!");
  1366. return;
  1367. }
  1368. returnErrorMsg("找不到记录");
  1369. }
  1370. }
  1371. public void set_erp_withdraw()
  1372. {
  1373. if (UrlPostParmsCheck("ctid"))
  1374. {
  1375. try
  1376. {
  1377. string eid = GetPostString("ctid");//商品id
  1378. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1379. CeWithdraw ceWithdrawSelect = null;
  1380. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1381. if (ceWithdrawSelect != null)
  1382. {
  1383. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1384. {
  1385. ceWithdrawSelect.status = -1;
  1386. ceWithdrawSelect.Update();
  1387. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1388. returnSuccessMsg("重新发起审核成功");
  1389. return;
  1390. }
  1391. else
  1392. {
  1393. returnSuccessMsg("请勿重复申请!");
  1394. return;
  1395. }
  1396. }
  1397. else
  1398. {
  1399. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1400. if (string.IsNullOrEmpty(CustomerUserId))
  1401. {
  1402. CustomerUserId = "-1";
  1403. }
  1404. int Userid = CurrentUser.UserID;//用户id
  1405. CeWithdraw ceWithdraw = new CeWithdraw();
  1406. ceWithdraw.tid = eid;
  1407. ceWithdraw.userid = Userid;
  1408. ceWithdraw.providerid = CustomerUserId;
  1409. ceWithdraw.status = 3;
  1410. ceWithdraw.creationtime = DateTime.Now;
  1411. ceWithdraw.Create();
  1412. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1413. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1414. return;
  1415. }
  1416. }
  1417. catch
  1418. {
  1419. returnErrorMsg("申请撤回订单失败");
  1420. return;
  1421. }
  1422. }
  1423. }
  1424. public void ins_erp_billinfo()
  1425. {
  1426. if (UrlPostParmsCheck("ctid"))
  1427. {
  1428. string eid = GetPostString("ctid");
  1429. CeErpTradeCell entity = null;
  1430. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1431. if (entity != null)
  1432. {
  1433. CeErpBill bill = CeErpBill.GetByTid(eid);
  1434. bool isHave = false;
  1435. if (bill != null)
  1436. {
  1437. isHave = true;
  1438. if (bill.state != 4)
  1439. {
  1440. returnErrorMsg("此单已经申请过发票了");
  1441. return;
  1442. }
  1443. }
  1444. if (entity.IsNeedBill == 0)
  1445. {
  1446. entity.IsNeedBill = 1;
  1447. }
  1448. entity.Update();
  1449. string errjson = "";
  1450. try
  1451. {
  1452. CeErpBill bill_entity = new CeErpBill();
  1453. bill_entity.tid = entity.tid;
  1454. bill_entity.title = GetPostString("title");
  1455. string taxstr = GetPostString("tax");
  1456. taxstr = taxstr.Replace(" ", "");
  1457. bill_entity.tax = taxstr;
  1458. bill_entity.bank = GetPostString("bank");
  1459. string bankacstr = GetPostString("bankac");
  1460. bankacstr = bankacstr.Replace(" ", "");
  1461. bill_entity.bankac = bankacstr;
  1462. bill_entity.address = GetPostString("address");
  1463. bill_entity.phone = GetPostString("phone");
  1464. bill_entity.price = GetPostString("price");
  1465. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1466. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1467. {
  1468. billCount += 1;
  1469. }
  1470. string prebill = "ltb";
  1471. for (int idx = 1; idx <= billCount; idx++)
  1472. {
  1473. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1474. string billoid = prebill + idx + dtstr;
  1475. bill_entity.billOrderId += billoid;
  1476. if (idx < billCount)
  1477. {
  1478. bill_entity.billOrderId += ",";
  1479. }
  1480. }
  1481. bill_entity.productId = GetPostInt("ProductName");
  1482. bill_entity.num = GetPostInt("num");
  1483. bill_entity.unit = GetPostString("unit");
  1484. bill_entity.type = GetPostString("type");
  1485. bill_entity.sendType = GetPostString("SendType");
  1486. bill_entity.email = GetPostString("email");
  1487. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1488. bill_entity.shopName = GetPostString("ShopName");
  1489. bill_entity.applymemo = GetPostString("applyMemo");
  1490. bill_entity.createTime = DateTime.Now;
  1491. bill_entity.state = 0;
  1492. bill_entity.userId = CurrentUser.UserID;
  1493. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1494. bill_entity.Create();
  1495. }
  1496. catch (Exception ex)
  1497. {
  1498. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1499. returnErrorMsg("创建发票出错!");
  1500. return;
  1501. }
  1502. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1503. returnSuccessMsg("发票申请成功!");
  1504. return;
  1505. }
  1506. returnErrorMsg("找不到记录");
  1507. }
  1508. }
  1509. public void ins_erp_neworder()
  1510. {
  1511. if (UrlPostParmsCheck("receiver_name"))
  1512. {
  1513. CeErpTrade entity = new CeErpTrade();
  1514. string plat_form = GetPostString("platform");
  1515. string preStr = "N_";
  1516. if (plat_form == "拼多多")
  1517. {
  1518. preStr = "P_";
  1519. }
  1520. else if (plat_form == "阿里巴巴")
  1521. {
  1522. preStr = "A_";
  1523. }
  1524. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1525. entity.seller_nick = GetPostString("seller_nick");
  1526. entity.buyer_nick = GetPostString("buyer_nick");
  1527. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1528. entity.total_fee = entity.payment;
  1529. entity.pay_time = DateTime.Now;
  1530. entity.status = "NOT_SHIPPED";
  1531. entity.receiver_name = GetPostString("receiver_name");
  1532. entity.receiver_mobile = GetPostString("receiver_mobile");
  1533. entity.receiver_state = GetPostString("receiver_state");
  1534. entity.receiver_city = GetPostString("receiver_city");
  1535. entity.receiver_district = GetPostString("receiver_district");
  1536. entity.receiver_address = GetPostString("receiver_address");
  1537. if (entity.receiver_state == "" || entity.receiver_city == "")
  1538. {
  1539. returnErrorMsg("收件地址不能为空");
  1540. return;
  1541. }
  1542. int shopId = 0;
  1543. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1544. if (nShop != null)
  1545. {
  1546. shopId = nShop.ID;
  1547. }
  1548. if (shopId != 34 && entity.payment == 0)
  1549. {
  1550. returnErrorMsg("公司自用的单金额才能为0");
  1551. return;
  1552. }
  1553. entity.Create();
  1554. CeErpTradeCell entitycell = new CeErpTradeCell();
  1555. entitycell.ctid = entity.tid;
  1556. entitycell.tid = entity.tid;
  1557. entitycell.ShopId = shopId;
  1558. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1559. entitycell.OrderState = 0;
  1560. entitycell.pay_time = entity.pay_time;
  1561. entitycell.IsOffLineOrder = 1;
  1562. entitycell.Create();
  1563. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1564. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1565. return;
  1566. }
  1567. }
  1568. public void ins_erp_neworder2()
  1569. {
  1570. if (UrlPostParmsCheck("receiver_name"))
  1571. {
  1572. //string plat_form = GetPostString("platform");
  1573. string preStr = "X_";
  1574. string memo = GetPostString("memo");
  1575. string productId = GetPostString("productId");
  1576. string primg = GetPostString("proofimg");
  1577. string sellerNick = GetPostString("seller_nick");
  1578. string addFrom = GetPostString("addfrom");
  1579. if (addFrom == "1")
  1580. {
  1581. preStr = "N_";
  1582. }
  1583. int shopId = 0;
  1584. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1585. if (nShop != null)
  1586. {
  1587. shopId = nShop.ID;
  1588. }
  1589. else
  1590. {
  1591. returnErrorMsg("找不到对应店铺");
  1592. return;
  1593. }
  1594. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1595. {
  1596. returnErrorMsg("必须上传付款凭证");
  1597. return;
  1598. }
  1599. CeErpTrade entity = new CeErpTrade();
  1600. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1601. entity.seller_nick = sellerNick;
  1602. entity.buyer_nick = GetPostString("buyer_nick");
  1603. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1604. entity.total_fee = entity.payment;
  1605. entity.pay_time = DateTime.Now;
  1606. entity.status = "NOT_SHIPPED";
  1607. entity.receiver_name = GetPostString("receiver_name");
  1608. entity.receiver_mobile = GetPostString("receiver_mobile");
  1609. entity.receiver_state = GetPostString("receiver_state");
  1610. entity.receiver_city = GetPostString("receiver_city");
  1611. entity.receiver_district = GetPostString("receiver_district");
  1612. entity.receiver_address = GetPostString("receiver_address");
  1613. entity.seller_memo = memo;
  1614. entity.orderFrom = 20;
  1615. entity.orderType = 15;
  1616. if (entity.receiver_state == "" || entity.receiver_city == "")
  1617. {
  1618. returnErrorMsg("收件地址不能为空");
  1619. return;
  1620. }
  1621. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1622. {
  1623. returnErrorMsg("公司自用的单金额才能为0");
  1624. return;
  1625. }
  1626. entity.Create();
  1627. string toWhere = GetPostString("towhere");
  1628. CeErpTradeCell entitycell = new CeErpTradeCell();
  1629. entitycell.ctid = entity.tid;
  1630. //唯一标识
  1631. entitycell.OrderSn = entity.tid;
  1632. //string orderSn = dataHelper.getSaleOrderSn();
  1633. //if (orderSn != "")
  1634. // {
  1635. // entitycell.OrderSn = orderSn;
  1636. // }
  1637. entitycell.tid = entity.tid;
  1638. //if (preStr == "X_")
  1639. //{
  1640. entitycell.IsOffLineOrder = 1;
  1641. //}
  1642. entitycell.CustomerUserId = CurrentUser.UserID;
  1643. entitycell.PayProofImg = primg;
  1644. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1645. entitycell.ProductId = Convert.ToInt32(productId);
  1646. entitycell.ShopId = shopId;
  1647. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1648. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1649. {
  1650. entitycell.IsXianHuo = 1;
  1651. }
  1652. entitycell.pay_time = entity.pay_time;
  1653. if (toWhere == "1")
  1654. {
  1655. entitycell.OrderState = 2;
  1656. }
  1657. else
  1658. {
  1659. entitycell.OrderState = 6;
  1660. entitycell.FinishPlaceTime = entitycell.pay_time;
  1661. }
  1662. if (shopId == 94)
  1663. {
  1664. entitycell.OrderState = 4;
  1665. entitycell.WaitDesignTime = entitycell.pay_time;
  1666. entitycell.StartDesignTime = entitycell.pay_time;
  1667. entitycell.DesignUserId = 218;
  1668. }
  1669. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1670. {
  1671. entitycell.OrderState = -1;//修改12-5
  1672. CeWithdraw ceWithdraw = new CeWithdraw();
  1673. ceWithdraw.tid = entity.tid;
  1674. ceWithdraw.providerid = "-1";
  1675. ceWithdraw.status = -1;
  1676. ceWithdraw.creationtime = DateTime.Now;
  1677. ceWithdraw.userid = 1337;
  1678. ceWithdraw.Create();
  1679. }
  1680. entitycell.Create();
  1681. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1682. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1683. {
  1684. addPlaceRegist(entitycell, CurrentUser.UserID);
  1685. }
  1686. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1687. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1688. return;
  1689. }
  1690. }
  1691. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1692. {
  1693. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1694. entity.PlactTime = tradecell.pay_time;
  1695. entity.AddUserId = userid;
  1696. entity.FileName = tradecell.seller_memo;
  1697. entity.Supplier = 24;
  1698. entity.CreateTime = DateTime.Now;
  1699. entity.Did = tradecell.ctid;
  1700. entity.tid = tradecell.tid;
  1701. entity.splitTag = tradecell.SplitTag;
  1702. entity.CurState = "未完成";
  1703. entity.Create();
  1704. }
  1705. public void get_erp_offlinelist()
  1706. {
  1707. DataStruct dStruct = GetPostStruct();
  1708. List<string> lw = new List<string>();
  1709. string tid = GetPostString("ctid");
  1710. string date1 = GetPostString("date1");
  1711. string date2 = GetPostString("date2");
  1712. if (tid.Length > 0 || date1.Length > 0)
  1713. {
  1714. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1715. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1716. if (dw.Length > 0) lw.Add(dw);
  1717. }
  1718. else
  1719. {
  1720. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1721. }
  1722. string shopname = GetPostString("shopname");
  1723. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1724. string buyernick = GetPostString("buyer_nick");
  1725. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1726. string customer = GetPostString("customer");
  1727. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1728. string design = GetPostString("design");
  1729. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1730. string orderState = GetPostString("orderState");
  1731. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1732. string address = GetPostString("address");
  1733. 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));
  1734. string sellermemo = GetPostString("seller_memo");
  1735. if (sellermemo.Length > 0)
  1736. {
  1737. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1738. }
  1739. string price1 = GetPostString("price1");
  1740. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1741. string price2 = GetPostString("price2");
  1742. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1743. //if (PKey != "admin")
  1744. //{
  1745. // string usershop = CurrentUser.User.pemShop;
  1746. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1747. //}
  1748. //if (ex_psize > 0)
  1749. //{
  1750. dStruct.Order = "pay_time desc";
  1751. //}
  1752. //else
  1753. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1754. lw.Add(string.Format("IsOffLineOrder=1"));
  1755. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1756. DataTable dt = null;
  1757. dt = WebCache.GetData("view_erptradecell", dStruct);
  1758. writeGridDataTableJson(dStruct.TotalCount, dt);
  1759. }
  1760. public void get_erp_returncashrecord()
  1761. {
  1762. DataStruct dStruct = GetPostStruct();
  1763. List<string> lw = new List<string>();
  1764. string tid = GetPostString("ctid");
  1765. if (tid.Length > 0)
  1766. {
  1767. lw.Add(string.Format("tid like '%{0}%'", tid));
  1768. dStruct.Order = "id desc";
  1769. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1770. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1771. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1772. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1773. return;
  1774. }
  1775. returnErrorMsg("id数据错误!");
  1776. }
  1777. public void ins_erp_returncashrecord()
  1778. {
  1779. if (UrlPostParmsCheck("tid"))
  1780. {
  1781. string tid = GetPostString("tid");
  1782. string retype = GetPostString("type");
  1783. StringBuilder sql = new StringBuilder();
  1784. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1785. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1786. if (dt.Rows.Count > 0)
  1787. {
  1788. returnErrorMsg("相同返现类型记录已存在");
  1789. return;
  1790. }
  1791. CeErpReturnCash entity = new CeErpReturnCash();
  1792. entity.tid = tid;
  1793. entity.seller_nick = GetPostString("seller_nick");
  1794. string pment = GetPostString("payment");
  1795. if (pment.Length > 0)
  1796. {
  1797. entity.payment = Convert.ToDouble(pment);
  1798. }
  1799. entity.buyer_nick = GetPostString("buyer_nick");
  1800. entity.cashstate = 0;
  1801. entity.rtype = retype;
  1802. string rPrice = GetPostString("returnprice");
  1803. if (rPrice.Length > 0)
  1804. {
  1805. entity.returnprice = Convert.ToDouble(rPrice);
  1806. }
  1807. entity.created = DateTime.Now;
  1808. entity.con = GetPostString("con");
  1809. entity.img = GetPostString("img");
  1810. entity.applyuserid = CurrentUser.UserID;
  1811. entity.Create();
  1812. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1813. returnSuccessMsg("操作成功!");
  1814. return;
  1815. }
  1816. }
  1817. public void set_erp_predelivery()
  1818. {
  1819. if (UrlPostParmsCheck("ctid"))
  1820. {
  1821. string eid = GetPostString("ctid");
  1822. CeErpTradeCell entity = null;
  1823. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1824. if (entity != null)
  1825. {
  1826. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1827. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1828. //{
  1829. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1830. // return;
  1831. //}
  1832. entity.IsPreDelivery = 1;
  1833. entity.Update();
  1834. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1835. returnSuccessMsg("预发货成功!");
  1836. return;
  1837. //string shop = GetPostString("seller_nick");
  1838. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1839. //string comName = GetPostString("comName");
  1840. //string comCode = GetPostString("comCode");
  1841. //string outSid = GetPostString("outSid");//运单号
  1842. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1843. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1844. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1845. //string apires = "";
  1846. //if (deliveryType == "虚拟发货")
  1847. //{
  1848. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1849. //}
  1850. //else
  1851. //{
  1852. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1853. //}
  1854. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1855. ////{
  1856. //if (apires.IndexOf("发货成功") != -1)
  1857. //{
  1858. // if (deliveryType != "虚拟发货")
  1859. // {
  1860. // //还要插入快递信息到 快递信息表
  1861. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1862. // exinfo.tid = eid;
  1863. // exinfo.out_sid = outSid;
  1864. // exinfo.company_code = comCode;
  1865. // exinfo.company_name = comName;
  1866. // exinfo.delivery_memo = deliveryMemo;
  1867. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1868. // exinfo.deliveryType = deliveryType;
  1869. // exinfo.Create();
  1870. // }
  1871. // returnSuccessMsg("发货成功!");
  1872. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1873. //}
  1874. //else
  1875. //{
  1876. // returnErrorMsg("淘宝发货失败!!");
  1877. //}
  1878. //return;
  1879. }
  1880. returnErrorMsg("找不到订单记录");
  1881. }
  1882. }
  1883. public void get_erp_unusuallist()
  1884. {
  1885. DataStruct dStruct = GetPostStruct();
  1886. List<string> lw = new List<string>();
  1887. string tid = GetPostString("ctid");
  1888. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1889. string shopname = GetPostString("shopname");
  1890. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1891. string buyernick = GetPostString("buyer_nick");
  1892. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1893. string ResponsibleMan = GetPostString("responsible");
  1894. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1895. string date1 = GetPostString("date1");
  1896. string date2 = GetPostString("date2");
  1897. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1898. if (dw.Length > 0) lw.Add(dw);
  1899. string price1 = GetPostString("price1");
  1900. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1901. string price2 = GetPostString("price2");
  1902. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1903. string orderState = GetPostString("orderState");
  1904. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1905. string sellermemo = GetPostString("seller_memo");
  1906. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1907. lw.Add(string.Format("UnusualTag > 0"));
  1908. lw.Add(string.Format("IsRefund<={0}", 1));
  1909. dStruct.Order = "pay_time desc";
  1910. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1911. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1912. writeGridDataTableJson(dStruct.TotalCount, dt);
  1913. }
  1914. public void set_erp_unusualtonomal()
  1915. {
  1916. if (UrlPostParmsCheck("ctid"))
  1917. {
  1918. string eid = GetPostString("ctid");
  1919. CeErpTradeCell entity = null;
  1920. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1921. if (entity != null)
  1922. {
  1923. entity.UnusualTag = -1;
  1924. entity.Update();
  1925. returnSuccessMsg("忽略成功!");
  1926. return;
  1927. }
  1928. returnErrorMsg("找不到记录");
  1929. }
  1930. }
  1931. public void ins_erp_unusualreason()
  1932. {
  1933. if (UrlPostParmsCheck("ctid"))
  1934. {
  1935. string eid = GetPostString("ctid");
  1936. CeErpTradeCell entity = null;
  1937. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1938. if (entity != null)
  1939. {
  1940. entity.MemoOpt = 4;
  1941. entity.UnusualCon = GetPostString("con");
  1942. entity.Update();
  1943. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1944. if (trade != null)
  1945. {
  1946. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1947. }
  1948. //查货是否超时
  1949. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1950. if (ceErpTradeCellExtend == null)
  1951. {
  1952. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1953. ceErpTradeCellExtend.ctid = entity.ctid;
  1954. }
  1955. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1956. {
  1957. ceErpTradeCellExtend.CheckOut += 1;
  1958. }
  1959. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1960. if (ceErpTradeCellExtend.ID > 0)
  1961. {
  1962. ceErpTradeCellExtend.Update();
  1963. }
  1964. else
  1965. {
  1966. ceErpTradeCellExtend.Create();
  1967. }
  1968. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1969. returnSuccessMsg("操作成功!");
  1970. return;
  1971. }
  1972. returnErrorMsg("找不到记录");
  1973. }
  1974. }
  1975. public void upd_erp_sampleorder()
  1976. {
  1977. if (UrlPostParmsCheck("ctid"))
  1978. {
  1979. string eid = GetPostString("ctid");
  1980. string[] eArr = eid.Split(',');
  1981. if (eArr.Length > 1)
  1982. {
  1983. List<string> eLst = new List<string>();
  1984. for (int i = 0; i < eArr.Length; i++)
  1985. {
  1986. eLst.Add("'" + eArr[i] + "'");
  1987. }
  1988. eid = string.Join(",", eLst.ToArray());
  1989. }
  1990. else
  1991. {
  1992. eid = "'" + eid + "'";
  1993. }
  1994. StringBuilder sql = new StringBuilder();
  1995. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1996. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1997. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1998. if (dt.Rows.Count > 0)
  1999. {
  2000. string errmsg = "";
  2001. foreach (DataRow dr in dt.Rows)
  2002. {
  2003. StringBuilder sqlsb = new StringBuilder();
  2004. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2005. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2006. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2007. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2008. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2009. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2010. {
  2011. continue;
  2012. }
  2013. else
  2014. {
  2015. string emsg = commonHelper.KeepChinese(apires);
  2016. errmsg += emsg;
  2017. }
  2018. }
  2019. if (errmsg.Length > 0)
  2020. {
  2021. returnErrorMsg(errmsg);
  2022. return;
  2023. }
  2024. returnSuccessMsg("操作成功");
  2025. return;
  2026. }
  2027. returnErrorMsg("找不到记录");
  2028. }
  2029. }
  2030. public void upd_erp_transcustomer()
  2031. {
  2032. if (UrlPostParmsCheck("ctid"))
  2033. {
  2034. string eid = GetPostString("ctid");
  2035. int userid = GetPostInt("CustomerUserId");
  2036. CeErpTradeCell entity = null;
  2037. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2038. if (entity != null)
  2039. {
  2040. //string[] mlist = entity.seller_memo.Split('-');
  2041. //string sql = "select * from view_erpuser where id=" + userid;
  2042. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2043. //if (dt != null && dt.Rows.Count > 0)
  2044. //{
  2045. // string nmemo = "";
  2046. // for(int i = 0; i < mlist.Length - 1; i++)
  2047. // {
  2048. // nmemo += mlist[i];
  2049. // nmemo += "-";
  2050. // }
  2051. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2052. // entity.seller_memo = nmemo;
  2053. //}
  2054. entity.CustomerUserId = userid;
  2055. entity.Update();
  2056. returnSuccessMsg("操作成功!");
  2057. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2058. return;
  2059. }
  2060. returnErrorMsg("找不到记录");
  2061. }
  2062. }
  2063. public void upd_erp_transdesigner()
  2064. {
  2065. if (UrlPostParmsCheck("ctid"))
  2066. {
  2067. string eids = GetPostString("ctid");
  2068. string[] ctidList = eids.Split(',');
  2069. int userid = GetPostInt("DesignUserId");
  2070. foreach (string ctid in ctidList)
  2071. {
  2072. CeErpTradeCell entity = null;
  2073. CeErpDesignerBill entitys = null;
  2074. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2075. entitys = CeErpDesignerBill.GetByTid(ctid);
  2076. if (entity != null)
  2077. {
  2078. if (entity.OrderState > 4)
  2079. {
  2080. continue;
  2081. }
  2082. //存在退款不能流转
  2083. if (entity.IsRefund > 0)
  2084. {
  2085. continue;
  2086. }
  2087. entity.DesignUserId = userid;
  2088. entity.WaitDesignTime = DateTime.Now;
  2089. entity.Update();
  2090. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2091. }
  2092. }
  2093. returnSuccessMsg("操作成功!");
  2094. }
  2095. }
  2096. public void upd_erp_distributedesigner()
  2097. {
  2098. if (UrlPostParmsCheck("ctid"))
  2099. {
  2100. string eid = GetPostString("ctid");
  2101. int userid = GetPostInt("DesignUserId");
  2102. string[] idlist = eid.Split(',');
  2103. if (idlist.Length <= 0)
  2104. {
  2105. returnErrorMsg("订单不能为空");
  2106. return;
  2107. }
  2108. foreach (string ctid in idlist)
  2109. {
  2110. CeErpTradeCell entity = null;
  2111. CeErpDesignerBill entitys = null;
  2112. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2113. else continue;
  2114. if (entity != null)
  2115. {
  2116. if (userid == 2125 || userid == 3542)
  2117. { }
  2118. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2119. {
  2120. returnErrorMsg("金额错误的订单无法指派");
  2121. return;
  2122. }
  2123. if (entity.OrderState >= 5)
  2124. {
  2125. returnErrorMsg("已经设计完成无法指派");
  2126. return;
  2127. }
  2128. if (entity.OrderState == -1)
  2129. {
  2130. returnErrorMsg("审核中的订单无法指派");
  2131. return;
  2132. }
  2133. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2134. {
  2135. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2136. return;
  2137. }
  2138. //157赖橙帆 159林晨
  2139. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479)
  2140. {
  2141. returnErrorMsg("指派设计共创无法再次指派!");
  2142. return;
  2143. }
  2144. entity.OrderState = 3;
  2145. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2146. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2147. {
  2148. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2149. entity.SupplierId = suid;
  2150. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2151. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2152. }
  2153. if (userid == 2125 && entity.seller_memo != "")
  2154. {
  2155. apiDesign.API_GetPrintData_CreateOrder(entity);
  2156. }
  2157. if (userid == 3542 && entity.seller_memo != "")
  2158. {
  2159. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2160. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2161. if (response.msg != "设计共创:成功")
  2162. {
  2163. returnErrorMsg(response.msg);
  2164. return;
  2165. }
  2166. entity.DispatchSort = 2;
  2167. }
  2168. else
  2169. {
  2170. if (entity.DispatchSort == 2)
  2171. {
  2172. ApiVo apiVo = new ApiVo();
  2173. apiVo.actionName = "closeDesign";
  2174. apiVo.orderNumber = entity.ctid;
  2175. designHelper.API_WorkCore(apiVo);//closeDesign
  2176. }
  2177. entity.DispatchSort = 0;
  2178. }
  2179. entity.DesignUserId = userid;
  2180. entity.WaitDesignTime = DateTime.Now;
  2181. entity.Update();
  2182. string name = commonHelper.getUserNameById(userid);
  2183. commonHelper.UpdateRelationOrder(entity.ctid);
  2184. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2185. }
  2186. }
  2187. returnSuccessMsg("操作成功!");
  2188. return;
  2189. }
  2190. }
  2191. public void get_erp_myorderlist()
  2192. {
  2193. DataStruct dStruct = GetPostStruct();
  2194. List<string> lw = new List<string>();
  2195. string tid = GetPostString("ctid");
  2196. if (tid.Length > 0)
  2197. {
  2198. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2199. }
  2200. else
  2201. {
  2202. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2203. }
  2204. //12-1 修改
  2205. string urgent = GetPostString("urgent");
  2206. string back = GetPostString("back");
  2207. string offlineSearch = GetPostString("offlineSearch");
  2208. if (!string.IsNullOrWhiteSpace(urgent))
  2209. {
  2210. if (urgent.Equals("true"))
  2211. {
  2212. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2213. }
  2214. }
  2215. if (!string.IsNullOrWhiteSpace(back))
  2216. {
  2217. if (back.Equals("true"))
  2218. {
  2219. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2220. }
  2221. }
  2222. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2223. {
  2224. if (offlineSearch.Equals("true"))
  2225. {
  2226. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2227. }
  2228. }
  2229. //end
  2230. string shopname = GetPostString("shopname");
  2231. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2232. string buyernick = GetPostString("buyer_nick");
  2233. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2234. string design = GetPostString("design");
  2235. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2236. string orderState = GetPostString("orderState");
  2237. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2238. string sellermemo = GetPostString("seller_memo");
  2239. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2240. string date1 = GetPostString("date1");
  2241. string date2 = GetPostString("date2");
  2242. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2243. if (dw.Length > 0) lw.Add(dw);
  2244. string price1 = GetPostString("price1");
  2245. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2246. string price2 = GetPostString("price2");
  2247. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2248. string urgency = GetPostString("urgency");
  2249. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2250. string after = GetPostString("after");
  2251. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2252. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2253. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2254. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2255. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2256. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2257. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2258. if (dt != null && dt.Rows.Count > 0)
  2259. {
  2260. foreach (DataRow dr in dt.Rows)
  2261. {
  2262. try
  2263. {
  2264. // 对象操作
  2265. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2266. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2267. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2268. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2269. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2270. if (dStruct.PageSize != 100000)
  2271. {
  2272. if (dr["DispatchSort"].ToString() == "2")
  2273. {
  2274. dr["gongchuang"] = 200;
  2275. }
  2276. else
  2277. {
  2278. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2279. dr["gongchuang"] = response.code;
  2280. }
  2281. }
  2282. }
  2283. catch (NullReferenceException ex)
  2284. {
  2285. }
  2286. }
  2287. }
  2288. writeGridDataTableJson(dStruct.TotalCount, dt);
  2289. }
  2290. public void get_erp_myreturnorderlist()
  2291. {
  2292. DataStruct dStruct = GetPostStruct();
  2293. List<string> lw = new List<string>();
  2294. string tid = GetPostString("ctid");
  2295. if (tid.Length > 0)
  2296. {
  2297. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2298. }
  2299. else
  2300. {
  2301. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2302. }
  2303. string shopname = GetPostString("shopname");
  2304. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2305. string buyernick = GetPostString("buyer_nick");
  2306. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2307. string design = GetPostString("design");
  2308. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2309. string orderState = GetPostString("orderState");
  2310. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2311. string sellermemo = GetPostString("seller_memo");
  2312. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2313. string date1 = GetPostString("date1");
  2314. string date2 = GetPostString("date2");
  2315. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2316. if (dw.Length > 0) lw.Add(dw);
  2317. string price1 = GetPostString("price1");
  2318. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2319. string price2 = GetPostString("price2");
  2320. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2321. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2322. {
  2323. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2324. }
  2325. else
  2326. {
  2327. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2328. }
  2329. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2330. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2331. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2332. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2333. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2334. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2335. if (dt != null && dt.Rows.Count > 0)
  2336. {
  2337. foreach (DataRow dr in dt.Rows)
  2338. {
  2339. try
  2340. {
  2341. // 对象操作
  2342. if (dStruct.PageSize != 100000)
  2343. {
  2344. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2345. dr["gongchuang"] = response.code;
  2346. }
  2347. }
  2348. catch (NullReferenceException ex)
  2349. {
  2350. // 处理空引用异常
  2351. }
  2352. }
  2353. }
  2354. writeGridDataTableJson(dStruct.TotalCount, dt);
  2355. }
  2356. public void get_erp_myorderlist_pregather()
  2357. {
  2358. string date1 = GetPostString("date1");
  2359. string date2 = GetPostString("date2");
  2360. int userId = CurrentUser.UserID; //客服id
  2361. string orderWhere = "";
  2362. List<string> lw = new List<string>();
  2363. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2364. if (dw.Length > 0) lw.Add(dw);
  2365. lw.Add(string.Format("CustomerUserId={0}", userId));
  2366. lw.Add(string.Format("OrderState<9"));
  2367. orderWhere = string.Join(" and ", lw.ToArray());
  2368. string orderWhere2 = "";
  2369. List<string> lw2 = new List<string>();
  2370. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2371. if (dw2.Length > 0) lw2.Add(dw2);
  2372. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2373. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2374. string sql = string.Format("select *" +
  2375. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2376. "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 " +
  2377. "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 " +
  2378. "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");
  2379. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2380. //writeGridDataTableJson(dt.Rows.Count, dt);
  2381. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2382. }
  2383. public void upd_erp_publishorder()
  2384. {
  2385. if (UrlPostParmsCheck("ctid"))
  2386. {
  2387. string eid = GetPostString("ctid");
  2388. CeErpTradeCell entity = null;
  2389. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2390. if (entity != null)
  2391. {
  2392. entity.OrderState = 0; //发布后,变为待抢单
  2393. entity.Update();
  2394. commonHelper.UpdateRelationOrder(entity.ctid);
  2395. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2396. returnSuccessMsg("发布成功!");
  2397. return;
  2398. }
  2399. returnErrorMsg("找不到记录");
  2400. }
  2401. }
  2402. public void get_erp_my_tiporder()
  2403. {
  2404. StringBuilder sql = new StringBuilder();
  2405. int userId = 0;
  2406. if (CurrentUser != null) userId = CurrentUser.UserID;
  2407. string posCode = CurrentUser.UserPost.Post.Code;
  2408. string isTipedAfterSaleVerify = GetPostString("af");
  2409. DataTable dt = new DataTable();
  2410. if (posCode != "Supplier")
  2411. {
  2412. if (posCode == "CustomerService" || posCode == "Director")
  2413. {
  2414. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2415. }
  2416. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2417. {
  2418. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2419. }
  2420. else
  2421. {
  2422. string teamIds = CurrentUser.User.TeamIds;
  2423. if (teamIds == "")
  2424. {
  2425. teamIds = "0";
  2426. }
  2427. 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);
  2428. }
  2429. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2430. }
  2431. if (dt.Rows.Count <= 0)
  2432. {
  2433. string key = "aftersale_order_" + userId;
  2434. if (RedisHelper.HasKey(key))
  2435. {
  2436. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2437. dt.Columns.Add("ctid", typeof(string));
  2438. dt.Columns.Add("IsReadTag", typeof(int));
  2439. foreach (var i in list)
  2440. {
  2441. DataRow data = dt.NewRow();
  2442. data["ctid"] = i;
  2443. data["IsReadTag"] = 4;
  2444. dt.Rows.Add(data);
  2445. }
  2446. RedisHelper.StringDelete(key);
  2447. }
  2448. }
  2449. if (dt.Rows.Count <= 0)
  2450. {
  2451. sql = new StringBuilder();
  2452. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2453. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2454. }
  2455. if (posCode == "Supplier")
  2456. {
  2457. string ids = CurrentUser.User.pemVend;
  2458. if (ids != null && ids.Length > 0)
  2459. {
  2460. string[] ids_list = ids.Split(',');
  2461. foreach (var item in ids_list)
  2462. {
  2463. string key = "return_order_" + item;
  2464. if (RedisHelper.HasKey(key))
  2465. {
  2466. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2467. dt.Columns.Add("ctid", typeof(string));
  2468. dt.Columns.Add("IsReadTag", typeof(int));
  2469. foreach (var i in list)
  2470. {
  2471. DataRow data = dt.NewRow();
  2472. data["ctid"] = i;
  2473. data["IsReadTag"] = 1;
  2474. dt.Rows.Add(data);
  2475. }
  2476. RedisHelper.StringDelete(key);
  2477. }
  2478. }
  2479. }
  2480. if (dt.Rows.Count <= 0)
  2481. {
  2482. sql = new StringBuilder();
  2483. 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);
  2484. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2485. }
  2486. }
  2487. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2488. }
  2489. public void reset_erp_tiporder()
  2490. {
  2491. string ids = GetPostString("ids");
  2492. string[] ctidList = ids.Split(',');
  2493. foreach (string ctid in ctidList)
  2494. {
  2495. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2496. if (enty != null)
  2497. {
  2498. enty.IsReadTag = 0;
  2499. enty.Update();
  2500. }
  2501. }
  2502. returnSuccessMsg("成功!");
  2503. return;
  2504. }
  2505. public void get_erp_designlist()
  2506. {
  2507. DataStruct dStruct = GetPostStruct();
  2508. List<string> lw = new List<string>();
  2509. string tid = GetPostString("ctid");
  2510. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2511. string shopname = GetPostString("shopname");
  2512. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2513. string buyernick = GetPostString("buyer_nick");
  2514. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2515. string customer = GetPostString("customer");
  2516. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2517. string design = GetPostString("design");
  2518. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2519. string orderState = GetPostString("orderState");
  2520. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2521. lw.Add(string.Format("OrderState<6"));
  2522. string address = GetPostString("address");
  2523. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2524. string sellermemo = GetPostString("seller_memo");
  2525. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2526. string date1 = GetPostString("date1");
  2527. string date2 = GetPostString("date2");
  2528. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2529. if (dw.Length > 0) lw.Add(dw);
  2530. string apdate1 = GetPostString("apdate1");
  2531. string apdate2 = GetPostString("apdate2");
  2532. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2533. if (dwap.Length > 0) lw.Add(dwap);
  2534. string price1 = GetPostString("price1");
  2535. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2536. string price2 = GetPostString("price2");
  2537. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2538. string designTime = GetPostString("designtime");
  2539. if (designTime.Length > 0)
  2540. {
  2541. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2542. }
  2543. string usershop = CurrentUser.User.pemShop;
  2544. if (usershop.Length > 0)
  2545. {
  2546. lw.Add(string.Format("shopId in ({0})", usershop));
  2547. }
  2548. int myOrgid = CurrentUser.UserPost.OrgID;
  2549. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2550. if (myOrgCode.IndexOf("Designer") != -1)
  2551. {
  2552. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2553. {
  2554. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2555. }
  2556. else
  2557. {
  2558. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2559. }
  2560. }
  2561. else
  2562. {
  2563. string orgId = GetPostString("designerhd");
  2564. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2565. }
  2566. if (tid.Length > 0 || buyernick.Length > 0)
  2567. {
  2568. lw.Add(string.Format("OrderState >= 3"));
  2569. }
  2570. else
  2571. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2572. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2573. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2574. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2575. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2576. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2577. if (dt != null && dt.Rows.Count > 0)
  2578. {
  2579. foreach (DataRow dr in dt.Rows)
  2580. {
  2581. try
  2582. {
  2583. // 对象操作
  2584. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2585. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2586. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2587. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2588. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2589. if (dStruct.PageSize != 100000)
  2590. {
  2591. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2592. dr["gongchuang"] = response.code;
  2593. }
  2594. }
  2595. catch (NullReferenceException ex)
  2596. {
  2597. }
  2598. }
  2599. }
  2600. writeGridDataTableJson(dStruct.TotalCount, dt);
  2601. }
  2602. public void get_erp_mydesignlist()
  2603. {
  2604. DataStruct dStruct = GetPostStruct();
  2605. List<string> lw = new List<string>();
  2606. string tid = GetPostString("ctid");
  2607. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2608. string shopname = GetPostString("shopname");
  2609. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2610. string buyernick = GetPostString("buyer_nick");
  2611. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2612. string customer = GetPostString("customer");
  2613. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2614. string orderState = GetPostString("orderState");
  2615. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2616. //lw.Add(string.Format("OrderState<6"));
  2617. string date1 = GetPostString("date1");
  2618. string date2 = GetPostString("date2");
  2619. string dw = GetDateWhere("pay_time", date1, date2);
  2620. if (dw.Length > 0) lw.Add(dw);
  2621. string apdate1 = GetPostString("apdate1");
  2622. string apdate2 = GetPostString("apdate2");
  2623. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2624. if (dwap.Length > 0) lw.Add(dwap);
  2625. string price1 = GetPostString("price1");
  2626. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2627. string price2 = GetPostString("price2");
  2628. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2629. string olddownload = GetPostString("olddown");
  2630. if (olddownload == "1")
  2631. {
  2632. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2633. }
  2634. else if (olddownload == "2")
  2635. {
  2636. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2637. }
  2638. string sellermemo = GetPostString("seller_memo");
  2639. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2640. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2641. if (CurrentUser.User.TeamIds.Length > 0)
  2642. {
  2643. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2644. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2645. else
  2646. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2647. }
  2648. else
  2649. {
  2650. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2651. }
  2652. if (tid.Length <= 0)
  2653. {
  2654. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2655. }
  2656. lw.Add(string.Format("IsReturn!=3"));
  2657. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2658. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2659. string teamids = CurrentUser.User.TeamIds.ToString();
  2660. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2661. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2662. if (dt != null && dt.Rows.Count > 0)
  2663. {
  2664. foreach (DataRow dr in dt.Rows)
  2665. {
  2666. try
  2667. {
  2668. // 对象操作
  2669. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2670. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2671. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2672. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2673. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2674. if (dStruct.PageSize != 100000)
  2675. {
  2676. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2677. dr["gongchuang"] = response.code;
  2678. }
  2679. }
  2680. catch (NullReferenceException ex)
  2681. {
  2682. }
  2683. }
  2684. }
  2685. writeGridDataTableJson(dStruct.TotalCount, dt);
  2686. }
  2687. public void set_erp_startdesign()
  2688. {
  2689. if (UrlPostParmsCheck("ctid"))
  2690. {
  2691. string eid = GetPostString("ctid");
  2692. CeErpTradeCell entity = null;
  2693. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2694. if (entity != null)
  2695. {
  2696. if (entity.OrderState != 3)
  2697. {
  2698. returnErrorMsg("请刷新,订单已经设计了");
  2699. return;
  2700. }
  2701. entity.StartDesignTime = DateTime.Now;
  2702. entity.OrderState = 4;
  2703. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2704. {
  2705. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2706. entity.SupplierId = suid;
  2707. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2708. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2709. }
  2710. //entity.MakeSupplier = suname;
  2711. entity.Update();
  2712. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2713. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2714. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2715. commonHelper.getCytPrice(entity);
  2716. returnSuccessMsg("操作成功!");
  2717. return;
  2718. }
  2719. returnErrorMsg("找不到记录");
  2720. }
  2721. }
  2722. public void ins_erp_designselfmemo()
  2723. {
  2724. if (UrlPostParmsCheck("ctid"))
  2725. {
  2726. string eid = GetPostString("ctid");
  2727. string con = GetPostString("con");
  2728. CeErpTradeCell entity = null;
  2729. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2730. if (entity != null)
  2731. {
  2732. entity.DesignSelfMemo = con;
  2733. entity.Update();
  2734. returnSuccessMsg("操作成功!");
  2735. return;
  2736. }
  2737. returnErrorMsg("找不到记录");
  2738. }
  2739. }
  2740. public void ins_erp_designprice()
  2741. {
  2742. if (UrlPostParmsCheck("ctid"))
  2743. {
  2744. string eid = GetPostString("ctid");
  2745. int uid = CurrentUser.UserID;
  2746. string userName = CurrentUser.UserName;
  2747. CeErpTradeCell entity = null;
  2748. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2749. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2750. if (entitys == null)
  2751. {
  2752. entitys = new CeErpDesignerBill();
  2753. }
  2754. if (entity != null)
  2755. {
  2756. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2757. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2758. entity.StartDesignTime = DateTime.Now;
  2759. entity.OrderState = 4;
  2760. string suname = "";
  2761. if (entity.SupplierId == 0)
  2762. {
  2763. int sid = commonHelper.autoDistributeToSupplier(entity);
  2764. entity.SupplierId = sid;
  2765. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2766. }
  2767. entity.Update();
  2768. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2769. if (ceErpUserPost != null)
  2770. {
  2771. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2772. if (ceErpPost != null)
  2773. {
  2774. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2775. {
  2776. entitys.tid = entity.ctid;
  2777. entitys.oid = entity.tid;
  2778. entitys.uid = uid;
  2779. entitys.userName = userName;
  2780. entitys.designerType = 1;
  2781. entitys.designerTypeText = "内部设计师";
  2782. entitys.price = Convert.ToDouble(GetPostString("price"));
  2783. entitys.designNum = GetPostInt("designNum");
  2784. entitys.modifyNum = GetPostInt("modifyNum");
  2785. entitys.designSize = GetPostString("designSize");
  2786. entitys.modifySize = GetPostString("modifySize");
  2787. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2788. {
  2789. entitys.create_time = DateTime.Now;
  2790. entitys.create_u_id = uid;
  2791. entitys.create_u_name = userName;
  2792. entitys.Save();
  2793. }
  2794. else
  2795. {
  2796. entitys.update_time = DateTime.Now;
  2797. entitys.update_u_id = uid;
  2798. entitys.update_u_name = userName;
  2799. entitys.Update();
  2800. }
  2801. }
  2802. }
  2803. }
  2804. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2805. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2806. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2807. if (suname != "")
  2808. {
  2809. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2810. }
  2811. commonHelper.getCytPrice(entity);
  2812. returnSuccessMsg("操作成功!");
  2813. return;
  2814. }
  2815. returnErrorMsg("找不到记录");
  2816. }
  2817. }
  2818. public void upload_erp_filecomplete()
  2819. {
  2820. if (UrlPostParmsCheck("ctid"))
  2821. {
  2822. string eid = GetPostString("ctid");
  2823. CeErpTradeCell entity = null;
  2824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2825. if (entity != null)
  2826. {
  2827. entity.OrderState = 5; //设计完成
  2828. entity.Update();
  2829. returnSuccessMsg(eid + "上传成功,设计完成!");
  2830. return;
  2831. }
  2832. returnErrorMsg("找不到订单记录");
  2833. }
  2834. }
  2835. public void get_erp_designovertimelist()
  2836. {
  2837. DataStruct dStruct = GetPostStruct();
  2838. List<string> lw = new List<string>();
  2839. string tid = GetPostString("ctid");
  2840. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2841. string shopname = GetPostString("shopname");
  2842. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2843. string buyernick = GetPostString("buyer_nick");
  2844. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2845. string ResponsibleMan = GetPostString("responsible");
  2846. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2847. string date1 = GetPostString("date1");
  2848. string date2 = GetPostString("date2");
  2849. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2850. if (dw.Length > 0) lw.Add(dw);
  2851. string price1 = GetPostString("price1");
  2852. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2853. string price2 = GetPostString("price2");
  2854. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2855. string orderState = GetPostString("orderState");
  2856. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2857. string sellermemo = GetPostString("seller_memo");
  2858. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2859. lw.Add(string.Format("UnusualTag=3"));
  2860. lw.Add(string.Format("IsRefund<={0}", 1));
  2861. dStruct.Order = "WaitDesignTime desc";
  2862. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2863. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2864. writeGridDataTableJson(dStruct.TotalCount, dt);
  2865. }
  2866. //设计管理 获取抢单大厅列表
  2867. public void get_erp_grabinglist()
  2868. {
  2869. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2870. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2871. bool oldOrder = false;
  2872. if (org != null)
  2873. {
  2874. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2875. }
  2876. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2877. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2878. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2879. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2880. //先处理订单数据
  2881. if (dt.Rows.Count > 0)
  2882. {
  2883. Dictionary<string, int> design = null;
  2884. int count = 0;
  2885. foreach (DataRow row in dt.Rows)
  2886. {
  2887. if (map.ContainsKey(row["ShopId"].ToString()))
  2888. {
  2889. map.TryGetValue(row["ShopId"].ToString(), out design);
  2890. }
  2891. else
  2892. {
  2893. design = new Dictionary<string, int>();
  2894. }
  2895. if (design.ContainsKey(row["ProductId"].ToString()))
  2896. {
  2897. design.TryGetValue(row["ProductId"].ToString(), out count);
  2898. }
  2899. count++;
  2900. design[row["ProductId"].ToString()] = count;
  2901. map[row["ShopId"].ToString()] = design;
  2902. }
  2903. }
  2904. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2905. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2906. //把店铺排序和技能排序分类
  2907. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2908. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2909. if (design_dt.Rows.Count > 0)
  2910. {
  2911. Dictionary<string, string> design = null;
  2912. List<string> shopIds = null;
  2913. foreach (DataRow row in design_dt.Rows)
  2914. {
  2915. if ("0".Equals(row["designId"].ToString()))
  2916. {
  2917. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2918. {
  2919. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2920. }
  2921. else
  2922. {
  2923. shopIds = new List<string>();
  2924. }
  2925. shopIds.Add(row["shopId"].ToString());
  2926. shop_orders[row["orders"].ToString()] = shopIds;
  2927. }
  2928. else
  2929. {
  2930. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2931. {
  2932. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2933. }
  2934. else
  2935. {
  2936. design = new Dictionary<string, string>();
  2937. }
  2938. design[row["orders"].ToString()] = row["designId"].ToString();
  2939. design_orders[row["shopId"].ToString()] = design;
  2940. }
  2941. }
  2942. //处理成key value后根据key排序
  2943. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2944. foreach (List<string> val in shop_orders.Values)
  2945. {
  2946. if (val != null)
  2947. {
  2948. foreach (string key in val)
  2949. {
  2950. if (design_orders.ContainsKey(key.ToString()))
  2951. {
  2952. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2953. }
  2954. }
  2955. }
  2956. }
  2957. }
  2958. //校验哪个优先级有订单
  2959. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2960. foreach (string key in shop_orders.Keys)
  2961. {
  2962. List<string> ids = null;
  2963. shop_orders.TryGetValue(key, out ids);
  2964. //id为shopid
  2965. foreach (string id in ids)
  2966. {
  2967. Dictionary<string, int> list = null;
  2968. Dictionary<string, string> desing = null;
  2969. map.TryGetValue(id, out list);
  2970. design_orders.TryGetValue(id, out desing);
  2971. if (list != null && desing != null)
  2972. {
  2973. foreach (var item in desing)
  2974. {
  2975. int count = 0;
  2976. if (list.ContainsKey(item.Value))
  2977. {
  2978. list.TryGetValue(item.Value, out count);
  2979. if (count > 0)
  2980. {
  2981. designIds[id] = item.Value;
  2982. break;
  2983. }
  2984. }
  2985. }
  2986. }
  2987. }
  2988. if (designIds.Count > 0)
  2989. {
  2990. break;
  2991. }
  2992. }
  2993. DataTable table = new DataTable();
  2994. table.Columns.Add("tid", typeof(string));
  2995. table.Columns.Add("ctid", typeof(string));
  2996. table.Columns.Add("seller_nick", typeof(string));
  2997. table.Columns.Add("productName", typeof(string));
  2998. table.Columns.Add("pay_time", typeof(string));
  2999. table.Columns.Add("seller_memo", typeof(string));
  3000. if (designIds.Count > 0)
  3001. {
  3002. string shopId = "";
  3003. string productId = "";
  3004. foreach (var designInfo in designIds)
  3005. {
  3006. shopId = designInfo.Key;
  3007. productId = designInfo.Value;
  3008. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3009. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3010. if (dt.Rows.Count > 0)
  3011. {
  3012. foreach (DataRow row in dt.Rows)
  3013. {
  3014. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3015. {
  3016. DataRow data = table.NewRow();
  3017. data["ctid"] = row["ctid"].ToString();
  3018. data["tid"] = row["tid"].ToString();
  3019. data["seller_nick"] = ceErpShop.ShopName;
  3020. data["pay_time"] = row["pay_time"].ToString();
  3021. data["seller_memo"] = row["seller_memo"].ToString();
  3022. data["productName"] = ceErpProduct.PType;
  3023. table.Rows.Add(data);
  3024. }
  3025. }
  3026. }
  3027. }
  3028. }
  3029. writeGridDataTableJson(table.Rows.Count, table);
  3030. }
  3031. private object rushLockObject = new object();
  3032. public void set_erp_grabingorder()
  3033. {
  3034. if (UrlPostParmsCheck("ctid"))
  3035. {
  3036. int total = CurrentUser.User.Person.Total;
  3037. int userId = CurrentUser.User.ID;
  3038. int noFinish = CurrentUser.User.Person.NoFinish;
  3039. int finalization = CurrentUser.User.Person.Finalization;
  3040. string eids = GetPostString("ctid");
  3041. string key = "RushKey_" + userId;
  3042. int count = 0;
  3043. if (erpRedis.RedisHelper.KeyExists(key))
  3044. {
  3045. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3046. if (redisCount != null)
  3047. {
  3048. count = Convert.ToInt32(redisCount);
  3049. }
  3050. }
  3051. if (count >= total)
  3052. {
  3053. returnErrorMsg("半小时内已经抢" + total + "单");
  3054. return;
  3055. }
  3056. string[] ctidlist = eids.Split(',');
  3057. if (count + ctidlist.Length > total)
  3058. {
  3059. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3060. return;
  3061. }
  3062. int itag = 0;
  3063. lock (rushLockObject)
  3064. {
  3065. if (ctidlist.Length > 0)
  3066. {
  3067. string[] dtList = new string[ctidlist.Length];
  3068. for (int i = 0; i < ctidlist.Length; i++)
  3069. {
  3070. dtList[i] = "'" + ctidlist[i] + "'";
  3071. }
  3072. 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"));
  3073. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3074. if (dt_user.Rows.Count > 0)
  3075. {
  3076. int doing = 0;//未定稿
  3077. int finish = 0;//已完成
  3078. foreach (DataRow dr in dt_user.Rows)
  3079. {
  3080. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3081. {
  3082. doing++;
  3083. }
  3084. else
  3085. {
  3086. finish++;
  3087. }
  3088. }
  3089. if (doing >= noFinish)
  3090. {
  3091. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3092. return;
  3093. }
  3094. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3095. {
  3096. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3097. return;
  3098. }
  3099. }
  3100. //校验选择单子状态
  3101. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3102. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3103. if (dt.Rows.Count > 0)
  3104. {
  3105. List<string> list = new List<string>();
  3106. foreach (DataRow dr in dt.Rows)
  3107. {
  3108. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3109. {
  3110. list.Add(dr["ctid"].ToString());
  3111. }
  3112. }
  3113. if (list.Count > 0)
  3114. {
  3115. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3116. return;
  3117. }
  3118. }
  3119. foreach (string ctid in ctidlist)
  3120. {
  3121. CeErpTradeCell entity = null;
  3122. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3123. if (entity != null)
  3124. {
  3125. entity.OrderState = 3;
  3126. entity.DesignUserId = CurrentUser.UserID;
  3127. entity.WaitDesignTime = DateTime.Now;
  3128. entity.StartDesignTime = DateTime.Now;
  3129. entity.Update();
  3130. commonHelper.UpdateRelationOrder(entity.ctid);
  3131. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3132. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3133. itag++;
  3134. }
  3135. }
  3136. }
  3137. }
  3138. count += ctidlist.Length;
  3139. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3140. if (itag == 0)
  3141. returnErrorMsg("没有找到相关订单");
  3142. else
  3143. returnSuccessMsg("抢单成功!");
  3144. return;
  3145. }
  3146. }
  3147. public void get_erp_waitorderlist()
  3148. {
  3149. DataStruct dStruct = GetPostStruct();
  3150. List<string> lw = new List<string>();
  3151. string tid = GetPostString("ctid");
  3152. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3153. string shopname = GetPostString("shopname");
  3154. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3155. string buyernick = GetPostString("buyer_nick");
  3156. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3157. string customer = GetPostString("customer");
  3158. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3159. string design = GetPostString("design");
  3160. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3161. string orderState = GetPostString("orderState");
  3162. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3163. string supplier = GetPostString("supplier");
  3164. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3165. string sellermemo = GetPostString("seller_memo");
  3166. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3167. string otherMemo = GetPostString("otherMemo");
  3168. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3169. string address = GetPostString("address");
  3170. 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));
  3171. string date1 = GetPostString("date1");
  3172. string date2 = GetPostString("date2");
  3173. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3174. if (dw.Length > 0) lw.Add(dw);
  3175. string price1 = GetPostString("price1");
  3176. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3177. string price2 = GetPostString("price2");
  3178. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3179. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3180. lw.Add(string.Format("IsSample != 2 "));
  3181. lw.Add(string.Format("OrderState = 5 "));
  3182. lw.Add(string.Format("IsRefund<={0}", 1));
  3183. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3184. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3185. string pagesize = GetPostString("pagesize");
  3186. if (pagesize != null)
  3187. {
  3188. dStruct.PageSize = 200;
  3189. }
  3190. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3191. if (dt != null)
  3192. {
  3193. foreach (DataRow dr in dt.Rows)
  3194. {
  3195. 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();
  3196. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3197. {
  3198. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3199. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3200. entity.SupplierId = suid;
  3201. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3202. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3203. entity.Update();
  3204. }
  3205. }
  3206. }
  3207. writeGridDataTableJson(dStruct.TotalCount, dt);
  3208. }
  3209. public void get_erp_supplierwaitorderlist()
  3210. {
  3211. DataStruct dStruct = GetPostStruct();
  3212. List<string> lw = new List<string>();
  3213. string tid = GetPostString("ctid");
  3214. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3215. string shopname = GetPostString("shopname");
  3216. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3217. string sellermemo = GetPostString("seller_memo");
  3218. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3219. string date1 = GetPostString("date1");
  3220. string date2 = GetPostString("date2");
  3221. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3222. if (dw.Length > 0) lw.Add(dw);
  3223. lw.Add(string.Format("OrderState = 5 "));
  3224. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3225. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3226. {
  3227. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3228. }
  3229. string supplier = GetPostString("supplier");
  3230. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3231. {
  3232. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3233. }
  3234. lw.Add(string.Format("IsRefund<={0}", 1));
  3235. dStruct.Order = "FinishDesignTime desc";
  3236. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3237. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3238. if (dt != null)
  3239. {
  3240. foreach (DataRow dr in dt.Rows)
  3241. {
  3242. 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();
  3243. }
  3244. }
  3245. writeGridDataTableJson(dStruct.TotalCount, dt);
  3246. }
  3247. public void upd_erp_verifytosupplier()
  3248. {
  3249. if (UrlPostParmsCheck("ctid"))
  3250. {
  3251. string eids = GetPostString("ctid");
  3252. CeErpTradeCell entity = null;
  3253. string[] eidsList = eids.Split(',');
  3254. if (eidsList.Length <= 0)
  3255. {
  3256. returnErrorMsg("订单号不能空");
  3257. return;
  3258. }
  3259. List<string> tLst = new List<string>();
  3260. foreach (string ctidstr in eidsList)
  3261. {
  3262. tLst.Add("'" + ctidstr + "'");
  3263. CeErpDataSendOrderInfo.createObject(ctidstr);
  3264. }
  3265. string needtids = string.Join(",", tLst.ToArray());
  3266. StringBuilder sql = new StringBuilder();
  3267. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3268. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3269. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3270. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3271. returnSuccessMsg("操作成功!");
  3272. return;
  3273. /**foreach (string ctidstr in eidsList)
  3274. {
  3275. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3276. if (entity != null)
  3277. {
  3278. if (entity.SupplierId == 0)
  3279. {
  3280. continue;
  3281. }
  3282. entity.IsVerifyToSupplier = true;
  3283. if (entity.IsReturn == 1) //1是供应商打回
  3284. {
  3285. entity.IsReturn = 0;
  3286. }
  3287. entity.FinishPlaceTime = DateTime.Now;
  3288. entity.PlaceUserId = CurrentUser.UserID;
  3289. entity.Update();
  3290. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3291. }
  3292. }
  3293. returnSuccessMsg("操作成功!");
  3294. return;**/
  3295. }
  3296. }
  3297. public void upd_erp_supplierback()
  3298. {
  3299. if (UrlPostParmsCheck("ctid"))
  3300. {
  3301. string eid = GetPostString("ctid");
  3302. string reason = GetPostString("returnreason");
  3303. CeErpTradeCell entity = null;
  3304. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3305. if (entity != null)
  3306. {
  3307. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3308. {
  3309. string key = "return_order_" + entity.SupplierId;
  3310. List<string> list = new List<string>();
  3311. if (RedisHelper.HasKey(key))
  3312. {
  3313. object data = RedisHelper.StringGet(key);
  3314. list = Convert.ToString(data).Split(',').ToList();
  3315. }
  3316. list.Add(eid);
  3317. RedisHelper.StringSet(key, string.Join(",", list));
  3318. }
  3319. entity.IsVerifyToSupplier = false;
  3320. entity.IsReturn = 1;
  3321. entity.ReturnTime = DateTime.Now;
  3322. entity.ReturnReason = reason;
  3323. if (entity.OrderState == 6)
  3324. {
  3325. entity.OrderState = 5;
  3326. }
  3327. entity.Update();
  3328. CeErpSukuraData.createInfo(entity.ctid, 5);
  3329. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3330. returnSuccessMsg("操作成功!");
  3331. return;
  3332. }
  3333. returnErrorMsg("找不到订单记录");
  3334. }
  3335. }
  3336. public void upd_erp_toaftersaleorder()
  3337. {
  3338. if (UrlPostParmsCheck("ctid"))
  3339. {
  3340. string eid = GetPostString("ctid");
  3341. string reason = GetPostString("returnreason");
  3342. CeErpTradeCell entity = null;
  3343. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3344. if (entity != null)
  3345. {
  3346. if (entity.isAfterSaleOrder != 1)
  3347. {
  3348. returnErrorMsg("带S的售后单才能打回给售后");
  3349. return;
  3350. }
  3351. if (entity.OrderState >= 5)
  3352. {
  3353. returnErrorMsg("已经设计完成了不能打回给售后");
  3354. return;
  3355. }
  3356. entity.OrderState = 0;
  3357. entity.IsReturn = 3;
  3358. entity.ReturnTime = DateTime.Now;
  3359. entity.ReturnReason = reason;
  3360. entity.Update();
  3361. CeErpSukuraData.createInfo(entity.ctid, 5);
  3362. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3363. returnSuccessMsg("操作成功!");
  3364. return;
  3365. }
  3366. returnErrorMsg("找不到订单记录");
  3367. }
  3368. }
  3369. public void upd_erp_aftersaletodesign()
  3370. {
  3371. if (UrlPostParmsCheck("ctid"))
  3372. {
  3373. string eid = GetPostString("ctid");
  3374. CeErpTradeCell entity = null;
  3375. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3376. if (entity != null)
  3377. {
  3378. entity.OrderState = 3;
  3379. entity.IsReturn = 0;
  3380. entity.Update();
  3381. CeErpSukuraData.createInfo(entity.ctid, 5);
  3382. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3383. returnSuccessMsg("操作成功!");
  3384. return;
  3385. }
  3386. returnErrorMsg("找不到订单记录");
  3387. }
  3388. }
  3389. public void assign_erp_supplier()
  3390. {
  3391. if (UrlPostParmsCheck("ctid"))
  3392. {
  3393. string eids = GetPostString("ctid");
  3394. int sid = GetPostInt("SupplierName");
  3395. string fromTag = GetPostString("tag");
  3396. string[] eidList = eids.Split(',');
  3397. if (eidList.Length <= 0)
  3398. {
  3399. returnErrorMsg("指派不能为空");
  3400. return;
  3401. }
  3402. string errMsg = "";
  3403. string suname = commonHelper.getSupplierNameById(sid);
  3404. foreach (string ctid in eidList)
  3405. {
  3406. CeErpTradeCell entity = null;
  3407. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3408. if (entity != null)
  3409. {
  3410. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3411. {
  3412. errMsg += (ctid + "指派失败!!!");
  3413. continue;
  3414. }
  3415. entity.SupplierId = sid;
  3416. entity.Update();
  3417. commonHelper.UpdateRelationOrder(entity.ctid);
  3418. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3419. if (entity.OrderState >= 6)
  3420. {
  3421. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3422. //{
  3423. // string msl = entity.MakeSupplier;
  3424. // string[] mslist = msl.Split(',');
  3425. // 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);
  3426. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3427. //}
  3428. //else
  3429. //{
  3430. StringBuilder sql = new StringBuilder();
  3431. 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);
  3432. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3433. //}
  3434. }
  3435. }
  3436. else
  3437. {
  3438. continue;
  3439. }
  3440. }
  3441. if (errMsg.Length > 0)
  3442. {
  3443. returnErrorMsg(errMsg);
  3444. return;
  3445. }
  3446. returnSuccessMsg("操作成功!");
  3447. return;
  3448. }
  3449. }
  3450. public void assign_erp_makesupplier()
  3451. {
  3452. if (UrlPostParmsCheck("ctid"))
  3453. {
  3454. string eids = GetPostString("ctid");
  3455. string sname = GetPostString("SupplierName");
  3456. string[] eidList = eids.Split(',');
  3457. if (eidList.Length <= 0)
  3458. {
  3459. returnErrorMsg("指派不能为空");
  3460. return;
  3461. }
  3462. List<string> tLst = new List<string>();
  3463. foreach (string ctid in eidList)
  3464. {
  3465. CeErpTradeCell entity = null;
  3466. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3467. if (entity != null)
  3468. {
  3469. entity.MakeSupplier = sname;
  3470. entity.Update();
  3471. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3472. tLst.Add("'" + ctid + "'");
  3473. }
  3474. else
  3475. {
  3476. continue;
  3477. }
  3478. }
  3479. string ctids = string.Join(",", tLst.ToArray());
  3480. StringBuilder sql2 = new StringBuilder();
  3481. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3482. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3483. returnSuccessMsg("操作成功!");
  3484. return;
  3485. }
  3486. }
  3487. public void ins_erp_returnreason()
  3488. {
  3489. if (UrlPostParmsCheck("ctid"))
  3490. {
  3491. string eid = GetPostString("ctid");
  3492. CeErpTradeCell entity = null;
  3493. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3494. string userpost = CurrentUser.UserPost.Post.Code;
  3495. if (entity != null)
  3496. {
  3497. bool isPlace = false;
  3498. if (entity.OrderState > 6)
  3499. {
  3500. returnErrorMsg("已发货无法打回!");
  3501. return;
  3502. }
  3503. if (entity.OrderState == 6)
  3504. {
  3505. isPlace = true;
  3506. }
  3507. bool isNeedUpdateCell2 = false;
  3508. if (entity.OrderState >= 6)
  3509. {
  3510. isNeedUpdateCell2 = true;
  3511. }
  3512. int returnTag = 2;
  3513. if (userpost == "Supplier")
  3514. {
  3515. returnTag = 1;
  3516. }
  3517. int toType = GetPostInt("totype");
  3518. string fromType = "3";
  3519. if (entity.OrderState < 5)
  3520. {
  3521. fromType = "3";
  3522. }
  3523. else
  3524. {
  3525. fromType = "4";
  3526. }
  3527. if (entity.IsXianHuo == 0)
  3528. {
  3529. if (returnTag == 2)
  3530. {
  3531. if (toType == 1)
  3532. {
  3533. entity.OrderState = 0;
  3534. entity.ReturnUserType = 1;
  3535. string clearman = GetPostString("clearman");
  3536. if (!string.IsNullOrEmpty(clearman))
  3537. {
  3538. entity.DesignUserId = 0;
  3539. }
  3540. }
  3541. else
  3542. {
  3543. entity.OrderState = 3;
  3544. entity.ReturnUserType = 2;
  3545. }
  3546. entity.IsReadTag = 1;
  3547. }
  3548. else if (returnTag == 1)
  3549. {
  3550. entity.OrderState = 5;
  3551. }
  3552. entity.IsVerifyToSupplier = false;
  3553. }
  3554. if (entity.IsXianHuo == 1)
  3555. {
  3556. entity.OrderState = 5;
  3557. }
  3558. entity.UnusualTag = 0;
  3559. entity.UnusualTime = null;
  3560. entity.UnusualCon = "";
  3561. entity.IsReturn = returnTag;
  3562. entity.ReturnTime = DateTime.Now;
  3563. entity.ReturnReason = GetPostString("returnreason");
  3564. entity.Update();
  3565. if (entity.OrderState == 3)
  3566. {
  3567. ApiVo apiVo = new ApiVo();
  3568. apiVo.orderNumber = entity.ctid;
  3569. apiVo.actionName = "rebutDesign";
  3570. apiVo.orderRemarks = entity.ReturnReason;
  3571. designHelper.API_WorkCore(apiVo);//rebutDesign
  3572. }
  3573. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3574. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3575. {
  3576. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3577. }
  3578. CeErpSukuraData.createInfo(entity.ctid, 5);
  3579. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3580. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3581. if (isPlace)
  3582. {
  3583. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3584. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3585. if (dth != null && dth.Rows.Count > 0)
  3586. {
  3587. dataSendOrderBean dataSendOrderBean = null;
  3588. foreach (DataRow item in dth.Rows)
  3589. {
  3590. try
  3591. {
  3592. dataSendOrderBean = new dataSendOrderBean();
  3593. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3594. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3595. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3596. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3597. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3598. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3599. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3600. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3601. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3602. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3603. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3604. dataSendOrderBean.Radio1723534706288 = "打回";
  3605. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3606. if (result != null)
  3607. {
  3608. if ("0".Equals(result.errcode))
  3609. {
  3610. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3611. }
  3612. else
  3613. {
  3614. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3615. }
  3616. }
  3617. }
  3618. catch (Exception ex)
  3619. {
  3620. }
  3621. }
  3622. }
  3623. }
  3624. if (isNeedUpdateCell2)
  3625. {
  3626. if (entity.MakeSupplier.IndexOf(",") != -1)
  3627. {
  3628. StringBuilder sql2 = new StringBuilder();
  3629. 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);
  3630. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3631. }
  3632. else
  3633. {
  3634. StringBuilder sql2 = new StringBuilder();
  3635. 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);
  3636. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3637. }
  3638. }
  3639. returnSuccessMsg("操作成功!");
  3640. return;
  3641. }
  3642. returnErrorMsg("找不到订单记录");
  3643. }
  3644. }
  3645. public void cyt_erp_returnreason()
  3646. {
  3647. if (UrlPostParmsCheck("ctid"))
  3648. {
  3649. string eid = GetPostString("ctid");
  3650. CeErpTradeCell entity = null;
  3651. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3652. string userpost = CurrentUser.UserPost.Post.Code;
  3653. if (entity != null)
  3654. {
  3655. if (entity.OrderState > 6)
  3656. {
  3657. returnErrorMsg("已发货无法打回!");
  3658. return;
  3659. }
  3660. JObject jsonObject = new JObject
  3661. {
  3662. { "Userid", "77886" },
  3663. { "Pwd", "lt666888" },
  3664. { "LTOrderId",eid }
  3665. };
  3666. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3667. JObject jsonObjects = JObject.Parse(response);
  3668. string msg = (string)jsonObjects["msg"];
  3669. if (msg != "取消成功")
  3670. {
  3671. returnErrorMsg(msg);
  3672. return;
  3673. }
  3674. bool isNeedUpdateCell2 = false;
  3675. if (entity.OrderState >= 6)
  3676. {
  3677. isNeedUpdateCell2 = true;
  3678. }
  3679. int returnTag = 2;
  3680. if (userpost == "Supplier")
  3681. {
  3682. returnTag = 1;
  3683. }
  3684. if (entity.IsXianHuo == 0)
  3685. {
  3686. if (returnTag == 2)
  3687. {
  3688. int toType = GetPostInt("totype");
  3689. if (toType == 1)
  3690. {
  3691. entity.OrderState = 0;
  3692. entity.ReturnUserType = 1;
  3693. }
  3694. else
  3695. {
  3696. entity.OrderState = 4;
  3697. entity.ReturnUserType = 2;
  3698. }
  3699. entity.IsReadTag = 1;
  3700. }
  3701. else if (returnTag == 1)
  3702. {
  3703. entity.OrderState = 5;
  3704. }
  3705. entity.IsVerifyToSupplier = false;
  3706. }
  3707. entity.UnusualTag = 0;
  3708. entity.UnusualTime = null;
  3709. entity.UnusualCon = "";
  3710. entity.IsReturn = returnTag;
  3711. entity.ReturnTime = DateTime.Now;
  3712. entity.ReturnReason = GetPostString("returnreason");
  3713. entity.Update();
  3714. if (entity.OrderState == 4)
  3715. {
  3716. ApiVo apiVo = new ApiVo();
  3717. apiVo.orderNumber = entity.ctid;
  3718. apiVo.actionName = "rebutDesign";
  3719. apiVo.orderRemarks = entity.ReturnReason;
  3720. designHelper.API_WorkCore(apiVo);//rebutDesign
  3721. }
  3722. CeErpSukuraData.createInfo(entity.ctid, 5);
  3723. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3724. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3725. if (isNeedUpdateCell2)
  3726. {
  3727. if (entity.MakeSupplier.IndexOf(",") != -1)
  3728. {
  3729. StringBuilder sql2 = new StringBuilder();
  3730. 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);
  3731. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3732. }
  3733. else
  3734. {
  3735. StringBuilder sql2 = new StringBuilder();
  3736. 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);
  3737. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3738. }
  3739. }
  3740. returnSuccessMsg("操作成功!");
  3741. return;
  3742. }
  3743. returnErrorMsg("找不到订单记录");
  3744. }
  3745. }
  3746. public void upd_erp_xianhuoreturntag()
  3747. {
  3748. if (UrlPostParmsCheck("ctid"))
  3749. {
  3750. string eids = GetPostString("ctid");
  3751. string[] ctids = eids.Split(',');
  3752. foreach (string ctid in ctids)
  3753. {
  3754. CeErpTradeCell entity = null;
  3755. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3756. if (entity != null)
  3757. {
  3758. entity.IsReturn = 0;
  3759. entity.Update();
  3760. CeErpSukuraData.createInfo(entity.ctid, 5);
  3761. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3762. }
  3763. }
  3764. returnSuccessMsg("操作成功!");
  3765. return;
  3766. }
  3767. }
  3768. public void get_erp_waitdeliverylist()
  3769. {
  3770. DataStruct dStruct = GetPostStruct();
  3771. List<string> lw = new List<string>();
  3772. string tid = GetPostString("ctid");
  3773. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3774. string shopname = GetPostString("shopname");
  3775. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3776. string buyernick = GetPostString("buyer_nick");
  3777. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3778. //if (tid.Length == 0 && buyernick.Length == 0)
  3779. //{
  3780. // lw.Add(string.Format("IsRefund<={0}", 1));
  3781. //}
  3782. string customer = GetPostString("customer");
  3783. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3784. string design = GetPostString("design");
  3785. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3786. string orderState = GetPostString("orderState");
  3787. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3788. string address = GetPostString("address");
  3789. 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));
  3790. string sellermemo = GetPostString("seller_memo");
  3791. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3792. string supplier = GetPostString("supplier");
  3793. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3794. string OrderArea = GetPostString("order_area");
  3795. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3796. string placedate1 = GetPostString("placedate1");
  3797. string placedate2 = GetPostString("placedate2");
  3798. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3799. if (fdw.Length > 0) lw.Add(fdw);
  3800. string price1 = GetPostString("price1");
  3801. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3802. string price2 = GetPostString("price2");
  3803. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3804. string unusualCon = GetPostString("unusualcon");
  3805. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3806. string otherMemo = GetPostString("otherMemo");
  3807. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3808. string posTag = CurrentUser.UserPost.Post.Code;
  3809. if (posTag == "Supplier")
  3810. {
  3811. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3812. }
  3813. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3814. lw.Add(string.Format("type != 'PDD' "));
  3815. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3816. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3817. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3818. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3819. /*if (tid.Length > 0)
  3820. {
  3821. List<string> tids = new List<string>();
  3822. if (dt != null && dt.Rows.Count > 0)
  3823. {
  3824. foreach (DataRow item in dt.Rows)
  3825. {
  3826. tids.Add("'" + item["tid"] + "'");
  3827. }
  3828. }
  3829. if (tids.Count > 0)
  3830. {
  3831. lw.RemoveAt(0);
  3832. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3833. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3834. dt = WebCache.GetData("view_erptradecell", dStruct);
  3835. }
  3836. }*/
  3837. writeGridDataTableJson(dStruct.TotalCount, dt);
  3838. }
  3839. public void get_erp_changedeliverylist()
  3840. {
  3841. DataStruct dStruct = GetPostStruct();
  3842. List<string> lw = new List<string>();
  3843. string tid = GetPostString("ctid");
  3844. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3845. string shopname = GetPostString("shopname");
  3846. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3847. string buyernick = GetPostString("buyer_nick");
  3848. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3849. //if (tid.Length == 0 && buyernick.Length == 0)
  3850. //{
  3851. // lw.Add(string.Format("IsRefund<={0}", 1));
  3852. //}
  3853. string customer = GetPostString("customer");
  3854. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3855. string design = GetPostString("design");
  3856. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3857. string orderState = GetPostString("orderState");
  3858. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3859. string address = GetPostString("address");
  3860. 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));
  3861. string sellermemo = GetPostString("seller_memo");
  3862. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3863. string supplier = GetPostString("supplier");
  3864. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3865. string OrderArea = GetPostString("order_area");
  3866. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3867. string placedate1 = GetPostString("placedate1");
  3868. string placedate2 = GetPostString("placedate2");
  3869. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3870. if (fdw.Length > 0) lw.Add(fdw);
  3871. string price1 = GetPostString("price1");
  3872. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3873. string price2 = GetPostString("price2");
  3874. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3875. string unusualCon = GetPostString("unusualcon");
  3876. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3877. string otherMemo = GetPostString("otherMemo");
  3878. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3879. string posTag = CurrentUser.UserPost.Post.Code;
  3880. if (posTag == "Supplier")
  3881. {
  3882. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3883. }
  3884. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3885. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3886. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3887. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3888. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3889. /*if (tid.Length > 0)
  3890. {
  3891. List<string> tids = new List<string>();
  3892. if (dt != null && dt.Rows.Count > 0)
  3893. {
  3894. foreach (DataRow item in dt.Rows)
  3895. {
  3896. tids.Add("'" + item["tid"] + "'");
  3897. }
  3898. }
  3899. if (tids.Count > 0)
  3900. {
  3901. lw.RemoveAt(0);
  3902. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3903. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3904. dt = WebCache.GetData("view_erptradecell", dStruct);
  3905. }
  3906. }*/
  3907. writeGridDataTableJson(dStruct.TotalCount, dt);
  3908. }
  3909. public void get_erp_pddderiving()
  3910. {
  3911. DataStruct dStruct = GetPostStruct();
  3912. List<string> lw = new List<string>();
  3913. string tid = GetPostString("ctid");
  3914. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3915. string shopname = GetPostString("shopname");
  3916. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3917. string buyernick = GetPostString("buyer_nick");
  3918. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3919. //if (tid.Length == 0 && buyernick.Length == 0)
  3920. //{
  3921. // lw.Add(string.Format("IsRefund<={0}", 1));
  3922. //}
  3923. string customer = GetPostString("customer");
  3924. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3925. string design = GetPostString("design");
  3926. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3927. string orderState = GetPostString("orderState");
  3928. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3929. string address = GetPostString("address");
  3930. 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));
  3931. string sellermemo = GetPostString("seller_memo");
  3932. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3933. string supplier = GetPostString("supplier");
  3934. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3935. string OrderArea = GetPostString("order_area");
  3936. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3937. string placedate1 = GetPostString("placedate1");
  3938. string placedate2 = GetPostString("placedate2");
  3939. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3940. if (fdw.Length > 0) lw.Add(fdw);
  3941. string price1 = GetPostString("price1");
  3942. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3943. string price2 = GetPostString("price2");
  3944. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3945. string unusualCon = GetPostString("unusualcon");
  3946. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3947. string posTag = CurrentUser.UserPost.Post.Code;
  3948. if (posTag == "Supplier")
  3949. {
  3950. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3951. }
  3952. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3953. lw.Add(string.Format("type = 'PDD' "));
  3954. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3955. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3956. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3957. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3958. /*if (tid.Length > 0)
  3959. {
  3960. List<string> tids = new List<string>();
  3961. if (dt != null && dt.Rows.Count > 0)
  3962. {
  3963. foreach (DataRow item in dt.Rows)
  3964. {
  3965. tids.Add("'" + item["tid"] + "'");
  3966. }
  3967. }
  3968. if (tids.Count > 0)
  3969. {
  3970. lw.RemoveAt(0);
  3971. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3972. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3973. dt = WebCache.GetData("view_erptradecell", dStruct);
  3974. }
  3975. }*/
  3976. writeGridDataTableJson(dStruct.TotalCount, dt);
  3977. }
  3978. public void get_erp_jdderiving()
  3979. {
  3980. DataStruct dStruct = GetPostStruct();
  3981. List<string> lw = new List<string>();
  3982. string tid = GetPostString("ctid");
  3983. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3984. string shopname = GetPostString("shopname");
  3985. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3986. string buyernick = GetPostString("buyer_nick");
  3987. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3988. //if (tid.Length == 0 && buyernick.Length == 0)
  3989. //{
  3990. // lw.Add(string.Format("IsRefund<={0}", 1));
  3991. //}
  3992. string customer = GetPostString("customer");
  3993. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3994. string design = GetPostString("design");
  3995. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3996. string orderState = GetPostString("orderState");
  3997. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3998. string address = GetPostString("address");
  3999. 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));
  4000. string sellermemo = GetPostString("seller_memo");
  4001. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4002. string supplier = GetPostString("supplier");
  4003. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4004. string OrderArea = GetPostString("order_area");
  4005. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4006. string placedate1 = GetPostString("placedate1");
  4007. string placedate2 = GetPostString("placedate2");
  4008. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4009. if (fdw.Length > 0) lw.Add(fdw);
  4010. string price1 = GetPostString("price1");
  4011. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4012. string price2 = GetPostString("price2");
  4013. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4014. string unusualCon = GetPostString("unusualcon");
  4015. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4016. string posTag = CurrentUser.UserPost.Post.Code;
  4017. if (posTag == "Supplier")
  4018. {
  4019. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4020. }
  4021. lw.Add(string.Format("OrderState = 6 "));
  4022. lw.Add(string.Format("type = 'JD' "));
  4023. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4024. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4025. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4026. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4027. writeGridDataTableJson(dStruct.TotalCount, dt);
  4028. }
  4029. public void get_erp_demoorderlist()
  4030. {
  4031. DataStruct dStruct = GetPostStruct();
  4032. List<string> lw = new List<string>();
  4033. string tid = GetPostString("ctid");
  4034. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  4035. string shopname = GetPostString("shopname");
  4036. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4037. string buyernick = GetPostString("buyer_nick");
  4038. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4039. string customer = GetPostString("customer");
  4040. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4041. string design = GetPostString("design");
  4042. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4043. string orderState = GetPostString("orderState");
  4044. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4045. string address = GetPostString("address");
  4046. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4047. string sellermemo = GetPostString("seller_memo");
  4048. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4049. string supplier = GetPostString("supplier");
  4050. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4051. string OrderArea = GetPostString("order_area");
  4052. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4053. string date1 = GetPostString("date1");
  4054. string date2 = GetPostString("date2");
  4055. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4056. if (dw.Length > 0) lw.Add(dw);
  4057. string price1 = GetPostString("price1");
  4058. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4059. string price2 = GetPostString("price2");
  4060. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4061. string posTag = CurrentUser.UserPost.Post.Code;
  4062. if (posTag == "Supplier")
  4063. {
  4064. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4065. }
  4066. //lw.Add(string.Format("OrderState = 6 "));
  4067. lw.Add(string.Format("IsSample={0}", 3));
  4068. lw.Add(string.Format("IsRefund<={0}", 1));
  4069. dStruct.Order = "pay_time desc";
  4070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4071. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4072. writeGridDataTableJson(dStruct.TotalCount, dt);
  4073. }
  4074. public void save_erp_checkmemo()
  4075. {
  4076. if (UrlPostParmsCheck("ctid"))
  4077. {
  4078. string ctid = GetPostString("ctid");
  4079. CeErpTradeCell entity = null;
  4080. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4081. if (entity != null)
  4082. {
  4083. entity.CheckMemo = GetPostString("CheckMemo");
  4084. entity.Update();
  4085. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4086. if (trade != null)
  4087. {
  4088. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4089. }
  4090. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4091. returnSuccessMsg("保存成功!");
  4092. return;
  4093. }
  4094. returnErrorMsg("找不到记录");
  4095. }
  4096. }
  4097. public void get_erp_returnlist()
  4098. {
  4099. DataStruct dStruct = GetPostStruct();
  4100. List<string> lw = new List<string>();
  4101. string tid = GetPostString("ctid");
  4102. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4103. string shopname = GetPostString("shopname");
  4104. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4105. string buyernick = GetPostString("buyer_nick");
  4106. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4107. string customer = GetPostString("customer");
  4108. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4109. string design = GetPostString("design");
  4110. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4111. string orderState = GetPostString("orderState");
  4112. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4113. string address = GetPostString("address");
  4114. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4115. string sellermemo = GetPostString("seller_memo");
  4116. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4117. string supplier = GetPostString("supplier");
  4118. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4119. string date1 = GetPostString("date1");
  4120. string date2 = GetPostString("date2");
  4121. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4122. if (dw.Length > 0) lw.Add(dw);
  4123. string bdate1 = GetPostString("backdate1");
  4124. string bdate2 = GetPostString("backdate2");
  4125. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4126. if (dw_back.Length > 0) lw.Add(dw_back);
  4127. string price1 = GetPostString("price1");
  4128. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4129. string price2 = GetPostString("price2");
  4130. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4131. lw.Add(string.Format("IsReturn>0"));
  4132. lw.Add(string.Format("IsXianHuo=0"));
  4133. lw.Add(string.Format("IsReturn!=3"));
  4134. string backtype = GetPostString("backtype");
  4135. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4136. dStruct.Order = "FinishDesignTime desc";
  4137. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4138. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4139. writeGridDataTableJson(dStruct.TotalCount, dt);
  4140. }
  4141. public void get_erp_today_sumreturn()
  4142. {
  4143. DataStruct dStruct = GetPostStruct();
  4144. List<string> lw = new List<string>();
  4145. string bdate1 = GetPostString("returnTimeS");
  4146. string bdate2 = GetPostString("returnTimeE");
  4147. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4148. if (dw_back.Length > 0) lw.Add(dw_back);
  4149. lw.Add(string.Format("IsReturn=0"));
  4150. lw.Add(string.Format("IsXianHuo=0"));
  4151. string mainWhere = string.Join(" and ", lw.ToArray());
  4152. string sql = "";
  4153. if (dw_back.Length > 0)
  4154. {
  4155. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4156. }
  4157. else
  4158. {
  4159. 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 + "'";
  4160. }
  4161. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4162. decimal total = 0, today_finish = 0;
  4163. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4164. {
  4165. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4166. }
  4167. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4168. {
  4169. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4170. }
  4171. var res = new
  4172. {
  4173. data = total,
  4174. data1 = today_finish,
  4175. };
  4176. string ro_jsond = JsonConvert.SerializeObject(res);
  4177. returnSuccess(ro_jsond);
  4178. return;
  4179. }
  4180. public void get_erp_allreturnlist()
  4181. {
  4182. DataStruct dStruct = GetPostStruct();
  4183. List<string> lw = new List<string>();
  4184. string tid = GetPostString("ctid");
  4185. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4186. string shopname = GetPostString("shopname");
  4187. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4188. string buyernick = GetPostString("buyer_nick");
  4189. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4190. string customer = GetPostString("customer");
  4191. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4192. string design = GetPostString("design");
  4193. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4194. string orderState = GetPostString("orderState");
  4195. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4196. string address = GetPostString("address");
  4197. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4198. string sellermemo = GetPostString("seller_memo");
  4199. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4200. string supplier = GetPostString("supplier");
  4201. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4202. string date1 = GetPostString("date1");
  4203. string date2 = GetPostString("date2");
  4204. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4205. if (dw.Length > 0) lw.Add(dw);
  4206. string bdate1 = GetPostString("backdate1");
  4207. string bdate2 = GetPostString("backdate2");
  4208. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4209. if (dw_back.Length > 0) lw.Add(dw_back);
  4210. string price1 = GetPostString("price1");
  4211. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4212. string price2 = GetPostString("price2");
  4213. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4214. string backreason = GetPostString("backreason");
  4215. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4216. lw.Add(string.Format("IsXianHuo=0"));
  4217. lw.Add(string.Format("ReturnTime != ''"));
  4218. string backtype = GetPostString("backtype");
  4219. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4220. dStruct.Order = "FinishDesignTime desc";
  4221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4222. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4223. writeGridDataTableJson(dStruct.TotalCount, dt);
  4224. }
  4225. public void get_erp_aftersalereturnlist()
  4226. {
  4227. DataStruct dStruct = GetPostStruct();
  4228. List<string> lw = new List<string>();
  4229. string tid = GetPostString("ctid");
  4230. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4231. string shopname = GetPostString("shopname");
  4232. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4233. string buyernick = GetPostString("buyer_nick");
  4234. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4235. string customer = GetPostString("customer");
  4236. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4237. string design = GetPostString("design");
  4238. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4239. string orderState = GetPostString("orderState");
  4240. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4241. string address = GetPostString("address");
  4242. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4243. string sellermemo = GetPostString("seller_memo");
  4244. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4245. string supplier = GetPostString("supplier");
  4246. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4247. string date1 = GetPostString("date1");
  4248. string date2 = GetPostString("date2");
  4249. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4250. if (dw.Length > 0) lw.Add(dw);
  4251. string bdate1 = GetPostString("backdate1");
  4252. string bdate2 = GetPostString("backdate2");
  4253. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4254. if (dw_back.Length > 0) lw.Add(dw_back);
  4255. string price1 = GetPostString("price1");
  4256. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4257. string price2 = GetPostString("price2");
  4258. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4259. lw.Add(string.Format("IsReturn=3"));
  4260. string backtype = GetPostString("backtype");
  4261. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4262. string backreason = GetPostString("backreason");
  4263. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4264. dStruct.Order = "ReturnTime desc";
  4265. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4266. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4267. writeGridDataTableJson(dStruct.TotalCount, dt);
  4268. }
  4269. public void get_erp_xianhuoreturnlist()
  4270. {
  4271. DataStruct dStruct = GetPostStruct();
  4272. List<string> lw = new List<string>();
  4273. string tid = GetPostString("ctid");
  4274. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4275. string shopname = GetPostString("shopname");
  4276. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4277. string buyernick = GetPostString("buyer_nick");
  4278. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4279. string customer = GetPostString("customer");
  4280. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4281. string design = GetPostString("design");
  4282. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4283. string orderState = GetPostString("orderState");
  4284. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4285. string address = GetPostString("address");
  4286. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4287. string sellermemo = GetPostString("seller_memo");
  4288. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4289. string supplier = GetPostString("supplier");
  4290. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4291. string OrderArea = GetPostString("order_area");
  4292. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4293. string date1 = GetPostString("date1");
  4294. string date2 = GetPostString("date2");
  4295. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4296. if (dw.Length > 0) lw.Add(dw);
  4297. string price1 = GetPostString("price1");
  4298. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4299. string price2 = GetPostString("price2");
  4300. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4301. string posTag = CurrentUser.UserPost.Post.Code;
  4302. if (posTag == "Supplier")
  4303. {
  4304. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4305. }
  4306. lw.Add(string.Format("OrderState=6 "));
  4307. lw.Add(string.Format("IsXianHuo=1 "));
  4308. lw.Add(string.Format("IsReturn>0 "));
  4309. lw.Add(string.Format("IsReturn!=3"));
  4310. lw.Add(string.Format("IsRefund<={0}", 1));
  4311. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4312. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4313. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4314. writeGridDataTableJson(dStruct.TotalCount, dt);
  4315. }
  4316. public void set_erp_orderdelivery()
  4317. {
  4318. if (UrlPostParmsCheck("ctid"))
  4319. {
  4320. string eid = GetPostString("ctid");
  4321. CeErpTradeCell entity = null;
  4322. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4323. if (entity != null)
  4324. {
  4325. if (entity.OrderState >= 7)
  4326. {
  4327. returnErrorMsg("此单已发货,无需重复发货");
  4328. return;
  4329. }
  4330. if (entity.OrderState != 6)
  4331. {
  4332. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4333. return;
  4334. }
  4335. string shop = GetPostString("seller_nick");
  4336. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4337. string comName = GetPostString("comName");
  4338. string comCode = GetPostString("comCode");
  4339. string outSid = GetPostString("outSid");
  4340. string deliveryType = GetPostString("deliveryType");
  4341. string deliveryMemo = GetPostString("deliveryMemo");
  4342. outSid = outSid.Trim();
  4343. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4344. if (mainEn == null)
  4345. {
  4346. returnErrorMsg("找不到原始订单记录");
  4347. return;
  4348. }
  4349. bool isInitOrderDeliv = false;
  4350. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4351. {
  4352. isInitOrderDeliv = true;
  4353. }
  4354. string apires = "";
  4355. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4356. 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)
  4357. {
  4358. apires = "发货成功true";
  4359. }
  4360. else
  4361. {
  4362. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4363. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4364. }
  4365. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4366. {
  4367. entity.OrderState = 7;//发货后订单已发货
  4368. entity.OutSid = outSid;
  4369. entity.MemoOpt = 0;
  4370. entity.FinishDeliveryTime = DateTime.Now;
  4371. entity.Update();
  4372. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4373. commonHelper.UpdateRelationOrder(entity.ctid);
  4374. //还要插入快递信息到 快递信息表
  4375. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4376. exinfo.tid = eid;
  4377. exinfo.out_sid = outSid;
  4378. exinfo.company_code = comCode;
  4379. exinfo.company_name = comName;
  4380. exinfo.delivery_memo = deliveryMemo;
  4381. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4382. exinfo.deliveryType = deliveryType;
  4383. exinfo.Create();
  4384. returnSuccessMsg("发货操作成功!");
  4385. commonHelper.UpdateRelationOrder(entity.ctid);
  4386. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4387. CeErpSukuraData.createInfo(entity.ctid, 4);
  4388. if (entity.SupplierId == 64)
  4389. {
  4390. commonHelper.sendCytExpress(exinfo);
  4391. }
  4392. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4393. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4394. }
  4395. else
  4396. {
  4397. string errmsg = commonHelper.KeepChinese(apires);
  4398. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4399. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4400. }
  4401. return;
  4402. }
  4403. returnErrorMsg("找不到订单记录");
  4404. }
  4405. }
  4406. public void set_erp_multidelivery()
  4407. {
  4408. string eids = GetPostString("tids");
  4409. string[] eidList = eids.Split(',');
  4410. if (eidList.Length <= 0)
  4411. {
  4412. returnErrorMsg("发货不能为空");
  4413. return;
  4414. }
  4415. foreach (string ctid in eidList)
  4416. {
  4417. if (ctid.Length <= 0) continue;
  4418. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4419. if (expInfo != null)
  4420. {
  4421. StringBuilder sql = new StringBuilder();
  4422. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4423. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4424. if (dt.Rows.Count > 0)
  4425. {
  4426. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4427. {
  4428. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4429. expInfo.state = "异常";
  4430. expInfo.isMultiDelivery = 1;
  4431. expInfo.Update();
  4432. continue;
  4433. }
  4434. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4435. {
  4436. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4437. expInfo.state = "异常";
  4438. expInfo.Update();
  4439. continue;
  4440. }
  4441. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4442. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4443. bool isInitOrderDeliv = false;
  4444. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4445. {
  4446. isInitOrderDeliv = true;
  4447. expInfo.isMultiDelivery = 1;
  4448. }
  4449. if (ctid.IndexOf("N") != -1)
  4450. {
  4451. StringBuilder sqlbucha = new StringBuilder();
  4452. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4453. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4454. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4455. commonHelper.UpdateRelationOrder(ctid);
  4456. expInfo.delivery_memo = "发货成功";
  4457. expInfo.state = "发货成功";
  4458. expInfo.isMultiDelivery = 1;
  4459. expInfo.Update();
  4460. }
  4461. else
  4462. {
  4463. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4464. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4465. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4466. {
  4467. expInfo.delivery_memo = "发货成功";
  4468. expInfo.state = "发货成功";
  4469. expInfo.isMultiDelivery = 1;
  4470. expInfo.Update();
  4471. commonHelper.UpdateRelationOrder(ctid);
  4472. CeErpSukuraData.createInfo(ctid, 4);
  4473. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4474. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4475. }
  4476. else
  4477. {
  4478. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4479. expInfo.state = "异常";
  4480. expInfo.Update();
  4481. }
  4482. }
  4483. }
  4484. }
  4485. }
  4486. returnSuccessMsg("操作完成");
  4487. }
  4488. public void reset_erp_memoopt()
  4489. {
  4490. if (UrlPostParmsCheck("ctid"))
  4491. {
  4492. string eid = GetPostString("ctid");
  4493. CeErpTradeCell entity = null;
  4494. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4495. if (entity != null)
  4496. {
  4497. string stropt = "";
  4498. if (entity.MemoOpt == 1)
  4499. {
  4500. stropt = "“改稿”";
  4501. }
  4502. else if (entity.MemoOpt == 2)
  4503. {
  4504. stropt = "“定稿”";
  4505. }
  4506. else if (entity.MemoOpt == 3)
  4507. {
  4508. stropt = "“完成查货”";
  4509. CeErpSukuraData.createInfo(entity.ctid, 6);
  4510. }
  4511. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4512. entity.MemoOpt = 0;
  4513. entity.Update();
  4514. returnSuccessMsg("操作成功!");
  4515. return;
  4516. }
  4517. returnErrorMsg("找不到记录");
  4518. }
  4519. }
  4520. public void get_erp_deliveryunusual()
  4521. {
  4522. DataStruct dStruct = GetPostStruct();
  4523. List<string> lw = new List<string>();
  4524. string tid = GetPostString("ctid");
  4525. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4526. string shopname = GetPostString("shopname");
  4527. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4528. string buyernick = GetPostString("buyer_nick");
  4529. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4530. string customer = GetPostString("customer");
  4531. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4532. string design = GetPostString("design");
  4533. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4534. string sellermemo = GetPostString("seller_memo");
  4535. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4536. string supplier = GetPostString("supplier");
  4537. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4538. string date1 = GetPostString("date1");
  4539. string date2 = GetPostString("date2");
  4540. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4541. if (dw.Length > 0) lw.Add(dw);
  4542. string placedate1 = GetPostString("placedate1");
  4543. string placedate2 = GetPostString("placedate2");
  4544. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4545. if (dw_place.Length > 0) lw.Add(dw_place);
  4546. string price1 = GetPostString("price1");
  4547. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4548. string price2 = GetPostString("price2");
  4549. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4550. string unusualCon = GetPostString("unusualcon");
  4551. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4552. string posTag = CurrentUser.UserPost.Post.Code;
  4553. if (posTag == "Supplier")
  4554. {
  4555. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4556. }
  4557. lw.Add(string.Format("OrderState = 6"));
  4558. lw.Add(string.Format("UnusualTag = 5"));
  4559. lw.Add(string.Format("IsRefund<={0}", 1));
  4560. dStruct.Order = "FinishPlaceTime desc";
  4561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4562. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4563. writeGridDataTableJson(dStruct.TotalCount, dt);
  4564. }
  4565. public void get_erp_deliveryedlist()
  4566. {
  4567. DataStruct dStruct = GetPostStruct();
  4568. List<string> lw = new List<string>();
  4569. string tid = GetPostString("ctid");
  4570. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4571. string shopname = GetPostString("shopname");
  4572. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4573. string buyernick = GetPostString("buyer_nick");
  4574. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4575. string customer = GetPostString("customer");
  4576. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4577. string design = GetPostString("design");
  4578. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4579. string sellermemo = GetPostString("seller_memo");
  4580. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4581. string logistics = GetPostString("logistics");
  4582. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4583. string date1 = GetPostString("date1");
  4584. string date2 = GetPostString("date2");
  4585. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4586. //if (dw.Length > 0) lw.Add(dw);
  4587. string placedate1 = GetPostString("placedate1");
  4588. string placedate2 = GetPostString("placedate2");
  4589. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4590. if (fdw.Length > 0) lw.Add(fdw);
  4591. string devdate1 = GetPostString("deliverydate1");
  4592. string devdate2 = GetPostString("deliverydate2");
  4593. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4594. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4595. string price1 = GetPostString("price1");
  4596. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4597. string price2 = GetPostString("price2");
  4598. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4599. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4600. {
  4601. if (tid.Length > 0)
  4602. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4603. if (buyernick.Length > 0)
  4604. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4605. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4606. if (dw.Length > 0) lw.Add(dw);
  4607. }
  4608. else
  4609. {
  4610. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4611. }
  4612. string posTag = CurrentUser.UserPost.Post.Code;
  4613. if (posTag == "Supplier")
  4614. {
  4615. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4616. }
  4617. else
  4618. {
  4619. string supplier = GetPostString("supplier");
  4620. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4621. }
  4622. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4623. lw.Add(string.Format("IsRefund!={0}", 2));
  4624. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4625. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4626. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4627. /*if (tid.Length > 0)
  4628. {
  4629. List<string> tids = new List<string>();
  4630. if (dt != null && dt.Rows.Count > 0)
  4631. {
  4632. foreach (DataRow item in dt.Rows)
  4633. {
  4634. tids.Add("'" + item["tid"] + "'");
  4635. }
  4636. }
  4637. if (tids.Count > 0)
  4638. {
  4639. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4640. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4641. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4642. dt = WebCache.GetData("view_erptradecell", dStruct);
  4643. }
  4644. }*/
  4645. if (dt != null)
  4646. {
  4647. foreach (DataRow dr in dt.Rows)
  4648. {
  4649. 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();
  4650. }
  4651. }
  4652. writeGridDataTableJson(dStruct.TotalCount, dt);
  4653. }
  4654. public void get_erp_pdddeliveryed()
  4655. {
  4656. DataStruct dStruct = GetPostStruct();
  4657. List<string> lw = new List<string>();
  4658. string tid = GetPostString("ctid");
  4659. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4660. string shopname = GetPostString("shopname");
  4661. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4662. string buyernick = GetPostString("buyer_nick");
  4663. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4664. string customer = GetPostString("customer");
  4665. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4666. string design = GetPostString("design");
  4667. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4668. string sellermemo = GetPostString("seller_memo");
  4669. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4670. string logistics = GetPostString("logistics");
  4671. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4672. string date1 = GetPostString("date1");
  4673. string date2 = GetPostString("date2");
  4674. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4675. //if (dw.Length > 0) lw.Add(dw);
  4676. string placedate1 = GetPostString("placedate1");
  4677. string placedate2 = GetPostString("placedate2");
  4678. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4679. if (fdw.Length > 0) lw.Add(fdw);
  4680. string devdate1 = GetPostString("deliverydate1");
  4681. string devdate2 = GetPostString("deliverydate2");
  4682. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4683. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4684. string price1 = GetPostString("price1");
  4685. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4686. string price2 = GetPostString("price2");
  4687. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4688. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4689. {
  4690. if (tid.Length > 0)
  4691. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4692. if (buyernick.Length > 0)
  4693. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4694. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4695. if (dw.Length > 0) lw.Add(dw);
  4696. }
  4697. else
  4698. {
  4699. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4700. }
  4701. string posTag = CurrentUser.UserPost.Post.Code;
  4702. if (posTag == "Supplier")
  4703. {
  4704. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4705. }
  4706. else
  4707. {
  4708. string supplier = GetPostString("supplier");
  4709. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4710. }
  4711. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4712. lw.Add(string.Format("type = 'PDD' "));
  4713. lw.Add(string.Format("IsRefund!={0}", 2));
  4714. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4715. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4716. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4717. /* if (tid.Length > 0)
  4718. {
  4719. List<string> tids = new List<string>();
  4720. if (dt != null && dt.Rows.Count > 0)
  4721. {
  4722. foreach (DataRow item in dt.Rows)
  4723. {
  4724. tids.Add("'" + item["tid"] + "'");
  4725. }
  4726. }
  4727. if (tids.Count > 0)
  4728. {
  4729. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4730. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4731. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4732. dt = WebCache.GetData("view_erptradecell", dStruct);
  4733. }
  4734. }*/
  4735. foreach (DataRow dr in dt.Rows)
  4736. {
  4737. 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();
  4738. }
  4739. writeGridDataTableJson(dStruct.TotalCount, dt);
  4740. }
  4741. public void get_erp_jddeliveryed()
  4742. {
  4743. DataStruct dStruct = GetPostStruct();
  4744. List<string> lw = new List<string>();
  4745. string tid = GetPostString("ctid");
  4746. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4747. string shopname = GetPostString("shopname");
  4748. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4749. string buyernick = GetPostString("buyer_nick");
  4750. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4751. string customer = GetPostString("customer");
  4752. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4753. string design = GetPostString("design");
  4754. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4755. string sellermemo = GetPostString("seller_memo");
  4756. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4757. string date1 = GetPostString("date1");
  4758. string date2 = GetPostString("date2");
  4759. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4760. //if (dw.Length > 0) lw.Add(dw);
  4761. string placedate1 = GetPostString("placedate1");
  4762. string placedate2 = GetPostString("placedate2");
  4763. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4764. if (fdw.Length > 0) lw.Add(fdw);
  4765. string devdate1 = GetPostString("deliverydate1");
  4766. string devdate2 = GetPostString("deliverydate2");
  4767. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4768. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4769. string price1 = GetPostString("price1");
  4770. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4771. string price2 = GetPostString("price2");
  4772. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4773. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4774. {
  4775. if (tid.Length > 0)
  4776. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4777. if (buyernick.Length > 0)
  4778. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4779. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4780. if (dw.Length > 0) lw.Add(dw);
  4781. }
  4782. else
  4783. {
  4784. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4785. }
  4786. string posTag = CurrentUser.UserPost.Post.Code;
  4787. if (posTag == "Supplier")
  4788. {
  4789. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4790. }
  4791. else
  4792. {
  4793. string supplier = GetPostString("supplier");
  4794. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4795. }
  4796. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4797. lw.Add(string.Format("type = 'JD' "));
  4798. lw.Add(string.Format("IsRefund!={0}", 2));
  4799. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4800. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4801. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4802. foreach (DataRow dr in dt.Rows)
  4803. {
  4804. 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();
  4805. }
  4806. writeGridDataTableJson(dStruct.TotalCount, dt);
  4807. }
  4808. public void get_erp_allplacelist()
  4809. {
  4810. DataStruct dStruct = GetPostStruct();
  4811. List<string> lw = new List<string>();
  4812. string tid = GetPostString("ctid");
  4813. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4814. string shopname = GetPostString("shopname");
  4815. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4816. string buyernick = GetPostString("buyer_nick");
  4817. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4818. string customer = GetPostString("customer");
  4819. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4820. string design = GetPostString("design");
  4821. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4822. string sellermemo = GetPostString("seller_memo");
  4823. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4824. string supplier = GetPostString("supplier");
  4825. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4826. string date1 = GetPostString("date1");
  4827. string date2 = GetPostString("date2");
  4828. string pldate1 = GetPostString("placedate1");
  4829. string pldate2 = GetPostString("placedate2");
  4830. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4831. //if (dw.Length > 0) lw.Add(dw);
  4832. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4833. {
  4834. if (tid.Length > 0)
  4835. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4836. if (buyernick.Length > 0)
  4837. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4838. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4839. if (dw.Length > 0) lw.Add(dw);
  4840. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4841. if (dw_place.Length > 0) lw.Add(dw_place);
  4842. }
  4843. else
  4844. {
  4845. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4846. {
  4847. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4848. }
  4849. }
  4850. string price1 = GetPostString("price1");
  4851. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4852. string price2 = GetPostString("price2");
  4853. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4854. string posTag = CurrentUser.UserPost.Post.Code;
  4855. if (posTag == "Supplier")
  4856. {
  4857. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4858. }
  4859. lw.Add(string.Format("OrderState >= 6"));
  4860. lw.Add(string.Format("IsSample != 2 "));
  4861. lw.Add(string.Format("isDianziOrder = 0 "));
  4862. //lw.Add(string.Format("IsRefund<={0}", 1));
  4863. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4864. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4865. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4866. foreach (DataRow dr in dt.Rows)
  4867. {
  4868. 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();
  4869. }
  4870. writeGridDataTableJson(dStruct.TotalCount, dt);
  4871. }
  4872. public void get_erp_financeallplacelist()
  4873. {
  4874. DataStruct dStruct = GetPostStruct();
  4875. List<string> lw = new List<string>();
  4876. string tid = GetPostString("ctid");
  4877. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4878. string shopname = GetPostString("shopname");
  4879. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4880. string buyernick = GetPostString("buyer_nick");
  4881. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4882. string customer = GetPostString("customer");
  4883. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4884. string design = GetPostString("design");
  4885. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4886. string sellermemo = GetPostString("seller_memo");
  4887. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4888. string supplier = GetPostString("supplier");
  4889. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4890. string date1 = GetPostString("date1");
  4891. string date2 = GetPostString("date2");
  4892. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4893. if (dw.Length > 0) lw.Add(dw);
  4894. string pldate1 = GetPostString("placedate1");
  4895. string pldate2 = GetPostString("placedate2");
  4896. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4897. if (dw_place.Length > 0) lw.Add(dw_place);
  4898. string price1 = GetPostString("price1");
  4899. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4900. string price2 = GetPostString("price2");
  4901. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4902. string posTag = CurrentUser.UserPost.Post.Code;
  4903. if (posTag == "Supplier")
  4904. {
  4905. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4906. }
  4907. //lw.Add(string.Format("OrderState >= 6"));
  4908. lw.Add(string.Format("IsSample != 2 "));
  4909. lw.Add(string.Format("isDianziOrder = 0 "));
  4910. //lw.Add(string.Format("IsRefund<={0}", 1));
  4911. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4912. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4913. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4914. foreach (DataRow dr in dt.Rows)
  4915. {
  4916. 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();
  4917. }
  4918. writeGridDataTableJson(dStruct.TotalCount, dt);
  4919. }
  4920. public void get_erp_expresslist()
  4921. {
  4922. int listtype = GetInt("ltype");
  4923. DataStruct dStruct = GetPostStruct();
  4924. List<string> lw = new List<string>();
  4925. string tid = GetPostString("tid");
  4926. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4927. string outsid = GetPostString("out_sid");
  4928. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4929. string importer = GetPostString("ImportUserName");
  4930. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4931. string file = GetPostString("import_file");
  4932. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4933. string printman = GetPostString("printman");
  4934. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4935. string date1 = GetPostString("date1");
  4936. string date2 = GetPostString("date2");
  4937. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4938. if (dw.Length > 0) lw.Add(dw);
  4939. string fdate1 = GetPostString("finishdate1");
  4940. string fdate2 = GetPostString("finishdate2");
  4941. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4942. if (fdw.Length > 0) lw.Add(fdw);
  4943. string supplierId = GetPostString("supplierId");
  4944. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  4945. if (listtype == 1)
  4946. {
  4947. lw.Add(string.Format("importUserId !=0"));
  4948. }
  4949. string posTag = CurrentUser.UserPost.Post.Code;
  4950. if (posTag == "Supplier")
  4951. {
  4952. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4953. }
  4954. if (dStruct.PageSize != 100000)
  4955. {
  4956. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4957. }
  4958. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4959. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4960. writeGridDataTableJson(dStruct.TotalCount, dt);
  4961. }
  4962. public void set_erp_buchaorderdelivery()
  4963. {
  4964. if (UrlPostParmsCheck("ctid"))
  4965. {
  4966. string eid = GetPostString("ctid");
  4967. CeErpTradeCell entity = null;
  4968. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4969. if (entity != null)
  4970. {
  4971. if (entity.IsSample != 2)
  4972. {
  4973. returnErrorMsg("补差价单才能标记为已发货");
  4974. return;
  4975. }
  4976. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4977. entity.OrderState = 7;
  4978. entity.Update();
  4979. returnSuccessMsg("操作成功!");
  4980. return;
  4981. }
  4982. returnErrorMsg("找不到记录");
  4983. }
  4984. }
  4985. public void get_stdtemplates()
  4986. {
  4987. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4988. //string res = taobaoHelper.test();
  4989. string res = apiHelper.API_PrintTemplate();
  4990. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4991. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4992. {
  4993. int sidx = res.IndexOf("error_code");
  4994. int eidx = res.IndexOf("success");
  4995. string msg = res.Substring(sidx, eidx - sidx);
  4996. returnErrorMsg(msg);
  4997. return;
  4998. }
  4999. if (res.Length <= 0)
  5000. {
  5001. returnErrorMsg("模板数据为空!");
  5002. return;
  5003. }
  5004. ReturnSuccess(res);
  5005. }
  5006. public void cancel_print_order()
  5007. {
  5008. if (UrlPostParmsCheck("ctid"))
  5009. {
  5010. string ctid = GetPostString("ctid");
  5011. CeErpTradeCell entity = null;
  5012. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5013. if (entity != null)
  5014. {
  5015. string res = "";
  5016. string code = entity.LastBillWaybillCode;
  5017. if (code == "")
  5018. {
  5019. code = entity.OutSid;
  5020. }
  5021. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5022. XLog.SaveLog(0, "取消面单" + res);
  5023. }
  5024. }
  5025. }
  5026. public void set_erp_printwaybill()
  5027. {
  5028. if (UrlPostParmsCheck("ctid"))
  5029. {
  5030. string ctid = GetPostString("ctid");
  5031. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5032. string cpName = GetPostString("cpname");
  5033. string isTogether = GetPostString("together");
  5034. //var res_obj = new
  5035. //{
  5036. // restype = 1,
  5037. // 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\"}"
  5038. //};
  5039. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5040. //ReturnSuccess(ro_json);
  5041. //return;
  5042. bool isUseLastWayBillCode = false;
  5043. CeErpTradeCell entity = null;
  5044. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5045. if (entity != null)
  5046. {
  5047. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5048. {
  5049. isUseLastWayBillCode = true;
  5050. }
  5051. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5052. {
  5053. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5054. return;
  5055. }
  5056. }
  5057. string res = "";
  5058. Api_waybill_code_response_Obj fullObj = null;
  5059. string pData_str = "";
  5060. string curUseWayBillCode = "";
  5061. if (isUseLastWayBillCode == false)
  5062. {
  5063. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5064. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5065. if (res.IndexOf("failure") != -1)
  5066. {
  5067. //int idx = res.IndexOf("sub_message");
  5068. //int idx2 = res.IndexOf("flag");
  5069. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5070. string errMsgNeed = commonHelper.KeepChinese(res);
  5071. var res_objd = new
  5072. {
  5073. restype = 0,
  5074. data = "获取面单失败" + errMsgNeed
  5075. };
  5076. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5077. returnSuccess(ro_jsond);
  5078. if (res.IndexOf("停发") != -1)
  5079. {
  5080. entity.UnusualCon = "物流停发";
  5081. entity.Update();
  5082. }
  5083. //returnErrorMsg("获取面单失败,"+emsg);
  5084. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5085. return;
  5086. }
  5087. else if (res.IndexOf("errorMsg") != -1)
  5088. {
  5089. //int idx = res.IndexOf("errorMsg");
  5090. //int idx2 = res.IndexOf("}]}");
  5091. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5092. string errMsgNeed = commonHelper.KeepChinese(res);
  5093. var res_objf = new
  5094. {
  5095. restype = 0,
  5096. data = "获取面单失败2" + errMsgNeed
  5097. };
  5098. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5099. if (res.IndexOf("停发") != -1)
  5100. {
  5101. entity.UnusualCon = "物流停发";
  5102. entity.Update();
  5103. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5104. if (trade != null)
  5105. {
  5106. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5107. }
  5108. }
  5109. returnSuccess(ro_jsonf);
  5110. //returnErrorMsg("获取面单失败," + emsg);
  5111. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5112. return;
  5113. }
  5114. try
  5115. {
  5116. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5117. //res = res.Replace(" ", "");
  5118. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5119. }
  5120. catch (Exception ex)
  5121. {
  5122. XLog.SaveLog(0, "生成fullObj" + res);
  5123. var res_objf = new
  5124. {
  5125. restype = 0,
  5126. data = "生成fullObj发生错误" + ex.Message
  5127. };
  5128. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5129. returnSuccess(ro_jsonf);
  5130. return;
  5131. }
  5132. if (fullObj.response.data.content.Count > 0)
  5133. {
  5134. ContentItem codeObj = fullObj.response.data.content[0];
  5135. if (cpCode.IndexOf("SFFQ-") != -1)
  5136. {
  5137. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5138. }
  5139. else
  5140. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5141. curUseWayBillCode = codeObj.waybillCode;
  5142. }
  5143. else
  5144. {
  5145. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5146. var res_objf = new
  5147. {
  5148. restype = 0,
  5149. data = "生成fullObj找不到快递单号waybillCode"
  5150. };
  5151. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5152. returnSuccess(ro_jsonf);
  5153. return;
  5154. }
  5155. }
  5156. else
  5157. {
  5158. //使用上次打印的快递单号
  5159. if (cpCode == "SFFQ-LY")
  5160. {
  5161. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5162. }
  5163. else
  5164. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5165. curUseWayBillCode = entity.LastBillWaybillCode;
  5166. }
  5167. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5168. {
  5169. var res_obje = new
  5170. {
  5171. restype = 0,
  5172. data = "获取加密打印数据失败"
  5173. };
  5174. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5175. returnSuccess(ro_jsone);
  5176. entity.LastBillCpCode = cpCode;
  5177. entity.LastBillWaybillCode = curUseWayBillCode;
  5178. entity.Update();
  5179. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5180. //returnErrorMsg("获取加密打印数据失败");
  5181. return;
  5182. }
  5183. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5184. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5185. string btnType = "";
  5186. if (entity != null)
  5187. {
  5188. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5189. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5190. //cpcode是 YTO-CAINIAO
  5191. //string comCode = cpCode.Split('-')[0].ToString();
  5192. string apires = "";
  5193. if (ctid.IndexOf("N") != -1)
  5194. {
  5195. apires = "发货成功";
  5196. }
  5197. else
  5198. {
  5199. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5200. }
  5201. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5202. //打单后发货
  5203. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5204. {
  5205. try
  5206. {
  5207. btnType = "待发货";
  5208. entity.OutSid = curUseWayBillCode;
  5209. entity.OrderState = 7;
  5210. entity.IsUrgency = false;
  5211. entity.LastBillCpCode = "";
  5212. entity.LastBillWaybillCode = "";
  5213. entity.FinishDeliveryTime = DateTime.Now;
  5214. entity.IsReturn = 0;
  5215. entity.MemoOpt = 0;
  5216. entity.Update();
  5217. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5218. //还要插入快递信息到 快递信息表
  5219. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5220. exinfo.tid = entity.ctid;
  5221. exinfo.out_sid = entity.OutSid;
  5222. exinfo.company_code = cpCode;
  5223. exinfo.company_name = cpName;
  5224. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5225. exinfo.deliveryType = "发货成功";
  5226. exinfo.print_time = DateTime.Now;
  5227. exinfo.printUser = CurrentUser.UserName;
  5228. exinfo.Create();
  5229. commonHelper.UpdateRelationOrder(entity.ctid);
  5230. CeErpSukuraData.createInfo(ctid, 4);
  5231. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5232. if (entity.SupplierId == 64)
  5233. {
  5234. commonHelper.sendCytExpress(exinfo);
  5235. }
  5236. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5237. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5238. if (isTogether == "1")
  5239. {
  5240. StringBuilder sqlsb = new StringBuilder();
  5241. 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);
  5242. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5243. }
  5244. }
  5245. catch (Exception ex)
  5246. {
  5247. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5248. }
  5249. }
  5250. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5251. {
  5252. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5253. if (entity.OrderState == 6)
  5254. {
  5255. entity.OrderState = 7;
  5256. }
  5257. entity.FinishDeliveryTime = DateTime.Now;
  5258. btnType = "已发货";
  5259. entity.Update();
  5260. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5261. exinfo.tid = entity.ctid;
  5262. exinfo.out_sid = entity.OutSid;
  5263. exinfo.company_code = cpCode;
  5264. exinfo.company_name = cpName;
  5265. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5266. exinfo.deliveryType = "发货成功";
  5267. exinfo.print_time = DateTime.Now;
  5268. exinfo.printUser = CurrentUser.UserName;
  5269. exinfo.Create();
  5270. commonHelper.UpdateRelationOrder(entity.ctid);
  5271. CeErpSukuraData.createInfo(entity.ctid, 4);
  5272. if (entity.SupplierId == 64)
  5273. {
  5274. commonHelper.sendCytExpress(exinfo);
  5275. }
  5276. if (isTogether == "1")
  5277. {
  5278. StringBuilder sqlsb = new StringBuilder();
  5279. 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);
  5280. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5281. }
  5282. //不处理
  5283. }
  5284. else
  5285. {
  5286. entity.LastBillCpCode = cpCode;
  5287. entity.LastBillWaybillCode = curUseWayBillCode;
  5288. entity.Update();
  5289. string errmsg = commonHelper.KeepChinese(apires);
  5290. var res_objz = new
  5291. {
  5292. restype = 0,
  5293. data = "打单后发货失败"
  5294. };
  5295. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5296. returnSuccess(ro_jsonz);
  5297. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5298. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5299. return;
  5300. }
  5301. }
  5302. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5303. var res_obj = new
  5304. {
  5305. restype = 1,
  5306. data = pData_str
  5307. };
  5308. string ro_json = JsonConvert.SerializeObject(res_obj);
  5309. ReturnSuccess(ro_json);
  5310. return;
  5311. }
  5312. }
  5313. private string GetUTF8String(byte[] vs)
  5314. {
  5315. throw new NotImplementedException();
  5316. }
  5317. public void set_erp_printwaybill_cn()
  5318. {
  5319. if (UrlPostParmsCheck("ctid"))
  5320. {
  5321. string ctid = GetPostString("ctid");
  5322. string cpCode = GetPostString("cpcode");
  5323. string cpName = GetPostString("cpname");
  5324. string tempUrl = GetPostString("tempurl");
  5325. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5326. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5327. //string res = taobaoHelper.test();
  5328. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5329. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5330. {
  5331. int sidx = res.IndexOf("errorMsg");
  5332. int eidx = res.IndexOf("}");
  5333. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5334. var res_objzxx = new
  5335. {
  5336. restype = 0,
  5337. data = msg
  5338. };
  5339. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5340. returnSuccess(ro_jsonzxx);
  5341. //returnErrorMsg(msg);
  5342. return;
  5343. }
  5344. int idx = res.IndexOf("waybillCode");
  5345. int idx2 = res.IndexOf("printData");
  5346. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5347. string eid = GetPostString("ctid");
  5348. CeErpTradeCell entity = null;
  5349. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5350. if (entity != null)
  5351. {
  5352. string osid = entity.OutSid;
  5353. entity.OutSid = osid + "," + outsid;
  5354. entity.FinishDeliveryTime = DateTime.Now;
  5355. entity.OrderState = 7;
  5356. entity.IsReturn = 0;
  5357. entity.Update();
  5358. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5359. exinfo.tid = entity.ctid;
  5360. exinfo.out_sid = outsid;
  5361. exinfo.company_code = cpCode;
  5362. exinfo.company_name = cpName;
  5363. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5364. exinfo.deliveryType = "发货成功";
  5365. exinfo.print_time = DateTime.Now;
  5366. exinfo.printUser = CurrentUser.UserName;
  5367. exinfo.Create();
  5368. if (entity.SupplierId == 64)
  5369. {
  5370. commonHelper.sendCytExpress(exinfo);
  5371. }
  5372. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5373. }
  5374. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5375. var res_objz = new
  5376. {
  5377. restype = 1,
  5378. data = res
  5379. };
  5380. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5381. returnSuccess(ro_jsonz);
  5382. //ReturnSuccess(res);
  5383. }
  5384. }
  5385. ////打单,打印面单 获取面单号
  5386. //public void set_erp_printwaybill()
  5387. //{
  5388. // if (UrlPostParmsCheck("ctid"))
  5389. // {
  5390. // string ctid = GetPostString("ctid");
  5391. // string cpCode = GetPostString("cpcode");
  5392. // string tempUrl = GetPostString("tempurl");
  5393. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5394. // //string res = taobaoHelper.test();
  5395. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5396. // if (res.IndexOf("error_response") != -1)
  5397. // {
  5398. // int sidx = res.IndexOf("sub_msg");
  5399. // int eidx = res.IndexOf("request_id");
  5400. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5401. // returnErrorMsg(msg);
  5402. // return;
  5403. // }
  5404. // int idx = res.IndexOf("waybill_code");
  5405. // int idx2 = res.IndexOf("}]}");
  5406. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5407. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5408. // ReturnSuccess(res);
  5409. // }
  5410. //}
  5411. public void cancel_erp_aftersale()
  5412. {
  5413. if (UrlPostParmsCheck("ctid"))
  5414. {
  5415. string eid = GetPostString("ctid");
  5416. CeErpTradeCell entity = null;
  5417. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5418. if (entity != null)
  5419. {
  5420. //有过处理的售后,取消也不能删除 售 字,保留
  5421. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5422. {
  5423. entity.AfterSaleState = 4;
  5424. }
  5425. else
  5426. entity.AfterSaleState = 0;
  5427. entity.Update();
  5428. returnSuccessMsg("操作成功!");
  5429. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5430. return;
  5431. }
  5432. returnErrorMsg("找不到订单记录");
  5433. }
  5434. }
  5435. public void get_erp_aftersalelist()
  5436. {
  5437. DataStruct dStruct = GetPostStruct();
  5438. List<string> lw = new List<string>();
  5439. int st = GetInt("st");
  5440. string tid = GetPostString("ctid");
  5441. if (st == 3)
  5442. {
  5443. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5444. }
  5445. else
  5446. {
  5447. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5448. }
  5449. string shopname = GetPostString("shopname");
  5450. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5451. string buyernick = GetPostString("buyer_nick");
  5452. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5453. string sellermemo = GetPostString("seller_memo");
  5454. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5455. string orderState = GetPostString("orderState");
  5456. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5457. string afterState = GetPostString("afterstate");
  5458. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5459. string date1 = GetPostString("date1");
  5460. string date2 = GetPostString("date2");
  5461. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5462. if (dw.Length > 0) lw.Add(dw);
  5463. string price1 = GetPostString("price1");
  5464. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5465. string price2 = GetPostString("price2");
  5466. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5467. //lw.Add(string.Format("IsRefund!={0}", 1));
  5468. string reason = GetPostString("reason");
  5469. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5470. string method = GetPostString("method");
  5471. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5472. string handler = GetPostString("handler");
  5473. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5474. string handledate1 = GetPostString("handledate1");
  5475. string handledate2 = GetPostString("handledate2");
  5476. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5477. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5478. string finish1 = GetPostString("finishdate1");
  5479. string finish2 = GetPostString("finishdate2");
  5480. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5481. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5482. string afterdate1 = GetPostString("afterdate1");
  5483. string afterdate2 = GetPostString("afterdate2");
  5484. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5485. if (afterDate.Length > 0) lw.Add(afterDate);
  5486. string supplier = GetPostString("supplier");
  5487. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5488. string responsible = GetPostString("responsibleman");
  5489. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5490. string customer = GetPostString("customer");
  5491. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5492. string design = GetPostString("design");
  5493. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5494. string afterMemoType = GetPostString("aftermemotype");
  5495. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5496. string posCode = CurrentUser.UserPost.Post.Code;
  5497. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5498. //{
  5499. // string vstate = GetPostString("vstate");
  5500. // if (vstate.Length > 0)
  5501. // {
  5502. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5503. // }
  5504. // if (posCode == "Supplier")
  5505. // {
  5506. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5507. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5508. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5509. // }
  5510. // else
  5511. // {
  5512. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5513. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5514. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5515. // {
  5516. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5517. // }
  5518. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5519. // {
  5520. // int orgid = CurrentUser.UserPost.OrgID;
  5521. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5522. // }
  5523. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5524. // {
  5525. // string shopid = CurrentUser.User.pemShop;
  5526. // lw.Add(string.Format("shopId in ({0})", shopid));
  5527. // }
  5528. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5529. // //{
  5530. // // int org_id = CurrentUser.UserPost.OrgID;
  5531. // // lw.Add(string.Format("OrgID={0}", org_id));
  5532. // //}
  5533. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5534. // }
  5535. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5536. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5537. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5538. //}
  5539. if (st == 5)
  5540. {
  5541. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5542. {
  5543. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5544. {
  5545. string shopid = CurrentUser.User.pemShop;
  5546. lw.Add(string.Format("shopId in ({0})", shopid));
  5547. }
  5548. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5549. {
  5550. int mrOrgid = CurrentUser.UserPost.OrgID;
  5551. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5552. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5553. }
  5554. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5555. //{
  5556. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5557. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5558. //}
  5559. else
  5560. {
  5561. string userIdStr = "";
  5562. if (posCode == "CustomerService")
  5563. {
  5564. userIdStr = CurrentUser.UserID + "_k";
  5565. }
  5566. else if (posCode == "Designer" || posCode == "wxDesigner")
  5567. {
  5568. userIdStr = CurrentUser.UserID + "_s";
  5569. }
  5570. else if (posCode == "Place")
  5571. {
  5572. userIdStr = CurrentUser.UserID + "_x";
  5573. }
  5574. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5575. }
  5576. }
  5577. string placedate1 = GetPostString("placedate1");
  5578. string placedate2 = GetPostString("placedate2");
  5579. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5580. if (dwplace.Length > 0) lw.Add(dwplace);
  5581. string supState = GetPostString("supState");
  5582. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5583. string searchType = GetPostString("searchType");
  5584. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5585. {
  5586. lw.Add(string.Format("BackNum>1"));
  5587. }
  5588. lw.Add(string.Format("AfterSaleState>0"));
  5589. if (ex_psize > 0)
  5590. {
  5591. if (CurrentUser.UserPost.Post.Code == "Finance")
  5592. dStruct.Order = "pay_time desc";
  5593. else
  5594. dStruct.Order = "HandleTime desc";
  5595. }
  5596. else
  5597. dStruct.Order = "HandleTime desc";
  5598. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5599. DataTable dt = WebCache.GetData("view_test", dStruct);
  5600. writeGridDataTableJson(dStruct.TotalCount, dt);
  5601. }
  5602. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5603. //{
  5604. // lw.Add(string.Format("AfterSaleState=4"));
  5605. // string code = CurrentUser.UserPost.Post.Code;
  5606. // if (code == "CustomerService")
  5607. // {
  5608. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5609. // }
  5610. // else if (code == "Designer" || code == "DesignerMr")
  5611. // {
  5612. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5613. // }
  5614. // else if (code == "Place" || code == "PlaceMr")
  5615. // {
  5616. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5617. // }
  5618. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5619. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5620. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5621. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5622. //}
  5623. //else //处理中的售后,待处理和处理中合并
  5624. //{
  5625. // if (afterState.Length <= 0)
  5626. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5627. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5628. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5629. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5630. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5631. //}
  5632. }
  5633. public void get_erp_disagreeftersalelist()
  5634. {
  5635. DataStruct dStruct = GetPostStruct();
  5636. List<string> lw = new List<string>();
  5637. int st = 2;
  5638. string tid = GetPostString("ctid");
  5639. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5640. string shopname = GetPostString("shopname");
  5641. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5642. string buyernick = GetPostString("buyer_nick");
  5643. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5644. string sellermemo = GetPostString("seller_memo");
  5645. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5646. string orderState = GetPostString("orderState");
  5647. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5648. string afterState = GetPostString("afterstate");
  5649. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5650. string date1 = GetPostString("date1");
  5651. string date2 = GetPostString("date2");
  5652. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5653. if (dw.Length > 0) lw.Add(dw);
  5654. string price1 = GetPostString("price1");
  5655. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5656. string price2 = GetPostString("price2");
  5657. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5658. //lw.Add(string.Format("IsRefund!={0}", 1));
  5659. string reason = GetPostString("reason");
  5660. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5661. string method = GetPostString("method");
  5662. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5663. string handler = GetPostString("handler");
  5664. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5665. string handledate1 = GetPostString("handledate1");
  5666. string handledate2 = GetPostString("handledate2");
  5667. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5668. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5669. string afterdate1 = GetPostString("afterdate1");
  5670. string afterdate2 = GetPostString("afterdate2");
  5671. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5672. if (afterDate.Length > 0) lw.Add(afterDate);
  5673. string backdate1 = GetPostString("backdate1");
  5674. string backdate2 = GetPostString("backdate2");
  5675. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5676. if (backDate.Length > 0) lw.Add(backDate);
  5677. string supplier = GetPostString("supplier");
  5678. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5679. string responsible = GetPostString("responsibleman");
  5680. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5681. string customer = GetPostString("customer");
  5682. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5683. string design = GetPostString("design");
  5684. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5685. string afterSaleMemo = GetPostString("afterSaleMemo");
  5686. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5687. string afterMemoType = GetPostString("aftermemotype");
  5688. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5689. string aftersakereason = GetPostString("aftersakereason");
  5690. if (aftersakereason.Length > 0)
  5691. {
  5692. if (aftersakereason == "1")
  5693. {
  5694. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5695. }
  5696. if (aftersakereason == "2")
  5697. {
  5698. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5699. }
  5700. }
  5701. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5702. string poscode = CurrentUser.UserPost.Post.Code;
  5703. if (poscode != "SysAdmin")
  5704. {
  5705. string shopid = CurrentUser.User.pemShop;
  5706. lw.Add(string.Format("shopId in ({0})", shopid));
  5707. }
  5708. string searchType = GetPostString("searchType");
  5709. if (searchType == "wait")
  5710. {
  5711. lw.Add(string.Format("HandleTime is null"));
  5712. }
  5713. if (searchType == "handling")
  5714. {
  5715. lw.Add(string.Format("HandleTime is not null "));
  5716. }
  5717. if (searchType == "back" || searchType == "puBack")
  5718. {
  5719. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5720. }
  5721. if (searchType == "reBack")
  5722. {
  5723. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5724. }
  5725. if (searchType == "moreBack")
  5726. {
  5727. lw.Add(string.Format("backNum > 1"));
  5728. }
  5729. lw.Add(string.Format("(AfterSaleState=5)"));
  5730. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5731. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5732. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5733. writeGridDataTableJson(dStruct.TotalCount, dt);
  5734. }
  5735. public void get_erp_handlingaftersalelist()
  5736. {
  5737. DataStruct dStruct = GetPostStruct();
  5738. List<string> lw = new List<string>();
  5739. int st = 2;
  5740. string tid = GetPostString("ctid");
  5741. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5742. string shopname = GetPostString("shopname");
  5743. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5744. string buyernick = GetPostString("buyer_nick");
  5745. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5746. string sellermemo = GetPostString("seller_memo");
  5747. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5748. string orderState = GetPostString("orderState");
  5749. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5750. string afterState = GetPostString("afterstate");
  5751. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5752. string date1 = GetPostString("date1");
  5753. string date2 = GetPostString("date2");
  5754. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5755. if (dw.Length > 0) lw.Add(dw);
  5756. string price1 = GetPostString("price1");
  5757. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5758. string price2 = GetPostString("price2");
  5759. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5760. //lw.Add(string.Format("IsRefund!={0}", 1));
  5761. string reason = GetPostString("reason");
  5762. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5763. string method = GetPostString("method");
  5764. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5765. string handler = GetPostString("handler");
  5766. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5767. string handledate1 = GetPostString("handledate1");
  5768. string handledate2 = GetPostString("handledate2");
  5769. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5770. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5771. string afterdate1 = GetPostString("afterdate1");
  5772. string afterdate2 = GetPostString("afterdate2");
  5773. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5774. if (afterDate.Length > 0) lw.Add(afterDate);
  5775. string supplier = GetPostString("supplier");
  5776. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5777. string responsible = GetPostString("responsibleman");
  5778. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5779. string customer = GetPostString("customer");
  5780. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5781. string design = GetPostString("design");
  5782. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5783. string afterSaleMemo = GetPostString("afterSaleMemo");
  5784. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5785. string afterMemoType = GetPostString("aftermemotype");
  5786. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5787. string afterresult = GetPostString("afterresult");
  5788. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5789. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5790. string poscode = CurrentUser.UserPost.Post.Code;
  5791. if (poscode != "SysAdmin")
  5792. {
  5793. string shopid = CurrentUser.User.pemShop;
  5794. lw.Add(string.Format("shopId in ({0})", shopid));
  5795. }
  5796. string searchType = GetPostString("searchType");
  5797. if (searchType == "wait")
  5798. {
  5799. lw.Add(string.Format("HandleTime is null"));
  5800. }
  5801. if (searchType == "documentary")
  5802. {
  5803. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5804. }
  5805. if (searchType == "handling")
  5806. {
  5807. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5808. }
  5809. if (searchType == "back" || searchType == "puBack")
  5810. {
  5811. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5812. }
  5813. if (searchType == "reBack")
  5814. {
  5815. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5816. }
  5817. if (afterState.Length <= 0)
  5818. {
  5819. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5820. }
  5821. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5822. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5823. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5824. writeGridDataTableJson(dStruct.TotalCount, dt);
  5825. }
  5826. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5827. //public void get_erp_back_handlingaftersalelist()
  5828. //{
  5829. // DataStruct dStruct = GetPostStruct();
  5830. // List<string> lw = new List<string>();
  5831. // string tid = GetPostString("ctid");
  5832. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5833. // string shopname = GetPostString("shopname");
  5834. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5835. // string buyernick = GetPostString("buyer_nick");
  5836. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5837. // string sellermemo = GetPostString("seller_memo");
  5838. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5839. // string orderState = GetPostString("orderState");
  5840. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5841. // string afterState = GetPostString("afterstate");
  5842. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5843. // string date1 = GetPostString("date1");
  5844. // string date2 = GetPostString("date2");
  5845. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5846. // if (dw.Length > 0) lw.Add(dw);
  5847. // string price1 = GetPostString("price1");
  5848. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5849. // string price2 = GetPostString("price2");
  5850. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5851. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5852. // string reason = GetPostString("reason");
  5853. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5854. // string method = GetPostString("method");
  5855. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5856. // string handler = GetPostString("handler");
  5857. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5858. // string handledate1 = GetPostString("handledate1");
  5859. // string handledate2 = GetPostString("handledate2");
  5860. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5861. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5862. // string afterdate1 = GetPostString("afterdate1");
  5863. // string afterdate2 = GetPostString("afterdate2");
  5864. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5865. // if (afterDate.Length > 0) lw.Add(afterDate);
  5866. // string supplier = GetPostString("supplier");
  5867. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5868. // string responsible = GetPostString("responsibleman");
  5869. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5870. // string customer = GetPostString("customer");
  5871. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5872. // string design = GetPostString("design");
  5873. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5874. // string afterMemoType = GetPostString("aftermemotype");
  5875. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5876. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5877. // if (afterState.Length <= 0)
  5878. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5879. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5880. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5881. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5882. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5883. //}
  5884. public void get_erp_aftersaleverifylist()
  5885. {
  5886. DataStruct dStruct = GetPostStruct();
  5887. List<string> lw = new List<string>();
  5888. string tid = GetPostString("ctid");
  5889. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5890. string shopname = GetPostString("shopname");
  5891. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5892. string buyernick = GetPostString("buyer_nick");
  5893. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5894. string sellermemo = GetPostString("seller_memo");
  5895. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5896. string orderState = GetPostString("orderState");
  5897. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5898. //lw.Add(string.Format("IsRefund!={0}", 1));
  5899. string reason = GetPostString("reason");
  5900. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5901. string method = GetPostString("method");
  5902. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5903. string handler = GetPostString("handler");
  5904. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5905. string handledate1 = GetPostString("handledate1");
  5906. string handledate2 = GetPostString("handledate2");
  5907. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5908. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5909. string finish1 = GetPostString("finishdate1");
  5910. string finish2 = GetPostString("finishdate2");
  5911. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5912. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5913. string supplier = GetPostString("supplier");
  5914. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5915. string responsible = GetPostString("responsibleman");
  5916. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5917. string posCode = CurrentUser.UserPost.Post.Code;
  5918. string vstate = GetPostString("vstate");
  5919. if (vstate.Length > 0)
  5920. {
  5921. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5922. }
  5923. if (posCode == "Supplier")
  5924. {
  5925. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5926. lw.Add(string.Format("VerifyState = 0"));
  5927. lw.Add("type = 1");
  5928. lw.Add(string.Format("AfterSaleState={0}", 3));
  5929. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5930. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5931. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5932. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5933. writeGridDataTableJson(dStruct.TotalCount, dt);
  5934. }
  5935. else if (posCode == "logistics")
  5936. {
  5937. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5938. lw.Add(string.Format("VerifyState = 0"));
  5939. lw.Add("type = 2");
  5940. lw.Add(string.Format("AfterSaleState={0}", 3));
  5941. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5942. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5943. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5944. writeGridDataTableJson(dStruct.TotalCount, dt);
  5945. }
  5946. else
  5947. {
  5948. lw.Add(string.Format("(AfterSaleState = 3)"));
  5949. string reasonState = GetPostString("reasonState");
  5950. lw.Add("type = 0");
  5951. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5952. || posCode == "Summarize" || posCode == "Finance")
  5953. {
  5954. if (reasonState == "2")
  5955. {
  5956. lw.Add("VerifyState = 3");
  5957. }
  5958. else if (reasonState == "1")
  5959. {
  5960. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5961. }
  5962. else
  5963. {
  5964. lw.Add("VerifyState in (0,3)");
  5965. }
  5966. //不加条件,可以看全部
  5967. }
  5968. 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")
  5969. {
  5970. int orgid = CurrentUser.UserPost.OrgID;
  5971. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5972. if (string.IsNullOrEmpty(manageOrgId))
  5973. {
  5974. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5975. }
  5976. else
  5977. {
  5978. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5979. }
  5980. if (reasonState == "1")
  5981. {
  5982. lw.Add("VerifyState = 3");
  5983. }
  5984. else if (reasonState == "2")
  5985. {
  5986. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5987. }
  5988. else
  5989. {
  5990. }
  5991. }
  5992. else
  5993. {
  5994. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5995. }
  5996. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5997. //{
  5998. // int org_id = CurrentUser.UserPost.OrgID;
  5999. // lw.Add(string.Format("OrgID={0}", org_id));
  6000. //}
  6001. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6002. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6003. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6004. writeGridDataTableJson(dStruct.TotalCount, dt);
  6005. }
  6006. }
  6007. public void get_erp_finishaftersalelist()
  6008. {
  6009. DataStruct dStruct = GetPostStruct();
  6010. List<string> lw = new List<string>();
  6011. int st = 4;
  6012. string tid = GetPostString("ctid");
  6013. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  6014. string shopname = GetPostString("shopname");
  6015. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6016. //lw.Add(string.Format("IsRefund!={0}", 1));
  6017. string reason = GetPostString("reason");
  6018. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6019. string method = GetPostString("method");
  6020. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6021. string buyernick = GetPostString("buyer_nick");
  6022. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6023. string handler = GetPostString("handler");
  6024. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6025. string handledate1 = GetPostString("handledate1");
  6026. string handledate2 = GetPostString("handledate2");
  6027. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6028. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6029. string finish1 = GetPostString("finishdate1");
  6030. string finish2 = GetPostString("finishdate2");
  6031. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6032. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6033. string supplier = GetPostString("supplier");
  6034. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6035. string responsible = GetPostString("responsibleman");
  6036. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6037. string vstate = GetPostString("vstate");
  6038. if (vstate.Length > 0)
  6039. {
  6040. if ("3".Equals(vstate))
  6041. {
  6042. lw.Add(string.Format("IsTem=1"));
  6043. }
  6044. else
  6045. {
  6046. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6047. }
  6048. }
  6049. lw.Add(string.Format("AfterSaleState=4"));
  6050. string code = CurrentUser.UserPost.Post.Code;
  6051. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6052. {
  6053. //不加条件,可以看全部
  6054. }
  6055. else if (code == "Supplier")
  6056. {
  6057. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6058. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6059. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6060. }
  6061. else if (code == "logistics")
  6062. {
  6063. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6064. lw.Add("type = 2");
  6065. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6066. }
  6067. 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")
  6068. {
  6069. int orgid = CurrentUser.UserPost.OrgID;
  6070. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6071. if (string.IsNullOrEmpty(manageOrgIds))
  6072. {
  6073. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6074. }
  6075. else
  6076. {
  6077. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6078. }
  6079. }
  6080. else
  6081. {
  6082. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6083. }
  6084. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6085. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6086. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6087. writeGridDataTableJson(dStruct.TotalCount, dt);
  6088. }
  6089. public void handle_erp_aftersale()
  6090. {
  6091. if (UrlPostParmsCheck("ctid"))
  6092. {
  6093. string eid = GetPostString("ctid");
  6094. string responStr = GetPostString("AfterSaleResponsible");
  6095. if (responStr.Length <= 0)
  6096. {
  6097. returnErrorMsg("售后责任人不能为空");
  6098. return;
  6099. }
  6100. bool isDesign = false;
  6101. double designFree = 0.00;
  6102. int responsibleId = 0;
  6103. CeErpTradeCell entity = null;
  6104. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6105. if (entity != null)
  6106. {
  6107. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6108. string afterMethod = GetPostString("AfterSaleMethod");
  6109. if (isNeedNewOrder == 1)
  6110. {
  6111. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6112. bool ishav = true;
  6113. if (newentity == null)
  6114. {
  6115. newentity = entity.Clone() as CeErpTradeCell;
  6116. ishav = false;
  6117. newentity.ctid = "S_" + entity.ctid;
  6118. newentity.OrderState = 0;
  6119. }
  6120. //唯一标识
  6121. newentity.OrderSn = newentity.ctid;
  6122. /* string orderSn = dataHelper.getSaleOrderSn();
  6123. if (orderSn != "")
  6124. {
  6125. newentity.OrderSn = orderSn;
  6126. }*/
  6127. newentity.AfterSaleState = 0;
  6128. newentity.AfterSaleMethod = afterMethod;
  6129. if (!ishav)
  6130. {
  6131. string memo_str = newentity.seller_memo;
  6132. memo_str = memo_str.Replace("(", "(");
  6133. memo_str = memo_str.Replace(")", ")");
  6134. int sIndex = memo_str.IndexOf("(");
  6135. int eIndex = memo_str.IndexOf(")");
  6136. if (sIndex == -1 || eIndex == -1)
  6137. {
  6138. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6139. return;
  6140. }
  6141. string first = memo_str.Substring(0, sIndex + 1);
  6142. string memoCtid = newentity.OrderSn;
  6143. //if (memoCtid.IndexOf("C") != -1)
  6144. //{
  6145. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6146. //if (CIdx.IndexOf("+") != -1)
  6147. //{
  6148. //CIdx = "C" + CIdx.Split('+')[1];
  6149. //}
  6150. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6151. //}
  6152. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6153. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6154. string newMemo = first + memoCtid + last;
  6155. newentity.seller_memo = newMemo;
  6156. newentity.FinishPlaceTime = null;
  6157. newentity.UnusualTag = 0;
  6158. newentity.UnusualCon = "";
  6159. newentity.UnusualTime = null;
  6160. newentity.AfterSaleMemo = "";
  6161. newentity.AfterSaleMethod = afterMethod;
  6162. newentity.AfterSalePreTime = null;
  6163. newentity.AfterSaleReason = "";
  6164. newentity.AfterSaleResponsible = "";
  6165. newentity.AfterSaleState = 0;
  6166. newentity.AfterSaleTime = null;
  6167. newentity.AfterSaleUserId = 0;
  6168. newentity.AfterSaleSupplierState = 0;
  6169. newentity.LastBillWaybillCode = "";
  6170. newentity.LastBillCpCode = "";
  6171. newentity.FinishAfterSaleTime = null;
  6172. newentity.HandleTime = null;
  6173. newentity.IsSF = 0;
  6174. newentity.IsOldCustomer = 0;
  6175. newentity.UrgencyTime = null;
  6176. newentity.ResponsibleUserId = "";
  6177. newentity.IsVerifyToSupplier = false;
  6178. newentity.payment = 0;
  6179. newentity.CheckMemo = "";
  6180. newentity.OutSid = "";
  6181. newentity.CheckOrderTime = null;
  6182. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6183. }
  6184. newentity.isAfterSaleOrder = 1;
  6185. newentity.IsRefund = 0;
  6186. string receiveMobile = GetPostString("receiver_mobile");
  6187. if (receiveMobile.Length > 0)
  6188. {
  6189. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6190. if (trade != null)
  6191. {
  6192. trade.receiver_name = GetPostString("receiver_name");
  6193. trade.receiver_mobile = receiveMobile;
  6194. trade.receiver_state = GetPostString("receiver_state");
  6195. trade.receiver_city = GetPostString("receiver_city");
  6196. trade.receiver_district = GetPostString("receiver_district");
  6197. trade.receiver_address = GetPostString("receiver_address");
  6198. newentity.IsOffLineOrder = 1;
  6199. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6200. }
  6201. }
  6202. string st = GetPostString("ToState");
  6203. if (st.Length > 0)
  6204. {
  6205. if (newentity.OrderState <= 3)
  6206. {
  6207. newentity.WaitDesignTime = DateTime.Now;
  6208. newentity.StartDesignTime = null;
  6209. newentity.FinishDesignTime = null;
  6210. newentity.OrderState = 3;
  6211. if (st == "下单员")
  6212. {
  6213. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6214. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6215. {
  6216. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6217. }
  6218. }
  6219. else
  6220. {
  6221. newentity.WaitDesignTime = DateTime.Now;
  6222. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6223. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6224. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6225. {
  6226. DataRow user = dt1.Rows[0];
  6227. //找主管
  6228. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6229. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6230. if (dt != null && dt.Rows.Count > 0)
  6231. {
  6232. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6233. newentity.DesignUserId = designMr;
  6234. string key = "aftersale_order_" + designMr;
  6235. if (RedisHelper.HasKey(key))
  6236. {
  6237. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6238. list.Add(newentity.ctid);
  6239. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6240. }
  6241. }
  6242. //账号正常
  6243. if (user["State"].ToString() == "0")
  6244. {
  6245. newentity.DesignUserId = entity.DesignUserId;
  6246. string key = "aftersale_order_" + entity.DesignUserId;
  6247. if (RedisHelper.HasKey(key))
  6248. {
  6249. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6250. list.Add(newentity.ctid);
  6251. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6252. }
  6253. }
  6254. }
  6255. }
  6256. }
  6257. if (entity.IsXianHuo == 1)
  6258. {
  6259. newentity.OrderState = 6;
  6260. entity.FinishPlaceTime = DateTime.Now;
  6261. }
  6262. }
  6263. if (ishav)
  6264. {
  6265. newentity.Update();
  6266. }
  6267. else
  6268. {
  6269. newentity.Create();
  6270. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6271. newCellExtend.ctid = newentity.ctid;
  6272. newCellExtend.orderFrom = 20;
  6273. newCellExtend.orderType = 30;
  6274. if (st == "下单员")
  6275. {
  6276. }
  6277. else
  6278. {
  6279. newCellExtend.ReprintTime = DateTime.Now;
  6280. }
  6281. newCellExtend.Create();
  6282. }
  6283. if (st != "下单员")
  6284. {
  6285. designHelper.API_GetPrintData_CreateOrder(newentity);
  6286. }
  6287. }
  6288. //处理售后扩展
  6289. string resIdStr = GetPostString("ResponsibleUserId");
  6290. string refundFees = GetPostString("refundFrees");
  6291. int IsComplain = GetPostInt("isComplain");
  6292. int IsBad = GetPostInt("isBad");
  6293. string IsOriginal = GetPostString("isOriginal");
  6294. double diffResultPrice = GetPostDouble("diffResultPrice");
  6295. string textResult = GetPostString("textResult");
  6296. string supplierResponsible = GetPostString("supplierResponsible");
  6297. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6298. if (ceErpTradeAfterSaleExtend == null)
  6299. {
  6300. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6301. ceErpTradeAfterSaleExtend.tid = eid;
  6302. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6303. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6304. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6305. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6306. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6307. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6308. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6309. ceErpTradeAfterSaleExtend.Create();
  6310. }
  6311. else
  6312. {
  6313. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6314. {
  6315. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6316. }
  6317. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6318. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6319. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6320. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6321. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6322. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6323. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6324. ceErpTradeAfterSaleExtend.Update();
  6325. }
  6326. int gysid = GetPostInt("ResponsibleSupId");
  6327. if (entity.AfterSaleUserId == 0)
  6328. {
  6329. entity.AfterSaleUserId = CurrentUser.UserID;
  6330. }
  6331. entity.ResponsibleUserId = resIdStr;
  6332. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6333. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6334. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6335. {
  6336. CeErpTradeResponsible.DelByTid(eid, -1);
  6337. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6338. int backNum = 0;
  6339. if (number != null)
  6340. {
  6341. backNum = number.BackNum;
  6342. }
  6343. char[] separator = { ',' };
  6344. string[] sArray = resIdStr.Split(separator);
  6345. string[] refundFreeList = { };
  6346. if (refundFees.Length > 0)
  6347. {
  6348. refundFreeList = refundFees.Split(separator);
  6349. }
  6350. int index = -1;
  6351. foreach (string i in sArray)
  6352. {
  6353. index++;
  6354. if (i.Length <= 0) continue;
  6355. char[] separator2 = { '_' };
  6356. string idstr = i.Split(separator2)[0];
  6357. string idtype = i.Split(separator2)[1];
  6358. double refudFree = 0;
  6359. if (refundFreeList.Length > 0)
  6360. {
  6361. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6362. }
  6363. if (idtype == "s")
  6364. {
  6365. isDesign = true;
  6366. designFree = refudFree;
  6367. }
  6368. int userId = Convert.ToInt32(idstr);
  6369. int type = 0;
  6370. if (idtype == "g")
  6371. {
  6372. type = 1;
  6373. }
  6374. if (idtype == "w")
  6375. {
  6376. type = 2;
  6377. }
  6378. if (idtype == "t")
  6379. {
  6380. type = 3;
  6381. }
  6382. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6383. if (ceErpTradeResponsible == null)
  6384. {
  6385. ceErpTradeResponsible = new CeErpTradeResponsible();
  6386. ceErpTradeResponsible.tid = eid;
  6387. ceErpTradeResponsible.UserId = userId;
  6388. ceErpTradeResponsible.createdTime = DateTime.Now;
  6389. ceErpTradeResponsible.type = type;
  6390. if (type == 1)
  6391. {
  6392. ceErpTradeResponsible.IsSup = 1;
  6393. }
  6394. if (type == 2)
  6395. {
  6396. ceErpTradeResponsible.IsFlow = 1;
  6397. }
  6398. }
  6399. ceErpTradeResponsible.RefundFee = refudFree;
  6400. ceErpTradeResponsible.VerifyState = 0;
  6401. if (userId == 2125 || idtype == "w")
  6402. {
  6403. ceErpTradeResponsible.VerifyState = 1;
  6404. }
  6405. if (idtype == "w" && userId == 101)
  6406. {
  6407. ceErpTradeResponsible.VerifyState = 0;
  6408. }
  6409. if (ceErpTradeResponsible.ID > 0)
  6410. {
  6411. ceErpTradeResponsible.Update();
  6412. }
  6413. else
  6414. {
  6415. ceErpTradeResponsible.Create();
  6416. }
  6417. if (isDesign)
  6418. {
  6419. responsibleId = ceErpTradeResponsible.ID;
  6420. }
  6421. }
  6422. CeErpTradeResponsible.NumByTid(backNum, eid);
  6423. }
  6424. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6425. if (ceErpTradeCellExtend != null)
  6426. {
  6427. ceErpTradeCellExtend.returnVisit = 0;
  6428. ceErpTradeCellExtend.Update();
  6429. }
  6430. if (entity.HandleTime != null)
  6431. {
  6432. if (entity.AfterSaleState == 1)
  6433. {
  6434. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6435. }
  6436. else
  6437. {
  6438. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6439. }
  6440. }
  6441. else
  6442. {
  6443. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6444. entity.HandleTime = DateTime.Now;
  6445. }
  6446. bool isCompale = false;
  6447. if (entity.AfterSaleState == 5)
  6448. {
  6449. isCompale = true;
  6450. entity.AfterSaleState = 3;
  6451. }
  6452. entity.AfterSaleSupplierState = 0;
  6453. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6454. {
  6455. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6456. }
  6457. string sImgs = GetPostString("img");
  6458. entity.AfterSaleSupplierImg = sImgs;
  6459. entity.supRefundType = GetPostString("supRefundType");
  6460. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6461. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6462. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6463. entity.AfterSaleMemoType = GetPostString("MemoType");
  6464. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6465. {
  6466. //entity.AfterSaleSupplierState = 2;
  6467. }
  6468. string df = GetPostString("DeductFee");
  6469. if (df == "")
  6470. {
  6471. df = "0";
  6472. }
  6473. string rf = GetPostString("RefundFee");
  6474. if (rf == "")
  6475. {
  6476. rf = "0";
  6477. }
  6478. string pm = GetPostString("AfterSalePayment");
  6479. if (pm == "")
  6480. {
  6481. pm = "0";
  6482. }
  6483. entity.AfterSalePayment = Convert.ToDouble(pm);
  6484. entity.DeductFee = Convert.ToDouble(df);
  6485. entity.RefundFee = Convert.ToDouble(rf);
  6486. entity.Update();
  6487. string toState = GetPostString("ToState");
  6488. string original = GetPostString("isOriginal");
  6489. ApiVo apiVo = new ApiVo();
  6490. apiVo.orderNumber = entity.ctid;
  6491. apiVo.actionName = "afterDesign";
  6492. apiVo.orderRemarks = entity.AfterSaleMethod;
  6493. apiVo.reasonRemarks = entity.AfterSaleReason;
  6494. apiVo.isDesign = isDesign;
  6495. apiVo.designFree = designFree;
  6496. apiVo.responsibleId = responsibleId;
  6497. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6498. if (toState == "设计师")
  6499. {
  6500. apiVo.isOriginal = Convert.ToBoolean(original);
  6501. }
  6502. designHelper.API_WorkCore(apiVo);//afterDesign
  6503. CeErpMethod methodSql = new CeErpMethod();
  6504. methodSql.con = entity.AfterSaleMethod;
  6505. methodSql.addTime = DateTime.Now;
  6506. methodSql.Create();
  6507. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6508. CeErpMethod.ExecuteNonQuery(delsql);
  6509. if (isCompale)
  6510. {
  6511. aftersale_data_change(entity.ctid);
  6512. }
  6513. returnSuccessMsg("操作成功!");
  6514. return;
  6515. }
  6516. returnErrorMsg("找不到订单记录");
  6517. }
  6518. }
  6519. public void ins_erp_toresponsible()
  6520. {
  6521. if (UrlPostParmsCheck("ctid"))
  6522. {
  6523. string eid = GetPostString("ctid");
  6524. CeErpTradeCell entity = null;
  6525. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6526. if (entity != null)
  6527. {
  6528. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6529. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6530. {
  6531. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6532. return;
  6533. }
  6534. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6535. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6536. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6537. if (entity.AfterSalePreTime == null)
  6538. {
  6539. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6540. {
  6541. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6542. }
  6543. }
  6544. entity.AfterSalePreTime = DateTime.Now;
  6545. //预完成给售后主管审核客户问题直接完成
  6546. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6547. {
  6548. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6549. {
  6550. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6551. }
  6552. }
  6553. ceErpTradeAfterSaleExtend.Update();
  6554. entity.AfterSaleState = 2;
  6555. entity.Update();
  6556. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6557. aftersale_data_change(entity.ctid);
  6558. returnSuccessMsg("操作成功!");
  6559. return;
  6560. }
  6561. returnErrorMsg("找不到订单记录");
  6562. }
  6563. }
  6564. public void cancel_erp_aftersaleanddelnew()
  6565. {
  6566. if (UrlPostParmsCheck("ctid"))
  6567. {
  6568. string eid = GetPostString("ctid");
  6569. CeErpTradeCell entity = null;
  6570. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6571. if (entity != null)
  6572. {
  6573. entity.AfterSaleState = 0;
  6574. entity.AfterSaleReason = "";
  6575. entity.AfterSaleMethod = "";
  6576. entity.AfterSaleMemo = "";
  6577. entity.AfterSaleResponsible = "";
  6578. entity.ResponsibleUserId = "";
  6579. entity.DeductFee = 0;
  6580. entity.RefundFee = 0;
  6581. entity.IsArbitrate = 0;
  6582. CeErpTradeResponsible.DelByTid(eid, -1);
  6583. entity.Update();
  6584. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6585. if (after != null)
  6586. {
  6587. if (after.OrderState < 5)
  6588. CeErpTradeCell.DelByCtid("S_" + eid);
  6589. }
  6590. returnSuccessMsg("操作成功!");
  6591. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6592. return;
  6593. }
  6594. returnErrorMsg("找不到订单记录");
  6595. }
  6596. }
  6597. public void get_erp_aftersale_pregather()
  6598. {
  6599. List<string> lw = new List<string>();
  6600. int st = GetInt("st");
  6601. string tid = GetPostString("ctid");
  6602. if (tid.Length > 0) lw.Add(string.Format("(tid = '{0}' or ctid = '{0}' or orderSn = '{0}')", tid));
  6603. string shopname = GetPostString("shopname");
  6604. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6605. string buyernick = GetPostString("buyer_nick");
  6606. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6607. string sellermemo = GetPostString("seller_memo");
  6608. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6609. string orderState = GetPostString("orderState");
  6610. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6611. string reason = GetPostString("reason");
  6612. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6613. string method = GetPostString("method");
  6614. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6615. string handler = GetPostString("handler");
  6616. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6617. string handledate1 = GetPostString("handledate1");
  6618. string handledate2 = GetPostString("handledate2");
  6619. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6620. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6621. string supplier = GetPostString("supplier");
  6622. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6623. string responsible = GetPostString("responsibleman");
  6624. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6625. string customer = GetPostString("customer");
  6626. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6627. string design = GetPostString("design");
  6628. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6629. string afterMemoType = GetPostString("aftermemotype");
  6630. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6631. string afterSaleMemo = GetPostString("afterSaleMemo");
  6632. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6633. string afterresult = GetPostString("afterresult");
  6634. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6635. string poscode = CurrentUser.UserPost.Post.Code;
  6636. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6637. {
  6638. string shopid = CurrentUser.User.pemShop;
  6639. lw.Add(string.Format("shopId in ({0})", shopid));
  6640. }
  6641. var mainwhere = string.Join(" and ", lw.ToArray());
  6642. string ro_json = "";
  6643. string type = GetPostString("gather_type");
  6644. int number = 0;
  6645. if (poscode == "AfterSale")
  6646. {
  6647. //处理中
  6648. if (type == "Handling")
  6649. {
  6650. 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) : ""));
  6651. DataTable dt = null;
  6652. try
  6653. {
  6654. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6655. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6656. }
  6657. catch (Exception e)
  6658. {
  6659. dt = new DataTable();
  6660. }
  6661. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6662. return;
  6663. }
  6664. if (type == "Wait")
  6665. {
  6666. //待处理
  6667. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6668. DataTable dt1 = null;
  6669. try
  6670. {
  6671. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6672. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6673. }
  6674. catch (Exception e)
  6675. {
  6676. dt1 = new DataTable();
  6677. }
  6678. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6679. return;
  6680. }
  6681. if (type == "back")
  6682. {
  6683. //打回
  6684. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6685. DataTable dt2 = null;
  6686. try
  6687. {
  6688. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6689. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6690. }
  6691. catch (Exception e)
  6692. {
  6693. dt2 = new DataTable();
  6694. }
  6695. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6696. return;
  6697. }
  6698. if (type == "preCompletion")
  6699. {
  6700. //预完成
  6701. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6702. DataTable dt3 = null;
  6703. try
  6704. {
  6705. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6706. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6707. }
  6708. catch (Exception e)
  6709. {
  6710. dt3 = new DataTable();
  6711. }
  6712. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6713. return;
  6714. }
  6715. if (type == "documentary")
  6716. {
  6717. //跟单中
  6718. 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) : ""));
  6719. DataTable dt4 = null;
  6720. try
  6721. {
  6722. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6723. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6724. }
  6725. catch (Exception e)
  6726. {
  6727. dt4 = new DataTable();
  6728. }
  6729. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6730. return;
  6731. }
  6732. if (type == "reBack")
  6733. {
  6734. //被打回
  6735. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6736. DataTable dt1 = null;
  6737. try
  6738. {
  6739. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6740. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6741. }
  6742. catch (Exception e)
  6743. {
  6744. dt1 = new DataTable();
  6745. }
  6746. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6747. return;
  6748. }
  6749. }
  6750. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6751. {
  6752. if (type == "puBack")
  6753. {
  6754. //退回
  6755. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6756. DataTable dt = null;
  6757. try
  6758. {
  6759. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6760. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6761. }
  6762. catch (Exception e)
  6763. {
  6764. dt = new DataTable();
  6765. }
  6766. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6767. return;
  6768. }
  6769. if (type == "reBack")
  6770. {
  6771. //打回
  6772. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6773. DataTable dt1 = null;
  6774. try
  6775. {
  6776. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6777. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6778. }
  6779. catch (Exception e)
  6780. {
  6781. dt1 = new DataTable();
  6782. }
  6783. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6784. return;
  6785. }
  6786. if (type == "examEd")
  6787. {
  6788. //已审核
  6789. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6790. DataTable dt2 = null;
  6791. try
  6792. {
  6793. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6794. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6795. }
  6796. catch (Exception e)
  6797. {
  6798. dt2 = new DataTable();
  6799. }
  6800. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  6801. return;
  6802. }
  6803. if (type == "waitExam")
  6804. {
  6805. //待审核
  6806. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6807. DataTable dt3 = null;
  6808. try
  6809. {
  6810. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6811. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6812. }
  6813. catch (Exception e)
  6814. {
  6815. dt3 = new DataTable();
  6816. }
  6817. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  6818. return;
  6819. }
  6820. if (type == "Handling")
  6821. {
  6822. //处理中
  6823. 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) : ""));
  6824. DataTable dt4 = null;
  6825. try
  6826. {
  6827. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6828. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6829. }
  6830. catch (Exception e)
  6831. {
  6832. dt4 = new DataTable();
  6833. }
  6834. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6835. return;
  6836. }
  6837. if (type == "Wait")
  6838. {
  6839. //待处理
  6840. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6841. DataTable dt5 = null;
  6842. try
  6843. {
  6844. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6845. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  6846. }
  6847. catch (Exception e)
  6848. {
  6849. dt5 = new DataTable();
  6850. }
  6851. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6852. return;
  6853. }
  6854. if (type == "documentary")
  6855. {
  6856. //跟单中
  6857. 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) : ""));
  6858. DataTable dt6 = null;
  6859. try
  6860. {
  6861. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6862. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  6863. }
  6864. catch (Exception e)
  6865. {
  6866. dt6 = new DataTable();
  6867. }
  6868. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6869. return;
  6870. }
  6871. }
  6872. returnSuccess(ro_json);
  6873. }
  6874. public void end_erp_aftersale()
  6875. {
  6876. if (UrlPostParmsCheck("ctid"))
  6877. {
  6878. string eid = GetPostString("ctid");
  6879. CeErpTradeCell entity = null;
  6880. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6881. if (entity != null)
  6882. {
  6883. string stype = GetPostString("stype");
  6884. string typeStr = stype;
  6885. entity.AfterSaleState = 4;
  6886. entity.FinishAfterSaleTime = DateTime.Now;
  6887. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6888. entity.Update();
  6889. ApiVo apiVo = new ApiVo();
  6890. apiVo.orderNumber = entity.ctid;
  6891. apiVo.actionName = "afterOver";
  6892. designHelper.API_WorkCore(apiVo); //afterOver
  6893. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6894. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6895. CeErpSukuraData.createInfo(entity.ctid, 8);
  6896. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6897. returnSuccessMsg("操作成功!");
  6898. return;
  6899. }
  6900. returnErrorMsg("找不到订单记录");
  6901. }
  6902. }
  6903. public void ins_erp_finishaftersale()
  6904. {
  6905. if (UrlPostParmsCheck("id"))
  6906. {
  6907. string eid = GetPostString("id");
  6908. CeErpTradeResponsible entity = null;
  6909. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6910. if (entity != null)
  6911. {
  6912. entity.VerifyState = 1;
  6913. entity.VerifyTime = DateTime.Now;
  6914. entity.Update();
  6915. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6916. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6917. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6918. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6919. if (dt.Rows.Count <= 0)
  6920. {
  6921. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6922. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6923. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6924. CeErpSukuraData.createInfo(entity.tid, 8);
  6925. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6926. {
  6927. CeErpDesignerBill.Del(entity.tid);
  6928. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6929. }
  6930. }
  6931. returnSuccessMsg("操作成功!");
  6932. return;
  6933. }
  6934. returnErrorMsg("找不到订单记录");
  6935. }
  6936. }
  6937. public void upd_erp_arbitrateaftersale()
  6938. {
  6939. if (UrlPostParmsCheck("id"))
  6940. {
  6941. string eid = GetPostString("id");
  6942. CeErpTradeResponsible entity = null;
  6943. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6944. if (entity != null)
  6945. {
  6946. entity.IsArbitrate = 1;
  6947. entity.ArbitradeMemo = GetPostString("reason");
  6948. entity.VerifyState = 2;
  6949. entity.Update();
  6950. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6951. if (tradecell != null)
  6952. {
  6953. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6954. tradecell.IsArbitrate = 1;
  6955. tradecell.Update();
  6956. }
  6957. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6958. returnSuccessMsg("操作成功!");
  6959. return;
  6960. }
  6961. returnErrorMsg("找不到订单记录");
  6962. }
  6963. }
  6964. public void upd_erp_backaftersale()
  6965. {
  6966. if (UrlPostParmsCheck("tid"))
  6967. {
  6968. string eid = GetPostString("tid");
  6969. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6970. int backNum = 0;
  6971. if (number != null)
  6972. {
  6973. backNum = number.BackNum;
  6974. }
  6975. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6976. CeErpTradeCell entity = null;
  6977. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6978. if (entity != null)
  6979. {
  6980. entity.AfterSaleBackReason = GetPostString("backreason");
  6981. entity.AfterSaleState = 1;
  6982. entity.AfterSaleSupplierState = 0;
  6983. entity.Update();
  6984. returnSuccessMsg("操作成功!");
  6985. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6986. return;
  6987. }
  6988. returnErrorMsg("找不到订单记录");
  6989. }
  6990. }
  6991. public void get_erp_supplieraftersalelist()
  6992. {
  6993. DataStruct dStruct = GetPostStruct();
  6994. List<string> lw = new List<string>();
  6995. string tid = GetPostString("ctid");
  6996. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6997. string shopname = GetPostString("shopname");
  6998. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6999. string buyernick = GetPostString("buyer_nick");
  7000. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7001. string sellermemo = GetPostString("seller_memo");
  7002. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7003. string orderState = GetPostString("orderState");
  7004. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7005. string afterState = GetPostString("afterstate");
  7006. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7007. string date1 = GetPostString("date1");
  7008. string date2 = GetPostString("date2");
  7009. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7010. if (dw.Length > 0) lw.Add(dw);
  7011. string price1 = GetPostString("price1");
  7012. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7013. string price2 = GetPostString("price2");
  7014. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7015. string reason = GetPostString("reason");
  7016. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7017. string method = GetPostString("method");
  7018. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7019. string handledate1 = GetPostString("handledate1");
  7020. string handledate2 = GetPostString("handledate2");
  7021. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7022. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7023. string handler = GetPostString("handler");
  7024. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7025. string afterdate1 = GetPostString("afterdate1");
  7026. string afterdate2 = GetPostString("afterdate2");
  7027. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7028. if (afterDate.Length > 0) lw.Add(afterDate);
  7029. string customer = GetPostString("customer");
  7030. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7031. string design = GetPostString("design");
  7032. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7033. string afterMemoType = GetPostString("aftermemotype");
  7034. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7035. string vstate = GetPostString("vstate");
  7036. if (vstate.Length > 0)
  7037. {
  7038. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7039. }
  7040. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7041. string supplier = GetPostString("supplier");
  7042. int supid = commonHelper.getSupplierIDByName(supplier);
  7043. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7044. string posCode = CurrentUser.UserPost.Post.Code;
  7045. if (posCode == "Supplier")
  7046. {
  7047. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7048. }
  7049. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7050. {
  7051. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7052. }
  7053. else
  7054. {
  7055. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7056. }
  7057. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7058. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7059. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7060. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7061. writeGridDataTableJson(dStruct.TotalCount, dt);
  7062. }
  7063. public void upd_erp_supverifyaftersale()
  7064. {
  7065. if (UrlPostParmsCheck("id"))
  7066. {
  7067. string id = GetPostString("id");
  7068. int st = GetPostInt("afterstate");
  7069. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7070. CeErpTradeCell entity = null;
  7071. if (ceErpTradeResponsible != null)
  7072. {
  7073. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7074. }
  7075. string afmemo = GetPostString("supmemo");
  7076. string image = GetPostString("image");
  7077. if (entity != null)
  7078. {
  7079. entity.AfterSaleSupplierState = st;
  7080. entity.AfterSaleSupplierMemo = afmemo;
  7081. if (st == 1)
  7082. {
  7083. ceErpTradeResponsible.VerifyState = 1;
  7084. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7085. ceErpTradeResponsible.Update();
  7086. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7087. if (isAll)
  7088. {
  7089. entity.AfterSaleState = 4;
  7090. entity.FinishAfterSaleTime = DateTime.Now;
  7091. }
  7092. }
  7093. else
  7094. {
  7095. CeErpTradeResponsible.dateByTid(entity.ctid);
  7096. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7097. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7098. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7099. if (num <= 1)
  7100. {
  7101. entity.AfterSaleState = 1;
  7102. }
  7103. else
  7104. {
  7105. entity.AfterSaleState = 5;
  7106. }
  7107. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7108. if (ceErpTradeAfterSaleExtend != null)
  7109. {
  7110. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7111. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7112. ceErpTradeAfterSaleExtend.Update();
  7113. }
  7114. else
  7115. {
  7116. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7117. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7118. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7119. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7120. ceErpTradeAfterSaleExtend.Create();
  7121. }
  7122. }
  7123. if (entity.AfterSaleState == 4)
  7124. {
  7125. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7126. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7127. {
  7128. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7129. }
  7130. ApiVo apiVo = new ApiVo();
  7131. apiVo.orderNumber = entity.ctid;
  7132. apiVo.actionName = "afterOver";
  7133. designHelper.API_WorkCore(apiVo); //afterOver
  7134. }
  7135. entity.Update();
  7136. returnSuccessMsg("操作成功!");
  7137. CeErpSukuraData.createInfo(entity.ctid, 8);
  7138. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7139. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7140. return;
  7141. }
  7142. returnErrorMsg("找不到订单记录");
  7143. }
  7144. }
  7145. public void upd_erp_masteraftersale()
  7146. {
  7147. if (UrlPostParmsCheck("id"))
  7148. {
  7149. string id = GetPostString("id");
  7150. int st = GetPostInt("afterstate");
  7151. string afmemo = GetPostString("supmemo");
  7152. string image = GetPostString("image");
  7153. string textResult = GetPostString("textResult");
  7154. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7155. if (ceErpTradeResponsible != null)
  7156. {
  7157. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7158. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7159. ceErpTradeResponsible.Update();
  7160. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7161. if (entity != null)
  7162. {
  7163. entity.AfterSaleSupplierState = st;
  7164. entity.AfterSaleSupplierMemo = afmemo;
  7165. if (st == 1)
  7166. {
  7167. }
  7168. else
  7169. {
  7170. CeErpTradeResponsible.dateByTid(entity.ctid);
  7171. //退回到售后
  7172. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7173. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7174. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7175. if (num <= 1)
  7176. {
  7177. entity.AfterSaleState = 1;
  7178. }
  7179. else
  7180. {
  7181. entity.AfterSaleState = 5;
  7182. }
  7183. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7184. if (ceErpTradeAfterSaleExtend != null)
  7185. {
  7186. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7187. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7188. ceErpTradeAfterSaleExtend.Update();
  7189. }
  7190. else
  7191. {
  7192. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7193. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7194. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7195. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7196. ceErpTradeAfterSaleExtend.Create();
  7197. }
  7198. }
  7199. entity.Update();
  7200. returnSuccessMsg("操作成功!");
  7201. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7202. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7203. return;
  7204. }
  7205. }
  7206. returnErrorMsg("找不到订单记录");
  7207. }
  7208. }
  7209. public void upd_erp_personaftersale()
  7210. {
  7211. if (UrlPostParmsCheck("id"))
  7212. {
  7213. string id = GetPostString("id");
  7214. int st = GetPostInt("afterstate");
  7215. string afmemo = GetPostString("supmemo");
  7216. string image = GetPostString("image");
  7217. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7218. if (ceErpTradeResponsible != null)
  7219. {
  7220. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7221. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7222. ceErpTradeResponsible.Update();
  7223. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7224. if (entity != null)
  7225. {
  7226. entity.AfterSaleSupplierMemo = afmemo;
  7227. entity.AfterSaleSupplierState = st;
  7228. if (st == 1)
  7229. {
  7230. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7231. if (isAll)
  7232. {
  7233. entity.AfterSaleState = 4;
  7234. entity.FinishAfterSaleTime = DateTime.Now;
  7235. }
  7236. }
  7237. else
  7238. {
  7239. CeErpTradeResponsible.dateByTid(entity.ctid);
  7240. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7241. if (ceErpTradeAfterSaleExtend != null)
  7242. {
  7243. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7244. ceErpTradeAfterSaleExtend.Update();
  7245. }
  7246. else
  7247. {
  7248. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7249. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7250. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7251. ceErpTradeAfterSaleExtend.Create();
  7252. }
  7253. //退回到主管
  7254. //entity.AfterSaleState = 2;
  7255. }
  7256. if (entity.AfterSaleState == 4)
  7257. {
  7258. ApiVo apiVo = new ApiVo();
  7259. apiVo.orderNumber = entity.ctid;
  7260. apiVo.actionName = "afterOver";
  7261. designHelper.API_WorkCore(apiVo); //afterOver
  7262. }
  7263. entity.Update();
  7264. returnSuccessMsg("操作成功!");
  7265. CeErpSukuraData.createInfo(entity.ctid, 8);
  7266. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7267. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7268. return;
  7269. }
  7270. }
  7271. returnErrorMsg("找不到订单记录");
  7272. }
  7273. }
  7274. public void set_erp_supplierrefundtag()
  7275. {
  7276. if (UrlPostParmsCheck("ctid"))
  7277. {
  7278. string eid = GetPostString("ctid");
  7279. CeErpTradeCell entity = null;
  7280. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7281. if (entity != null)
  7282. {
  7283. entity.IsSupplierRefund = GetPostInt("tag");
  7284. entity.Update();
  7285. returnSuccessMsg("操作成功!");
  7286. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7287. return;
  7288. }
  7289. returnErrorMsg("找不到订单记录");
  7290. }
  7291. }
  7292. public void get_erp_refundlist()
  7293. {
  7294. DataStruct dStruct = GetPostStruct();
  7295. List<string> lw = new List<string>();
  7296. string tid = GetPostString("tid");
  7297. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7298. //string rid = GetPostString("refund_id");
  7299. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7300. string shopname = GetPostString("shopname");
  7301. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7302. string buyernick = GetPostString("buyer_nick");
  7303. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7304. string customer = GetPostString("customer");
  7305. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7306. string design = GetPostString("design");
  7307. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7308. string sellermemo = GetPostString("seller_memo");
  7309. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7310. //string date1 = GetPostString("date1");
  7311. //string date2 = GetPostString("date2");
  7312. //string dateType = GetPostString("dateType");
  7313. //if (dateType.Length > 0)
  7314. //{
  7315. // if (dateType == "1001") dateType = "0";
  7316. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7317. // if (searchDT.Count == 2)
  7318. // {
  7319. // date1 = searchDT[0].ToString();
  7320. // date2 = searchDT[1].ToString();
  7321. // }
  7322. //}
  7323. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7324. //if (dw.Length > 0) lw.Add(dw);
  7325. string redate1 = GetPostString("refunddate1");
  7326. string redate2 = GetPostString("refunddate2");
  7327. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7328. if (dwdate.Length > 0) lw.Add(dwdate);
  7329. string price1 = GetPostString("price1");
  7330. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7331. string price2 = GetPostString("price2");
  7332. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7333. string ispartrefund = GetPostString("ispartrefund");
  7334. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7335. string refundState = GetPostString("refundvstate");
  7336. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7337. int st = GetInt("st");
  7338. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7339. {
  7340. string responsible = GetPostString("responsibleman");
  7341. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7342. lw.Add(string.Format("RefundState>={0}", st));
  7343. string code = CurrentUser.UserPost.Post.Code;
  7344. if (code == "CustomerService")
  7345. {
  7346. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7347. }
  7348. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7349. {
  7350. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7351. }
  7352. else if (code == "Place" || code == "PlaceMr")
  7353. {
  7354. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7355. }
  7356. dStruct.Order = "RefundState asc,created desc";
  7357. }
  7358. else if (st == 10)
  7359. {
  7360. string responsible = GetPostString("responsibleman");
  7361. if (responsible == "空白")
  7362. {
  7363. lw.Add(string.Format("ResponsibleUserName = ''"));
  7364. }
  7365. else if (responsible.Length > 0)
  7366. {
  7367. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7368. }
  7369. lw.Add(string.Format("RefundState>=0"));
  7370. dStruct.Order = "created desc";
  7371. }
  7372. else
  7373. {
  7374. string responsible = GetPostString("responsibleman");
  7375. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7376. lw.Add(string.Format("RefundState={0}", st));
  7377. dStruct.Order = "created desc";
  7378. }
  7379. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7380. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7381. dt.Columns.Add("refund_fees");
  7382. foreach (DataRow dr in dt.Rows)
  7383. {
  7384. String status = dr["status"].ToString();
  7385. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7386. {
  7387. dr["refund_fees"] = dr["refund_fee"];
  7388. }
  7389. else
  7390. {
  7391. dr["refund_fees"] = "0.0";
  7392. }
  7393. }
  7394. writeGridDataTableJson(dStruct.TotalCount, dt);
  7395. }
  7396. public void get_erp_refunddesignlist()
  7397. {
  7398. DataStruct dStruct = GetPostStruct();
  7399. List<string> lw = new List<string>();
  7400. string tid = GetPostString("tid");
  7401. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7402. string shopname = GetPostString("shopname");
  7403. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7404. string buyernick = GetPostString("buyer_nick");
  7405. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7406. string customer = GetPostString("customer");
  7407. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7408. string design = GetPostString("design");
  7409. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7410. string sellermemo = GetPostString("seller_memo");
  7411. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7412. string redate1 = GetPostString("refunddate1");
  7413. string redate2 = GetPostString("refunddate2");
  7414. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7415. if (dwdate.Length > 0) lw.Add(dwdate);
  7416. string price1 = GetPostString("price1");
  7417. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7418. string price2 = GetPostString("price2");
  7419. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7420. string ispartrefund = GetPostString("ispartrefund");
  7421. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7422. string designerorg = GetPostString("designerorg");
  7423. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7424. string refundState = GetPostString("refundState");
  7425. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7426. int myOrgid = CurrentUser.UserPost.OrgID;
  7427. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7428. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7429. {
  7430. if (CurrentUser.User.TeamIds.Length > 0)
  7431. {
  7432. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7433. }
  7434. else
  7435. {
  7436. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7437. }
  7438. }
  7439. else if ("SysAdmin".Equals(myOrgCode))
  7440. {
  7441. }
  7442. else
  7443. {
  7444. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7445. {
  7446. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7447. }
  7448. else
  7449. {
  7450. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7451. }
  7452. }
  7453. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7454. dStruct.Order = "created desc";
  7455. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7456. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7457. dt.Columns.Add("refund_fees");
  7458. foreach (DataRow dr in dt.Rows)
  7459. {
  7460. String status = dr["status"].ToString();
  7461. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7462. {
  7463. dr["refund_fees"] = dr["refund_fee"];
  7464. }
  7465. else
  7466. {
  7467. dr["refund_fees"] = "0.0";
  7468. }
  7469. }
  7470. writeGridDataTableJson(dStruct.TotalCount, dt);
  7471. }
  7472. public void handle_erp_refundtag()
  7473. {
  7474. if (UrlPostParmsCheck("refund_id"))
  7475. {
  7476. string eid = GetPostString("refund_id");
  7477. string respMan = GetPostString("ResponsibleName");
  7478. if (respMan.Length <= 0)
  7479. {
  7480. returnErrorMsg("责任人不能为空");
  7481. return;
  7482. }
  7483. CeErpTradeRefund entity = null;
  7484. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7485. if (entity != null)
  7486. {
  7487. entity.ResponsibleUserName = respMan;
  7488. string userid = GetPostString("ResponsibleUserId");
  7489. if (userid.Length > 0)
  7490. {
  7491. entity.ResponsibleUserId = userid;
  7492. }
  7493. entity.Memo = GetPostString("Memo");
  7494. if (respMan.IndexOf("客服") != -1 ||
  7495. respMan.IndexOf("设计师") != -1 ||
  7496. respMan.IndexOf("下单员") != -1)
  7497. {
  7498. entity.RefundState = 2;
  7499. }
  7500. else
  7501. {
  7502. entity.RefundState = 3;
  7503. }
  7504. entity.modified = DateTime.Now;
  7505. entity.Update();
  7506. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7507. returnSuccessMsg("操作成功!");
  7508. return;
  7509. }
  7510. returnErrorMsg("找不到订单记录");
  7511. }
  7512. }
  7513. public void handle_erp_designrefundtag()
  7514. {
  7515. if (UrlPostParmsCheck("refund_id"))
  7516. {
  7517. string eid = GetPostString("refund_id");
  7518. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7519. if (ceErpTradeCellExtend == null)
  7520. {
  7521. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7522. ceErpTradeCellExtend.ctid = eid;
  7523. }
  7524. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7525. if (ceErpTradeCellExtend.ID > 0)
  7526. {
  7527. ceErpTradeCellExtend.Update();
  7528. }
  7529. else
  7530. {
  7531. ceErpTradeCellExtend.Create();
  7532. }
  7533. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7534. returnSuccessMsg("操作成功!");
  7535. return;
  7536. }
  7537. returnErrorMsg("找不到订单记录");
  7538. }
  7539. public void upd_erp_refundverify()
  7540. {
  7541. if (UrlPostParmsCheck("refund_id"))
  7542. {
  7543. string eid = GetPostString("refund_id");
  7544. CeErpTradeRefund entity = null;
  7545. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7546. if (entity != null)
  7547. {
  7548. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7549. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7550. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7551. {
  7552. entity.RefundState = 2;
  7553. }
  7554. else
  7555. {
  7556. entity.RefundState = 3;
  7557. }
  7558. entity.Update();
  7559. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7560. returnSuccessMsg("操作成功!");
  7561. return;
  7562. }
  7563. returnErrorMsg("找不到订单记录");
  7564. }
  7565. }
  7566. public void upd_erp_refundapprove()
  7567. {
  7568. if (UrlPostParmsCheck("refund_id"))
  7569. {
  7570. string eid = GetPostString("refund_id");
  7571. CeErpTradeRefund entity = null;
  7572. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7573. if (entity != null)
  7574. {
  7575. int apr = GetPostInt("approve");
  7576. if (apr == 0)
  7577. {
  7578. entity.RefundState = 1;
  7579. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7580. }
  7581. else if (apr == 1)
  7582. {
  7583. entity.RefundState = 3;
  7584. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7585. }
  7586. entity.modified = DateTime.Now;
  7587. entity.Update();
  7588. returnSuccessMsg("操作成功!");
  7589. return;
  7590. }
  7591. returnErrorMsg("找不到订单记录");
  7592. }
  7593. }
  7594. public void get_erp_billlist()
  7595. {
  7596. DataStruct dStruct = GetPostStruct();
  7597. List<string> lw = new List<string>();
  7598. string title = GetPostString("title");
  7599. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7600. string tid = GetPostString("tid");
  7601. string tids = GetPostString("tids");
  7602. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7603. if (tids.Length > 0)
  7604. {
  7605. tids = "'" + tids + "'";
  7606. tids = tids.Replace(",", "','");
  7607. lw.Add(string.Format("tid in ({0})", tids));
  7608. }
  7609. string shopname = GetPostString("shopname");
  7610. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7611. string buyernick = GetPostString("buyer_nick");
  7612. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7613. string customer = GetPostString("customer");
  7614. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7615. string date1 = GetPostString("date1");
  7616. string date2 = GetPostString("date2");
  7617. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7618. if (dw.Length > 0) lw.Add(dw);
  7619. string price1 = GetPostString("price1");
  7620. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7621. string price2 = GetPostString("price2");
  7622. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7623. string returndate1 = GetPostString("returndate1");
  7624. string returndate2 = GetPostString("returndate2");
  7625. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7626. if (dw1.Length > 0) lw.Add(dw1);
  7627. string billtype = GetPostString("billtype");
  7628. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7629. string billstate = GetPostString("billstate");
  7630. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7631. string usershop = CurrentUser.User.pemShop;
  7632. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7633. dStruct.Order = "createTime desc";
  7634. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7635. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7636. //foreach (DataRow dr in dt.Rows)
  7637. //{
  7638. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7639. //}
  7640. writeGridDataTableJson(dStruct.TotalCount, dt);
  7641. }
  7642. public void modify_erp_billinfo()
  7643. {
  7644. if (UrlPostParmsCheck("ID"))
  7645. {
  7646. string eid = GetPostString("ID");
  7647. CeErpBill bill_entity = null;
  7648. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7649. if (bill_entity != null)
  7650. {
  7651. bill_entity.tid = GetPostString("tid");
  7652. bill_entity.title = GetPostString("title");
  7653. bill_entity.tax = GetPostString("tax");
  7654. bill_entity.bank = GetPostString("bank");
  7655. bill_entity.bankac = GetPostString("bankac");
  7656. bill_entity.address = GetPostString("address");
  7657. bill_entity.phone = GetPostString("phone");
  7658. bill_entity.price = GetPostString("price");
  7659. bill_entity.productId = GetPostInt("ProductName");
  7660. bill_entity.num = GetPostInt("num");
  7661. bill_entity.unit = GetPostString("unit");
  7662. bill_entity.type = GetPostString("type");
  7663. bill_entity.sendType = GetPostString("SendType");
  7664. bill_entity.email = GetPostString("email");
  7665. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7666. bill_entity.shopName = GetPostString("ShopName");
  7667. bill_entity.applymemo = GetPostString("applymemo");
  7668. bill_entity.modifyTime = DateTime.Now;
  7669. bill_entity.createTime = DateTime.Now;
  7670. bill_entity.state = 0;
  7671. bill_entity.Update();
  7672. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7673. returnSuccessMsg("发票修改成功!");
  7674. return;
  7675. }
  7676. returnErrorMsg("找不到对应记录");
  7677. }
  7678. }
  7679. public void set_erp_invoicing()
  7680. {
  7681. if (UrlPostParmsCheck("id"))
  7682. {
  7683. try
  7684. {
  7685. string eid = GetPostString("id");
  7686. CeErpBill bill_entity = null;
  7687. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7688. if (bill_entity != null)
  7689. {
  7690. int ComId = GetPostInt("ComId");
  7691. //string memo = GetPostString("Memo");
  7692. int allInfo = GetPostInt("allinfo");
  7693. string clert = CurrentUser.User.Name;
  7694. //string detailValue = GetPostString("detailvalue");
  7695. string billId = bill_entity.billOrderId;
  7696. string[] billIdList = billId.Split(',');
  7697. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7698. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7699. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7700. {
  7701. billCount += 1;
  7702. }
  7703. if (billId.Length <= 0 || billIdList.Length != billCount)
  7704. {
  7705. bill_entity.billOrderId = "";
  7706. string prebill = "ltb";
  7707. for (int idx = 1; idx <= billCount; idx++)
  7708. {
  7709. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7710. string billoid = prebill + idx + dtstr;
  7711. bill_entity.billOrderId += billoid;
  7712. if (idx < billCount)
  7713. {
  7714. bill_entity.billOrderId += ",";
  7715. }
  7716. }
  7717. }
  7718. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7719. if (bill_entity.state == 5)
  7720. {
  7721. string errMsg = bill_entity.failerror;
  7722. string[] errlist = errMsg.Split('|');
  7723. string[] errTags = new string[errlist.Length];
  7724. for (int itag = 0; itag < errlist.Length; itag++)
  7725. {
  7726. if (errlist[itag].Length <= 0) continue;
  7727. errTags[itag] = errlist[itag].Split('&')[0];
  7728. }
  7729. for (int iii = 0; iii < errTags.Length; iii++)
  7730. {
  7731. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7732. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7733. if (billOrderList.Length >= erroBillOrderTag)
  7734. {
  7735. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7736. if (needModifyBillId.Length <= 19)
  7737. {
  7738. needModifyBillId = needModifyBillId + "1";
  7739. }
  7740. else
  7741. {
  7742. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7743. last = last + 1;
  7744. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7745. }
  7746. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7747. }
  7748. }
  7749. }
  7750. bool isHaveBillSucces = false;
  7751. string totalRes = "";
  7752. bill_entity.failerror = "";
  7753. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7754. {
  7755. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7756. totalRes += res;
  7757. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7758. {
  7759. isHaveBillSucces = true;
  7760. bill_entity.comId = ComId;
  7761. bill_entity.state = 1;
  7762. bill_entity.executeTime = DateTime.Now;
  7763. bill_entity.executeUser = clert;
  7764. }
  7765. else
  7766. {
  7767. bill_entity.state = 5;
  7768. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7769. }
  7770. }
  7771. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7772. bill_entity.Update();
  7773. if (isHaveBillSucces)
  7774. {
  7775. StringBuilder sql = new StringBuilder();
  7776. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7777. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7778. }
  7779. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7780. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7781. {
  7782. returnErrorMsg("开票失败");
  7783. }
  7784. else
  7785. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7786. return;
  7787. }
  7788. returnErrorMsg("找不到对应记录");
  7789. }
  7790. catch (Exception ex)
  7791. {
  7792. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7793. returnErrorMsg("操作失败");
  7794. }
  7795. }
  7796. }
  7797. public void get_erp_invoicing_back()
  7798. {
  7799. if (UrlPostParmsCheck("id"))
  7800. {
  7801. try
  7802. {
  7803. string id = GetPostString("id");
  7804. CeErpBill entiy = CeErpBill.Get(id);
  7805. if (entiy != null)
  7806. {
  7807. if (entiy.state == 0)
  7808. {
  7809. returnErrorMsg("发票还未开具");
  7810. return;
  7811. }
  7812. string[] billOrderList = entiy.billOrderId.Split(',');
  7813. int iTag = 0;
  7814. entiy.fplsh = "";
  7815. entiy.fpdm = "";
  7816. entiy.fphm = "";
  7817. foreach (string billOrderId in billOrderList)
  7818. {
  7819. iTag++;
  7820. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7821. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7822. {
  7823. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7824. try
  7825. {
  7826. Invoicing_get_response_Obj iObj = null;
  7827. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7828. if (iObj != null)
  7829. {
  7830. entiy.state = 2;
  7831. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7832. entiy.fpdm += iObj.list[0].c_fpdm;
  7833. entiy.fphm += iObj.list[0].c_fphm;
  7834. if (iTag < billOrderList.Length)
  7835. {
  7836. entiy.fplsh += ",";
  7837. entiy.fpdm += ",";
  7838. entiy.fphm += ",";
  7839. }
  7840. entiy.Update();
  7841. }
  7842. StringBuilder sql = new StringBuilder();
  7843. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7844. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7845. returnSuccessMsg("开票成功");
  7846. }
  7847. catch (Exception ex)
  7848. {
  7849. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7850. }
  7851. return;
  7852. }
  7853. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7854. {
  7855. var res_obj = new
  7856. {
  7857. data = "开票中"
  7858. };
  7859. string ro_json = JsonConvert.SerializeObject(res_obj);
  7860. returnSuccess(ro_json);
  7861. return;
  7862. }
  7863. else
  7864. {
  7865. int eidx = res.IndexOf("c_resultmsg");
  7866. int lidx = res.IndexOf("c_status");
  7867. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7868. entiy.state = 5;
  7869. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7870. entiy.Update();
  7871. returnErrorMsg("开票失败");
  7872. return;
  7873. }
  7874. }
  7875. }
  7876. }
  7877. catch (Exception ex)
  7878. {
  7879. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7880. }
  7881. return;
  7882. }
  7883. }
  7884. public void get_erp_invoicing()
  7885. {
  7886. if (UrlPostParmsCheck("id"))
  7887. {
  7888. try
  7889. {
  7890. string id = GetPostString("id");
  7891. CeErpBill entiy = CeErpBill.Get(id);
  7892. if (entiy != null)
  7893. {
  7894. if (entiy.state == 0)
  7895. {
  7896. returnErrorMsg("发票还未开具");
  7897. return;
  7898. }
  7899. if (entiy.sendType == "纸质发票")
  7900. {
  7901. if (entiy.img.Length <= 0)
  7902. {
  7903. returnErrorMsg("查无纸质发票");
  7904. return;
  7905. }
  7906. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7907. returnSuccess(returnres);
  7908. return;
  7909. }
  7910. string[] billOrderList = entiy.billOrderId.Split(',');
  7911. int iTag = 0;
  7912. string fpUrl = "";
  7913. entiy.fplsh = "";
  7914. entiy.fpdm = "";
  7915. entiy.fphm = "";
  7916. foreach (string billOrderId in billOrderList)
  7917. {
  7918. iTag++;
  7919. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7920. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7921. {
  7922. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7923. Invoicing_get_response_Obj iObj = null;
  7924. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7925. if (iObj != null)
  7926. {
  7927. //entiy.state = 2;
  7928. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7929. entiy.fpdm += iObj.list[0].c_fpdm;
  7930. entiy.fphm += iObj.list[0].c_fphm;
  7931. if (iTag < billOrderList.Length)
  7932. {
  7933. entiy.fplsh += ",";
  7934. entiy.fpdm += ",";
  7935. entiy.fphm += ",";
  7936. }
  7937. entiy.Update();
  7938. fpUrl += iObj.list[0].c_url + ",";
  7939. }
  7940. //returnSuccess(res);
  7941. StringBuilder sql = new StringBuilder();
  7942. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7943. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7944. }
  7945. else
  7946. {
  7947. int eidx = res.IndexOf("c_resultmsg");
  7948. //int lidx = res.IndexOf("c_status");
  7949. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7950. //开票失败
  7951. entiy.state = 5;
  7952. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7953. entiy.Update();
  7954. returnErrorMsg("开票失败");
  7955. return;
  7956. }
  7957. }
  7958. var returnObj = new
  7959. {
  7960. data = fpUrl
  7961. };
  7962. string ro_json = JsonConvert.SerializeObject(returnObj);
  7963. returnSuccess(ro_json);
  7964. }
  7965. }
  7966. catch (Exception ex)
  7967. {
  7968. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7969. }
  7970. return;
  7971. }
  7972. }
  7973. public void save_erp_billimg()
  7974. {
  7975. if (UrlPostParmsCheck("id"))
  7976. {
  7977. string eid = GetPostString("id");
  7978. CeErpBill bill_entity = null;
  7979. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7980. if (bill_entity != null)
  7981. {
  7982. bill_entity.img = GetPostString("img");
  7983. bill_entity.executeTime = DateTime.Now;
  7984. bill_entity.state = 2;
  7985. bill_entity.Update();
  7986. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7987. returnSuccessMsg("保存成功");
  7988. }
  7989. return;
  7990. }
  7991. }
  7992. public void upd_erp_billreturnback()
  7993. {
  7994. if (UrlPostParmsCheck("id"))
  7995. {
  7996. int eid = GetPostInt("id");
  7997. CeErpBill bill_entity = null;
  7998. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7999. if (bill_entity != null)
  8000. {
  8001. bill_entity.state = 3;
  8002. bill_entity.returnReason = GetPostString("reason");
  8003. bill_entity.Update();
  8004. returnSuccessMsg("驳回成功!");
  8005. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8006. }
  8007. return;
  8008. }
  8009. }
  8010. public void cancel_erp_bill()
  8011. {
  8012. if (UrlPostParmsCheck("id"))
  8013. {
  8014. int eid = GetPostInt("id");
  8015. int detailValue = GetPostInt("detailvalue");
  8016. CeErpBill bill_entity = null;
  8017. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8018. string cres = "";
  8019. string gres = "";
  8020. if (bill_entity != null)
  8021. {
  8022. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8023. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8024. {
  8025. int iTag = 0;
  8026. bill_entity.fplsh = "";
  8027. bill_entity.fpdm = "";
  8028. bill_entity.fphm = "";
  8029. foreach (string billOrderId in billOrderList)
  8030. {
  8031. iTag++;
  8032. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8033. if (gres.IndexOf("success") != -1)
  8034. {
  8035. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8036. Invoicing_get_response_Obj iObj = null;
  8037. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8038. if (iObj != null)
  8039. {
  8040. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8041. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8042. bill_entity.fphm += iObj.list[0].c_fphm;
  8043. if (iTag < billOrderList.Length)
  8044. {
  8045. bill_entity.fplsh += ",";
  8046. bill_entity.fpdm += ",";
  8047. bill_entity.fphm += ",";
  8048. }
  8049. bill_entity.Update();
  8050. }
  8051. }
  8052. else
  8053. {
  8054. returnErrorMsg(gres);
  8055. return;
  8056. }
  8057. }
  8058. }
  8059. if (bill_entity.sendType == "纸质发票")
  8060. {
  8061. //作废
  8062. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8063. //if (DateTime.Now.Month == extime.Month)
  8064. //{
  8065. //cres = taobaoHelper.cancel_invoicing(eid);
  8066. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8067. //{
  8068. bill_entity.state = 4;//已作废
  8069. bill_entity.Update();
  8070. returnSuccessMsg("发票已作废");
  8071. return;
  8072. //}
  8073. //else
  8074. //{
  8075. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8076. // bill_entity.Update();
  8077. // returnErrorMsg(cres);
  8078. // return;
  8079. //}
  8080. //}
  8081. //else
  8082. //{
  8083. // returnErrorMsg("纸质发票只能作废本月的发票");
  8084. // return;
  8085. //}
  8086. }
  8087. //红冲
  8088. int redTag = 0;
  8089. string[] fpdmList = bill_entity.fpdm.Split(',');
  8090. string[] fphmList = bill_entity.fphm.Split(',');
  8091. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8092. {
  8093. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8094. return;
  8095. }
  8096. foreach (string billOrderId in billOrderList)
  8097. {
  8098. redTag++;
  8099. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8100. cres += onecres;
  8101. cres += ",";
  8102. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8103. {
  8104. bill_entity.state = 4;//已作废
  8105. //bill_entity.Update();
  8106. //returnSuccessMsg("发票已红冲");
  8107. }
  8108. else if (onecres.IndexOf("重复冲红") != -1)
  8109. {
  8110. bill_entity.state = 4;//已作废
  8111. //bill_entity.Update();
  8112. //returnSuccessMsg("发票已红冲");
  8113. }
  8114. else
  8115. {
  8116. string errmsg = commonHelper.KeepChinese(onecres);
  8117. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8118. }
  8119. }
  8120. bill_entity.Update();
  8121. if (cres.IndexOf("失败") != -1)
  8122. returnErrorMsg("红冲失败");
  8123. else
  8124. returnSuccessMsg("发票已红冲");
  8125. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8126. return;
  8127. }
  8128. return;
  8129. }
  8130. }
  8131. public void del_erp_billorder()
  8132. {
  8133. if (UrlPostParmsCheck("id"))
  8134. {
  8135. string eid = GetPostString("id");
  8136. CeErpBill.Del(eid);
  8137. CeErpBill bill = CeErpBill.Get(eid);
  8138. if (bill != null)
  8139. {
  8140. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8141. }
  8142. returnSuccessMsg("删除成功");
  8143. }
  8144. }
  8145. public void finish_erp_bill()
  8146. {
  8147. if (UrlPostParmsCheck("ids"))
  8148. {
  8149. string eids = GetPostString("ids");
  8150. string[] list = eids.Split(',');
  8151. foreach (string eid in list)
  8152. {
  8153. CeErpBill bill = CeErpBill.Get(eid);
  8154. if (bill != null)
  8155. {
  8156. bill.state = 2;
  8157. bill.Update();
  8158. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8159. }
  8160. }
  8161. returnSuccessMsg("操作成功");
  8162. }
  8163. }
  8164. public void get_erp_returncash()
  8165. {
  8166. DataStruct dStruct = GetPostStruct();
  8167. List<string> lw = new List<string>();
  8168. string tid = GetPostString("tid");
  8169. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8170. string shopname = GetPostString("shopname");
  8171. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8172. string buyernick = GetPostString("buyer_nick");
  8173. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8174. string customer = GetPostString("customer");
  8175. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8176. string returndate1 = GetPostString("returndate1");
  8177. string returndate2 = GetPostString("returndate2");
  8178. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8179. if (dw.Length > 0) lw.Add(dw);
  8180. string finishDate1 = GetPostString("finishdate1");
  8181. string finishDate2 = GetPostString("finishdate2");
  8182. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8183. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8184. string returntype = GetPostString("returntype");
  8185. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8186. string returnvstate = GetPostString("returnvstate");
  8187. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8188. dStruct.Order = "created desc";
  8189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8190. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8191. writeGridDataTableJson(dStruct.TotalCount, dt);
  8192. }
  8193. public void get_erp_staygoods()
  8194. {
  8195. DataStruct dStruct = GetPostStruct();
  8196. List<string> lw = new List<string>();
  8197. string tid = GetPostString("tid");
  8198. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8199. string shopname = GetPostString("shopname");
  8200. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8201. string wangwang = GetPostString("wangwang");
  8202. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8203. string customer = GetPostString("customer");
  8204. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8205. string returndate1 = GetPostString("returndate1");
  8206. string returndate2 = GetPostString("returndate2");
  8207. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8208. if (dw.Length > 0) lw.Add(dw);
  8209. string finishDate1 = GetPostString("finishdate1");
  8210. string finishDate2 = GetPostString("finishdate2");
  8211. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8212. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8213. string returnvstate = GetPostString("returnvstate");
  8214. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8215. string persuadetype = GetPostString("persuadetype");
  8216. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8217. string customerOrg = GetPostString("customerOrg");
  8218. if (customerOrg.Length > 0)
  8219. {
  8220. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8221. }
  8222. dStruct.Order = "creata_time desc";
  8223. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8224. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8225. writeGridDataTableJson(dStruct.TotalCount, dt);
  8226. }
  8227. public void upd_erp_staygoods()
  8228. {
  8229. if (UrlPostParmsCheck("id"))
  8230. {
  8231. int eid = GetPostInt("id");
  8232. CeErpStayGoods entity = null;
  8233. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8234. if (entity != null)
  8235. {
  8236. entity.audit_type = 1;
  8237. entity.audit_time = DateTime.Now;
  8238. entity.audit_u_id = CurrentUser.UserID;
  8239. entity.audit_u_name = CurrentUser.UserName;
  8240. entity.Update();
  8241. returnSuccessMsg("审核成功!");
  8242. return;
  8243. }
  8244. returnErrorMsg("找不到订单记录");
  8245. }
  8246. }
  8247. public void upd_erp_stayGoodsback()
  8248. {
  8249. if (UrlPostParmsCheck("id"))
  8250. {
  8251. int eid = GetPostInt("id");
  8252. CeErpStayGoods entity = null;
  8253. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8254. if (entity != null)
  8255. {
  8256. entity.audit_text = GetPostString("reason");
  8257. entity.audit_type = 2;
  8258. entity.audit_time = DateTime.Now;
  8259. entity.audit_u_id = CurrentUser.UserID;
  8260. entity.audit_u_name = CurrentUser.UserName;
  8261. entity.Update();
  8262. returnSuccessMsg("退回成功!");
  8263. return;
  8264. }
  8265. returnErrorMsg("找不到订单记录");
  8266. }
  8267. }
  8268. public void upd_erp_returncashverify()
  8269. {
  8270. if (UrlPostParmsCheck("ID"))
  8271. {
  8272. int eid = GetPostInt("ID");
  8273. CeErpReturnCash entity = null;
  8274. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8275. if (entity != null)
  8276. {
  8277. entity.cashstate = 1;
  8278. entity.verifytime = DateTime.Now;
  8279. entity.verifyuserid = CurrentUser.UserID;
  8280. entity.Update();
  8281. returnSuccessMsg("审核成功!");
  8282. return;
  8283. }
  8284. returnErrorMsg("找不到订单记录");
  8285. }
  8286. }
  8287. public void upd_all_erp_returncashverify()
  8288. {
  8289. if (UrlPostParmsCheck("ID"))
  8290. {
  8291. String[] list = GetPostString("ID").Split(',');
  8292. CeErpReturnCash entity = null;
  8293. for (int i = 0; i < list.Length; i++)
  8294. {
  8295. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8296. if (entity != null)
  8297. {
  8298. if (entity.cashstate == 1)
  8299. {
  8300. returnErrorMsg("已审核过的订单不需要在审核!");
  8301. return;
  8302. }
  8303. entity.cashstate = 1;
  8304. entity.verifytime = DateTime.Now;
  8305. entity.verifyuserid = CurrentUser.UserID;
  8306. entity.Update();
  8307. }
  8308. }
  8309. returnSuccessMsg("审核成功!");
  8310. return;
  8311. }
  8312. }
  8313. public void upd_erp_returncashback()
  8314. {
  8315. if (UrlPostParmsCheck("ID"))
  8316. {
  8317. int eid = GetPostInt("ID");
  8318. CeErpReturnCash entity = null;
  8319. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8320. if (entity != null)
  8321. {
  8322. entity.backreason = GetPostString("reason");
  8323. entity.cashstate = 2;
  8324. entity.verifytime = DateTime.Now;
  8325. entity.verifyuserid = CurrentUser.UserID;
  8326. entity.Update();
  8327. returnSuccessMsg("退回成功!");
  8328. return;
  8329. }
  8330. returnErrorMsg("找不到订单记录");
  8331. }
  8332. }
  8333. public void upd_erp_returnprice()
  8334. {
  8335. if (UrlPostParmsCheck("ID"))
  8336. {
  8337. int eid = GetPostInt("ID");
  8338. CeErpReturnCash entity = null;
  8339. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8340. if (entity != null)
  8341. {
  8342. if (entity.cashstate == 1)
  8343. {
  8344. returnErrorMsg("审核通过了不能改");
  8345. return;
  8346. }
  8347. entity.returnprice = GetPostDouble("returnprice");
  8348. entity.Update();
  8349. returnSuccessMsg("修改成功!");
  8350. return;
  8351. }
  8352. returnErrorMsg("找不到订单记录");
  8353. }
  8354. }
  8355. public void del_erp_returncash()
  8356. {
  8357. if (UrlPostParmsCheck("ID"))
  8358. {
  8359. int eid = GetPostInt("ID");
  8360. CeErpReturnCash.Del(eid);
  8361. returnSuccessMsg("操作成功");
  8362. return;
  8363. }
  8364. }
  8365. public void test_for_do_sql()
  8366. {
  8367. string sql = GetPostString("sqlstr");
  8368. if (sql.Length > 0)
  8369. {
  8370. try
  8371. {
  8372. DbHelper.DbConn.ExecuteNonQuery(sql);
  8373. var res_obj = new
  8374. {
  8375. data = "成功",
  8376. };
  8377. string ro_json = JsonConvert.SerializeObject(res_obj);
  8378. returnSuccess(ro_json);
  8379. }
  8380. catch (Exception ex)
  8381. {
  8382. var res_obj = new
  8383. {
  8384. data = ex.Message,
  8385. };
  8386. string ro_json = JsonConvert.SerializeObject(res_obj);
  8387. returnSuccess(ro_json);
  8388. }
  8389. }
  8390. }
  8391. public void get_user_info()
  8392. {
  8393. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8394. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8395. }
  8396. public void get_total_data()
  8397. {
  8398. int userId = CurrentUser.UserID;
  8399. string sql = "";
  8400. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8401. {
  8402. 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);
  8403. }
  8404. else
  8405. {
  8406. 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 " +
  8407. "(select ID from CE_ErpUser where ID = {0}) d " +
  8408. "left join " +
  8409. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8410. ") a on d.ID = a.id left join " +
  8411. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8412. ") b on a.id = b.id1 left join" +
  8413. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8414. ") c on a.id = c.id2;", userId);
  8415. }
  8416. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8417. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8418. }
  8419. public void get_date_area_total_data2()
  8420. {
  8421. int userId = CurrentUser.UserID;
  8422. string date_type = GetPostString("timetype");
  8423. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8424. string sql = "";
  8425. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8426. {
  8427. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8428. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8429. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8430. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8431. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8432. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8433. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8434. ") a on e.ID = a.id left join " +
  8435. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8436. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8437. ") b on a.id = b.id1 " +
  8438. "left join " +
  8439. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8440. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8441. ") c on a.id = c.id2 " +
  8442. "left join " +
  8443. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8444. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8445. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8446. }
  8447. else
  8448. {
  8449. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8450. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8451. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8452. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8453. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8454. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8455. ") a on e.ID = a.id left join " +
  8456. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8457. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8458. ") c on a.id = c.id2 " +
  8459. "left join " +
  8460. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8461. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8462. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8463. }
  8464. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8465. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8466. }
  8467. public void get_date_area_total_data()
  8468. {
  8469. int userId = CurrentUser.UserID;
  8470. string date_type = GetPostString("timetype");
  8471. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8472. string date1 = searchDT[0].ToString();
  8473. string date2 = searchDT[1].ToString();
  8474. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8475. {
  8476. SqlParameter[] sqlParameter ={
  8477. new SqlParameter("@userId", SqlDbType.Int,4),
  8478. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8479. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8480. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8481. };
  8482. sqlParameter[0].Value = userId;
  8483. sqlParameter[1].Value = date1;
  8484. sqlParameter[2].Value = date2;
  8485. sqlParameter[3].Direction = ParameterDirection.Output;
  8486. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8487. string res = sqlParameter[3].Value.ToString();
  8488. var res_obj = new
  8489. {
  8490. data = res
  8491. };
  8492. string ro_json = JsonConvert.SerializeObject(res_obj);
  8493. returnSuccess(ro_json);
  8494. }
  8495. else
  8496. {
  8497. SqlParameter[] sqlParameter ={
  8498. new SqlParameter("@userId", SqlDbType.Int,4),
  8499. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8500. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8501. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8502. };
  8503. sqlParameter[0].Value = userId;
  8504. sqlParameter[1].Value = date1;
  8505. sqlParameter[2].Value = date2;
  8506. sqlParameter[3].Direction = ParameterDirection.Output;
  8507. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8508. string res = sqlParameter[3].Value.ToString();
  8509. var res_obj = new
  8510. {
  8511. data = res
  8512. };
  8513. string ro_json = JsonConvert.SerializeObject(res_obj);
  8514. returnSuccess(ro_json);
  8515. }
  8516. //writeGridDataViewJson(dt.Rows.Count, dv);
  8517. }
  8518. public void get_order_list()
  8519. {
  8520. string strFields = GetPostString("paraFields");
  8521. string strOrder = GetPostString("paraOrder");
  8522. string strWhere = GetPostString("paraWhere");
  8523. string strPageSize = GetPostString("paraPageSize");
  8524. DataStruct dStruct = GetPostStruct();
  8525. dStruct.PageSize = int.Parse(strPageSize);
  8526. dStruct.Fileds = strFields;
  8527. dStruct.Order = strOrder;
  8528. dStruct.MainWhere = strWhere;
  8529. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8530. writeGridDataTableJson(dStruct.TotalCount, dt);
  8531. }
  8532. ////获取待开始订单列表
  8533. //public void get_wait_design_order_list()
  8534. //{
  8535. // string date_type = GetPostString("date_type");
  8536. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8537. // DataStruct dStruct = GetPostStruct();
  8538. // dStruct.PageSize = 1000;
  8539. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8540. // List<string> lw = new List<string>();
  8541. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8542. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8543. // dStruct.Order = "WaitDesignTime asc";
  8544. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8545. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8546. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8547. //}
  8548. //获取完成单量排名
  8549. public void get_finish_order_count_ranking()
  8550. {
  8551. /* string date_type = GetPostString("date_type");
  8552. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8553. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8554. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8555. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8556. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8557. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8558. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8559. writeGridDataTableJson(0, new DataTable());
  8560. }
  8561. public void get_finish_order_amount_ranking()
  8562. {
  8563. /*string date_type = GetPostString("date_type");
  8564. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8565. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8566. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8567. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8568. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8569. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8570. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8571. writeGridDataTableJson(0, new DataTable());
  8572. }
  8573. public void get_finish_refund_count_ranking()
  8574. {
  8575. string date_type = GetPostString("date_type");
  8576. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8577. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8578. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8579. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8580. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8581. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8582. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8583. writeGridDataTableJson(dt.Rows.Count, dt);
  8584. }
  8585. public void get_finish_refund_amount_ranking()
  8586. {
  8587. string date_type = GetPostString("date_type");
  8588. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8589. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8590. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8591. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8592. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8593. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8594. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8595. writeGridDataTableJson(dt.Rows.Count, dt);
  8596. }
  8597. public void set_erp_finishorder_director()
  8598. {
  8599. if (UrlPostParmsCheck("ctid"))
  8600. {
  8601. string eid = GetPostString("ctid");
  8602. CeErpTradeCell entity = null;
  8603. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8604. if (entity != null)
  8605. {
  8606. entity.OrderState = 8;
  8607. entity.Update();
  8608. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8609. returnSuccessMsg("操作成功!");
  8610. return;
  8611. }
  8612. returnErrorMsg("找不到记录");
  8613. }
  8614. }
  8615. public void get_erp_placeregistlist()
  8616. {
  8617. DataStruct dStruct = GetPostStruct();
  8618. List<string> lw = new List<string>();
  8619. string outsid = GetPostString("outsid");
  8620. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8621. string memo = GetPostString("memo");
  8622. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8623. string filename = GetPostString("filename");
  8624. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8625. string islate = GetPostString("islate");
  8626. if (islate.Length > 0)
  8627. {
  8628. if (islate == "1")
  8629. lw.Add(string.Format("OutLate>0"));
  8630. else
  8631. lw.Add(string.Format("OutLate=0"));
  8632. }
  8633. string placedate1 = GetPostString("placedate1");
  8634. string placedate2 = GetPostString("placedate2");
  8635. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8636. if (dw.Length > 0) lw.Add(dw);
  8637. string deliveryDate1 = GetPostString("deliverydate1");
  8638. string deliveryDate2 = GetPostString("deliverydate2");
  8639. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8640. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8641. dStruct.Order = "ID desc";
  8642. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8643. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8644. writeGridDataTableJson(dStruct.TotalCount, dt);
  8645. }
  8646. public void ins_erp_placeregist()
  8647. {
  8648. if (UrlPostParmsCheck("id"))
  8649. {
  8650. string eid = GetPostString("id");
  8651. CeErpPlaceRegister entity = null;
  8652. if (eid == "0")//新增
  8653. {
  8654. entity = new CeErpPlaceRegister();
  8655. string xdTime = GetPostString("placeTime");
  8656. if (xdTime.Length > 0)
  8657. {
  8658. entity.PlactTime = Convert.ToDateTime(xdTime);
  8659. }
  8660. string fhTime = GetPostString("deliveryTime");
  8661. if (fhTime.Length > 0)
  8662. {
  8663. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8664. }
  8665. string preTime = GetPostString("preOutTime");
  8666. if (preTime.Length > 0)
  8667. {
  8668. entity.PreOutTime = Convert.ToDateTime(preTime);
  8669. }
  8670. entity.DeliveryCount = GetPostInt("deliveryCount");
  8671. entity.ReceiveCount = GetPostInt("receiveCount");
  8672. entity.OutSid = GetPostString("outSid");
  8673. entity.FileName = GetPostString("fileName");
  8674. entity.Memo = GetPostString("memo");
  8675. entity.AddUserId = CurrentUser.UserID;
  8676. entity.CreateTime = DateTime.Now;
  8677. entity.Img = GetPostString("img");
  8678. entity.Supplier = GetPostInt("supplier");
  8679. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8680. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8681. {
  8682. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8683. DateTime dt2 = (DateTime)entity.PreOutTime;
  8684. TimeSpan span = dt1.Subtract(dt2);
  8685. if (span.Days > 0)
  8686. {
  8687. entity.OutLate = span.Days;
  8688. }
  8689. }
  8690. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8691. entity.Create();
  8692. returnSuccessMsg("添加成功!");
  8693. return;
  8694. }
  8695. else //修改
  8696. {
  8697. entity = CeErpPlaceRegister.Get(eid);
  8698. if (entity != null)
  8699. {
  8700. string xdTime = GetPostString("placeTime");
  8701. if (xdTime.Length > 0)
  8702. {
  8703. entity.PlactTime = Convert.ToDateTime(xdTime);
  8704. }
  8705. string fhTime = GetPostString("deliveryTime");
  8706. if (fhTime.Length > 0)
  8707. {
  8708. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8709. }
  8710. string preTime = GetPostString("preOutTime");
  8711. if (preTime.Length > 0)
  8712. {
  8713. entity.PreOutTime = Convert.ToDateTime(preTime);
  8714. }
  8715. entity.DeliveryCount = GetPostInt("deliveryCount");
  8716. entity.ReceiveCount = GetPostInt("receiveCount");
  8717. if (entity.DeliveryCount == entity.ReceiveCount)
  8718. {
  8719. entity.CurState = "已完成";
  8720. }
  8721. else
  8722. {
  8723. entity.CurState = "未完成";
  8724. }
  8725. entity.OutSid = GetPostString("outSid");
  8726. entity.FileName = GetPostString("fileName");
  8727. entity.Memo = GetPostString("memo");
  8728. entity.Img = GetPostString("img");
  8729. entity.Supplier = GetPostInt("supplier");
  8730. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8731. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8732. {
  8733. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8734. DateTime dt2 = (DateTime)entity.PreOutTime;
  8735. TimeSpan span = dt1.Subtract(dt2);
  8736. if (span.Days > 0)
  8737. {
  8738. entity.OutLate = span.Days;
  8739. }
  8740. }
  8741. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8742. entity.Update();
  8743. returnSuccessMsg("修改成功");
  8744. return;
  8745. }
  8746. returnErrorMsg("找不到对应的记录");
  8747. return;
  8748. }
  8749. }
  8750. returnErrorMsg("缺少必要参数");
  8751. }
  8752. public void del_erp_placeregist()
  8753. {
  8754. string eid = GetPostString("id");
  8755. CeErpPlaceRegister.Del(eid);
  8756. returnSuccessMsg("删除成功!");
  8757. return;
  8758. }
  8759. public void ins_erp_placeregistbyorder()
  8760. {
  8761. string ctid = GetPostString("ctid");
  8762. if (ctid.Length > 0)
  8763. {
  8764. StringBuilder sql = new StringBuilder();
  8765. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8766. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8767. if (dt.Rows.Count > 0)
  8768. {
  8769. foreach (DataRow dr in dt.Rows)
  8770. {
  8771. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8772. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8773. entity.AddUserId = CurrentUser.UserID;
  8774. entity.tid = dr["tid"].ToString();
  8775. entity.Did = Convert.ToString(dr["ctid"]);
  8776. entity.splitTag = dr["SplitTag"].ToString();
  8777. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8778. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8779. if (pre_ctid.Length > 0)
  8780. {
  8781. sellmemo = sellmemo.Replace(pre_ctid, "");
  8782. }
  8783. sellmemo = sellmemo.Replace("[", "");
  8784. sellmemo = sellmemo.Replace("]", "");
  8785. entity.FileName = sellmemo;
  8786. string count = dr["ProductCount"].ToString();
  8787. int usecount = commonHelper.getIntCountFromString(count);
  8788. entity.DeliveryCount = usecount;
  8789. entity.CurState = "未完成";
  8790. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8791. {
  8792. entity.Supplier = 24;//dl手提袋定制
  8793. }
  8794. else
  8795. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8796. entity.CreateTime = DateTime.Now;
  8797. entity.Create();
  8798. }
  8799. returnSuccessMsg("操作成功");
  8800. return;
  8801. }
  8802. returnErrorMsg("没有找到对应订单");
  8803. return;
  8804. }
  8805. returnErrorMsg("缺少订单编号");
  8806. return;
  8807. }
  8808. public void get_erp_persuadelist()
  8809. {
  8810. DataStruct dStruct = GetPostStruct();
  8811. List<string> lw = new List<string>();
  8812. string ctid = GetPostString("ctid");
  8813. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8814. string shopname = GetPostString("shopname");
  8815. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8816. string buyernick = GetPostString("buyer_nick");
  8817. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8818. string customer = GetPostString("customer");
  8819. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8820. string returndate1 = GetPostString("returndate1");
  8821. string returndate2 = GetPostString("returndate2");
  8822. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8823. if (dw.Length > 0) lw.Add(dw);
  8824. string finishDate1 = GetPostString("finishdate1");
  8825. string finishDate2 = GetPostString("finishdate2");
  8826. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8827. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8828. string persuadetype = GetPostString("persuadetype");
  8829. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8830. string returnvstate = GetPostString("returnvstate");
  8831. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8832. dStruct.Order = "created desc";
  8833. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8834. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8835. writeGridDataTableJson(dStruct.TotalCount, dt);
  8836. }
  8837. public void upd_erp_returnpersuadeback()
  8838. {
  8839. if (UrlPostParmsCheck("ID"))
  8840. {
  8841. int eid = GetPostInt("ID");
  8842. CeErpPersuade entity = null;
  8843. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8844. if (entity != null)
  8845. {
  8846. entity.backreason = GetPostString("reason");
  8847. entity.pstate = 2;
  8848. entity.verifytime = DateTime.Now;
  8849. entity.verifyuserid = CurrentUser.UserID;
  8850. entity.Update();
  8851. returnSuccessMsg("退回成功!");
  8852. return;
  8853. }
  8854. returnErrorMsg("找不到订单记录");
  8855. }
  8856. }
  8857. public void upd_erp_returnpersuadeverify()
  8858. {
  8859. if (UrlPostParmsCheck("ID"))
  8860. {
  8861. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8862. {
  8863. returnErrorMsg("暂无权限审核");
  8864. return;
  8865. }
  8866. int eid = GetPostInt("ID");
  8867. CeErpPersuade entity = null;
  8868. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8869. if (entity != null)
  8870. {
  8871. entity.pstate = 1;
  8872. entity.verifytime = DateTime.Now;
  8873. entity.verifyuserid = CurrentUser.UserID;
  8874. entity.Update();
  8875. returnSuccessMsg("审核成功!");
  8876. return;
  8877. }
  8878. returnErrorMsg("找不到订单记录");
  8879. }
  8880. }
  8881. public void del_erp_persuade()
  8882. {
  8883. if (UrlPostParmsCheck("ID"))
  8884. {
  8885. int eid = GetPostInt("ID");
  8886. CeErpPersuade.Del(eid);
  8887. returnSuccessMsg("操作成功");
  8888. return;
  8889. }
  8890. }
  8891. public void get_erp_oldcustoupload()
  8892. {
  8893. DataStruct dStruct = GetPostStruct();
  8894. List<string> lw = new List<string>();
  8895. string buyernick = GetPostString("buyer_nick");
  8896. if (buyernick.Length > 0)
  8897. {
  8898. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8899. }
  8900. else
  8901. return;
  8902. dStruct.Order = "pay_time desc";
  8903. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8904. DataTable dt = null;
  8905. dt = WebCache.GetData("view_erptradecell", dStruct);
  8906. writeGridDataTableJson(dStruct.TotalCount, dt);
  8907. }
  8908. public void get_erp_checkorderlist()
  8909. {
  8910. DataStruct dStruct = GetPostStruct();
  8911. List<string> lw = new List<string>();
  8912. string tid = GetPostString("ctid");
  8913. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8914. string shopname = GetPostString("shopname");
  8915. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8916. string buyernick = GetPostString("buyer_nick");
  8917. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8918. string customer = GetPostString("customer");
  8919. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8920. string design = GetPostString("design");
  8921. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8922. string orderState = GetPostString("orderState");
  8923. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8924. string address = GetPostString("address");
  8925. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8926. string sellermemo = GetPostString("seller_memo");
  8927. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8928. string supplier = GetPostString("supplier");
  8929. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8930. {
  8931. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8932. }
  8933. else
  8934. {
  8935. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8936. }
  8937. string date1 = GetPostString("date1");
  8938. string date2 = GetPostString("date2");
  8939. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8940. if (dw.Length > 0) lw.Add(dw);
  8941. string placedate1 = GetPostString("placedate1");
  8942. string placedate2 = GetPostString("placedate2");
  8943. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8944. if (fdw.Length > 0) lw.Add(fdw);
  8945. string price1 = GetPostString("price1");
  8946. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8947. string price2 = GetPostString("price2");
  8948. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8949. string checkst = GetPostString("checkstate");
  8950. if (checkst.Length > 0 && "10".Equals(checkst))
  8951. {
  8952. lw.Add(string.Format("CheckOut>0"));
  8953. }
  8954. else
  8955. {
  8956. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8957. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8958. }
  8959. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8960. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8961. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8962. writeGridDataTableJson(dStruct.TotalCount, dt);
  8963. }
  8964. public void ins_erp_startCheck()
  8965. {
  8966. if (UrlPostParmsCheck("ctid"))
  8967. {
  8968. string eid = GetPostString("ctid");
  8969. CeErpTradeCell entity = null;
  8970. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8971. if (entity != null)
  8972. {
  8973. entity.MemoOpt = 4;
  8974. entity.Update();
  8975. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8976. CeErpSukuraData.createInfo(entity.ctid, 6);
  8977. returnSuccessMsg("操作成功!");
  8978. return;
  8979. }
  8980. returnErrorMsg("找不到记录");
  8981. }
  8982. }
  8983. public void upd_erp_sendXlw()
  8984. {
  8985. if (UrlPostParmsCheck("ctid"))
  8986. {
  8987. string eid = GetPostString("ctid");
  8988. CeErpTradeCell entity = null;
  8989. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8990. if (entity != null)
  8991. {
  8992. if (entity.IsSendGift == 1)
  8993. {
  8994. returnErrorMsg("请勿重复标记");
  8995. return;
  8996. }
  8997. entity.IsSendGift = 1;
  8998. entity.Update();
  8999. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9000. returnSuccessMsg("操作成功!");
  9001. return;
  9002. }
  9003. returnErrorMsg("找不到记录");
  9004. }
  9005. }
  9006. public void cancel_sendXlw()
  9007. {
  9008. if (UrlPostParmsCheck("ctid"))
  9009. {
  9010. string eid = GetPostString("ctid");
  9011. CeErpTradeCell entity = null;
  9012. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9013. if (entity != null)
  9014. {
  9015. if (entity.IsSendGift == 0)
  9016. {
  9017. returnErrorMsg("未标记小礼物");
  9018. return;
  9019. }
  9020. entity.IsSendGift = 0;
  9021. entity.Update();
  9022. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9023. returnSuccessMsg("操作成功!");
  9024. return;
  9025. }
  9026. returnErrorMsg("找不到记录");
  9027. }
  9028. }
  9029. public void get_erp_designbill()
  9030. {
  9031. DataStruct dStruct = GetPostStruct();
  9032. List<string> lw = new List<string>();
  9033. int isMy = GetInt("my");
  9034. if (isMy == 1)
  9035. {
  9036. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9037. }
  9038. string tid = GetPostString("tid");
  9039. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9040. string userName = GetPostString("design");
  9041. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9042. string price1 = GetPostString("price1");
  9043. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9044. string price2 = GetPostString("price2");
  9045. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9046. string rePrice1 = GetPostString("rePrice1");
  9047. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9048. string rePrice2 = GetPostString("rePrice2");
  9049. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9050. string designerType = GetPostString("designerType");
  9051. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9052. string orderState = GetPostString("orderState");
  9053. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9054. string endTime1 = GetPostString("endTime1");
  9055. string endTime2 = GetPostString("endTime2");
  9056. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9057. if (dw.Length > 0) lw.Add(dw);
  9058. string isDk = GetPostString("isDk");
  9059. if (isDk == "1")
  9060. {
  9061. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9062. }
  9063. else if (isDk == "0")
  9064. {
  9065. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9066. }
  9067. dStruct.Order = "oid, create_time desc";
  9068. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9069. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9070. writeGridDataTableJson(dStruct.TotalCount, dt);
  9071. }
  9072. public void upd_erp_designerbill()
  9073. {
  9074. if (UrlPostParmsCheck("ID"))
  9075. {
  9076. string eid = GetPostString("ID");
  9077. CeErpDesignerBill entity = null;
  9078. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9079. if (entity != null)
  9080. {
  9081. if (GetPostDouble("designerpirce") > 0)
  9082. {
  9083. entity.realPrice = GetPostDouble("designerpirce");
  9084. entity.update_time = DateTime.Now;
  9085. entity.update_u_id = CurrentUser.UserID;
  9086. entity.update_u_name = CurrentUser.UserName;
  9087. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9088. entity.Update();
  9089. returnSuccessMsg("操作成功!");
  9090. return;
  9091. }
  9092. else
  9093. {
  9094. entity.price = GetPostDouble("price");
  9095. entity.update_time = DateTime.Now;
  9096. entity.update_u_id = CurrentUser.UserID;
  9097. entity.update_u_name = CurrentUser.UserName;
  9098. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9099. entity.Update();
  9100. returnSuccessMsg("操作成功!");
  9101. return;
  9102. }
  9103. }
  9104. returnErrorMsg("找不到记录");
  9105. }
  9106. }
  9107. public void audit_erp_designerbill()
  9108. {
  9109. if (UrlPostParmsCheck("ID"))
  9110. {
  9111. string eid = GetPostString("ID");
  9112. CeErpDesignerBill entity = null;
  9113. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9114. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9115. if (entity != null)
  9116. {
  9117. entity.realPrice = GetPostDouble("designerpirce");
  9118. entity.update_time = DateTime.Now;
  9119. entity.update_u_id = CurrentUser.UserID;
  9120. entity.update_u_name = CurrentUser.UserName;
  9121. entity.isAudit = 1;
  9122. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9123. entity.Update();
  9124. if (orderEntity != null)
  9125. {
  9126. orderEntity.IsReadTag = 3;
  9127. orderEntity.Update();
  9128. }
  9129. returnSuccessMsg("操作成功!");
  9130. return;
  9131. }
  9132. returnErrorMsg("找不到记录");
  9133. }
  9134. }
  9135. public void all_audit_erp_designerbill()
  9136. {
  9137. if (UrlPostParmsCheck("idList"))
  9138. {
  9139. string[] list = GetPostString("idList").Split(',');
  9140. CeErpDesignerBill entity = null;
  9141. for (int i = 0; i < list.Length; i++)
  9142. {
  9143. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9144. if (entity == null) return;
  9145. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9146. if (orderEntity == null) return;
  9147. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9148. entity.update_time = DateTime.Now;
  9149. entity.update_u_id = CurrentUser.UserID;
  9150. entity.update_u_name = CurrentUser.UserName;
  9151. entity.isAudit = 1;
  9152. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9153. entity.Update();
  9154. orderEntity.IsReadTag = 3;
  9155. orderEntity.Update();
  9156. }
  9157. returnSuccessMsg("操作成功!");
  9158. return;
  9159. }
  9160. }
  9161. public void get_erp_sameorders()
  9162. {
  9163. if (UrlPostParmsCheck("ctid"))
  9164. {
  9165. string eid = GetPostString("ctid");
  9166. CeErpTradeCell entity = null;
  9167. entity = CeErpTradeCell.GetByCtid(eid);
  9168. if (entity != null)
  9169. {
  9170. StringBuilder sql = new StringBuilder();
  9171. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9172. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9173. var res = new
  9174. {
  9175. data = dt.Rows.Count
  9176. };
  9177. string ro_jsond = JsonConvert.SerializeObject(res);
  9178. returnSuccess(ro_jsond);
  9179. return;
  9180. }
  9181. returnErrorMsg("未找到订单");
  9182. return;
  9183. }
  9184. returnErrorMsg("缺少必要的参数");
  9185. }
  9186. public void get_erp_islasthavesameorder()
  9187. {
  9188. if (UrlPostParmsCheck("ctid"))
  9189. {
  9190. string eid = GetPostString("ctid");
  9191. string[] ctidList = eid.Split(',');
  9192. StringBuilder sql = new StringBuilder();
  9193. string tisCtid = "";
  9194. foreach (string ctid in ctidList)
  9195. {
  9196. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9197. if (entity != null)
  9198. {
  9199. sql = new StringBuilder();
  9200. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9201. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9202. if (dth.Rows.Count > 0)
  9203. {
  9204. tisCtid += entity.ctid;
  9205. tisCtid += ",";
  9206. }
  9207. }
  9208. }
  9209. if (tisCtid.Length > 0)
  9210. {
  9211. var res = new
  9212. {
  9213. data = tisCtid
  9214. };
  9215. string ro_jsond = JsonConvert.SerializeObject(res);
  9216. returnSuccess(ro_jsond);
  9217. }
  9218. else
  9219. {
  9220. var res = new
  9221. {
  9222. data = ""
  9223. };
  9224. string ro_jsond = JsonConvert.SerializeObject(res);
  9225. returnSuccess(ro_jsond);
  9226. }
  9227. return;
  9228. }
  9229. returnErrorMsg("缺少必要的参数");
  9230. }
  9231. public void file_client_down_url()
  9232. {
  9233. if (!UrlPostParmsCheck("userId"))
  9234. {
  9235. returnErrorMsg("缺少必要的参数");
  9236. }
  9237. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9238. }
  9239. public void checkout_form_data()
  9240. {
  9241. if (!UrlPostParmsCheck("tid"))
  9242. {
  9243. returnErrorMsg("缺少必要的参数");
  9244. }
  9245. string tid = GetPostString("tid");
  9246. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9247. if (ceErpOrderFormData != null)
  9248. {
  9249. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9250. returnSuccess(ro_jsond);
  9251. return;
  9252. }
  9253. returnErrorMsg("尚未有文件!");
  9254. }
  9255. public void back_supplier_audit()
  9256. {
  9257. int userId = CurrentUser.UserID;
  9258. StringBuilder sql = new StringBuilder();
  9259. 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);
  9260. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9261. if (dt.Rows.Count > 0)
  9262. {
  9263. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9264. }
  9265. else
  9266. {
  9267. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9268. }
  9269. }
  9270. public void back_supplier_query()
  9271. {
  9272. string eid = GetPostString("ctid");
  9273. if (eid != "")
  9274. {
  9275. StringBuilder sql = new StringBuilder();
  9276. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9277. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9278. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9279. }
  9280. else
  9281. {
  9282. returnErrorMsg("找不到订单记录");
  9283. return;
  9284. }
  9285. }
  9286. public void verified_to_order()
  9287. {
  9288. int userId = CurrentUser.UserID;
  9289. StringBuilder sql = new StringBuilder();
  9290. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9291. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9292. if (dt.Rows.Count > 0)
  9293. {
  9294. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9295. }
  9296. else
  9297. {
  9298. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9299. }
  9300. }
  9301. public void upd_supplier_audit()
  9302. {
  9303. if (UrlPostParmsCheck("ctid"))
  9304. {
  9305. string eid = GetPostString("ctid");
  9306. string reason = GetPostString("returnreason");
  9307. CeErpTradeCell entity = null;
  9308. CeWithdraw withdraw = null;
  9309. withdraw = CeWithdraw.GetByTid(eid);
  9310. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9311. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9312. {
  9313. if (withdraw != null)
  9314. {
  9315. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9316. {
  9317. returnSuccessMsg("您没有权限操作!");
  9318. return;
  9319. }
  9320. else
  9321. {
  9322. if (reason.Equals("1"))
  9323. {
  9324. if (entity.OrderState == -1)
  9325. {
  9326. if (entity.FinishPlaceTime == null)
  9327. {
  9328. entity.OrderState = 2;
  9329. }
  9330. else
  9331. {
  9332. entity.OrderState = 6;
  9333. }
  9334. }
  9335. entity.Update();
  9336. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9337. if (withdraw != null)
  9338. {
  9339. withdraw.status = int.Parse(reason);
  9340. withdraw.Update();
  9341. }
  9342. returnSuccessMsg("操作成功!");
  9343. return;
  9344. }
  9345. else
  9346. {
  9347. withdraw.status = int.Parse(reason);
  9348. withdraw.acknowledgingtime = DateTime.Now;
  9349. withdraw.Update();
  9350. returnSuccessMsg("查看详细请点击线下订单查询");
  9351. return;
  9352. }
  9353. }
  9354. }
  9355. // 第一个字符是 'N'
  9356. }
  9357. if (eid[0] != 'N')
  9358. {
  9359. }
  9360. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9361. {
  9362. entity.IsVerifyToSupplier = false;
  9363. entity.IsReturn = 1;
  9364. entity.ReturnTime = DateTime.Now;
  9365. entity.ReturnReason = reason;
  9366. if (entity.OrderState == 6)
  9367. {
  9368. entity.OrderState = 5;
  9369. }
  9370. entity.Update();
  9371. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9372. if (withdraw != null)
  9373. {
  9374. withdraw.status = int.Parse(reason);
  9375. withdraw.Update();
  9376. }
  9377. returnSuccessMsg("操作成功!");
  9378. return;
  9379. }
  9380. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9381. {
  9382. ;
  9383. if (withdraw != null)
  9384. {
  9385. withdraw.status = int.Parse(reason);
  9386. withdraw.acknowledgingtime = DateTime.Now;
  9387. withdraw.Update();
  9388. returnSuccessMsg("供应商取消撤回!");
  9389. return;
  9390. }
  9391. }
  9392. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9393. {
  9394. if (entity.OrderState == -1)
  9395. {
  9396. if (entity.FinishPlaceTime == null)
  9397. {
  9398. entity.OrderState = 2;
  9399. }
  9400. else
  9401. {
  9402. entity.OrderState = 3;
  9403. }
  9404. commonHelper.getCytPrice(entity);
  9405. }
  9406. entity.Update();
  9407. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9408. if (withdraw != null)
  9409. {
  9410. withdraw.status = int.Parse(reason);
  9411. withdraw.Update();
  9412. }
  9413. returnSuccessMsg("操作成功!");
  9414. return;
  9415. }
  9416. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9417. {
  9418. if (withdraw == null)
  9419. {
  9420. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9421. return;
  9422. }
  9423. }
  9424. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9425. {
  9426. if (withdraw != null)
  9427. {
  9428. withdraw.status = int.Parse(reason);
  9429. withdraw.acknowledgingtime = DateTime.Now;
  9430. withdraw.Update();
  9431. returnSuccessMsg("查看详细请点击线下订单查询");
  9432. return;
  9433. }
  9434. }
  9435. return;
  9436. }
  9437. }
  9438. //校验报价
  9439. public void refund_order_tip()
  9440. {
  9441. int userid = CurrentUser.UserID;
  9442. int sectionId = CurrentUser.UserPost.OrgID;
  9443. StringBuilder sql = new StringBuilder();
  9444. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9445. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9446. List<string> ids = new List<string>();
  9447. if (dth.Rows.Count > 0)
  9448. {
  9449. foreach (DataRow dr in dth.Rows)
  9450. {
  9451. ids.Add(dr["ID"].ToString());
  9452. }
  9453. try
  9454. {
  9455. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9456. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9457. }
  9458. catch (Exception ex)
  9459. {
  9460. }
  9461. }
  9462. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9463. }
  9464. public void refund_order_Design()
  9465. {
  9466. int userid = CurrentUser.UserID;
  9467. int sectionId = CurrentUser.UserPost.OrgID;
  9468. StringBuilder sql = new StringBuilder();
  9469. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9470. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9471. List<string> ids = new List<string>();
  9472. if (dth.Rows.Count > 0)
  9473. {
  9474. foreach (DataRow dr in dth.Rows)
  9475. {
  9476. ids.Add(dr["ID"].ToString());
  9477. }
  9478. try
  9479. {
  9480. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9481. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9482. }
  9483. catch (Exception ex)
  9484. {
  9485. }
  9486. }
  9487. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9488. }
  9489. public void change_order_info()
  9490. {
  9491. int userid = CurrentUser.UserID;
  9492. StringBuilder sql = new StringBuilder();
  9493. 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);
  9494. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9495. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9496. }
  9497. public void change_win_mome()
  9498. {
  9499. if (UrlPostParmsCheck("id,ctid"))
  9500. {
  9501. string id = GetPostString("id");
  9502. string ctid = GetPostString("ctid");
  9503. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9504. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9505. if (ce == null || ceErpMessageTip == null)
  9506. {
  9507. returnSuccessMsg("未找到对应的订单!");
  9508. return;
  9509. }
  9510. int type = GetPostInt("type");
  9511. string content = GetPostString("content");
  9512. if (type == 0)
  9513. {
  9514. content = content.Replace("(", "(");
  9515. content = content.Replace(")", ")");
  9516. string check = MidStrEx(content, "(", ")").Trim();
  9517. if (string.IsNullOrEmpty(check))
  9518. {
  9519. returnSuccessMsg("文件名格式不正确");
  9520. return;
  9521. }
  9522. }
  9523. ce.seller_memo = content;
  9524. ce.Update();
  9525. ceErpMessageTip.isVisit = true;
  9526. ceErpMessageTip.Update();
  9527. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9528. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9529. ApiVo apiVo = new ApiVo();
  9530. apiVo.orderNumber = ce.ctid;
  9531. apiVo.actionName = "demandDesign";
  9532. apiVo.orderRemarks = content;
  9533. apiVo.demandExamine = type + 1;
  9534. designHelper.API_WorkCore(apiVo);//demandDesign
  9535. returnSuccessMsg("修改成功!");
  9536. }
  9537. }
  9538. public static string MidStrEx(string sourse, string startstr, string endstr)
  9539. {
  9540. string result = string.Empty;
  9541. int startindex, endindex;
  9542. try
  9543. {
  9544. startindex = sourse.IndexOf(startstr);
  9545. if (startindex == -1)
  9546. return result;
  9547. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9548. endindex = tmpstr.IndexOf(endstr);
  9549. if (endindex == -1)
  9550. return result;
  9551. result = tmpstr.Remove(endindex);
  9552. }
  9553. catch (Exception ex)
  9554. {
  9555. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9556. }
  9557. return result;
  9558. }
  9559. public void refund_order_list()
  9560. {
  9561. int userid = CurrentUser.UserID;
  9562. int sectionId = CurrentUser.UserPost.OrgID;
  9563. StringBuilder sql = new StringBuilder();
  9564. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9565. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9566. DataStruct dStruct = GetPostStruct();
  9567. DataTable dt = null;
  9568. List<string> ids = new List<string>();
  9569. List<string> tids = new List<string>();
  9570. if (dth.Rows.Count > 0)
  9571. {
  9572. foreach (DataRow dr in dth.Rows)
  9573. {
  9574. tids.Add("'" + dr["tid"].ToString() + "'");
  9575. ids.Add(dr["id"].ToString());
  9576. }
  9577. try
  9578. {
  9579. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9580. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9581. List<string> lw = new List<string>();
  9582. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9583. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9584. dt = WebCache.GetData("view_orderlist", dStruct);
  9585. }
  9586. catch (Exception ex)
  9587. {
  9588. }
  9589. }
  9590. writeGridDataTableJson(dStruct.TotalCount, dt);
  9591. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9592. }
  9593. //新增
  9594. public void order_batch_downloads()
  9595. {
  9596. string ceid = GetPostString("tid");
  9597. String[] tid = ceid.Split(',');
  9598. order_batch_caiyingtong(tid);
  9599. /* (string success, string errors) = UploadFiles(tid);
  9600. returnSuccessMsg(success + errors);*/
  9601. return;
  9602. }
  9603. //报价接口
  9604. public void Get_To_Quote()
  9605. {
  9606. string ceid = GetPostString("ctid");
  9607. if (ceid != null)
  9608. {
  9609. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9610. if (entity != null)
  9611. {
  9612. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9613. {
  9614. return;
  9615. }
  9616. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9617. double price = 0;
  9618. if (cp == null)
  9619. {
  9620. JObject jsonObject12 = new JObject
  9621. {
  9622. { "UserId", "77886" },
  9623. { "Pwd", "lt666888" },
  9624. { "Filename", entity.seller_memo }
  9625. };
  9626. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9627. JObject jsonObjects1 = JObject.Parse(response1);
  9628. string ms1g = (string)jsonObjects1["msg"];
  9629. if (ms1g == "报价成功")
  9630. {
  9631. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9632. string data = (string)jsonObject1["price"];
  9633. 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 + "');";
  9634. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9635. returnSuccessMsg("获取报价成功:" + data);
  9636. price = Convert.ToDouble(data);
  9637. }
  9638. else
  9639. {
  9640. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9641. return;
  9642. }
  9643. }
  9644. String[] beizhu = entity.seller_memo.Split('-');
  9645. String chanp = "";
  9646. if (beizhu.Length > 0)
  9647. {
  9648. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9649. }
  9650. else
  9651. {
  9652. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9653. }
  9654. JObject jsonObject = new JObject
  9655. {
  9656. { "UserId", "77886" },
  9657. { "Pwd", "lt666888" },
  9658. { "Filename", chanp }
  9659. };
  9660. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9661. JObject jsonObjects = JObject.Parse(response);
  9662. string msg = (string)jsonObjects["msg"];
  9663. if (msg == "报价成功")
  9664. {
  9665. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9666. string data = (string)jsonObject1["price"];
  9667. 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 + "');";
  9668. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9669. returnSuccessMsg("获取报价成功:" + data);
  9670. price = Convert.ToDouble(data);
  9671. }
  9672. else
  9673. {
  9674. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9675. return;
  9676. }
  9677. if (price > 0)
  9678. {
  9679. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9680. if (ceErpTradeCellExtend == null)
  9681. {
  9682. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9683. ceErpTradeCellExtend.ctid = entity.ctid;
  9684. ceErpTradeCellExtend.payment_cyt = price;
  9685. ceErpTradeCellExtend.Create();
  9686. }
  9687. else
  9688. {
  9689. ceErpTradeCellExtend.payment_cyt = price;
  9690. ceErpTradeCellExtend.Update();
  9691. }
  9692. }
  9693. return;
  9694. }
  9695. }
  9696. else
  9697. {
  9698. returnErrorMsg("请至少选择一条数据");
  9699. return;
  9700. }
  9701. }
  9702. //新增
  9703. public void order_To_Supplier()
  9704. {
  9705. string ceid = GetPostString("tid");
  9706. String[] tid = ceid.Split(',');
  9707. if (tid.Length > 0)
  9708. {
  9709. try
  9710. {
  9711. for (int i = 0; i < tid.Length; i++)
  9712. {
  9713. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9714. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9715. entity.SupplierId = suid;
  9716. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9717. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9718. entity.Update();
  9719. }
  9720. }
  9721. catch (Exception ex)
  9722. {
  9723. returnErrorMsg("自动匹配供应商失败");
  9724. return;
  9725. }
  9726. }
  9727. else
  9728. {
  9729. returnErrorMsg("请至少选择一条数据");
  9730. return;
  9731. }
  9732. returnSuccessMsg("自动匹配供应商成功");
  9733. return;
  9734. }
  9735. public (string, string) UploadFiles(string[] urls)
  9736. {
  9737. string success = "";
  9738. string errors = "";
  9739. int userid = CurrentUser.UserID;
  9740. foreach (string url in urls)
  9741. {
  9742. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9743. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9744. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9745. {
  9746. JObject jsonObject = new JObject
  9747. {
  9748. { "Userid", "77886" },
  9749. { "pwd", "cyt86435015" },
  9750. { "content", base64FileContent },
  9751. { "ext", Path.GetExtension(fileName) }
  9752. };
  9753. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9754. JObject jsonObjects = JObject.Parse(response);
  9755. string msg = (string)jsonObjects["msg"];
  9756. if (msg.Equals("上传成功"))
  9757. {
  9758. success += url + " 上传成功";
  9759. }
  9760. else
  9761. {
  9762. errors += url + " 上传失败";
  9763. }
  9764. }
  9765. else
  9766. {
  9767. errors += url + " 格式出现问题";
  9768. }
  9769. }
  9770. if (urls.Length == 0)
  9771. {
  9772. return (success, errors);
  9773. }
  9774. return (success, errors);
  9775. }
  9776. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9777. {
  9778. return true; //总是接受
  9779. }
  9780. public static string HttpPost(string url, string param = null)
  9781. {
  9782. HttpWebRequest request;
  9783. //如果是发送HTTPS请求
  9784. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9785. {
  9786. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9787. request = WebRequest.Create(url) as HttpWebRequest;
  9788. request.ProtocolVersion = HttpVersion.Version10;
  9789. }
  9790. else
  9791. {
  9792. request = WebRequest.Create(url) as HttpWebRequest;
  9793. }
  9794. request.Method = "POST";
  9795. request.ContentType = "application/json";
  9796. request.Accept = "*/*";
  9797. request.Timeout = 120000;
  9798. request.AllowAutoRedirect = false;
  9799. StreamWriter requestStream = null;
  9800. WebResponse response = null;
  9801. string responseStr = null;
  9802. try
  9803. {
  9804. requestStream = new StreamWriter(request.GetRequestStream());
  9805. requestStream.Write(param);
  9806. requestStream.Close();
  9807. response = request.GetResponse();
  9808. if (response != null)
  9809. {
  9810. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9811. responseStr = reader.ReadToEnd();
  9812. reader.Close();
  9813. }
  9814. }
  9815. catch (Exception ex)
  9816. {
  9817. return ex.Message;
  9818. }
  9819. finally
  9820. {
  9821. request = null;
  9822. requestStream = null;
  9823. response = null;
  9824. }
  9825. return responseStr;
  9826. }
  9827. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9828. {
  9829. string base64FileContent;
  9830. string fileName;
  9831. using (WebClient webClient = new WebClient())
  9832. {
  9833. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9834. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9835. {
  9836. using (Stream stream = response.GetResponseStream())
  9837. {
  9838. using (MemoryStream memoryStream = new MemoryStream())
  9839. {
  9840. stream.CopyTo(memoryStream);
  9841. byte[] fileBytes = memoryStream.ToArray();
  9842. base64FileContent = Convert.ToBase64String(fileBytes);
  9843. fileName = response.Headers["Content-Disposition"];
  9844. if (!string.IsNullOrEmpty(fileName))
  9845. {
  9846. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9847. if (index >= 0)
  9848. {
  9849. fileName = fileName.Substring(index + 9).Trim('\"');
  9850. }
  9851. }
  9852. else
  9853. {
  9854. fileName = Path.GetFileName(downloadUrl);
  9855. }
  9856. }
  9857. }
  9858. }
  9859. }
  9860. return (fileName, base64FileContent);
  9861. }
  9862. //新增
  9863. public void order_batch_caiyingtong(string[] downloadUrls)
  9864. {
  9865. try
  9866. {
  9867. //遍历文件
  9868. DataStruct dStruct = GetPostStruct();
  9869. DataTable dt = null;
  9870. int userid = CurrentUser.UserID;
  9871. List<string> ids = new List<string>();//失败组
  9872. List<string> tids = new List<string>();
  9873. using (WebClient webClient = new WebClient())
  9874. {
  9875. foreach (var url in downloadUrls)
  9876. {
  9877. try
  9878. {
  9879. tids.Add("'" + url + "'");
  9880. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9881. if (entity != null)
  9882. {
  9883. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9884. if (cp == null)
  9885. {
  9886. JObject jsonObject = new JObject
  9887. {
  9888. { "Userid", "77886" },
  9889. { "pwd", "lt666888" },
  9890. { "Filename",entity.seller_memo }
  9891. };
  9892. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9893. JObject jsonObjects = JObject.Parse(response);
  9894. string msg = (string)jsonObjects["msg"];
  9895. if (msg == "报价成功")
  9896. {
  9897. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9898. DownloadAndConvertToBase64(url1);
  9899. }
  9900. else
  9901. {
  9902. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9903. }
  9904. }
  9905. else
  9906. {
  9907. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9908. JObject jsonObject = new JObject
  9909. {
  9910. { "Userid", "77886" },
  9911. { "pwd", "lt666888" },
  9912. { "Filename",chanp }
  9913. };
  9914. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9915. JObject jsonObjects = JObject.Parse(response);
  9916. string msg = (string)jsonObjects["msg"];
  9917. if (msg == "报价成功")
  9918. {
  9919. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9920. DownloadAndConvertToBase64(url1);
  9921. }
  9922. else
  9923. {
  9924. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9925. }
  9926. }
  9927. }
  9928. // 上传文件到FTP
  9929. }
  9930. catch (Exception ex)
  9931. {
  9932. Console.WriteLine($"An error occurred: {ex.Message}");
  9933. }
  9934. }
  9935. List<string> lw = new List<string>();
  9936. lw.Add(string.Format("( OrderState < 6 )"));
  9937. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9938. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9939. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9940. if (dt.Rows.Count > 0)
  9941. {
  9942. foreach (DataRow dr in dt.Rows)
  9943. {
  9944. ids.Add(dr["ctid"].ToString());
  9945. }
  9946. }
  9947. String ErrorMsgs = "";
  9948. foreach (String id in ids)
  9949. {
  9950. ErrorMsgs += id + ",";
  9951. }
  9952. if (ErrorMsgs.Length > 1)
  9953. {
  9954. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9955. }
  9956. if (ErrorMsgs.Length < 1)
  9957. {
  9958. ErrorMsgs = "上传成功";
  9959. returnSuccessMsg(ErrorMsgs);
  9960. }
  9961. else
  9962. {
  9963. returnErrorMsg("以下订单" + ErrorMsgs);
  9964. }
  9965. }
  9966. // 删除文件夹及其内容
  9967. /* Directory.Delete(localDirectory, true);*/
  9968. }
  9969. catch { }
  9970. }
  9971. public void get_center_data()
  9972. {
  9973. int userId = CurrentUser.UserID;
  9974. string postCode = CurrentUser.UserPost.Post.Code;
  9975. List<string> lw = new List<string>();
  9976. List<string> ww = new List<string>();
  9977. DateTime currentTime = DateTime.Now;
  9978. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9979. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9980. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9981. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9982. string sql = " SELECT ";
  9983. string startTime = "2023-10-01 11:22:31";
  9984. //设计
  9985. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9986. {
  9987. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9988. 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));
  9989. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9990. 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));
  9991. }
  9992. //客服
  9993. else if (postCode == "CustomerService" || postCode == "Director")
  9994. {
  9995. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9996. 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));
  9997. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9998. 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));
  9999. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10000. 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));
  10001. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10002. 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));
  10003. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10004. 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));
  10005. }
  10006. //售后
  10007. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10008. {
  10009. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10010. 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));
  10011. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10012. 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));
  10013. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10014. 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));
  10015. }
  10016. //下单部
  10017. else if (postCode == "Place" || postCode == "PlaceMr")
  10018. {
  10019. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10020. 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));
  10021. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10022. 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));
  10023. }
  10024. //车间
  10025. else if (postCode == "Supplier")
  10026. {
  10027. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10028. 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));
  10029. }
  10030. DataTable dt = new DataTable();
  10031. if (lw.Count > 0)
  10032. {
  10033. sql += string.Join(" , ", lw);
  10034. sql += " FROM ";
  10035. sql += string.Join(" , ", ww);
  10036. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10037. }
  10038. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10039. }
  10040. public void get_center_data_list()
  10041. {
  10042. int userId = CurrentUser.UserID;
  10043. string postCode = CurrentUser.UserPost.Post.Code;
  10044. string shopIds = CurrentUser.User.pemShop;
  10045. DataStruct dStruct = GetPostStruct();
  10046. List<string> lw = new List<string>();
  10047. DateTime currentTime = DateTime.Now;
  10048. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10049. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10050. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10051. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10052. string startTime = "2023-10-01 11:22:31";
  10053. int order_type = GetPostInt("order_type");
  10054. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10055. {
  10056. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10057. if (order_type == 0)
  10058. {
  10059. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10060. }
  10061. else if (order_type == 3)
  10062. {
  10063. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10064. }
  10065. else
  10066. {
  10067. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10068. }
  10069. }
  10070. //客服
  10071. if (postCode == "CustomerService" || postCode == "Director")
  10072. {
  10073. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10074. if (order_type == 0)
  10075. {
  10076. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10077. }
  10078. else if (order_type == 1)
  10079. {
  10080. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10081. }
  10082. else if (order_type == 2)
  10083. {
  10084. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10085. }
  10086. else if (order_type == 3)
  10087. {
  10088. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10089. }
  10090. else if (order_type == 4)
  10091. {
  10092. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10093. }
  10094. else
  10095. {
  10096. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10097. }
  10098. }
  10099. //售后
  10100. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10101. {
  10102. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10103. if (shopIds != "")
  10104. {
  10105. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10106. }
  10107. if (order_type == 2)
  10108. {
  10109. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10110. }
  10111. else if (order_type == 4)
  10112. {
  10113. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10114. }
  10115. else if (order_type == 5)
  10116. {
  10117. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10118. }
  10119. else
  10120. {
  10121. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10122. }
  10123. }
  10124. //下单部
  10125. if (postCode == "Place" || postCode == "PlaceMr")
  10126. {
  10127. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10128. if (shopIds != "")
  10129. {
  10130. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10131. }
  10132. else if (order_type == 1)
  10133. {
  10134. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10135. }
  10136. else if (order_type == 2)
  10137. {
  10138. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10139. }
  10140. else
  10141. {
  10142. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10143. }
  10144. }
  10145. //车间
  10146. if (postCode == "Supplier")
  10147. {
  10148. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10149. if (order_type == 5)
  10150. {
  10151. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10152. }
  10153. else
  10154. {
  10155. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10156. }
  10157. }
  10158. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10159. dStruct.Fileds = "tid,ctid";
  10160. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10161. writeGridDataTableJson(dStruct.TotalCount, dt);
  10162. }
  10163. public void aftersale_audit_master()
  10164. {
  10165. if (UrlPostParmsCheck("ctid"))
  10166. {
  10167. string ctid = GetPostString("ctid");
  10168. if (ctid.Length > 0)
  10169. {
  10170. bool result = aftersale_data_change(ctid);
  10171. if (result)
  10172. {
  10173. returnSuccessMsg("修改成功!");
  10174. return;
  10175. }
  10176. }
  10177. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10178. }
  10179. }
  10180. public void aftersale_batch_audit_master()
  10181. {
  10182. if (UrlPostParmsCheck("ctids"))
  10183. {
  10184. string ctids = GetPostString("ctids");
  10185. if (ctids.Length > 0)
  10186. {
  10187. List<string> list = new List<string>();
  10188. string[] ctid_list = ctids.Split(',');
  10189. foreach (var item in ctid_list)
  10190. {
  10191. bool result = aftersale_data_change(item);
  10192. if (!result)
  10193. {
  10194. list.Add(item);
  10195. }
  10196. }
  10197. if (list.Count > 0)
  10198. {
  10199. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10200. return;
  10201. }
  10202. returnSuccessMsg("修改成功!");
  10203. return;
  10204. }
  10205. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10206. }
  10207. }
  10208. public bool aftersale_data_change(string ctid)
  10209. {
  10210. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10211. if (ceErpTradeCell != null)
  10212. {
  10213. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10214. ceErpTradeCell.AfterSaleSupplierState = 0;
  10215. StringBuilder sql = new StringBuilder();
  10216. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10217. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10218. CeErpTradeResponsible.DelByTid(ctid, 0);
  10219. 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 == "不理赔")
  10220. {
  10221. CeErpTradeResponsible.DelByTid(ctid, 1);
  10222. ceErpTradeCell.AfterSaleSupplierState = 1;
  10223. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10224. ceErpTradeCell.AfterSaleState = 4;
  10225. }
  10226. else
  10227. {
  10228. ceErpTradeCell.AfterSaleState = 3;
  10229. }
  10230. bool needCyt = false;
  10231. if (dt != null)
  10232. {
  10233. if (dt.Rows.Count == 1)
  10234. {
  10235. bool isEnd = false;
  10236. foreach (DataRow dr in dt.Rows)
  10237. {
  10238. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10239. {
  10240. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10241. isEnd = true;
  10242. }
  10243. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10244. {
  10245. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10246. isEnd = true;
  10247. }
  10248. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10249. {
  10250. needCyt = true;
  10251. }
  10252. }
  10253. if (isEnd)
  10254. {
  10255. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10256. ceErpTradeCell.AfterSaleState = 4;
  10257. ceErpTradeCell.AfterSaleSupplierState = 1;
  10258. }
  10259. }
  10260. else
  10261. {
  10262. bool isAll = true;
  10263. foreach (DataRow dr in dt.Rows)
  10264. {
  10265. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10266. {
  10267. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10268. continue;
  10269. }
  10270. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10271. {
  10272. string path = "";
  10273. int OrgID = 0;
  10274. if (!Convert.IsDBNull(dr["OrgPath"]))
  10275. {
  10276. path = dr["OrgPath"].ToString();
  10277. }
  10278. if (!Convert.IsDBNull(dr["OrgID"]))
  10279. {
  10280. OrgID = Convert.ToInt32(dr["OrgID"]);
  10281. }
  10282. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10283. {
  10284. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10285. continue;
  10286. }
  10287. }
  10288. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10289. {
  10290. needCyt = true;
  10291. }
  10292. isAll = false;
  10293. }
  10294. if (isAll)
  10295. {
  10296. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10297. ceErpTradeCell.AfterSaleState = 4;
  10298. ceErpTradeCell.AfterSaleSupplierState = 1;
  10299. }
  10300. }
  10301. }
  10302. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10303. {
  10304. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10305. }
  10306. if (ceErpTradeCell.AfterSaleState == 4)
  10307. {
  10308. ApiVo apiVo = new ApiVo();
  10309. apiVo.orderNumber = ceErpTradeCell.ctid;
  10310. apiVo.actionName = "afterOver";
  10311. designHelper.API_WorkCore(apiVo); //afterOver
  10312. }
  10313. ceErpTradeCell.Update();
  10314. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10315. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10316. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10317. return true;
  10318. }
  10319. return false;
  10320. }
  10321. public void get_erp_wechatorder()
  10322. {
  10323. DataStruct dStruct = GetPostStruct();
  10324. List<string> lw = new List<string>();
  10325. string tid = GetPostString("tid");
  10326. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10327. string shopname = GetPostString("shopname");
  10328. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10329. string buyernick = GetPostString("buyer_nick");
  10330. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10331. string customer = GetPostString("customer");
  10332. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10333. string returndate1 = GetPostString("returndate1");
  10334. string returndate2 = GetPostString("returndate2");
  10335. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10336. if (dw.Length > 0) lw.Add(dw);
  10337. string finishDate1 = GetPostString("finishdate1");
  10338. string finishDate2 = GetPostString("finishdate2");
  10339. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10340. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10341. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10342. dStruct.Order = "created desc";
  10343. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10344. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10345. writeGridDataTableJson(dStruct.TotalCount, dt);
  10346. }
  10347. public void get_erp_wechatlist_sumprice()
  10348. {
  10349. DataStruct dStruct = GetPostStruct();
  10350. List<string> lw = new List<string>();
  10351. string tid = GetPostString("tid");
  10352. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10353. string shopname = GetPostString("shopname");
  10354. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10355. string buyernick = GetPostString("buyer_nick");
  10356. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10357. string customer = GetPostString("customer");
  10358. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10359. string returndate1 = GetPostString("returndate1");
  10360. string returndate2 = GetPostString("returndate2");
  10361. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10362. if (dw.Length > 0) lw.Add(dw);
  10363. string finishDate1 = GetPostString("finishdate1");
  10364. string finishDate2 = GetPostString("finishdate2");
  10365. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10366. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10367. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10368. string mainWhere = string.Join(" and ", lw.ToArray());
  10369. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10370. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10371. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10372. decimal total = 0;
  10373. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10374. {
  10375. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10376. }
  10377. var res = new
  10378. {
  10379. data = total
  10380. };
  10381. string ro_jsond = JsonConvert.SerializeObject(res);
  10382. returnSuccess(ro_jsond);
  10383. return;
  10384. }
  10385. public void get_erp_qr_waitdeliverylist()
  10386. {
  10387. DataStruct dStruct = GetPostStruct();
  10388. List<string> lw = new List<string>();
  10389. string tid = GetPostString("ctid");
  10390. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10391. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10392. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10393. var res_objz = new
  10394. {
  10395. restype = 1,
  10396. data = dt
  10397. };
  10398. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10399. returnSuccess(ro_jsonz);
  10400. }
  10401. public void get_erp_yield_list()
  10402. {
  10403. DataStruct dStruct = GetPostStruct();
  10404. List<string> lw = new List<string>();
  10405. string tid = GetPostString("ctid");
  10406. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10407. string shopname = GetPostString("shopname");
  10408. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10409. string buyernick = GetPostString("buyer_nick");
  10410. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10411. //if (tid.Length == 0 && buyernick.Length == 0)
  10412. //{
  10413. // lw.Add(string.Format("IsRefund<={0}", 1));
  10414. //}
  10415. string customer = GetPostString("customer");
  10416. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10417. string design = GetPostString("design");
  10418. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10419. string orderState = GetPostString("orderState");
  10420. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10421. string address = GetPostString("address");
  10422. 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));
  10423. string sellermemo = GetPostString("seller_memo");
  10424. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10425. string supplier = GetPostString("supplier");
  10426. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10427. string OrderArea = GetPostString("order_area");
  10428. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10429. string placedate1 = GetPostString("placedate1");
  10430. string placedate2 = GetPostString("placedate2");
  10431. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10432. if (fdw.Length > 0) lw.Add(fdw);
  10433. string price1 = GetPostString("price1");
  10434. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10435. string price2 = GetPostString("price2");
  10436. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10437. string unusualCon = GetPostString("unusualcon");
  10438. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10439. string posTag = CurrentUser.UserPost.Post.Code;
  10440. if (posTag == "Supplier")
  10441. {
  10442. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10443. }
  10444. lw.Add(string.Format("OrderState = 6 "));
  10445. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10446. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10447. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10448. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10449. writeGridDataTableJson(dStruct.TotalCount, dt);
  10450. }
  10451. public void change_erp_sup_state()
  10452. {
  10453. if (UrlPostParmsCheck("ctid"))
  10454. {
  10455. string ctid = GetPostString("ctid");
  10456. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10457. if (ceErpTradeCell != null)
  10458. {
  10459. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10460. if (ceErpTradeCellExtend == null)
  10461. {
  10462. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10463. ceErpTradeCellExtend.ctid = ctid;
  10464. ceErpTradeCellExtend.SupState = 1;
  10465. ceErpTradeCellExtend.Create();
  10466. }
  10467. else
  10468. {
  10469. ceErpTradeCellExtend.SupState = 1;
  10470. ceErpTradeCellExtend.Update();
  10471. }
  10472. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10473. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10474. return;
  10475. }
  10476. returnErrorMsg("找不到订单");
  10477. }
  10478. }
  10479. public void supplier_all_downs()
  10480. {
  10481. if (UrlPostParmsCheck("tids"))
  10482. {
  10483. string tids = GetPostString("tids");
  10484. if (tids != null && tids.Length > 0)
  10485. {
  10486. StringBuilder sql = new StringBuilder();
  10487. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10488. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10489. sql = new StringBuilder();
  10490. 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, "下载设计文件");
  10491. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10492. string[] list = tids.Split(',');
  10493. foreach (string ctid in list)
  10494. {
  10495. CeErpSukuraData.createInfo(ctid, 3);
  10496. }
  10497. designHelper.api_approveDesign(tids); //approveDesign
  10498. returnSuccessMsg("下载成功!");
  10499. return;
  10500. }
  10501. returnErrorMsg("下载订单更新失败");
  10502. }
  10503. }
  10504. public void uploaderFileSuccess()
  10505. {
  10506. if (UrlPostParmsCheck("fileName"))
  10507. {
  10508. string fileName = GetPostString("fileName");
  10509. ApiVo apiVo = new ApiVo();
  10510. apiVo.orderNumber = fileName;
  10511. apiVo.actionName = "finishDesign";
  10512. designHelper.API_WorkCore(apiVo);//finishDesign
  10513. returnSuccessMsg("");
  10514. }
  10515. }
  10516. public void get_sample2_order()
  10517. {
  10518. if (UrlPostParmsCheck("ctid"))
  10519. {
  10520. string ctid = GetPostString("ctid");
  10521. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10522. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10523. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10524. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10525. double total = 0.0;
  10526. double order_price = 0.0;
  10527. if (dt_bu.Rows.Count > 0)
  10528. {
  10529. foreach (DataRow dr in dt_bu.Rows)
  10530. {
  10531. total += Convert.ToDouble(dr["payment"]);
  10532. }
  10533. }
  10534. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10535. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10536. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10537. string tid = ctid.Replace("S_", "");
  10538. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10539. double paymant = 0.0;
  10540. if (entity != null)
  10541. {
  10542. paymant = entity.payment;
  10543. }
  10544. string return_reason = "";
  10545. if (dt_after != null && dt_after.Rows.Count > 0)
  10546. {
  10547. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10548. }
  10549. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10550. }
  10551. }
  10552. public void get_erp_design_status()
  10553. {
  10554. string designName = GetPostString("designName");
  10555. DataStruct dStruct = GetPostStruct();
  10556. if (designName.Length > 0)
  10557. {
  10558. 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";
  10559. sql_user += " and Name like '%" + designName + "%'";
  10560. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10561. List<string> ids_list = new List<string>();
  10562. if (user_table.Rows.Count > 0)
  10563. {
  10564. foreach (DataRow item in user_table.Rows)
  10565. {
  10566. ids_list.Add(item["id"].ToString());
  10567. string ids_s = item["TeamIds"].ToString();
  10568. if (ids_s.Length > 0)
  10569. {
  10570. ids_list.AddRange(ids_s.Split(','));
  10571. }
  10572. }
  10573. }
  10574. HashSet<string> set = new HashSet<string>(ids_list);
  10575. ids_list = set.ToList();
  10576. if (ids_list.Count > 0)
  10577. {
  10578. 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));
  10579. dStruct.MainWhere = sql;
  10580. DataTable dt = null;
  10581. dt = WebCache.GetData("view_ErpUser", dStruct);
  10582. writeGridDataTableJson(dStruct.TotalCount, dt);
  10583. }
  10584. }
  10585. }
  10586. public void change_erp_order_price()
  10587. {
  10588. string ctid = GetPostString("ctid");
  10589. double price = GetPostDouble("price");
  10590. if (ctid.Length > 0)
  10591. {
  10592. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10593. if (ceErpTradeCellExtend == null)
  10594. {
  10595. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10596. ceErpTradeCellExtend.ctid = ctid;
  10597. ceErpTradeCellExtend.payment_cyt = price;
  10598. ceErpTradeCellExtend.Create();
  10599. }
  10600. else
  10601. {
  10602. ceErpTradeCellExtend.payment_cyt = price;
  10603. ceErpTradeCellExtend.Update();
  10604. }
  10605. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10606. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10607. {
  10608. ceErpDataSendOrderInfo.isSync = false;
  10609. ceErpDataSendOrderInfo.Update();
  10610. }
  10611. if (ceErpDataSendOrderInfo == null)
  10612. {
  10613. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10614. ceErpDataSendOrderInfo.isSync = false;
  10615. ceErpDataSendOrderInfo.ctid = ctid;
  10616. ceErpDataSendOrderInfo.Create();
  10617. }
  10618. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10619. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10620. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10621. if (dth != null && dth.Rows.Count > 0)
  10622. {
  10623. dataSendOrderBean dataSendOrderBean = null;
  10624. foreach (DataRow item in dth.Rows)
  10625. {
  10626. try
  10627. {
  10628. dataSendOrderBean = new dataSendOrderBean();
  10629. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10630. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10631. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10632. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10633. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10634. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10635. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10636. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10637. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10638. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10639. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10640. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10641. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10642. if (result != null)
  10643. {
  10644. if ("0".Equals(result.errcode))
  10645. {
  10646. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10647. }
  10648. else
  10649. {
  10650. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10651. }
  10652. }
  10653. }
  10654. catch (Exception ex)
  10655. {
  10656. }
  10657. }
  10658. }
  10659. returnSuccessMsg("修改成功!");
  10660. return;
  10661. }
  10662. returnErrorMsg("找不到订单");
  10663. }
  10664. public void find_he_together()
  10665. {
  10666. string ctid = GetPostString("ctid");
  10667. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10668. List<string> list = new List<string>();
  10669. if (ceErpTradeCell != null)
  10670. {
  10671. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10672. {
  10673. 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);
  10674. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10675. if (table != null && table.Rows.Count > 0)
  10676. {
  10677. foreach (TableRow row in table.Rows)
  10678. {
  10679. }
  10680. }
  10681. }
  10682. }
  10683. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10684. }
  10685. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10686. {
  10687. //chy----19
  10688. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10689. //GD-CYT-----64
  10690. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10691. //ZHX----3
  10692. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10693. //JK----97
  10694. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10695. //ZT----70
  10696. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10697. //LHCY-----98
  10698. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10699. //XD-----90
  10700. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10701. //CYCY-----14
  10702. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10703. };
  10704. //其他改名
  10705. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10706. {
  10707. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10708. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10709. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10710. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10711. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10712. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10713. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10714. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10715. };
  10716. //不统计
  10717. List<int> no_suppliers = new List<int>()
  10718. {
  10719. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10720. };
  10721. //配件单
  10722. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10723. {
  10724. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10725. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10726. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10727. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10728. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10729. {"旗杆",new List<string>(){ "班旗" } },
  10730. {"牙签",new List<string>(){ "不干胶" } }
  10731. };
  10732. public void get_place_order_data()
  10733. {
  10734. string date1 = GetPostString("date1");
  10735. string date2 = GetPostString("date2");
  10736. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10737. DateTime start = DateTime.Parse(starttime);
  10738. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10739. DateTime end = DateTime.Parse(endtime);
  10740. if (date1 != null && date1.Length > 0)
  10741. {
  10742. DateTime dateTime = DateTime.Parse(date1);
  10743. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10744. start = DateTime.Parse(starttime);
  10745. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10746. end = DateTime.Parse(endtime);
  10747. }
  10748. if (date2 != null && date2.Length > 0)
  10749. {
  10750. DateTime dateTime = DateTime.Parse(date2);
  10751. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10752. end = DateTime.Parse(endtime);
  10753. }
  10754. 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);
  10755. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10756. //不干胶-----1,卡片-----29
  10757. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10758. foreach (DataRow row in data.Rows)
  10759. {
  10760. int productId = Convert.ToInt32(row["ProductId"]);
  10761. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10762. if (no_suppliers.Contains(supplierId))
  10763. {
  10764. continue;
  10765. }
  10766. string seller_memo = row["seller_memo"].ToString();
  10767. bool ispj = false;//是否配件单
  10768. bool isfirst = true;//第一个配
  10769. maps.Keys.ForEach(key =>
  10770. {
  10771. //备注包含配件
  10772. if (seller_memo.Contains(key) && isfirst)
  10773. {
  10774. List<string> list = maps[key];
  10775. ispj = true;
  10776. isfirst = false;
  10777. for (int i = 0; i < list.Count; i++)
  10778. {
  10779. if (seller_memo.Contains(list[i]))
  10780. {
  10781. ispj = false;
  10782. break;
  10783. }
  10784. }
  10785. }
  10786. });
  10787. if (ispj)
  10788. {
  10789. continue;
  10790. }
  10791. seller_memo = seller_memo.Replace("UV", "uv");
  10792. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10793. //吊牌归到卡片
  10794. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10795. seller_memo = seller_memo.Replace("卡套", "卡片");
  10796. seller_memo = seller_memo.Replace("封套", "卡片");
  10797. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10798. seller_memo = seller_memo.Replace("腰封", "卡片");
  10799. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10800. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10801. seller_memo = seller_memo.Replace("横幅", "条幅");
  10802. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10803. string map_key = "";
  10804. string type = "";
  10805. if (supplierMap.ContainsKey(supplierId))
  10806. {
  10807. foreach (var kvp in supplierMap[supplierId])
  10808. {
  10809. if (seller_memo.Contains(kvp.Key))
  10810. {
  10811. map_key = kvp.Value;
  10812. type = kvp.Value;
  10813. break;
  10814. }
  10815. }
  10816. }
  10817. if (map_key == "")
  10818. {
  10819. type = "其他";
  10820. map_key = "其他";
  10821. }
  10822. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10823. {
  10824. map_key = suppliers[supplierId];
  10825. }
  10826. if (supplierId == 70)
  10827. {
  10828. supplierId = 70;
  10829. }
  10830. map_key += "_" + row["SupplierName"].ToString();
  10831. Dictionary<string, int> map = null;
  10832. if (other_map.ContainsKey(map_key))
  10833. {
  10834. other_map.TryGetValue(map_key, out map);
  10835. }
  10836. else
  10837. {
  10838. map = new Dictionary<string, int>();
  10839. map.Add("dayDev", 0);//当天出货
  10840. map.Add("dayTotal", 0);//下单总数
  10841. map.Add("payTotal", 0);//500以上
  10842. map.Add("today", 0);//当天出货数量
  10843. map.Add("unusua", 0);//异常数
  10844. other_map.Add(map_key, map);
  10845. other_map.TryGetValue(map_key, out map);
  10846. }
  10847. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10848. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10849. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10850. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  10851. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10852. {
  10853. map["dayTotal"]++;
  10854. if (supplierId == 97)
  10855. {
  10856. supplierId = 97;
  10857. }
  10858. }
  10859. if (Convert.ToDecimal(row["payment"]) >= 500)
  10860. {
  10861. map["payTotal"]++;
  10862. }
  10863. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10864. {
  10865. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10866. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10867. {
  10868. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  10869. {
  10870. map["today"]++;
  10871. }
  10872. }
  10873. else
  10874. {
  10875. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10876. {
  10877. map["today"]++;
  10878. }
  10879. }
  10880. }
  10881. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10882. {
  10883. map["unusua"]++;
  10884. }
  10885. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10886. //GD-CYT-----64
  10887. DateTime two = palceTimeStart.AddHours(14);
  10888. DateTime three = palceTimeStart.AddHours(15);
  10889. DateTime four = palceTimeStart.AddHours(16);
  10890. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10891. {
  10892. //下午四点前 500-1000
  10893. string count = row["ProductCount"].ToString();
  10894. if (count != null && count.Length > 0)
  10895. {
  10896. int productCount = commonHelper.getPlaceProductCount(count);
  10897. if (productCount >= 500 && productCount <= 1000)
  10898. {
  10899. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10900. {
  10901. map["dayDev"]++;
  10902. }
  10903. }
  10904. }
  10905. }
  10906. //UV
  10907. else if ("uv".Equals(type))
  10908. {
  10909. //ZT----70
  10910. //ZHX----3
  10911. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10912. {
  10913. map["dayDev"]++;
  10914. }
  10915. //JK----97
  10916. //HZX----105
  10917. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10918. {
  10919. map["dayDev"]++;
  10920. if (supplierId == 97)
  10921. {
  10922. supplierId = 97;
  10923. }
  10924. }
  10925. }
  10926. //帆布---52|条幅---27
  10927. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10928. {
  10929. //LHCY-----98
  10930. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10931. {
  10932. map["dayDev"]++;
  10933. }
  10934. }
  10935. //条幅
  10936. else if ("条幅".Equals(type))
  10937. {
  10938. //XD-----90
  10939. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10940. {
  10941. map["dayDev"]++;
  10942. }
  10943. }
  10944. //桌布
  10945. else if ("桌布".Equals(type))
  10946. {
  10947. //XD-----90
  10948. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10949. {
  10950. map["dayDev"]++;
  10951. }
  10952. }
  10953. //DL---10
  10954. //AYTW---119
  10955. //FS-CYT-DY ----80
  10956. //JK----97
  10957. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10958. {
  10959. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10960. {
  10961. map["dayDev"]++;
  10962. }
  10963. }
  10964. }
  10965. DataTable dt = new DataTable();
  10966. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10967. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10968. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10969. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10970. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10971. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10972. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10973. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10974. other_map.Keys.ForEach(key =>
  10975. {
  10976. DataRow dr = dt.NewRow();
  10977. Dictionary<string, int> map = other_map[key];
  10978. string[] key_list = key.Split('_');
  10979. dr[0] = key_list[0];
  10980. dr[1] = key_list[1];
  10981. if (key_list.Length > 2)
  10982. {
  10983. dr[1] += "(" + key_list[2] + ")";
  10984. }
  10985. dr[2] = map["dayTotal"];
  10986. dr[3] = map["payTotal"];
  10987. dr[4] = map["today"];
  10988. dr[5] = map["unusua"];
  10989. dr[6] = map["dayDev"];
  10990. double rate = 0.00;
  10991. if (map["dayDev"] > 0)
  10992. {
  10993. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10994. }
  10995. dr[7] = rate.ToString();
  10996. dt.Rows.Add(dr);
  10997. });
  10998. DataView dv = new DataView(dt);
  10999. dv.Sort = "SupplierName";
  11000. //dv.Sort = "AllOrder desc";
  11001. DataTable dtNew = dv.ToTable();
  11002. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11003. }
  11004. public void check_order_desing_info()
  11005. {
  11006. string ctid = GetPostString("ctid");
  11007. if (!string.IsNullOrEmpty(ctid))
  11008. {
  11009. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11010. if (ceErpTradeCell != null)
  11011. {
  11012. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11013. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11014. return;
  11015. }
  11016. returnErrorMsg("找不到订单");
  11017. return;
  11018. }
  11019. returnErrorMsg("找不到订单");
  11020. }
  11021. public void get_timeout_detail()
  11022. {
  11023. string poscode = CurrentUser.UserPost.Post.Code;
  11024. DataStruct dStruct = GetPostStruct();
  11025. List<string> lw = new List<string>();
  11026. string id = GetPostString("id");
  11027. string pay_date1 = GetPostString("pay_date1");
  11028. string pay_date2 = GetPostString("pay_date2");
  11029. int type = GetPostInt("type");
  11030. if (type == 0)
  11031. {
  11032. if (pay_date1.Length > 0)
  11033. {
  11034. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11035. }
  11036. if (pay_date2.Length > 0)
  11037. {
  11038. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11039. }
  11040. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11041. }
  11042. if (type == 1)
  11043. {
  11044. if (pay_date1.Length > 0)
  11045. {
  11046. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11047. }
  11048. if (pay_date2.Length > 0)
  11049. {
  11050. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11051. }
  11052. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11053. }
  11054. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11055. DataTable dt = null;
  11056. dt = WebCache.GetData("view_orderlist", dStruct);
  11057. writeGridDataTableJson(dStruct.TotalCount, dt);
  11058. }
  11059. public void saveUrgentChargePrice()
  11060. {
  11061. string ctid = GetPostString("ctid");
  11062. if (!string.IsNullOrEmpty(ctid))
  11063. {
  11064. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11065. if (ceErpTradeCell != null)
  11066. {
  11067. double price = GetPostDouble("price");
  11068. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11069. if (ceErpTradeCellExtend == null)
  11070. {
  11071. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11072. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11073. }
  11074. ceErpTradeCellExtend.urgentCharge = price;
  11075. if (ceErpTradeCellExtend.ID > 0)
  11076. {
  11077. ceErpTradeCellExtend.Update();
  11078. }
  11079. else
  11080. {
  11081. ceErpTradeCellExtend.Save();
  11082. }
  11083. returnSuccessMsg("修改成功!");
  11084. return;
  11085. }
  11086. returnErrorMsg("找不到订单");
  11087. return;
  11088. }
  11089. returnErrorMsg("找不到订单");
  11090. }
  11091. public void finish_erp_order()
  11092. {
  11093. string ctid = GetPostString("ctid");
  11094. if (!string.IsNullOrEmpty(ctid))
  11095. {
  11096. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11097. {
  11098. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11099. if (ceErpTradeCell != null)
  11100. {
  11101. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11102. ceErpTradeCell.Update();
  11103. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11104. returnSuccessMsg("修改成功!");
  11105. return;
  11106. }
  11107. }
  11108. }
  11109. returnErrorMsg("找不到订单");
  11110. }
  11111. public void get_trade_order_list()
  11112. {
  11113. string tid = GetPostString("tid");
  11114. if (!string.IsNullOrEmpty(tid))
  11115. {
  11116. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11117. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11118. writeGridDataTableJson(data.Rows.Count, data);
  11119. return;
  11120. }
  11121. returnErrorMsg("找不到订单");
  11122. }
  11123. public void save_cell_spu()
  11124. {
  11125. string ctid = GetPostString("ctid");
  11126. string spu_id = GetPostString("spu_id");
  11127. if (!string.IsNullOrEmpty(ctid))
  11128. {
  11129. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11130. if (ceErpTradeCellExtend == null)
  11131. {
  11132. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11133. ceErpTradeCellExtend.ctid = ctid;
  11134. }
  11135. ceErpTradeCellExtend.spu_id = spu_id;
  11136. if (ceErpTradeCellExtend.ID == 0)
  11137. {
  11138. ceErpTradeCellExtend.Create();
  11139. }
  11140. else
  11141. {
  11142. ceErpTradeCellExtend.Update();
  11143. }
  11144. returnSuccessMsg("修改成功!");
  11145. return;
  11146. }
  11147. returnErrorMsg("找不到订单");
  11148. }
  11149. public void change_express_info()
  11150. {
  11151. string ctid = GetPostString("ctid");
  11152. string transNo = GetPostString("transNo");
  11153. string transCom = GetPostString("transCom");
  11154. if (!string.IsNullOrEmpty(ctid))
  11155. {
  11156. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11157. if (ceErpTradeCellExtend == null)
  11158. {
  11159. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11160. ceErpTradeCellExtend.ctid = ctid;
  11161. }
  11162. ceErpTradeCellExtend.modExpressNo = transNo;
  11163. ceErpTradeCellExtend.modExpressCom = transCom;
  11164. ceErpTradeCellExtend.readMod = 2;
  11165. if (ceErpTradeCellExtend.ID == 0)
  11166. {
  11167. ceErpTradeCellExtend.Create();
  11168. }
  11169. else
  11170. {
  11171. ceErpTradeCellExtend.Update();
  11172. }
  11173. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11174. returnSuccessMsg("修改成功!");
  11175. return;
  11176. }
  11177. returnErrorMsg("找不到订单");
  11178. }
  11179. public void get_change_express_list()
  11180. {
  11181. DataStruct dStruct = GetPostStruct();
  11182. List<string> lw = new List<string>();
  11183. int st = 2;
  11184. string tid = GetPostString("ctid");
  11185. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11186. string shopname = GetPostString("shopname");
  11187. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11188. string buyernick = GetPostString("buyer_nick");
  11189. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11190. string sellermemo = GetPostString("seller_memo");
  11191. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11192. string supplier = GetPostString("supplier");
  11193. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11194. string customer = GetPostString("customer");
  11195. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11196. string design = GetPostString("design");
  11197. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11198. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11199. string poscode = CurrentUser.UserPost.Post.Code;
  11200. if (poscode != "SysAdmin")
  11201. {
  11202. string shopid = CurrentUser.User.pemShop;
  11203. lw.Add(string.Format("shopId in ({0})", shopid));
  11204. }
  11205. lw.Add("readMod = 2");
  11206. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11207. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11208. writeGridDataTableJson(dStruct.TotalCount, dt);
  11209. }
  11210. public void deal_express_complete()
  11211. {
  11212. string ctid = GetPostString("ctid");
  11213. if (!string.IsNullOrEmpty(ctid))
  11214. {
  11215. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11216. if (ceErpTradeCellExtend == null)
  11217. {
  11218. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11219. ceErpTradeCellExtend.ctid = ctid;
  11220. }
  11221. ceErpTradeCellExtend.readMod = 1;
  11222. if (ceErpTradeCellExtend.ID == 0)
  11223. {
  11224. ceErpTradeCellExtend.Create();
  11225. }
  11226. else
  11227. {
  11228. ceErpTradeCellExtend.Update();
  11229. }
  11230. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11231. returnSuccessMsg("修改成功!");
  11232. return;
  11233. }
  11234. returnErrorMsg("找不到订单");
  11235. }
  11236. public void aftersale_return_visit()
  11237. {
  11238. string ctid = GetPostString("ctid");
  11239. if (!string.IsNullOrEmpty(ctid))
  11240. {
  11241. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11242. if (ceErpTradeCellExtend == null)
  11243. {
  11244. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11245. ceErpTradeCellExtend.ctid = ctid;
  11246. }
  11247. ceErpTradeCellExtend.returnVisit = 1;
  11248. if (ceErpTradeCellExtend.ID == 0)
  11249. {
  11250. ceErpTradeCellExtend.Create();
  11251. }
  11252. else
  11253. {
  11254. ceErpTradeCellExtend.Update();
  11255. }
  11256. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11257. if (ceErpTradeAfterSaleExtend != null)
  11258. {
  11259. ceErpTradeAfterSaleExtend.TextResult = "";
  11260. ceErpTradeAfterSaleExtend.Update();
  11261. }
  11262. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11263. returnSuccessMsg("修改成功!");
  11264. return;
  11265. }
  11266. returnErrorMsg("找不到订单");
  11267. }
  11268. public void orderPlaceInfo()
  11269. {
  11270. string ctids = GetPostString("ctids");
  11271. string[] list = ctids.Split(',');
  11272. foreach (string ctid in list)
  11273. {
  11274. CeErpSukuraData.createInfo(ctid, 3);
  11275. }
  11276. designHelper.api_approveDesign(ctids); //approveDesign
  11277. returnSuccessMsg("");
  11278. }
  11279. public void get_issue_list()
  11280. {
  11281. DataStruct dStruct = GetPostStruct();
  11282. List<string> lw = new List<string>();
  11283. int st = 2;
  11284. string tid = GetPostString("ctid");
  11285. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11286. string shopname = GetPostString("shopname");
  11287. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11288. string buyernick = GetPostString("buyer_nick");
  11289. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11290. string sellermemo = GetPostString("seller_memo");
  11291. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11292. string supplier = GetPostString("supplier");
  11293. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11294. string customer = GetPostString("customer");
  11295. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11296. string design = GetPostString("design");
  11297. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11298. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11299. string poscode = CurrentUser.UserPost.Post.Code;
  11300. if (poscode != "SysAdmin")
  11301. {
  11302. string shopid = CurrentUser.User.pemShop;
  11303. lw.Add(string.Format("shopId in ({0})", shopid));
  11304. }
  11305. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11306. {
  11307. lw.Add("IssueState = 1");
  11308. }
  11309. lw.Add("IssueState > 0");
  11310. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11311. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11312. writeGridDataTableJson(dStruct.TotalCount, dt);
  11313. }
  11314. public void saveIssueContent()
  11315. {
  11316. string ctid = GetPostString("ctid");
  11317. if (!string.IsNullOrEmpty(ctid))
  11318. {
  11319. string content = GetPostString("content");
  11320. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11321. if (ceErpTradeAfterSaleExtend == null)
  11322. {
  11323. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11324. ceErpTradeAfterSaleExtend.tid = ctid;
  11325. }
  11326. ceErpTradeAfterSaleExtend.IssueContent = content;
  11327. ceErpTradeAfterSaleExtend.IssueState = 1;
  11328. if (ceErpTradeAfterSaleExtend.ID > 0)
  11329. {
  11330. ceErpTradeAfterSaleExtend.Update();
  11331. }
  11332. else
  11333. {
  11334. ceErpTradeAfterSaleExtend.Create();
  11335. }
  11336. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11337. returnSuccessMsg("添加成功!");
  11338. return;
  11339. }
  11340. returnErrorMsg("找不到订单");
  11341. }
  11342. public void dealIssueContent()
  11343. {
  11344. string ctid = GetPostString("ctid");
  11345. if (!string.IsNullOrEmpty(ctid))
  11346. {
  11347. string content = GetPostString("content");
  11348. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11349. if (ceErpTradeAfterSaleExtend != null)
  11350. {
  11351. ceErpTradeAfterSaleExtend.IssueState = 2;
  11352. ceErpTradeAfterSaleExtend.Update();
  11353. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11354. returnSuccessMsg("修改完成!");
  11355. return;
  11356. }
  11357. }
  11358. returnErrorMsg("找不到订单");
  11359. }
  11360. public void set_tid_attachments()
  11361. {
  11362. string tid = GetPostString("tid");
  11363. string atta = GetPostString("atta");
  11364. if (!string.IsNullOrEmpty(tid))
  11365. {
  11366. if (string.IsNullOrEmpty(atta))
  11367. {
  11368. returnErrorMsg("文件地址为空");
  11369. return;
  11370. }
  11371. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11372. if (ceErpTradeCell != null)
  11373. {
  11374. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11375. if (ceErpTrade == null)
  11376. {
  11377. returnErrorMsg("找不到订单");
  11378. return;
  11379. }
  11380. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11381. bool isSend = false;
  11382. if (dt != null && dt.Rows.Count > 0)
  11383. {
  11384. foreach (DataRow row in dt.Rows)
  11385. {
  11386. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11387. {
  11388. isSend = true;
  11389. }
  11390. }
  11391. if (isSend)
  11392. {
  11393. returnErrorMsg("已发货无法修改");
  11394. return;
  11395. }
  11396. ceErpTrade.Attachments = atta;
  11397. ceErpTrade.Update();
  11398. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11399. returnSuccessMsg("上传成功!");
  11400. return;
  11401. }
  11402. }
  11403. }
  11404. returnErrorMsg("找不到订单");
  11405. }
  11406. public void get_tid_attachments()
  11407. {
  11408. string tid = GetPostString("tid");
  11409. if (!string.IsNullOrEmpty(tid))
  11410. {
  11411. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11412. if (ceErpTradeCell != null)
  11413. {
  11414. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11415. if (ceErpTrade == null)
  11416. {
  11417. returnErrorMsg("找不到订单");
  11418. return;
  11419. }
  11420. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11421. return;
  11422. }
  11423. }
  11424. returnErrorMsg("找不到订单");
  11425. }
  11426. }
  11427. }