sync.order.cs 589 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801
  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\":1743037314000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1743210111000,\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"JSBHUVZYT\",\"payment\":100.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2200806677467/O1CN01FNM4MW251wJNQ0RTV_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":50.0,\"refOlId\":\"4279817918999398627\",\"refSkuId\":\"0\",\"refSpuId\":\"743796792540\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":50.0,\"singleFee\":50.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【活动价】镜子贴纸定制婚礼迎宾牌装饰静电贴镜面玻璃窗户字母转印贴画墙贴\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1743040267000,\"openBuyerId\":\"AAEXRHraABkUZRPgSx1Mbz6h\",\"openBuyerNick\":\"天**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1743037310000,\"payTime\":1743037311000,\"payment\":100.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"齐齐哈尔市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"建华区\",\"receiverId\":\"82f9bfecd2ef7df766b42edd73faa2f3$\",\"receiverState\":\"黑龙江省\",\"receiverTown\":\"文化街道\",\"refOid\":\"4279817918999398627\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"500x640mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50,580x585mm-1张-uv静电膜-模切-单面印刷-天意5516-昕昕-50\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":100.0,\"totalPrice\":100.0,\"totalSellPrice\":100.0,\"type\":\"SALE\"}}");
  65. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. string select_tid = getTidByCtid(tid);
  110. lw.Add(string.Format("tid='{0}'", select_tid));
  111. }
  112. if (buyernick.Length > 0)
  113. {
  114. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  115. }
  116. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  117. if (dw.Length > 0)
  118. {
  119. lw.Add(dw);
  120. }
  121. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  122. {
  123. string usershop = CurrentUser.User.pemShop;
  124. lw.Add(string.Format("ShopId in ({0})", usershop));
  125. }
  126. }
  127. else
  128. {
  129. if (ex_psize == 0)
  130. {
  131. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  132. }
  133. if (PKey != "admin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. paramsCount++;
  138. }
  139. }
  140. string uploaddate1 = GetPostString("uploaddate1");
  141. string uploaddate2 = GetPostString("uploaddate2");
  142. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  143. if (update.Length > 0) lw.Add(update);
  144. string deliverydate1 = GetPostString("deliverydate1");
  145. string deliverydate2 = GetPostString("deliverydate2");
  146. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  147. if (deliverydate.Length > 0)
  148. {
  149. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  150. };
  151. string shopname = GetPostString("shopname");
  152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  153. string addwechat = GetPostString("addwechat");
  154. if (addwechat.Length > 0)
  155. {
  156. int addWt = Convert.ToInt32(addwechat);
  157. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  158. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  159. }
  160. string customer = GetPostString("customer");
  161. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  162. string design = GetPostString("design");
  163. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  164. string orderState = GetPostString("orderState");
  165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  166. string address = GetPostString("address");
  167. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  168. string sellermemo = GetPostString("seller_memo");
  169. if (sellermemo.Length > 0)
  170. {
  171. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  172. }
  173. string backReason = GetPostString("backReason");
  174. if (backReason.Length > 0)
  175. {
  176. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  177. }
  178. string apdate1 = GetPostString("apdate1");
  179. string apdate2 = GetPostString("apdate2");
  180. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  181. if (dwap.Length > 0) lw.Add(dwap);
  182. string price1 = GetPostString("price1");
  183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  184. string price2 = GetPostString("price2");
  185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  186. string isoldcustomer = GetPostString("isoldcus");
  187. string finishdate1 = GetPostString("finishdate1");
  188. string finishdate2 = GetPostString("finishdate2");
  189. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  190. bool isFinish = false;
  191. if (finishdate.Length > 0)
  192. {
  193. lw.Add(finishdate);
  194. isFinish = true;
  195. paramsCount++;
  196. }
  197. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  198. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  199. if (ex_psize > 0)
  200. {
  201. int UserID = CurrentUser.UserID;
  202. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  203. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  204. {
  205. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  206. }
  207. dStruct.Order = "pay_time desc";
  208. }
  209. string isNew = GetPostString("isNew");
  210. if (isNew == "true")
  211. {
  212. lw.Add(string.Format("IsNew = {0}", 1));
  213. }
  214. string overtime = GetPostString("overtime");
  215. if (overtime == "1")
  216. {
  217. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  218. }
  219. String usePost = CurrentUser.UserPost.Post.Code;
  220. if (usePost.Equals("Operation") == true)
  221. {
  222. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. else
  225. {
  226. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  227. }
  228. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  229. if (dStruct.PageSize == 100000)
  230. {
  231. dStruct.Order = "";
  232. }
  233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  234. DataTable dt = null;
  235. string tablename = "view_orderlist";
  236. if (isFinish)
  237. {
  238. tablename = "view_orderlist_end";
  239. }
  240. dt = WebCache.GetData(tablename, dStruct);
  241. if (dt != null && dt.Rows.Count > 0)
  242. {
  243. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  244. foreach (DataRow dr in dt.Rows)
  245. {
  246. try
  247. {
  248. if (dr["refund_fees"] != null)
  249. {
  250. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  251. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  252. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  253. if (payment == refund_fees)
  254. {
  255. dr["refund_fees"] = Math.Round(refund_fees, 2);
  256. }
  257. else if (refund_fees == total_fee)
  258. {
  259. dr["refund_fees"] = payment;
  260. }
  261. else
  262. {
  263. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  264. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  265. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  266. }
  267. }
  268. // 对象操作
  269. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  270. ceErpTradeCell.ctid = dr["ctid"].ToString();
  271. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  272. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  273. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  274. if (dStruct.PageSize != 100000)
  275. {
  276. if (dr["DispatchSort"].ToString() == "2")
  277. {
  278. dr["gongchuang"] = 200;
  279. }
  280. else
  281. {
  282. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  283. dr["gongchuang"] = response.code;
  284. }
  285. }
  286. }
  287. catch (NullReferenceException ex)
  288. {
  289. // 处理空引用异常
  290. dr["refund_fees"] = "0.00";
  291. }
  292. }
  293. }
  294. writeGridDataTableJson(dStruct.TotalCount, dt);
  295. }
  296. public void get_erp_orderlist_sumprice()
  297. {
  298. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  299. return;
  300. List<string> lw = new List<string>();
  301. string tid = GetPostString("ctid");
  302. string date1 = GetPostString("date1");
  303. string date2 = GetPostString("date2");
  304. if (tid.Length > 0 || date1.Length > 0)
  305. {
  306. lw.Add(string.Format("ctid like '%{0}%'", tid));
  307. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  308. if (dw.Length > 0) lw.Add(dw);
  309. }
  310. else
  311. {
  312. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  313. }
  314. string shopname = GetPostString("shopname");
  315. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  316. string buyernick = GetPostString("buyer_nick");
  317. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  318. string customer = GetPostString("customer");
  319. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  320. string design = GetPostString("design");
  321. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  322. string orderState = GetPostString("orderState");
  323. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  324. string address = GetPostString("address");
  325. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  326. string sellermemo = GetPostString("seller_memo");
  327. if (sellermemo.Length > 0)
  328. {
  329. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  330. }
  331. string apdate1 = GetPostString("apdate1");
  332. string apdate2 = GetPostString("apdate2");
  333. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  334. if (dwap.Length > 0) lw.Add(dwap);
  335. string price1 = GetPostString("price1");
  336. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  337. string price2 = GetPostString("price2");
  338. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  339. string isoldcustomer = GetPostString("isoldcus");
  340. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  341. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  342. if (PKey != "admin")
  343. {
  344. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  345. lw.Add(string.Format("shopId in ({0})", usershop));
  346. }
  347. //dStruct.Fileds = "tid,ctid,SplitTag,pay_time,seller_nick,buyer_nick,payment,seller_memo,OrderState,status,CustomerTb,DesignUserName,DesignPrice,end_time,WaitDesignTime,FinishDesignTime,FinishDeliveryTime,buyer_message,SupplierName,OutSid,receiver_name,receiver_mobile,receiver_state,receiver_city,receiver_address,isRefund,IsUrgency";
  348. string mainWhere = string.Join(" and ", lw.ToArray());
  349. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  350. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  351. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  352. decimal total = 0;
  353. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  354. {
  355. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  356. }
  357. var res = new
  358. {
  359. data = total
  360. };
  361. string ro_jsond = JsonConvert.SerializeObject(res);
  362. returnSuccess(ro_jsond);
  363. return;
  364. }
  365. public void get_erp_CustomerServiceGather()
  366. {
  367. string userWhere = "", orderWhere = "";
  368. List<string> lw = new List<string>();
  369. string customer = GetPostString("customer");
  370. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  371. string shopname = GetPostString("shopname");
  372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  373. string date1 = GetPostString("date1");
  374. string date2 = GetPostString("date2");
  375. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  376. if (dw.Length > 0) lw.Add(dw);
  377. orderWhere = string.Join(" and ", lw.ToArray());
  378. string sql = string.Format("select a.Name CusName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitRelease,0) WaitRelease, isnull(e.WaitRob,0) WaitRob, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  379. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  380. "left join " +
  381. "( " +
  382. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  383. ") as b on a.ID = b.CustomerUserId " +
  384. "left join " +
  385. "( " +
  386. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  387. ") as d on a.ID = d.CustomerUserId " +
  388. "left join " +
  389. "( " +
  390. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  391. ") as e on a.ID = e.CustomerUserId " +
  392. "left join " +
  393. "( " +
  394. " select CustomerUserId, RefundCount, RefundSum from " +
  395. " ( " +
  396. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  397. " from CE_ErpTradeRefund a " +
  398. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  399. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  400. " group by CustomerUserId " +
  401. " ) as a " +
  402. ") as f on a.ID = f.CustomerUserId " +
  403. "where a.PostCode = 'CustomerService'",
  404. userWhere, orderWhere);
  405. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  406. writeGridDataTableJson(dt.Rows.Count, dt);
  407. //writeGridDataTableJson(dt.Rows.Count, dt);
  408. }
  409. //设计汇总
  410. public void get_erp_DesignerGather()
  411. {
  412. string userWhere = "", orderWhere = "";
  413. List<string> lw = new List<string>();
  414. string Designer = GetPostString("designer");
  415. int org = GetPostInt("org");
  416. if (Designer.Length > 0)
  417. {
  418. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  419. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  420. }
  421. else if (org > 0)
  422. {
  423. userWhere = string.Format(" where OrgID ={0}", org);
  424. }
  425. string shopname = GetPostString("shopname");
  426. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  427. string state = GetPostString("state");
  428. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  429. string OrderArea = GetPostString("order_area");
  430. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  431. string date1 = GetPostString("date1");
  432. string date2 = GetPostString("date2");
  433. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  434. if (dw.Length > 0) lw.Add(dw);
  435. string UpDate1 = GetPostString("UpDate1");
  436. string UpDate2 = GetPostString("UpDate2");
  437. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  438. if (dw.Length > 0) lw.Add(dw);
  439. orderWhere = string.Join(" and ", lw.ToArray());
  440. string sql = string.Format("select *,cast(cast(z.DesignFinish as float) / (case z.AllOrder when 0 then 1 else z.AllOrder end) * 100 as numeric(18,2)) as FinalizationRate from (" +
  441. "select a.Name DesignerName,isnull(b.Amount,0) Amount, isnull(b.AllOrder,0) AllOrder, isnull(d.WaitDesign,0) WaitDesign, isnull(e.Designing,0) Designing, isnull(g.DesignFinish,0) DesignFinish, isnull(f.RefundCount,0) RefundCount, isnull(f.RefundSum,0) RefundSum " +
  442. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  443. "left join " +
  444. "( " +
  445. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  446. ") as b on a.ID = b.DesignUserId " +
  447. "left join " +
  448. "( " +
  449. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  450. ") as d on a.ID = d.DesignUserId " +
  451. "left join " +
  452. "( " +
  453. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  454. ") as e on a.ID = e.DesignUserId " +
  455. "left join " +
  456. "( " +
  457. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  458. ") as g on a.ID = g.DesignUserId " +
  459. "left join " +
  460. "( " +
  461. " select CustomerUserId, RefundCount, RefundSum from " +
  462. " ( " +
  463. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  464. " from CE_ErpTradeRefund a " +
  465. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  466. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  467. " group by CustomerUserId " +
  468. " ) as a " +
  469. ") as f on a.ID = f.CustomerUserId " +
  470. "where a.PostCode = 'Designer') as z",
  471. userWhere, orderWhere);
  472. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  473. writeGridDataTableJson(dt.Rows.Count, dt);
  474. }
  475. //删除tradecell的订单
  476. public void del_erp_cellorder()
  477. {
  478. if (UrlPostParmsCheck("ctid"))
  479. {
  480. string eid = GetPostString("ctid");
  481. CeErpTradeCell.DelByCtid(eid);
  482. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  483. returnSuccessMsg("删除成功");
  484. }
  485. }
  486. public void clear_erp_refundstate()
  487. {
  488. if (UrlPostParmsCheck("ids"))
  489. {
  490. string eids = GetPostString("ids");
  491. string[] ctidList = eids.Split(',');
  492. foreach (string ctid in ctidList)
  493. {
  494. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  495. if (entity != null)
  496. {
  497. entity.IsRefund = 0;
  498. entity.Update();
  499. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  500. }
  501. else
  502. continue;
  503. }
  504. returnSuccessMsg("操作成功");
  505. return;
  506. }
  507. returnErrorMsg("缺少必要参数");
  508. }
  509. public void set_erp_urgency()
  510. {
  511. if (UrlPostParmsCheck("ctid"))
  512. {
  513. string eid = GetPostString("ctid");
  514. CeErpTradeCell entity = null;
  515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  516. if (entity != null)
  517. {
  518. string utime = GetPostString("urgencytime");
  519. if (utime.Length > 0)
  520. {
  521. entity.UrgencyTime = Convert.ToDateTime(utime);
  522. }
  523. else
  524. {
  525. returnErrorMsg("请选择加急时间");
  526. return;
  527. }
  528. if (entity.OrderState <= 4)
  529. {
  530. //entity.seller_memo = entity.seller_memo + "-加急";
  531. string smemo = entity.seller_memo;
  532. int kindex = smemo.IndexOf(")");
  533. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  534. if (lastoneStr != "-")
  535. {
  536. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  537. }
  538. string prememo = smemo.Substring(0, kindex + 2);
  539. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  540. int lastkindex = lastmemo.IndexOf("(");
  541. DateTime urgtime = Convert.ToDateTime(utime);
  542. string newlastmemo = "";
  543. if (lastkindex == 0)
  544. {
  545. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  546. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  547. }
  548. else
  549. {
  550. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  551. }
  552. entity.seller_memo = prememo + newlastmemo;
  553. }
  554. entity.IsUrgency = true;
  555. entity.Update();
  556. ApiVo apiVo = new ApiVo();
  557. apiVo.orderNumber = entity.ctid;
  558. apiVo.actionName = "changeDesign";
  559. apiVo.orderRemarks = entity.seller_memo;
  560. apiVo.remarkSign = 3;
  561. designHelper.API_WorkCore(apiVo); //changeDesign
  562. CeErpSukuraData.createInfo(entity.ctid, 7);
  563. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  564. returnSuccessMsg("设置成功!");
  565. return;
  566. }
  567. returnErrorMsg("找不到记录");
  568. }
  569. }
  570. public void set_erp_reset()
  571. {
  572. if (UrlPostParmsCheck("ctid"))
  573. {
  574. string eid = GetPostString("ctid");
  575. CeErpTradeCell entity = null;
  576. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  577. if (entity != null)
  578. {
  579. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  580. {
  581. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  582. {
  583. returnErrorMsg("财务要求已下单已发货无法重置");
  584. return;
  585. }
  586. }
  587. entity.IsUrgency = false;
  588. entity.seller_memo = "";
  589. entity.OtherMemo = "";
  590. entity.OrderState = 0;
  591. entity.IsReturn = 0;
  592. //entity.IsRefund = 0;
  593. entity.MemoOpt = 0;
  594. entity.AfterSaleState = 0;
  595. entity.AfterSaleResponsible = "";
  596. entity.AfterSaleUserId = 0;
  597. entity.IsNeedBill = 0;
  598. entity.CustomerUserId = 0;
  599. entity.DesignUserId = 0;
  600. entity.SupplierId = 0;
  601. entity.PlaceUserId = 0;
  602. entity.ptid = "";
  603. entity.IsSample = 0;
  604. entity.IsXianHuo = 0;
  605. entity.isDianziOrder = 0;
  606. entity.DispatchSort = 0;
  607. entity.FinishPlaceTime = null;
  608. entity.Update();
  609. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  610. if (trade != null)
  611. {
  612. trade.seller_memo = "";
  613. trade.Update();
  614. }
  615. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  616. returnSuccessMsg("重置成功!");
  617. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  618. if (desginBill != null)
  619. {
  620. desginBill.isDel = 1;
  621. desginBill.Update();
  622. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  623. }
  624. ApiVo apiVo = new ApiVo();
  625. apiVo.orderNumber = entity.ctid;
  626. apiVo.actionName = "resetDesign";
  627. designHelper.API_WorkCore(apiVo);//resetDesign
  628. return;
  629. }
  630. returnErrorMsg("找不到记录");
  631. }
  632. }
  633. public void save_erp_sellermemo()
  634. {
  635. if (UrlPostParmsCheck("ctid"))
  636. {
  637. string ctid = GetPostString("ctid");
  638. CeErpTradeCell entity = null;
  639. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  640. if (entity != null)
  641. {
  642. string memo = GetPostString("seller_memo");
  643. memo = memo.Replace(" ", "");
  644. if (memo.Contains("补差"))
  645. {
  646. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  647. return;
  648. }
  649. if (entity.seller_memo != memo)
  650. {
  651. if (entity.IsSample == 2)
  652. {
  653. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  654. return;
  655. }
  656. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  657. {
  658. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  659. {
  660. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  661. return;
  662. }
  663. }
  664. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  665. }
  666. commonHelper.getCytPrice(entity);
  667. int memoopt = GetPostInt("MemoOpt");
  668. Boolean ismemoopt = false;
  669. if (memoopt > 0)
  670. {
  671. string stropt = "";
  672. if (memoopt == 1)
  673. {
  674. stropt = "“改稿”";
  675. ismemoopt = true;
  676. }
  677. else if (memoopt == 2)
  678. {
  679. stropt = "“定稿”";
  680. }
  681. else if (memoopt == 3)
  682. {
  683. stropt = "“查货”";
  684. CeErpSukuraData.createInfo(entity.ctid, 6);
  685. }
  686. entity.MemoOpt = Convert.ToInt32(memoopt);
  687. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  688. }
  689. if (entity.OrderState < 5)
  690. {
  691. memo = memo.Replace("(", "(");
  692. memo = memo.Replace(")", ")");
  693. }
  694. entity.seller_memo = memo;
  695. entity.Update();
  696. ApiVo apiVo = new ApiVo();
  697. apiVo.orderNumber = entity.ctid;
  698. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  699. apiVo.orderRemarks = memo;
  700. apiVo.remarkSign = memoopt;
  701. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  702. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  703. returnSuccessMsg("保存成功!");
  704. return;
  705. }
  706. returnErrorMsg("找不到记录");
  707. }
  708. }
  709. public void ins_erp_checkorder()
  710. {
  711. if (UrlPostParmsCheck("ctid"))
  712. {
  713. string ctid = GetPostString("ctid");
  714. CeErpTradeCell entity = null;
  715. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  716. if (entity != null)
  717. {
  718. if (entity.OrderState < 6)
  719. {
  720. returnErrorMsg("下单完成后才可查货");
  721. return;
  722. }
  723. /*if (entity.OrderState > 6)
  724. {
  725. returnErrorMsg("订单已发货");
  726. return;
  727. }*/
  728. if (entity.FinishPlaceTime != null)
  729. {
  730. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  731. {
  732. returnErrorMsg("下单时间不足,无法查货");
  733. return;
  734. }
  735. }
  736. entity.MemoOpt = 3;
  737. entity.CheckOrderTime = DateTime.Now;
  738. entity.Update();
  739. CeErpSukuraData.createInfo(entity.ctid, 6);
  740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  741. returnSuccessMsg("操作成功!");
  742. return;
  743. }
  744. returnErrorMsg("找不到记录");
  745. }
  746. }
  747. public void save_erp_othermemo()
  748. {
  749. if (UrlPostParmsCheck("ctid"))
  750. {
  751. string ctid = GetPostString("ctid");
  752. CeErpTradeCell entity = null;
  753. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  754. if (entity != null)
  755. {
  756. entity.OtherMemo = GetPostString("otherMemo");
  757. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  758. {
  759. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  760. StringBuilder sql = new StringBuilder();
  761. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  762. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  763. if (dt != null && dt.Rows.Count > 0)
  764. {
  765. foreach (DataRow dr in dt.Rows)
  766. {
  767. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  768. {
  769. //品类一直
  770. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  771. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  772. if (ceErpSampleCustomer == null)
  773. {
  774. ceErpSampleCustomer = new CeErpSampleCustomer();
  775. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  776. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  777. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  778. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  779. ceErpSampleCustomer.shopId = entity.ShopId;
  780. }
  781. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  782. ceErpSampleCustomer.lastTid = entity.tid;
  783. if (ceErpSampleCustomer.ID > 0)
  784. {
  785. ceErpSampleCustomer.Update();
  786. }
  787. else
  788. {
  789. ceErpSampleCustomer.Create();
  790. }
  791. }
  792. }
  793. }
  794. }
  795. //if (entity.IsOldCustomer == 1)
  796. //{
  797. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  798. //{
  799. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  800. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  801. //}
  802. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  803. //{
  804. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  805. // {
  806. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  807. // {
  808. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  809. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  810. // }
  811. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  812. // {
  813. // entity.OrderState = 2;
  814. // entity.DesignUserId = 0;
  815. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  816. // }
  817. // else
  818. // {
  819. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  820. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  821. // }
  822. // }
  823. //}
  824. //}
  825. entity.Update();
  826. returnSuccessMsg("保存成功!");
  827. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  828. return;
  829. }
  830. returnErrorMsg("找不到记录");
  831. }
  832. }
  833. public void save_erp_customermemo()
  834. {
  835. if (UrlPostParmsCheck("ctid"))
  836. {
  837. string ctid = GetPostString("ctid");
  838. CeErpTradeCell entity = null;
  839. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  840. if (entity != null)
  841. {
  842. entity.CustomerMemo = GetPostString("CustomerMemo");
  843. entity.Update();
  844. ApiVo apiVo = new ApiVo();
  845. apiVo.orderNumber = entity.ctid;
  846. apiVo.actionName = "followRemarks";
  847. apiVo.orderRemarks = entity.CustomerMemo;
  848. designHelper.API_WorkCore(apiVo);//followRemarks
  849. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  850. returnSuccessMsg("保存成功!");
  851. return;
  852. }
  853. returnErrorMsg("找不到记录");
  854. }
  855. }
  856. public void upd_erp_addmemotag()
  857. {
  858. if (UrlPostParmsCheck("ctid"))
  859. {
  860. ;
  861. string eid = GetPostString("ctid");
  862. string sfTagstr = GetPostString("memotag");
  863. CeErpTradeCell entity = null;
  864. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  865. if (entity != null)
  866. {
  867. if (entity.OrderState == 0)
  868. {
  869. returnErrorMsg("请先领单");
  870. return;
  871. }
  872. //撤销顺丰
  873. if (sfTagstr == "撤销顺丰")
  874. {
  875. entity.IsSF = 0;
  876. string reMsg = "";
  877. string oldmemo = entity.seller_memo;
  878. if (entity.OrderState < 5)
  879. {
  880. oldmemo = oldmemo.Replace("顺丰到付", "");
  881. oldmemo = oldmemo.Replace("顺丰寄付", "");
  882. entity.seller_memo = oldmemo;
  883. }
  884. else
  885. {
  886. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  887. {
  888. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  889. }
  890. }
  891. entity.Update();
  892. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  893. api.orderNumber = entity.ctid;
  894. api.actionName = "followRemarks";
  895. api.orderRemarks = entity.seller_memo;
  896. api.isSf = entity.IsSF.ToString();
  897. designHelper.API_WorkCore(api);//followRemarks
  898. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  899. returnSuccessMsg("撤销成功!" + reMsg);
  900. return;
  901. }
  902. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  903. {
  904. //string oldmemo = entity.seller_memo;
  905. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  906. string sfStr = GetPostString("memotag");
  907. string smemo = entity.seller_memo;
  908. int kindex = smemo.IndexOf(")");
  909. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  910. if (lastoneStr != "-")
  911. {
  912. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  913. }
  914. string prememo = smemo.Substring(0, kindex + 2);
  915. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  916. int lastkindex = lastmemo.IndexOf("(");
  917. string newlastmemo = "";
  918. if (lastkindex == 0)
  919. {
  920. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  921. newlastmemo = "(" + sfStr + "." + useLastmemo;
  922. }
  923. else
  924. {
  925. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  926. }
  927. entity.seller_memo = prememo + newlastmemo;
  928. }
  929. string sfTagMSg = "";
  930. if (sfTagstr == "顺丰寄付")
  931. {
  932. entity.IsSF = 1;
  933. sfTagMSg = "顺丰寄付";
  934. }
  935. else if (sfTagstr == "顺丰到付")
  936. {
  937. entity.IsSF = 2;
  938. sfTagMSg = "顺丰到付";
  939. }
  940. entity.Update();
  941. ApiVo apiVo = new ApiVo();
  942. apiVo.orderNumber = entity.ctid;
  943. apiVo.actionName = "orderRemarks";
  944. apiVo.orderRemarks = entity.seller_memo;
  945. apiVo.isSf = entity.IsSF.ToString();
  946. designHelper.API_WorkCore(apiVo);//orderRemarks
  947. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  948. returnSuccessMsg("标记成功!");
  949. return;
  950. }
  951. returnErrorMsg("找不到记录");
  952. }
  953. }
  954. public void upd_erp_ordertag()
  955. {
  956. if (UrlPostParmsCheck("ctid"))
  957. {
  958. string eid = GetPostString("ctid");
  959. CeErpTradeCell entity = null;
  960. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  961. if (entity != null)
  962. {
  963. int tag = GetPostInt("wechattag");
  964. //if(tag==4 && entity.IsSample == 2)
  965. //{
  966. // returnErrorMsg("补差价单不能标记微信单");
  967. // return;
  968. //}
  969. entity.wechatTag = tag;
  970. entity.Update();
  971. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  972. if (tag == 1)
  973. {
  974. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  975. if (cash == null)
  976. {
  977. CeErpTrade main = CeErpTrade.Get(entity.tid);
  978. cash = new CeErpReturnCash();
  979. cash.tid = entity.tid;
  980. cash.seller_nick = main.seller_nick;
  981. cash.payment = trade.payment;
  982. cash.buyer_nick = main.buyer_nick;
  983. cash.cashstate = 0;
  984. cash.rtype = "微信返现";
  985. cash.returnprice = 0;
  986. cash.created = DateTime.Now;
  987. cash.con = "订单标记微信单";
  988. cash.img = "";
  989. cash.applyuserid = CurrentUser.UserID;
  990. cash.Create();
  991. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  992. }
  993. else
  994. {
  995. cash.cashstate = 0;
  996. cash.Update();
  997. }
  998. CeErpSukuraData.createInfo(entity.ctid, 9);
  999. }
  1000. else if (tag == 2)
  1001. {
  1002. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1003. if (cash == null)
  1004. {
  1005. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1006. cash = new CeErpReturnCash();
  1007. cash.tid = entity.tid;
  1008. cash.seller_nick = main.seller_nick;
  1009. cash.payment = trade.payment;
  1010. cash.buyer_nick = main.buyer_nick;
  1011. cash.cashstate = 0;
  1012. cash.rtype = "推购返现";
  1013. cash.returnprice = 5;
  1014. cash.created = DateTime.Now;
  1015. cash.con = "订单标记推购单";
  1016. cash.img = "";
  1017. cash.applyuserid = CurrentUser.UserID;
  1018. cash.Create();
  1019. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1020. }
  1021. else
  1022. {
  1023. cash.cashstate = 0;
  1024. cash.Update();
  1025. }
  1026. CeErpSukuraData.createInfo(entity.ctid, 9);
  1027. }
  1028. else if (tag == 3)
  1029. {
  1030. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1031. if (pers == null)
  1032. {
  1033. pers = new CeErpPersuade();
  1034. pers.ctid = entity.ctid;
  1035. pers.pstate = 0;
  1036. pers.created = DateTime.Now;
  1037. pers.applyuserid = CurrentUser.UserID;
  1038. pers.Create();
  1039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1040. }
  1041. else
  1042. {
  1043. pers.pstate = 0;
  1044. pers.Update();
  1045. }
  1046. }
  1047. else if (tag == 4 || tag == 5)
  1048. {
  1049. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1050. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1051. if (pers == null)
  1052. {
  1053. pers = new CeErpStayGoods();
  1054. pers.t_id = entity.tid;
  1055. pers.status = "待审核";
  1056. pers.audit_type = 0;
  1057. if (tag == 4)
  1058. {
  1059. pers.stay_type = "微信推购";
  1060. }
  1061. else
  1062. {
  1063. pers.stay_type = "旺旺推购";
  1064. }
  1065. if (entity.IsXianHuo == 0)
  1066. {
  1067. pers.product_id = entity.ProductId;
  1068. }
  1069. pers.wangwang = main.buyer_nick;
  1070. pers.shop_name = main.seller_nick;
  1071. pers.creata_time = DateTime.Now;
  1072. pers.create_u_id = CurrentUser.UserID;
  1073. pers.create_u_name = CurrentUser.UserName;
  1074. pers.Create();
  1075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1076. }
  1077. else
  1078. {
  1079. pers.audit_type = 0;
  1080. pers.Update();
  1081. }
  1082. CeErpSukuraData.createInfo(entity.ctid, 10);
  1083. }
  1084. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1085. returnSuccessMsg("标记成功!");
  1086. return;
  1087. }
  1088. returnErrorMsg("找不到记录");
  1089. }
  1090. }
  1091. public void upd_erp_ordertag_cancel()
  1092. {
  1093. if (UrlPostParmsCheck("ctid"))
  1094. {
  1095. string eid = GetPostString("ctid");
  1096. CeErpTradeCell entity = null;
  1097. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1098. if (entity != null)
  1099. {
  1100. entity.wechatTag = 0;
  1101. entity.Update();
  1102. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1103. if (pers != null)
  1104. {
  1105. pers.status = "取消推购";
  1106. pers.audit_type = 3;
  1107. pers.Update();
  1108. }
  1109. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1110. returnSuccessMsg("标记成功!");
  1111. return;
  1112. }
  1113. returnErrorMsg("找不到记录");
  1114. }
  1115. }
  1116. public void upd_erp_addweichattag()
  1117. {
  1118. if (UrlPostParmsCheck("ctid"))
  1119. {
  1120. ;
  1121. string eid = GetPostString("ctid");
  1122. CeErpTradeCell entity = null;
  1123. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1124. if (entity != null)
  1125. {
  1126. if (entity.IsAddWechat > 0)
  1127. {
  1128. returnErrorMsg("此单已经标记过了");
  1129. return;
  1130. }
  1131. 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);
  1132. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1133. if (dt.Rows.Count > 0)
  1134. {
  1135. entity.IsAddWechat = 2;
  1136. }
  1137. else
  1138. {
  1139. entity.IsAddWechat = 1;
  1140. }
  1141. entity.Update();
  1142. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1143. returnSuccessMsg("标记成功!");
  1144. return;
  1145. }
  1146. returnErrorMsg("找不到记录");
  1147. }
  1148. }
  1149. public void upd_erp_getmyorder()
  1150. {
  1151. if (UrlPostParmsCheck("ctid"))
  1152. {
  1153. ;
  1154. string eid = GetPostString("ctid");
  1155. CeErpTradeCell entity = null;
  1156. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1157. if (entity != null)
  1158. {
  1159. if (entity.ctid.IndexOf("C") != -1)
  1160. {
  1161. StringBuilder sql = new StringBuilder();
  1162. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1163. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1164. if (dt.Rows.Count > 0)
  1165. {
  1166. decimal total = 0;
  1167. foreach (DataRow dr in dt.Rows)
  1168. {
  1169. total += Convert.ToDecimal(dr["payment"]);
  1170. }
  1171. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1172. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1173. {
  1174. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1175. return;
  1176. }
  1177. }
  1178. }
  1179. entity.CustomerUserId = CurrentUser.UserID;
  1180. if (entity.OrderState < 2)
  1181. {
  1182. entity.OrderState = 2;
  1183. if (entity.ShopId != 0)
  1184. {
  1185. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1186. }
  1187. }
  1188. entity.Update();
  1189. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1190. returnSuccessMsg("领单成功!");
  1191. return;
  1192. }
  1193. returnErrorMsg("找不到记录");
  1194. }
  1195. }
  1196. public void getmyorder_from_init()
  1197. {
  1198. if (UrlPostParmsCheck("ctid"))
  1199. {
  1200. string eid = GetPostString("ctid");
  1201. CeErpTradeCell entity = null;
  1202. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1203. if (entity != null)
  1204. {
  1205. string sellerMemo = GetPostString("sellerMemo");
  1206. if (sellerMemo.Length > 0)
  1207. {
  1208. entity.seller_memo = sellerMemo;
  1209. }
  1210. string oterhMemo = GetPostString("otherMemo");
  1211. if (oterhMemo.Length > 0)
  1212. {
  1213. entity.OtherMemo = oterhMemo;
  1214. }
  1215. int urg = GetPostInt("urgency");
  1216. entity.IsUrgency = (urg == 1 ? true : false);
  1217. int wechat = GetPostInt("wechat");
  1218. int command = GetPostInt("command");
  1219. if (wechat == 1)
  1220. {
  1221. entity.wechatTag = 1;
  1222. }
  1223. if (command == 1)
  1224. {
  1225. entity.wechatTag = 2;
  1226. }
  1227. string pPro = GetPostString("pprofession");
  1228. if (pPro.Length > 0)
  1229. {
  1230. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1231. string spro = GetPostString("profession");
  1232. if (spro.Length > 0)
  1233. {
  1234. entity.ProfessionId = Convert.ToInt32(spro);
  1235. }
  1236. }
  1237. string proId = GetPostString("productId");
  1238. if (proId.Length > 0)
  1239. {
  1240. entity.ProductId = Convert.ToInt32(proId);
  1241. }
  1242. entity.Material = GetPostString("material");
  1243. entity.Craft = GetPostString("craft");
  1244. entity.CustomerUserId = CurrentUser.UserID;
  1245. if (entity.OrderState < 2)
  1246. {
  1247. entity.OrderState = 2;
  1248. if (entity.ShopId != 0)
  1249. {
  1250. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1251. }
  1252. }
  1253. entity.Update();
  1254. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1255. returnSuccessMsg("领单成功!");
  1256. return;
  1257. }
  1258. returnErrorMsg("找不到记录");
  1259. }
  1260. }
  1261. public void upd_erp_setrelationorder()
  1262. {
  1263. if (UrlPostParmsCheck("ctid"))
  1264. {
  1265. ;
  1266. string eid = GetPostString("ctid");
  1267. string ftid = GetPostString("ftid");
  1268. CeErpTradeCell entity = null;
  1269. CeErpTradeCell fentity = null;
  1270. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1271. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1272. if (fentity == null)
  1273. {
  1274. returnErrorMsg("找不到关联的主订单");
  1275. return;
  1276. }
  1277. if (entity != null)
  1278. {
  1279. if (entity.OrderState >= 5)
  1280. {
  1281. returnErrorMsg("本单已经设计完成无法关联");
  1282. return;
  1283. }
  1284. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1285. {
  1286. returnErrorMsg("线下单续审核后才能关联!");
  1287. return;
  1288. }
  1289. entity.ptid = ftid;
  1290. entity.OrderState = fentity.OrderState;
  1291. //entity.status = fentity.status;
  1292. entity.CustomerUserId = fentity.CustomerUserId;
  1293. entity.DesignUserId = fentity.DesignUserId;
  1294. entity.seller_memo = "补差价单:" + ftid;
  1295. entity.IsSample = 2;
  1296. entity.Update();
  1297. ApiVo apiVo = new ApiVo();
  1298. apiVo.orderNumber = ftid;
  1299. apiVo.payment = entity.payment;
  1300. apiVo.actionName = "repairDesign";
  1301. designHelper.API_WorkCore(apiVo);//repairDesign
  1302. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1303. returnSuccessMsg("关联成功!");
  1304. return;
  1305. }
  1306. else
  1307. returnErrorMsg("找不到记录");
  1308. }
  1309. }
  1310. public void download_erp_neworder()
  1311. {
  1312. string seller = GetPostString("seller_nick");
  1313. string tid = GetPostString("tid");
  1314. if (seller.Length <= 0 || tid.Length <= 0)
  1315. {
  1316. returnErrorMsg("数据错误");
  1317. }
  1318. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1319. //{
  1320. // returnErrorMsg("找不到店铺Sessionkey");
  1321. //}
  1322. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1323. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1324. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1325. if (res.IndexOf("refOid") == -1)
  1326. {
  1327. returnErrorMsg("下载订单数据失败");
  1328. return;
  1329. }
  1330. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1331. returnSuccessMsg("下载完成");
  1332. //tmcHelper.createNewOrder(res);
  1333. //CeErpTrade entr = null;
  1334. //entr = CeErpTrade.Get(tid);
  1335. //if (entr != null)
  1336. //{
  1337. // returnSuccess("下载成功");
  1338. // //下载成功之后,Cell表生成对应的订单;
  1339. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1340. //}
  1341. //else
  1342. //{
  1343. // returnErrorMsg("下载失败或者创建订单失败");
  1344. //}
  1345. }
  1346. public void set_erp_atersale()
  1347. {
  1348. if (UrlPostParmsCheck("ctid"))
  1349. {
  1350. string eid = GetPostString("ctid");
  1351. string reason = GetPostString("AfterSaleReason");
  1352. CeErpTradeCell entity = null;
  1353. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1354. if (entity != null)
  1355. {
  1356. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1357. {
  1358. returnErrorMsg("此订单已经在售后");
  1359. return;
  1360. }
  1361. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1362. //entity.AfterSaleReason = reason;
  1363. entity.AfterSaleTime = DateTime.Now;
  1364. entity.Update();
  1365. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1366. returnSuccessMsg("转售后成功!");
  1367. return;
  1368. }
  1369. returnErrorMsg("找不到记录");
  1370. }
  1371. }
  1372. public void set_erp_withdraw()
  1373. {
  1374. if (UrlPostParmsCheck("ctid"))
  1375. {
  1376. try
  1377. {
  1378. string eid = GetPostString("ctid");//商品id
  1379. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1380. CeWithdraw ceWithdrawSelect = null;
  1381. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1382. if (ceWithdrawSelect != null)
  1383. {
  1384. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1385. {
  1386. ceWithdrawSelect.status = -1;
  1387. ceWithdrawSelect.Update();
  1388. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1389. returnSuccessMsg("重新发起审核成功");
  1390. return;
  1391. }
  1392. else
  1393. {
  1394. returnSuccessMsg("请勿重复申请!");
  1395. return;
  1396. }
  1397. }
  1398. else
  1399. {
  1400. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1401. if (string.IsNullOrEmpty(CustomerUserId))
  1402. {
  1403. CustomerUserId = "-1";
  1404. }
  1405. int Userid = CurrentUser.UserID;//用户id
  1406. CeWithdraw ceWithdraw = new CeWithdraw();
  1407. ceWithdraw.tid = eid;
  1408. ceWithdraw.userid = Userid;
  1409. ceWithdraw.providerid = CustomerUserId;
  1410. ceWithdraw.status = 3;
  1411. ceWithdraw.creationtime = DateTime.Now;
  1412. ceWithdraw.Create();
  1413. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1414. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1415. return;
  1416. }
  1417. }
  1418. catch
  1419. {
  1420. returnErrorMsg("申请撤回订单失败");
  1421. return;
  1422. }
  1423. }
  1424. }
  1425. public void ins_erp_billinfo()
  1426. {
  1427. if (UrlPostParmsCheck("ctid"))
  1428. {
  1429. string eid = GetPostString("ctid");
  1430. CeErpTradeCell entity = null;
  1431. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1432. if (entity != null)
  1433. {
  1434. CeErpBill bill = CeErpBill.GetByTid(eid);
  1435. bool isHave = false;
  1436. if (bill != null)
  1437. {
  1438. isHave = true;
  1439. if (bill.state != 4)
  1440. {
  1441. returnErrorMsg("此单已经申请过发票了");
  1442. return;
  1443. }
  1444. }
  1445. if (entity.IsNeedBill == 0)
  1446. {
  1447. entity.IsNeedBill = 1;
  1448. }
  1449. entity.Update();
  1450. string errjson = "";
  1451. try
  1452. {
  1453. CeErpBill bill_entity = new CeErpBill();
  1454. bill_entity.tid = entity.tid;
  1455. bill_entity.title = GetPostString("title");
  1456. string taxstr = GetPostString("tax");
  1457. taxstr = taxstr.Replace(" ", "");
  1458. bill_entity.tax = taxstr;
  1459. bill_entity.bank = GetPostString("bank");
  1460. string bankacstr = GetPostString("bankac");
  1461. bankacstr = bankacstr.Replace(" ", "");
  1462. bill_entity.bankac = bankacstr;
  1463. bill_entity.address = GetPostString("address");
  1464. bill_entity.phone = GetPostString("phone");
  1465. bill_entity.price = GetPostString("price");
  1466. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1467. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1468. {
  1469. billCount += 1;
  1470. }
  1471. string prebill = "ltb";
  1472. for (int idx = 1; idx <= billCount; idx++)
  1473. {
  1474. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1475. string billoid = prebill + idx + dtstr;
  1476. bill_entity.billOrderId += billoid;
  1477. if (idx < billCount)
  1478. {
  1479. bill_entity.billOrderId += ",";
  1480. }
  1481. }
  1482. bill_entity.productId = GetPostInt("ProductName");
  1483. bill_entity.num = GetPostInt("num");
  1484. bill_entity.unit = GetPostString("unit");
  1485. bill_entity.type = GetPostString("type");
  1486. bill_entity.sendType = GetPostString("SendType");
  1487. bill_entity.email = GetPostString("email");
  1488. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1489. bill_entity.shopName = GetPostString("ShopName");
  1490. bill_entity.applymemo = GetPostString("applyMemo");
  1491. bill_entity.createTime = DateTime.Now;
  1492. bill_entity.state = 0;
  1493. bill_entity.userId = CurrentUser.UserID;
  1494. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1495. bill_entity.Create();
  1496. }
  1497. catch (Exception ex)
  1498. {
  1499. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1500. returnErrorMsg("创建发票出错!");
  1501. return;
  1502. }
  1503. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1504. returnSuccessMsg("发票申请成功!");
  1505. return;
  1506. }
  1507. returnErrorMsg("找不到记录");
  1508. }
  1509. }
  1510. public void ins_erp_neworder()
  1511. {
  1512. if (UrlPostParmsCheck("receiver_name"))
  1513. {
  1514. CeErpTrade entity = new CeErpTrade();
  1515. string plat_form = GetPostString("platform");
  1516. string preStr = "N_";
  1517. if (plat_form == "拼多多")
  1518. {
  1519. preStr = "P_";
  1520. }
  1521. else if (plat_form == "阿里巴巴")
  1522. {
  1523. preStr = "A_";
  1524. }
  1525. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1526. entity.seller_nick = GetPostString("seller_nick");
  1527. entity.buyer_nick = GetPostString("buyer_nick");
  1528. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1529. entity.total_fee = entity.payment;
  1530. entity.pay_time = DateTime.Now;
  1531. entity.status = "NOT_SHIPPED";
  1532. entity.receiver_name = GetPostString("receiver_name");
  1533. entity.receiver_mobile = GetPostString("receiver_mobile");
  1534. entity.receiver_state = GetPostString("receiver_state");
  1535. entity.receiver_city = GetPostString("receiver_city");
  1536. entity.receiver_district = GetPostString("receiver_district");
  1537. entity.receiver_address = GetPostString("receiver_address");
  1538. if (entity.receiver_state == "" || entity.receiver_city == "")
  1539. {
  1540. returnErrorMsg("收件地址不能为空");
  1541. return;
  1542. }
  1543. int shopId = 0;
  1544. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1545. if (nShop != null)
  1546. {
  1547. shopId = nShop.ID;
  1548. }
  1549. if (shopId != 34 && entity.payment == 0)
  1550. {
  1551. returnErrorMsg("公司自用的单金额才能为0");
  1552. return;
  1553. }
  1554. entity.Create();
  1555. CeErpTradeCell entitycell = new CeErpTradeCell();
  1556. entitycell.ctid = entity.tid;
  1557. entitycell.tid = entity.tid;
  1558. entitycell.ShopId = shopId;
  1559. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1560. entitycell.OrderState = 0;
  1561. entitycell.pay_time = entity.pay_time;
  1562. entitycell.IsOffLineOrder = 1;
  1563. entitycell.Create();
  1564. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1565. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1566. return;
  1567. }
  1568. }
  1569. public void ins_erp_neworder2()
  1570. {
  1571. if (UrlPostParmsCheck("receiver_name"))
  1572. {
  1573. //string plat_form = GetPostString("platform");
  1574. string preStr = "X_";
  1575. string memo = GetPostString("memo");
  1576. string productId = GetPostString("productId");
  1577. string primg = GetPostString("proofimg");
  1578. string sellerNick = GetPostString("seller_nick");
  1579. string addFrom = GetPostString("addfrom");
  1580. if (addFrom == "1")
  1581. {
  1582. preStr = "N_";
  1583. }
  1584. int shopId = 0;
  1585. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1586. if (nShop != null)
  1587. {
  1588. shopId = nShop.ID;
  1589. }
  1590. else
  1591. {
  1592. returnErrorMsg("找不到对应店铺");
  1593. return;
  1594. }
  1595. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1596. {
  1597. returnErrorMsg("必须上传付款凭证");
  1598. return;
  1599. }
  1600. CeErpTrade entity = new CeErpTrade();
  1601. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1602. entity.seller_nick = sellerNick;
  1603. entity.buyer_nick = GetPostString("buyer_nick");
  1604. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1605. entity.total_fee = entity.payment;
  1606. entity.pay_time = DateTime.Now;
  1607. entity.status = "NOT_SHIPPED";
  1608. entity.receiver_name = GetPostString("receiver_name");
  1609. entity.receiver_mobile = GetPostString("receiver_mobile");
  1610. entity.receiver_state = GetPostString("receiver_state");
  1611. entity.receiver_city = GetPostString("receiver_city");
  1612. entity.receiver_district = GetPostString("receiver_district");
  1613. entity.receiver_address = GetPostString("receiver_address");
  1614. entity.seller_memo = memo;
  1615. entity.orderFrom = 20;
  1616. entity.orderType = 15;
  1617. if (entity.receiver_state == "" || entity.receiver_city == "")
  1618. {
  1619. returnErrorMsg("收件地址不能为空");
  1620. return;
  1621. }
  1622. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1623. {
  1624. returnErrorMsg("公司自用的单金额才能为0");
  1625. return;
  1626. }
  1627. entity.Create();
  1628. string toWhere = GetPostString("towhere");
  1629. CeErpTradeCell entitycell = new CeErpTradeCell();
  1630. entitycell.ctid = entity.tid;
  1631. //唯一标识
  1632. entitycell.OrderSn = entity.tid;
  1633. string orderSn = dataHelper.getSaleOrderSn();
  1634. if (orderSn != "")
  1635. {
  1636. entitycell.OrderSn = orderSn;
  1637. }
  1638. entitycell.tid = entity.tid;
  1639. //if (preStr == "X_")
  1640. //{
  1641. entitycell.IsOffLineOrder = 1;
  1642. //}
  1643. entitycell.CustomerUserId = CurrentUser.UserID;
  1644. entitycell.PayProofImg = primg;
  1645. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1646. entitycell.ProductId = Convert.ToInt32(productId);
  1647. entitycell.ShopId = shopId;
  1648. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1649. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1650. {
  1651. entitycell.IsXianHuo = 1;
  1652. }
  1653. entitycell.pay_time = entity.pay_time;
  1654. if (toWhere == "1")
  1655. {
  1656. entitycell.OrderState = 2;
  1657. }
  1658. else
  1659. {
  1660. entitycell.OrderState = 6;
  1661. entitycell.FinishPlaceTime = entitycell.pay_time;
  1662. }
  1663. if (shopId == 94)
  1664. {
  1665. entitycell.OrderState = 4;
  1666. entitycell.WaitDesignTime = entitycell.pay_time;
  1667. entitycell.StartDesignTime = entitycell.pay_time;
  1668. entitycell.DesignUserId = 218;
  1669. }
  1670. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1671. {
  1672. entitycell.OrderState = -1;//修改12-5
  1673. CeWithdraw ceWithdraw = new CeWithdraw();
  1674. ceWithdraw.tid = entity.tid;
  1675. ceWithdraw.providerid = "-1";
  1676. ceWithdraw.status = -1;
  1677. ceWithdraw.creationtime = DateTime.Now;
  1678. ceWithdraw.userid = 1337;
  1679. ceWithdraw.Create();
  1680. }
  1681. entitycell.Create();
  1682. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1683. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1684. {
  1685. addPlaceRegist(entitycell, CurrentUser.UserID);
  1686. }
  1687. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1688. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1689. return;
  1690. }
  1691. }
  1692. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1693. {
  1694. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1695. entity.PlactTime = tradecell.pay_time;
  1696. entity.AddUserId = userid;
  1697. entity.FileName = tradecell.seller_memo;
  1698. entity.Supplier = 24;
  1699. entity.CreateTime = DateTime.Now;
  1700. entity.Did = tradecell.ctid;
  1701. entity.tid = tradecell.tid;
  1702. entity.splitTag = tradecell.SplitTag;
  1703. entity.CurState = "未完成";
  1704. entity.Create();
  1705. }
  1706. public void get_erp_offlinelist()
  1707. {
  1708. DataStruct dStruct = GetPostStruct();
  1709. List<string> lw = new List<string>();
  1710. string tid = GetPostString("ctid");
  1711. string date1 = GetPostString("date1");
  1712. string date2 = GetPostString("date2");
  1713. if (tid.Length > 0 || date1.Length > 0)
  1714. {
  1715. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1716. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1717. if (dw.Length > 0) lw.Add(dw);
  1718. }
  1719. else
  1720. {
  1721. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1722. }
  1723. string shopname = GetPostString("shopname");
  1724. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1725. string buyernick = GetPostString("buyer_nick");
  1726. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1727. string customer = GetPostString("customer");
  1728. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1729. string design = GetPostString("design");
  1730. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1731. string orderState = GetPostString("orderState");
  1732. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1733. string address = GetPostString("address");
  1734. 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));
  1735. string sellermemo = GetPostString("seller_memo");
  1736. if (sellermemo.Length > 0)
  1737. {
  1738. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1739. }
  1740. string price1 = GetPostString("price1");
  1741. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1742. string price2 = GetPostString("price2");
  1743. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1744. //if (PKey != "admin")
  1745. //{
  1746. // string usershop = CurrentUser.User.pemShop;
  1747. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1748. //}
  1749. //if (ex_psize > 0)
  1750. //{
  1751. dStruct.Order = "pay_time desc";
  1752. //}
  1753. //else
  1754. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1755. lw.Add(string.Format("IsOffLineOrder=1"));
  1756. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1757. DataTable dt = null;
  1758. dt = WebCache.GetData("view_erptradecell", dStruct);
  1759. writeGridDataTableJson(dStruct.TotalCount, dt);
  1760. }
  1761. public void get_erp_returncashrecord()
  1762. {
  1763. DataStruct dStruct = GetPostStruct();
  1764. List<string> lw = new List<string>();
  1765. string tid = GetPostString("ctid");
  1766. if (tid.Length > 0)
  1767. {
  1768. lw.Add(string.Format("tid like '%{0}%'", tid));
  1769. dStruct.Order = "id desc";
  1770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1771. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1772. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1773. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1774. return;
  1775. }
  1776. returnErrorMsg("id数据错误!");
  1777. }
  1778. public void ins_erp_returncashrecord()
  1779. {
  1780. if (UrlPostParmsCheck("tid"))
  1781. {
  1782. string tid = GetPostString("tid");
  1783. string retype = GetPostString("type");
  1784. StringBuilder sql = new StringBuilder();
  1785. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1786. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1787. if (dt.Rows.Count > 0)
  1788. {
  1789. returnErrorMsg("相同返现类型记录已存在");
  1790. return;
  1791. }
  1792. CeErpReturnCash entity = new CeErpReturnCash();
  1793. entity.tid = tid;
  1794. entity.seller_nick = GetPostString("seller_nick");
  1795. string pment = GetPostString("payment");
  1796. if (pment.Length > 0)
  1797. {
  1798. entity.payment = Convert.ToDouble(pment);
  1799. }
  1800. entity.buyer_nick = GetPostString("buyer_nick");
  1801. entity.cashstate = 0;
  1802. entity.rtype = retype;
  1803. string rPrice = GetPostString("returnprice");
  1804. if (rPrice.Length > 0)
  1805. {
  1806. entity.returnprice = Convert.ToDouble(rPrice);
  1807. }
  1808. entity.created = DateTime.Now;
  1809. entity.con = GetPostString("con");
  1810. entity.img = GetPostString("img");
  1811. entity.applyuserid = CurrentUser.UserID;
  1812. entity.Create();
  1813. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1814. returnSuccessMsg("操作成功!");
  1815. return;
  1816. }
  1817. }
  1818. public void set_erp_predelivery()
  1819. {
  1820. if (UrlPostParmsCheck("ctid"))
  1821. {
  1822. string eid = GetPostString("ctid");
  1823. CeErpTradeCell entity = null;
  1824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1825. if (entity != null)
  1826. {
  1827. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1828. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1829. //{
  1830. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1831. // return;
  1832. //}
  1833. entity.IsPreDelivery = 1;
  1834. entity.Update();
  1835. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1836. returnSuccessMsg("预发货成功!");
  1837. return;
  1838. //string shop = GetPostString("seller_nick");
  1839. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1840. //string comName = GetPostString("comName");
  1841. //string comCode = GetPostString("comCode");
  1842. //string outSid = GetPostString("outSid");//运单号
  1843. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1844. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1845. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1846. //string apires = "";
  1847. //if (deliveryType == "虚拟发货")
  1848. //{
  1849. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1850. //}
  1851. //else
  1852. //{
  1853. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1854. //}
  1855. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1856. ////{
  1857. //if (apires.IndexOf("发货成功") != -1)
  1858. //{
  1859. // if (deliveryType != "虚拟发货")
  1860. // {
  1861. // //还要插入快递信息到 快递信息表
  1862. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1863. // exinfo.tid = eid;
  1864. // exinfo.out_sid = outSid;
  1865. // exinfo.company_code = comCode;
  1866. // exinfo.company_name = comName;
  1867. // exinfo.delivery_memo = deliveryMemo;
  1868. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1869. // exinfo.deliveryType = deliveryType;
  1870. // exinfo.Create();
  1871. // }
  1872. // returnSuccessMsg("发货成功!");
  1873. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1874. //}
  1875. //else
  1876. //{
  1877. // returnErrorMsg("淘宝发货失败!!");
  1878. //}
  1879. //return;
  1880. }
  1881. returnErrorMsg("找不到订单记录");
  1882. }
  1883. }
  1884. public void get_erp_unusuallist()
  1885. {
  1886. DataStruct dStruct = GetPostStruct();
  1887. List<string> lw = new List<string>();
  1888. string tid = GetPostString("ctid");
  1889. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1890. string shopname = GetPostString("shopname");
  1891. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1892. string buyernick = GetPostString("buyer_nick");
  1893. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1894. string ResponsibleMan = GetPostString("responsible");
  1895. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1896. string date1 = GetPostString("date1");
  1897. string date2 = GetPostString("date2");
  1898. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1899. if (dw.Length > 0) lw.Add(dw);
  1900. string price1 = GetPostString("price1");
  1901. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1902. string price2 = GetPostString("price2");
  1903. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1904. string orderState = GetPostString("orderState");
  1905. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1906. string sellermemo = GetPostString("seller_memo");
  1907. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1908. lw.Add(string.Format("UnusualTag > 0"));
  1909. lw.Add(string.Format("IsRefund<={0}", 1));
  1910. dStruct.Order = "pay_time desc";
  1911. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1912. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1913. writeGridDataTableJson(dStruct.TotalCount, dt);
  1914. }
  1915. public void set_erp_unusualtonomal()
  1916. {
  1917. if (UrlPostParmsCheck("ctid"))
  1918. {
  1919. string eid = GetPostString("ctid");
  1920. CeErpTradeCell entity = null;
  1921. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1922. if (entity != null)
  1923. {
  1924. entity.UnusualTag = -1;
  1925. entity.Update();
  1926. returnSuccessMsg("忽略成功!");
  1927. return;
  1928. }
  1929. returnErrorMsg("找不到记录");
  1930. }
  1931. }
  1932. public void ins_erp_unusualreason()
  1933. {
  1934. if (UrlPostParmsCheck("ctid"))
  1935. {
  1936. string eid = GetPostString("ctid");
  1937. CeErpTradeCell entity = null;
  1938. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1939. if (entity != null)
  1940. {
  1941. entity.MemoOpt = 4;
  1942. entity.UnusualCon = GetPostString("con");
  1943. entity.Update();
  1944. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1945. if (trade != null)
  1946. {
  1947. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1948. }
  1949. //查货是否超时
  1950. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1951. if (ceErpTradeCellExtend == null)
  1952. {
  1953. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1954. ceErpTradeCellExtend.ctid = entity.ctid;
  1955. }
  1956. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1957. {
  1958. ceErpTradeCellExtend.CheckOut += 1;
  1959. }
  1960. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1961. if (ceErpTradeCellExtend.ID > 0)
  1962. {
  1963. ceErpTradeCellExtend.Update();
  1964. }
  1965. else
  1966. {
  1967. ceErpTradeCellExtend.Create();
  1968. }
  1969. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1970. returnSuccessMsg("操作成功!");
  1971. return;
  1972. }
  1973. returnErrorMsg("找不到记录");
  1974. }
  1975. }
  1976. public void upd_erp_sampleorder()
  1977. {
  1978. if (UrlPostParmsCheck("ctid"))
  1979. {
  1980. string eid = GetPostString("ctid");
  1981. string[] eArr = eid.Split(',');
  1982. if (eArr.Length > 1)
  1983. {
  1984. List<string> eLst = new List<string>();
  1985. for (int i = 0; i < eArr.Length; i++)
  1986. {
  1987. eLst.Add("'" + eArr[i] + "'");
  1988. }
  1989. eid = string.Join(",", eLst.ToArray());
  1990. }
  1991. else
  1992. {
  1993. eid = "'" + eid + "'";
  1994. }
  1995. StringBuilder sql = new StringBuilder();
  1996. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1997. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1998. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1999. if (dt.Rows.Count > 0)
  2000. {
  2001. string errmsg = "";
  2002. foreach (DataRow dr in dt.Rows)
  2003. {
  2004. StringBuilder sqlsb = new StringBuilder();
  2005. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2006. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2007. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2008. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2009. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2010. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2011. {
  2012. continue;
  2013. }
  2014. else
  2015. {
  2016. string emsg = commonHelper.KeepChinese(apires);
  2017. errmsg += emsg;
  2018. }
  2019. }
  2020. if (errmsg.Length > 0)
  2021. {
  2022. returnErrorMsg(errmsg);
  2023. return;
  2024. }
  2025. returnSuccessMsg("操作成功");
  2026. return;
  2027. }
  2028. returnErrorMsg("找不到记录");
  2029. }
  2030. }
  2031. public void upd_erp_transcustomer()
  2032. {
  2033. if (UrlPostParmsCheck("ctid"))
  2034. {
  2035. string eid = GetPostString("ctid");
  2036. int userid = GetPostInt("CustomerUserId");
  2037. CeErpTradeCell entity = null;
  2038. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2039. if (entity != null)
  2040. {
  2041. //string[] mlist = entity.seller_memo.Split('-');
  2042. //string sql = "select * from view_erpuser where id=" + userid;
  2043. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2044. //if (dt != null && dt.Rows.Count > 0)
  2045. //{
  2046. // string nmemo = "";
  2047. // for(int i = 0; i < mlist.Length - 1; i++)
  2048. // {
  2049. // nmemo += mlist[i];
  2050. // nmemo += "-";
  2051. // }
  2052. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2053. // entity.seller_memo = nmemo;
  2054. //}
  2055. entity.CustomerUserId = userid;
  2056. entity.Update();
  2057. returnSuccessMsg("操作成功!");
  2058. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2059. return;
  2060. }
  2061. returnErrorMsg("找不到记录");
  2062. }
  2063. }
  2064. public void upd_erp_transdesigner()
  2065. {
  2066. if (UrlPostParmsCheck("ctid"))
  2067. {
  2068. string eids = GetPostString("ctid");
  2069. string[] ctidList = eids.Split(',');
  2070. int userid = GetPostInt("DesignUserId");
  2071. foreach (string ctid in ctidList)
  2072. {
  2073. CeErpTradeCell entity = null;
  2074. CeErpDesignerBill entitys = null;
  2075. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2076. entitys = CeErpDesignerBill.GetByTid(ctid);
  2077. if (entity != null)
  2078. {
  2079. if (entity.OrderState > 4)
  2080. {
  2081. continue;
  2082. }
  2083. //存在退款不能流转
  2084. if (entity.IsRefund > 0)
  2085. {
  2086. continue;
  2087. }
  2088. entity.DesignUserId = userid;
  2089. entity.WaitDesignTime = DateTime.Now;
  2090. entity.Update();
  2091. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2092. }
  2093. }
  2094. returnSuccessMsg("操作成功!");
  2095. }
  2096. }
  2097. public void upd_erp_distributedesigner()
  2098. {
  2099. if (UrlPostParmsCheck("ctid"))
  2100. {
  2101. string eid = GetPostString("ctid");
  2102. int userid = GetPostInt("DesignUserId");
  2103. string[] idlist = eid.Split(',');
  2104. if (idlist.Length <= 0)
  2105. {
  2106. returnErrorMsg("订单不能为空");
  2107. return;
  2108. }
  2109. foreach (string ctid in idlist)
  2110. {
  2111. CeErpTradeCell entity = null;
  2112. CeErpDesignerBill entitys = null;
  2113. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2114. else continue;
  2115. if (entity != null)
  2116. {
  2117. if (userid == 2125 || userid == 3542)
  2118. { }
  2119. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2120. {
  2121. returnErrorMsg("金额错误的订单无法指派");
  2122. return;
  2123. }
  2124. if (entity.OrderState >= 5)
  2125. {
  2126. returnErrorMsg("已经设计完成无法指派");
  2127. return;
  2128. }
  2129. if (entity.OrderState == -1)
  2130. {
  2131. returnErrorMsg("审核中的订单无法指派");
  2132. return;
  2133. }
  2134. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2135. {
  2136. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2137. return;
  2138. }
  2139. //157赖橙帆 159林晨
  2140. 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)
  2141. {
  2142. returnErrorMsg("指派设计共创无法再次指派!");
  2143. return;
  2144. }
  2145. entity.OrderState = 3;
  2146. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2147. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2148. {
  2149. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2150. entity.SupplierId = suid;
  2151. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2152. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2153. }
  2154. if (userid == 2125 && entity.seller_memo != "")
  2155. {
  2156. apiDesign.API_GetPrintData_CreateOrder(entity);
  2157. }
  2158. if (userid == 3542 && entity.seller_memo != "")
  2159. {
  2160. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2161. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2162. if (response.msg != "设计共创:成功")
  2163. {
  2164. returnErrorMsg(response.msg);
  2165. return;
  2166. }
  2167. entity.DispatchSort = 2;
  2168. }
  2169. else
  2170. {
  2171. if (entity.DispatchSort == 2)
  2172. {
  2173. ApiVo apiVo = new ApiVo();
  2174. apiVo.actionName = "closeDesign";
  2175. apiVo.orderNumber = entity.ctid;
  2176. designHelper.API_WorkCore(apiVo);//closeDesign
  2177. }
  2178. entity.DispatchSort = 0;
  2179. }
  2180. entity.DesignUserId = userid;
  2181. entity.WaitDesignTime = DateTime.Now;
  2182. entity.Update();
  2183. string name = commonHelper.getUserNameById(userid);
  2184. commonHelper.UpdateRelationOrder(entity.ctid);
  2185. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2186. }
  2187. }
  2188. returnSuccessMsg("操作成功!");
  2189. return;
  2190. }
  2191. }
  2192. public string getTidByCtid(string ctid)
  2193. {
  2194. string tid = "";
  2195. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2196. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2197. if (dataTable != null && dataTable.Rows.Count > 0)
  2198. {
  2199. tid = dataTable.Rows[0]["tid"].ToString();
  2200. }
  2201. return tid;
  2202. }
  2203. public void get_erp_myorderlist()
  2204. {
  2205. DataStruct dStruct = GetPostStruct();
  2206. List<string> lw = new List<string>();
  2207. string tid = GetPostString("ctid");
  2208. if (tid.Length > 0)
  2209. {
  2210. string select_tid = getTidByCtid(tid);
  2211. lw.Add(string.Format("tid='{0}'", select_tid));
  2212. }
  2213. else
  2214. {
  2215. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2216. }
  2217. //12-1 修改
  2218. string urgent = GetPostString("urgent");
  2219. string back = GetPostString("back");
  2220. string offlineSearch = GetPostString("offlineSearch");
  2221. if (!string.IsNullOrWhiteSpace(urgent))
  2222. {
  2223. if (urgent.Equals("true"))
  2224. {
  2225. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2226. }
  2227. }
  2228. if (!string.IsNullOrWhiteSpace(back))
  2229. {
  2230. if (back.Equals("true"))
  2231. {
  2232. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2233. }
  2234. }
  2235. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2236. {
  2237. if (offlineSearch.Equals("true"))
  2238. {
  2239. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2240. }
  2241. }
  2242. //end
  2243. string shopname = GetPostString("shopname");
  2244. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2245. string buyernick = GetPostString("buyer_nick");
  2246. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2247. string design = GetPostString("design");
  2248. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2249. string orderState = GetPostString("orderState");
  2250. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2251. string sellermemo = GetPostString("seller_memo");
  2252. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2253. string date1 = GetPostString("date1");
  2254. string date2 = GetPostString("date2");
  2255. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2256. if (dw.Length > 0) lw.Add(dw);
  2257. string price1 = GetPostString("price1");
  2258. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2259. string price2 = GetPostString("price2");
  2260. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2261. string urgency = GetPostString("urgency");
  2262. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2263. string after = GetPostString("after");
  2264. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2265. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2266. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2267. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2268. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2269. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2270. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2271. if (dt != null && dt.Rows.Count > 0)
  2272. {
  2273. foreach (DataRow dr in dt.Rows)
  2274. {
  2275. try
  2276. {
  2277. // 对象操作
  2278. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2279. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2280. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2281. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2282. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2283. if (dStruct.PageSize != 100000)
  2284. {
  2285. if (dr["DispatchSort"].ToString() == "2")
  2286. {
  2287. dr["gongchuang"] = 200;
  2288. }
  2289. else
  2290. {
  2291. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2292. dr["gongchuang"] = response.code;
  2293. }
  2294. }
  2295. }
  2296. catch (NullReferenceException ex)
  2297. {
  2298. }
  2299. }
  2300. }
  2301. writeGridDataTableJson(dStruct.TotalCount, dt);
  2302. }
  2303. public void get_erp_myreturnorderlist()
  2304. {
  2305. DataStruct dStruct = GetPostStruct();
  2306. List<string> lw = new List<string>();
  2307. string tid = GetPostString("ctid");
  2308. if (tid.Length > 0)
  2309. {
  2310. string select_tid = getTidByCtid(tid);
  2311. lw.Add(string.Format("tid='{0}'", select_tid));
  2312. }
  2313. else
  2314. {
  2315. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2316. }
  2317. string shopname = GetPostString("shopname");
  2318. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2319. string buyernick = GetPostString("buyer_nick");
  2320. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2321. string design = GetPostString("design");
  2322. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2323. string orderState = GetPostString("orderState");
  2324. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2325. string sellermemo = GetPostString("seller_memo");
  2326. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2327. string date1 = GetPostString("date1");
  2328. string date2 = GetPostString("date2");
  2329. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2330. if (dw.Length > 0) lw.Add(dw);
  2331. string price1 = GetPostString("price1");
  2332. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2333. string price2 = GetPostString("price2");
  2334. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2335. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2336. {
  2337. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2338. }
  2339. else
  2340. {
  2341. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2342. }
  2343. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2344. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2345. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2346. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2347. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2348. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2349. if (dt != null && dt.Rows.Count > 0)
  2350. {
  2351. foreach (DataRow dr in dt.Rows)
  2352. {
  2353. try
  2354. {
  2355. // 对象操作
  2356. if (dStruct.PageSize != 100000)
  2357. {
  2358. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2359. dr["gongchuang"] = response.code;
  2360. }
  2361. }
  2362. catch (NullReferenceException ex)
  2363. {
  2364. // 处理空引用异常
  2365. }
  2366. }
  2367. }
  2368. writeGridDataTableJson(dStruct.TotalCount, dt);
  2369. }
  2370. public void get_erp_myorderlist_pregather()
  2371. {
  2372. string date1 = GetPostString("date1");
  2373. string date2 = GetPostString("date2");
  2374. int userId = CurrentUser.UserID; //客服id
  2375. string orderWhere = "";
  2376. List<string> lw = new List<string>();
  2377. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2378. if (dw.Length > 0) lw.Add(dw);
  2379. lw.Add(string.Format("CustomerUserId={0}", userId));
  2380. lw.Add(string.Format("OrderState<9"));
  2381. orderWhere = string.Join(" and ", lw.ToArray());
  2382. string orderWhere2 = "";
  2383. List<string> lw2 = new List<string>();
  2384. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2385. if (dw2.Length > 0) lw2.Add(dw2);
  2386. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2387. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2388. string sql = string.Format("select *" +
  2389. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2390. "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 " +
  2391. "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 " +
  2392. "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");
  2393. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2394. //writeGridDataTableJson(dt.Rows.Count, dt);
  2395. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2396. }
  2397. public void upd_erp_publishorder()
  2398. {
  2399. if (UrlPostParmsCheck("ctid"))
  2400. {
  2401. string eid = GetPostString("ctid");
  2402. CeErpTradeCell entity = null;
  2403. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2404. if (entity != null)
  2405. {
  2406. entity.OrderState = 0; //发布后,变为待抢单
  2407. entity.Update();
  2408. commonHelper.UpdateRelationOrder(entity.ctid);
  2409. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2410. returnSuccessMsg("发布成功!");
  2411. return;
  2412. }
  2413. returnErrorMsg("找不到记录");
  2414. }
  2415. }
  2416. public void get_erp_my_tiporder()
  2417. {
  2418. StringBuilder sql = new StringBuilder();
  2419. int userId = 0;
  2420. if (CurrentUser != null) userId = CurrentUser.UserID;
  2421. string posCode = CurrentUser.UserPost.Post.Code;
  2422. string isTipedAfterSaleVerify = GetPostString("af");
  2423. DataTable dt = new DataTable();
  2424. if (posCode != "Supplier")
  2425. {
  2426. if (posCode == "CustomerService" || posCode == "Director")
  2427. {
  2428. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2429. }
  2430. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2431. {
  2432. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2433. }
  2434. else
  2435. {
  2436. string teamIds = CurrentUser.User.TeamIds;
  2437. if (teamIds == "")
  2438. {
  2439. teamIds = "0";
  2440. }
  2441. 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);
  2442. }
  2443. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2444. }
  2445. if (dt.Rows.Count <= 0)
  2446. {
  2447. string key = "aftersale_order_" + userId;
  2448. if (RedisHelper.HasKey(key))
  2449. {
  2450. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2451. dt.Columns.Add("ctid", typeof(string));
  2452. dt.Columns.Add("IsReadTag", typeof(int));
  2453. foreach (var i in list)
  2454. {
  2455. DataRow data = dt.NewRow();
  2456. data["ctid"] = i;
  2457. data["IsReadTag"] = 4;
  2458. dt.Rows.Add(data);
  2459. }
  2460. RedisHelper.StringDelete(key);
  2461. }
  2462. }
  2463. if (dt.Rows.Count <= 0)
  2464. {
  2465. sql = new StringBuilder();
  2466. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2467. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2468. }
  2469. if (posCode == "Supplier")
  2470. {
  2471. string ids = CurrentUser.User.pemVend;
  2472. if (ids != null && ids.Length > 0)
  2473. {
  2474. string[] ids_list = ids.Split(',');
  2475. foreach (var item in ids_list)
  2476. {
  2477. string key = "return_order_" + item;
  2478. if (RedisHelper.HasKey(key))
  2479. {
  2480. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2481. dt.Columns.Add("ctid", typeof(string));
  2482. dt.Columns.Add("IsReadTag", typeof(int));
  2483. foreach (var i in list)
  2484. {
  2485. DataRow data = dt.NewRow();
  2486. data["ctid"] = i;
  2487. data["IsReadTag"] = 1;
  2488. dt.Rows.Add(data);
  2489. }
  2490. RedisHelper.StringDelete(key);
  2491. }
  2492. }
  2493. }
  2494. if (dt.Rows.Count <= 0)
  2495. {
  2496. sql = new StringBuilder();
  2497. 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);
  2498. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2499. }
  2500. }
  2501. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2502. }
  2503. public void reset_erp_tiporder()
  2504. {
  2505. string ids = GetPostString("ids");
  2506. string[] ctidList = ids.Split(',');
  2507. foreach (string ctid in ctidList)
  2508. {
  2509. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2510. if (enty != null)
  2511. {
  2512. enty.IsReadTag = 0;
  2513. enty.Update();
  2514. }
  2515. }
  2516. returnSuccessMsg("成功!");
  2517. return;
  2518. }
  2519. public void get_erp_designlist()
  2520. {
  2521. DataStruct dStruct = GetPostStruct();
  2522. List<string> lw = new List<string>();
  2523. string tid = GetPostString("ctid");
  2524. if (tid.Length > 0)
  2525. {
  2526. string select_tid = getTidByCtid(tid);
  2527. lw.Add(string.Format("tid='{0}'", select_tid));
  2528. }
  2529. string shopname = GetPostString("shopname");
  2530. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2531. string buyernick = GetPostString("buyer_nick");
  2532. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2533. string customer = GetPostString("customer");
  2534. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2535. string design = GetPostString("design");
  2536. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2537. string orderState = GetPostString("orderState");
  2538. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2539. lw.Add(string.Format("OrderState<6"));
  2540. string address = GetPostString("address");
  2541. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2542. string sellermemo = GetPostString("seller_memo");
  2543. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2544. string date1 = GetPostString("date1");
  2545. string date2 = GetPostString("date2");
  2546. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2547. if (dw.Length > 0) lw.Add(dw);
  2548. string apdate1 = GetPostString("apdate1");
  2549. string apdate2 = GetPostString("apdate2");
  2550. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2551. if (dwap.Length > 0) lw.Add(dwap);
  2552. string price1 = GetPostString("price1");
  2553. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2554. string price2 = GetPostString("price2");
  2555. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2556. string designTime = GetPostString("designtime");
  2557. if (designTime.Length > 0)
  2558. {
  2559. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2560. }
  2561. string usershop = CurrentUser.User.pemShop;
  2562. if (usershop.Length > 0)
  2563. {
  2564. lw.Add(string.Format("shopId in ({0})", usershop));
  2565. }
  2566. int myOrgid = CurrentUser.UserPost.OrgID;
  2567. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2568. if (myOrgCode.IndexOf("Designer") != -1)
  2569. {
  2570. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2571. {
  2572. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2573. }
  2574. else
  2575. {
  2576. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2577. }
  2578. }
  2579. else
  2580. {
  2581. string orgId = GetPostString("designerhd");
  2582. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2583. }
  2584. if (tid.Length > 0 || buyernick.Length > 0)
  2585. {
  2586. lw.Add(string.Format("OrderState >= 3"));
  2587. }
  2588. else
  2589. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2590. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2591. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2592. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2593. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2594. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2595. if (dt != null && dt.Rows.Count > 0)
  2596. {
  2597. foreach (DataRow dr in dt.Rows)
  2598. {
  2599. try
  2600. {
  2601. // 对象操作
  2602. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2603. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2604. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2605. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2606. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2607. if (dStruct.PageSize != 100000)
  2608. {
  2609. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2610. dr["gongchuang"] = response.code;
  2611. }
  2612. }
  2613. catch (NullReferenceException ex)
  2614. {
  2615. }
  2616. }
  2617. }
  2618. writeGridDataTableJson(dStruct.TotalCount, dt);
  2619. }
  2620. public void get_erp_mydesignlist()
  2621. {
  2622. DataStruct dStruct = GetPostStruct();
  2623. List<string> lw = new List<string>();
  2624. string tid = GetPostString("ctid");
  2625. if (tid.Length > 0)
  2626. {
  2627. string select_tid = getTidByCtid(tid);
  2628. lw.Add(string.Format("tid='{0}'", select_tid));
  2629. }
  2630. string shopname = GetPostString("shopname");
  2631. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2632. string buyernick = GetPostString("buyer_nick");
  2633. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2634. string customer = GetPostString("customer");
  2635. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2636. string orderState = GetPostString("orderState");
  2637. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2638. //lw.Add(string.Format("OrderState<6"));
  2639. string date1 = GetPostString("date1");
  2640. string date2 = GetPostString("date2");
  2641. string dw = GetDateWhere("pay_time", date1, date2);
  2642. if (dw.Length > 0) lw.Add(dw);
  2643. string apdate1 = GetPostString("apdate1");
  2644. string apdate2 = GetPostString("apdate2");
  2645. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2646. if (dwap.Length > 0) lw.Add(dwap);
  2647. string price1 = GetPostString("price1");
  2648. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2649. string price2 = GetPostString("price2");
  2650. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2651. string olddownload = GetPostString("olddown");
  2652. if (olddownload == "1")
  2653. {
  2654. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2655. }
  2656. else if (olddownload == "2")
  2657. {
  2658. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2659. }
  2660. string sellermemo = GetPostString("seller_memo");
  2661. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2662. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2663. if (CurrentUser.User.TeamIds.Length > 0)
  2664. {
  2665. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2666. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2667. else
  2668. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2669. }
  2670. else
  2671. {
  2672. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2673. }
  2674. if (tid.Length <= 0)
  2675. {
  2676. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2677. }
  2678. lw.Add(string.Format("IsReturn!=3"));
  2679. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2680. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2681. string teamids = CurrentUser.User.TeamIds.ToString();
  2682. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2683. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2684. if (dt != null && dt.Rows.Count > 0)
  2685. {
  2686. foreach (DataRow dr in dt.Rows)
  2687. {
  2688. try
  2689. {
  2690. // 对象操作
  2691. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2692. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2693. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2694. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2695. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2696. if (dStruct.PageSize != 100000)
  2697. {
  2698. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2699. dr["gongchuang"] = response.code;
  2700. }
  2701. }
  2702. catch (NullReferenceException ex)
  2703. {
  2704. }
  2705. }
  2706. }
  2707. writeGridDataTableJson(dStruct.TotalCount, dt);
  2708. }
  2709. public void set_erp_startdesign()
  2710. {
  2711. if (UrlPostParmsCheck("ctid"))
  2712. {
  2713. string eid = GetPostString("ctid");
  2714. CeErpTradeCell entity = null;
  2715. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2716. if (entity != null)
  2717. {
  2718. if (entity.OrderState != 3)
  2719. {
  2720. returnErrorMsg("请刷新,订单已经设计了");
  2721. return;
  2722. }
  2723. entity.StartDesignTime = DateTime.Now;
  2724. entity.OrderState = 4;
  2725. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2726. {
  2727. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2728. entity.SupplierId = suid;
  2729. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2730. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2731. }
  2732. //entity.MakeSupplier = suname;
  2733. entity.Update();
  2734. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2735. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2736. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2737. commonHelper.getCytPrice(entity);
  2738. returnSuccessMsg("操作成功!");
  2739. return;
  2740. }
  2741. returnErrorMsg("找不到记录");
  2742. }
  2743. }
  2744. public void ins_erp_designselfmemo()
  2745. {
  2746. if (UrlPostParmsCheck("ctid"))
  2747. {
  2748. string eid = GetPostString("ctid");
  2749. string con = GetPostString("con");
  2750. CeErpTradeCell entity = null;
  2751. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2752. if (entity != null)
  2753. {
  2754. entity.DesignSelfMemo = con;
  2755. entity.Update();
  2756. returnSuccessMsg("操作成功!");
  2757. return;
  2758. }
  2759. returnErrorMsg("找不到记录");
  2760. }
  2761. }
  2762. public void ins_erp_designprice()
  2763. {
  2764. if (UrlPostParmsCheck("ctid"))
  2765. {
  2766. string eid = GetPostString("ctid");
  2767. int uid = CurrentUser.UserID;
  2768. string userName = CurrentUser.UserName;
  2769. CeErpTradeCell entity = null;
  2770. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2771. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2772. if (entitys == null)
  2773. {
  2774. entitys = new CeErpDesignerBill();
  2775. }
  2776. if (entity != null)
  2777. {
  2778. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2779. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2780. entity.StartDesignTime = DateTime.Now;
  2781. entity.OrderState = 4;
  2782. string suname = "";
  2783. if (entity.SupplierId == 0)
  2784. {
  2785. int sid = commonHelper.autoDistributeToSupplier(entity);
  2786. entity.SupplierId = sid;
  2787. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2788. }
  2789. entity.Update();
  2790. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2791. if (ceErpUserPost != null)
  2792. {
  2793. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2794. if (ceErpPost != null)
  2795. {
  2796. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2797. {
  2798. entitys.tid = entity.ctid;
  2799. entitys.oid = entity.tid;
  2800. entitys.uid = uid;
  2801. entitys.userName = userName;
  2802. entitys.designerType = 1;
  2803. entitys.designerTypeText = "内部设计师";
  2804. entitys.price = Convert.ToDouble(GetPostString("price"));
  2805. entitys.designNum = GetPostInt("designNum");
  2806. entitys.modifyNum = GetPostInt("modifyNum");
  2807. entitys.designSize = GetPostString("designSize");
  2808. entitys.modifySize = GetPostString("modifySize");
  2809. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2810. {
  2811. entitys.create_time = DateTime.Now;
  2812. entitys.create_u_id = uid;
  2813. entitys.create_u_name = userName;
  2814. entitys.Save();
  2815. }
  2816. else
  2817. {
  2818. entitys.update_time = DateTime.Now;
  2819. entitys.update_u_id = uid;
  2820. entitys.update_u_name = userName;
  2821. entitys.Update();
  2822. }
  2823. }
  2824. }
  2825. }
  2826. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2827. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2828. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2829. if (suname != "")
  2830. {
  2831. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2832. }
  2833. commonHelper.getCytPrice(entity);
  2834. returnSuccessMsg("操作成功!");
  2835. return;
  2836. }
  2837. returnErrorMsg("找不到记录");
  2838. }
  2839. }
  2840. public void upload_erp_filecomplete()
  2841. {
  2842. if (UrlPostParmsCheck("ctid"))
  2843. {
  2844. string eid = GetPostString("ctid");
  2845. CeErpTradeCell entity = null;
  2846. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2847. if (entity != null)
  2848. {
  2849. entity.OrderState = 5; //设计完成
  2850. entity.Update();
  2851. returnSuccessMsg(eid + "上传成功,设计完成!");
  2852. return;
  2853. }
  2854. returnErrorMsg("找不到订单记录");
  2855. }
  2856. }
  2857. public void get_erp_designovertimelist()
  2858. {
  2859. DataStruct dStruct = GetPostStruct();
  2860. List<string> lw = new List<string>();
  2861. string tid = GetPostString("ctid");
  2862. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2863. string shopname = GetPostString("shopname");
  2864. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2865. string buyernick = GetPostString("buyer_nick");
  2866. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2867. string ResponsibleMan = GetPostString("responsible");
  2868. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2869. string date1 = GetPostString("date1");
  2870. string date2 = GetPostString("date2");
  2871. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2872. if (dw.Length > 0) lw.Add(dw);
  2873. string price1 = GetPostString("price1");
  2874. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2875. string price2 = GetPostString("price2");
  2876. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2877. string orderState = GetPostString("orderState");
  2878. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2879. string sellermemo = GetPostString("seller_memo");
  2880. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2881. lw.Add(string.Format("UnusualTag=3"));
  2882. lw.Add(string.Format("IsRefund<={0}", 1));
  2883. dStruct.Order = "WaitDesignTime desc";
  2884. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2885. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2886. writeGridDataTableJson(dStruct.TotalCount, dt);
  2887. }
  2888. //设计管理 获取抢单大厅列表
  2889. public void get_erp_grabinglist()
  2890. {
  2891. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2892. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2893. bool oldOrder = false;
  2894. if (org != null)
  2895. {
  2896. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2897. }
  2898. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2899. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2900. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2901. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2902. //先处理订单数据
  2903. if (dt.Rows.Count > 0)
  2904. {
  2905. Dictionary<string, int> design = null;
  2906. int count = 0;
  2907. foreach (DataRow row in dt.Rows)
  2908. {
  2909. if (map.ContainsKey(row["ShopId"].ToString()))
  2910. {
  2911. map.TryGetValue(row["ShopId"].ToString(), out design);
  2912. }
  2913. else
  2914. {
  2915. design = new Dictionary<string, int>();
  2916. }
  2917. if (design.ContainsKey(row["ProductId"].ToString()))
  2918. {
  2919. design.TryGetValue(row["ProductId"].ToString(), out count);
  2920. }
  2921. count++;
  2922. design[row["ProductId"].ToString()] = count;
  2923. map[row["ShopId"].ToString()] = design;
  2924. }
  2925. }
  2926. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2927. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2928. //把店铺排序和技能排序分类
  2929. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2930. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2931. if (design_dt.Rows.Count > 0)
  2932. {
  2933. Dictionary<string, string> design = null;
  2934. List<string> shopIds = null;
  2935. foreach (DataRow row in design_dt.Rows)
  2936. {
  2937. if ("0".Equals(row["designId"].ToString()))
  2938. {
  2939. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2940. {
  2941. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2942. }
  2943. else
  2944. {
  2945. shopIds = new List<string>();
  2946. }
  2947. shopIds.Add(row["shopId"].ToString());
  2948. shop_orders[row["orders"].ToString()] = shopIds;
  2949. }
  2950. else
  2951. {
  2952. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2953. {
  2954. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2955. }
  2956. else
  2957. {
  2958. design = new Dictionary<string, string>();
  2959. }
  2960. design[row["orders"].ToString()] = row["designId"].ToString();
  2961. design_orders[row["shopId"].ToString()] = design;
  2962. }
  2963. }
  2964. //处理成key value后根据key排序
  2965. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2966. foreach (List<string> val in shop_orders.Values)
  2967. {
  2968. if (val != null)
  2969. {
  2970. foreach (string key in val)
  2971. {
  2972. if (design_orders.ContainsKey(key.ToString()))
  2973. {
  2974. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2975. }
  2976. }
  2977. }
  2978. }
  2979. }
  2980. //校验哪个优先级有订单
  2981. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2982. foreach (string key in shop_orders.Keys)
  2983. {
  2984. List<string> ids = null;
  2985. shop_orders.TryGetValue(key, out ids);
  2986. //id为shopid
  2987. foreach (string id in ids)
  2988. {
  2989. Dictionary<string, int> list = null;
  2990. Dictionary<string, string> desing = null;
  2991. map.TryGetValue(id, out list);
  2992. design_orders.TryGetValue(id, out desing);
  2993. if (list != null && desing != null)
  2994. {
  2995. foreach (var item in desing)
  2996. {
  2997. int count = 0;
  2998. if (list.ContainsKey(item.Value))
  2999. {
  3000. list.TryGetValue(item.Value, out count);
  3001. if (count > 0)
  3002. {
  3003. designIds[id] = item.Value;
  3004. break;
  3005. }
  3006. }
  3007. }
  3008. }
  3009. }
  3010. if (designIds.Count > 0)
  3011. {
  3012. break;
  3013. }
  3014. }
  3015. DataTable table = new DataTable();
  3016. table.Columns.Add("tid", typeof(string));
  3017. table.Columns.Add("ctid", typeof(string));
  3018. table.Columns.Add("seller_nick", typeof(string));
  3019. table.Columns.Add("productName", typeof(string));
  3020. table.Columns.Add("pay_time", typeof(string));
  3021. table.Columns.Add("seller_memo", typeof(string));
  3022. if (designIds.Count > 0)
  3023. {
  3024. string shopId = "";
  3025. string productId = "";
  3026. foreach (var designInfo in designIds)
  3027. {
  3028. shopId = designInfo.Key;
  3029. productId = designInfo.Value;
  3030. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3031. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3032. if (dt.Rows.Count > 0)
  3033. {
  3034. foreach (DataRow row in dt.Rows)
  3035. {
  3036. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3037. {
  3038. DataRow data = table.NewRow();
  3039. data["ctid"] = row["ctid"].ToString();
  3040. data["tid"] = row["tid"].ToString();
  3041. data["seller_nick"] = ceErpShop.ShopName;
  3042. data["pay_time"] = row["pay_time"].ToString();
  3043. data["seller_memo"] = row["seller_memo"].ToString();
  3044. data["productName"] = ceErpProduct.PType;
  3045. table.Rows.Add(data);
  3046. }
  3047. }
  3048. }
  3049. }
  3050. }
  3051. writeGridDataTableJson(table.Rows.Count, table);
  3052. }
  3053. private object rushLockObject = new object();
  3054. public void set_erp_grabingorder()
  3055. {
  3056. if (UrlPostParmsCheck("ctid"))
  3057. {
  3058. int total = CurrentUser.User.Person.Total;
  3059. int userId = CurrentUser.User.ID;
  3060. int noFinish = CurrentUser.User.Person.NoFinish;
  3061. int finalization = CurrentUser.User.Person.Finalization;
  3062. string eids = GetPostString("ctid");
  3063. string key = "RushKey_" + userId;
  3064. int count = 0;
  3065. if (erpRedis.RedisHelper.KeyExists(key))
  3066. {
  3067. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3068. if (redisCount != null)
  3069. {
  3070. count = Convert.ToInt32(redisCount);
  3071. }
  3072. }
  3073. if (count >= total)
  3074. {
  3075. returnErrorMsg("半小时内已经抢" + total + "单");
  3076. return;
  3077. }
  3078. string[] ctidlist = eids.Split(',');
  3079. if (count + ctidlist.Length > total)
  3080. {
  3081. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3082. return;
  3083. }
  3084. int itag = 0;
  3085. lock (rushLockObject)
  3086. {
  3087. if (ctidlist.Length > 0)
  3088. {
  3089. string[] dtList = new string[ctidlist.Length];
  3090. for (int i = 0; i < ctidlist.Length; i++)
  3091. {
  3092. dtList[i] = "'" + ctidlist[i] + "'";
  3093. }
  3094. 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"));
  3095. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3096. if (dt_user.Rows.Count > 0)
  3097. {
  3098. int doing = 0;//未定稿
  3099. int finish = 0;//已完成
  3100. foreach (DataRow dr in dt_user.Rows)
  3101. {
  3102. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3103. {
  3104. doing++;
  3105. }
  3106. else
  3107. {
  3108. finish++;
  3109. }
  3110. }
  3111. if (doing >= noFinish)
  3112. {
  3113. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3114. return;
  3115. }
  3116. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3117. {
  3118. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3119. return;
  3120. }
  3121. }
  3122. //校验选择单子状态
  3123. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3124. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3125. if (dt.Rows.Count > 0)
  3126. {
  3127. List<string> list = new List<string>();
  3128. foreach (DataRow dr in dt.Rows)
  3129. {
  3130. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3131. {
  3132. list.Add(dr["ctid"].ToString());
  3133. }
  3134. }
  3135. if (list.Count > 0)
  3136. {
  3137. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3138. return;
  3139. }
  3140. }
  3141. foreach (string ctid in ctidlist)
  3142. {
  3143. CeErpTradeCell entity = null;
  3144. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3145. if (entity != null)
  3146. {
  3147. entity.OrderState = 3;
  3148. entity.DesignUserId = CurrentUser.UserID;
  3149. entity.WaitDesignTime = DateTime.Now;
  3150. entity.StartDesignTime = DateTime.Now;
  3151. entity.Update();
  3152. commonHelper.UpdateRelationOrder(entity.ctid);
  3153. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3154. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3155. itag++;
  3156. }
  3157. }
  3158. }
  3159. }
  3160. count += ctidlist.Length;
  3161. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3162. if (itag == 0)
  3163. returnErrorMsg("没有找到相关订单");
  3164. else
  3165. returnSuccessMsg("抢单成功!");
  3166. return;
  3167. }
  3168. }
  3169. public void get_erp_waitorderlist()
  3170. {
  3171. DataStruct dStruct = GetPostStruct();
  3172. List<string> lw = new List<string>();
  3173. string tid = GetPostString("ctid");
  3174. if (tid.Length > 0)
  3175. {
  3176. string select_tid = getTidByCtid(tid);
  3177. lw.Add(string.Format("tid='{0}'", select_tid));
  3178. }
  3179. string shopname = GetPostString("shopname");
  3180. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3181. string buyernick = GetPostString("buyer_nick");
  3182. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3183. string customer = GetPostString("customer");
  3184. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3185. string design = GetPostString("design");
  3186. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3187. string orderState = GetPostString("orderState");
  3188. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3189. string supplier = GetPostString("supplier");
  3190. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3191. string sellermemo = GetPostString("seller_memo");
  3192. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3193. string otherMemo = GetPostString("otherMemo");
  3194. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3195. string address = GetPostString("address");
  3196. 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));
  3197. string date1 = GetPostString("date1");
  3198. string date2 = GetPostString("date2");
  3199. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3200. if (dw.Length > 0) lw.Add(dw);
  3201. string price1 = GetPostString("price1");
  3202. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3203. string price2 = GetPostString("price2");
  3204. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3205. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3206. lw.Add(string.Format("IsSample != 2 "));
  3207. lw.Add(string.Format("OrderState = 5 "));
  3208. lw.Add(string.Format("IsRefund<={0}", 1));
  3209. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3210. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3211. string pagesize = GetPostString("pagesize");
  3212. if (pagesize != null)
  3213. {
  3214. dStruct.PageSize = 200;
  3215. }
  3216. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3217. if (dt != null)
  3218. {
  3219. foreach (DataRow dr in dt.Rows)
  3220. {
  3221. 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();
  3222. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3223. {
  3224. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3225. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3226. entity.SupplierId = suid;
  3227. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3228. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3229. entity.Update();
  3230. }
  3231. }
  3232. }
  3233. writeGridDataTableJson(dStruct.TotalCount, dt);
  3234. }
  3235. public void get_erp_supplierwaitorderlist()
  3236. {
  3237. DataStruct dStruct = GetPostStruct();
  3238. List<string> lw = new List<string>();
  3239. string tid = GetPostString("ctid");
  3240. if (tid.Length > 0)
  3241. {
  3242. string select_tid = getTidByCtid(tid);
  3243. lw.Add(string.Format("tid='{0}'", select_tid));
  3244. }
  3245. string shopname = GetPostString("shopname");
  3246. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3247. string sellermemo = GetPostString("seller_memo");
  3248. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3249. string date1 = GetPostString("date1");
  3250. string date2 = GetPostString("date2");
  3251. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3252. if (dw.Length > 0) lw.Add(dw);
  3253. lw.Add(string.Format("OrderState = 5 "));
  3254. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3255. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3256. {
  3257. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3258. }
  3259. string supplier = GetPostString("supplier");
  3260. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3261. {
  3262. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3263. }
  3264. lw.Add(string.Format("IsRefund<={0}", 1));
  3265. dStruct.Order = "FinishDesignTime desc";
  3266. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3267. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3268. if (dt != null)
  3269. {
  3270. foreach (DataRow dr in dt.Rows)
  3271. {
  3272. 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();
  3273. }
  3274. }
  3275. writeGridDataTableJson(dStruct.TotalCount, dt);
  3276. }
  3277. public void upd_erp_verifytosupplier()
  3278. {
  3279. if (UrlPostParmsCheck("ctid"))
  3280. {
  3281. string eids = GetPostString("ctid");
  3282. CeErpTradeCell entity = null;
  3283. string[] eidsList = eids.Split(',');
  3284. if (eidsList.Length <= 0)
  3285. {
  3286. returnErrorMsg("订单号不能空");
  3287. return;
  3288. }
  3289. List<string> tLst = new List<string>();
  3290. foreach (string ctidstr in eidsList)
  3291. {
  3292. tLst.Add("'" + ctidstr + "'");
  3293. CeErpDataSendOrderInfo.createObject(ctidstr);
  3294. }
  3295. string needtids = string.Join(",", tLst.ToArray());
  3296. StringBuilder sql = new StringBuilder();
  3297. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3298. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3299. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3300. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3301. returnSuccessMsg("操作成功!");
  3302. return;
  3303. /**foreach (string ctidstr in eidsList)
  3304. {
  3305. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3306. if (entity != null)
  3307. {
  3308. if (entity.SupplierId == 0)
  3309. {
  3310. continue;
  3311. }
  3312. entity.IsVerifyToSupplier = true;
  3313. if (entity.IsReturn == 1) //1是供应商打回
  3314. {
  3315. entity.IsReturn = 0;
  3316. }
  3317. entity.FinishPlaceTime = DateTime.Now;
  3318. entity.PlaceUserId = CurrentUser.UserID;
  3319. entity.Update();
  3320. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3321. }
  3322. }
  3323. returnSuccessMsg("操作成功!");
  3324. return;**/
  3325. }
  3326. }
  3327. public void upd_erp_supplierback()
  3328. {
  3329. if (UrlPostParmsCheck("ctid"))
  3330. {
  3331. string eid = GetPostString("ctid");
  3332. string reason = GetPostString("returnreason");
  3333. CeErpTradeCell entity = null;
  3334. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3335. if (entity != null)
  3336. {
  3337. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3338. {
  3339. string key = "return_order_" + entity.SupplierId;
  3340. List<string> list = new List<string>();
  3341. if (RedisHelper.HasKey(key))
  3342. {
  3343. object data = RedisHelper.StringGet(key);
  3344. list = Convert.ToString(data).Split(',').ToList();
  3345. }
  3346. list.Add(eid);
  3347. RedisHelper.StringSet(key, string.Join(",", list));
  3348. }
  3349. entity.IsVerifyToSupplier = false;
  3350. entity.IsReturn = 1;
  3351. entity.ReturnTime = DateTime.Now;
  3352. entity.ReturnReason = reason;
  3353. if (entity.OrderState == 6)
  3354. {
  3355. entity.OrderState = 5;
  3356. }
  3357. entity.Update();
  3358. CeErpSukuraData.createInfo(entity.ctid, 5);
  3359. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3360. returnSuccessMsg("操作成功!");
  3361. return;
  3362. }
  3363. returnErrorMsg("找不到订单记录");
  3364. }
  3365. }
  3366. public void upd_erp_toaftersaleorder()
  3367. {
  3368. if (UrlPostParmsCheck("ctid"))
  3369. {
  3370. string eid = GetPostString("ctid");
  3371. string reason = GetPostString("returnreason");
  3372. CeErpTradeCell entity = null;
  3373. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3374. if (entity != null)
  3375. {
  3376. if (entity.isAfterSaleOrder != 1)
  3377. {
  3378. returnErrorMsg("带S的售后单才能打回给售后");
  3379. return;
  3380. }
  3381. if (entity.OrderState >= 5)
  3382. {
  3383. returnErrorMsg("已经设计完成了不能打回给售后");
  3384. return;
  3385. }
  3386. entity.OrderState = 0;
  3387. entity.IsReturn = 3;
  3388. entity.ReturnTime = DateTime.Now;
  3389. entity.ReturnReason = reason;
  3390. entity.Update();
  3391. CeErpSukuraData.createInfo(entity.ctid, 5);
  3392. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3393. returnSuccessMsg("操作成功!");
  3394. return;
  3395. }
  3396. returnErrorMsg("找不到订单记录");
  3397. }
  3398. }
  3399. public void upd_erp_aftersaletodesign()
  3400. {
  3401. if (UrlPostParmsCheck("ctid"))
  3402. {
  3403. string eid = GetPostString("ctid");
  3404. CeErpTradeCell entity = null;
  3405. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3406. if (entity != null)
  3407. {
  3408. entity.OrderState = 3;
  3409. entity.IsReturn = 0;
  3410. entity.Update();
  3411. CeErpSukuraData.createInfo(entity.ctid, 5);
  3412. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3413. returnSuccessMsg("操作成功!");
  3414. return;
  3415. }
  3416. returnErrorMsg("找不到订单记录");
  3417. }
  3418. }
  3419. public void assign_erp_supplier()
  3420. {
  3421. if (UrlPostParmsCheck("ctid"))
  3422. {
  3423. string eids = GetPostString("ctid");
  3424. int sid = GetPostInt("SupplierName");
  3425. string fromTag = GetPostString("tag");
  3426. string[] eidList = eids.Split(',');
  3427. if (eidList.Length <= 0)
  3428. {
  3429. returnErrorMsg("指派不能为空");
  3430. return;
  3431. }
  3432. string errMsg = "";
  3433. string suname = commonHelper.getSupplierNameById(sid);
  3434. foreach (string ctid in eidList)
  3435. {
  3436. CeErpTradeCell entity = null;
  3437. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3438. if (entity != null)
  3439. {
  3440. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3441. {
  3442. errMsg += (ctid + "指派失败!!!");
  3443. continue;
  3444. }
  3445. entity.SupplierId = sid;
  3446. entity.Update();
  3447. commonHelper.UpdateRelationOrder(entity.ctid);
  3448. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3449. if (entity.OrderState >= 6)
  3450. {
  3451. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3452. //{
  3453. // string msl = entity.MakeSupplier;
  3454. // string[] mslist = msl.Split(',');
  3455. // 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);
  3456. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3457. //}
  3458. //else
  3459. //{
  3460. StringBuilder sql = new StringBuilder();
  3461. 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);
  3462. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3463. //}
  3464. }
  3465. }
  3466. else
  3467. {
  3468. continue;
  3469. }
  3470. }
  3471. if (errMsg.Length > 0)
  3472. {
  3473. returnErrorMsg(errMsg);
  3474. return;
  3475. }
  3476. returnSuccessMsg("操作成功!");
  3477. return;
  3478. }
  3479. }
  3480. public void assign_erp_makesupplier()
  3481. {
  3482. if (UrlPostParmsCheck("ctid"))
  3483. {
  3484. string eids = GetPostString("ctid");
  3485. string sname = GetPostString("SupplierName");
  3486. string[] eidList = eids.Split(',');
  3487. if (eidList.Length <= 0)
  3488. {
  3489. returnErrorMsg("指派不能为空");
  3490. return;
  3491. }
  3492. List<string> tLst = new List<string>();
  3493. foreach (string ctid in eidList)
  3494. {
  3495. CeErpTradeCell entity = null;
  3496. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3497. if (entity != null)
  3498. {
  3499. entity.MakeSupplier = sname;
  3500. entity.Update();
  3501. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3502. tLst.Add("'" + ctid + "'");
  3503. }
  3504. else
  3505. {
  3506. continue;
  3507. }
  3508. }
  3509. string ctids = string.Join(",", tLst.ToArray());
  3510. StringBuilder sql2 = new StringBuilder();
  3511. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3512. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3513. returnSuccessMsg("操作成功!");
  3514. return;
  3515. }
  3516. }
  3517. public void ins_erp_returnreason()
  3518. {
  3519. if (UrlPostParmsCheck("ctid"))
  3520. {
  3521. string eid = GetPostString("ctid");
  3522. CeErpTradeCell entity = null;
  3523. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3524. string userpost = CurrentUser.UserPost.Post.Code;
  3525. if (entity != null)
  3526. {
  3527. bool isPlace = false;
  3528. if (entity.OrderState > 6)
  3529. {
  3530. returnErrorMsg("已发货无法打回!");
  3531. return;
  3532. }
  3533. if (entity.OrderState == 6)
  3534. {
  3535. isPlace = true;
  3536. }
  3537. bool isNeedUpdateCell2 = false;
  3538. if (entity.OrderState >= 6)
  3539. {
  3540. isNeedUpdateCell2 = true;
  3541. }
  3542. int returnTag = 2;
  3543. if (userpost == "Supplier")
  3544. {
  3545. returnTag = 1;
  3546. }
  3547. int toType = GetPostInt("totype");
  3548. string fromType = "3";
  3549. if (entity.OrderState < 5)
  3550. {
  3551. fromType = "3";
  3552. }
  3553. else
  3554. {
  3555. fromType = "4";
  3556. }
  3557. if (entity.IsXianHuo == 0)
  3558. {
  3559. if (returnTag == 2)
  3560. {
  3561. if (toType == 1)
  3562. {
  3563. entity.OrderState = 0;
  3564. entity.ReturnUserType = 1;
  3565. string clearman = GetPostString("clearman");
  3566. if (!string.IsNullOrEmpty(clearman))
  3567. {
  3568. entity.DesignUserId = 0;
  3569. }
  3570. }
  3571. else
  3572. {
  3573. entity.OrderState = 3;
  3574. entity.ReturnUserType = 2;
  3575. }
  3576. entity.IsReadTag = 1;
  3577. }
  3578. else if (returnTag == 1)
  3579. {
  3580. entity.OrderState = 5;
  3581. }
  3582. entity.IsVerifyToSupplier = false;
  3583. }
  3584. if (entity.IsXianHuo == 1)
  3585. {
  3586. entity.OrderState = 5;
  3587. }
  3588. entity.UnusualTag = 0;
  3589. entity.UnusualTime = null;
  3590. entity.UnusualCon = "";
  3591. entity.IsReturn = returnTag;
  3592. entity.ReturnTime = DateTime.Now;
  3593. entity.ReturnReason = GetPostString("returnreason");
  3594. entity.Update();
  3595. if (entity.OrderState == 3)
  3596. {
  3597. ApiVo apiVo = new ApiVo();
  3598. apiVo.orderNumber = entity.ctid;
  3599. apiVo.actionName = "rebutDesign";
  3600. apiVo.orderRemarks = entity.ReturnReason;
  3601. designHelper.API_WorkCore(apiVo);//rebutDesign
  3602. }
  3603. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3604. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3605. {
  3606. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3607. }
  3608. CeErpSukuraData.createInfo(entity.ctid, 5);
  3609. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3610. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3611. if (isPlace)
  3612. {
  3613. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3614. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3615. if (dth != null && dth.Rows.Count > 0)
  3616. {
  3617. dataSendOrderBean dataSendOrderBean = null;
  3618. foreach (DataRow item in dth.Rows)
  3619. {
  3620. try
  3621. {
  3622. dataSendOrderBean = new dataSendOrderBean();
  3623. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3624. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3625. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3626. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3627. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3628. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3629. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3630. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3631. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3632. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3633. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3634. dataSendOrderBean.Radio1723534706288 = "打回";
  3635. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3636. if (result != null)
  3637. {
  3638. if ("0".Equals(result.errcode))
  3639. {
  3640. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3641. }
  3642. else
  3643. {
  3644. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3645. }
  3646. }
  3647. }
  3648. catch (Exception ex)
  3649. {
  3650. }
  3651. }
  3652. }
  3653. }
  3654. if (isNeedUpdateCell2)
  3655. {
  3656. if (entity.MakeSupplier.IndexOf(",") != -1)
  3657. {
  3658. StringBuilder sql2 = new StringBuilder();
  3659. 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);
  3660. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3661. }
  3662. else
  3663. {
  3664. StringBuilder sql2 = new StringBuilder();
  3665. 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);
  3666. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3667. }
  3668. }
  3669. returnSuccessMsg("操作成功!");
  3670. return;
  3671. }
  3672. returnErrorMsg("找不到订单记录");
  3673. }
  3674. }
  3675. public void cyt_erp_returnreason()
  3676. {
  3677. if (UrlPostParmsCheck("ctid"))
  3678. {
  3679. string eid = GetPostString("ctid");
  3680. CeErpTradeCell entity = null;
  3681. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3682. string userpost = CurrentUser.UserPost.Post.Code;
  3683. if (entity != null)
  3684. {
  3685. if (entity.OrderState > 6)
  3686. {
  3687. returnErrorMsg("已发货无法打回!");
  3688. return;
  3689. }
  3690. JObject jsonObject = new JObject
  3691. {
  3692. { "Userid", "77886" },
  3693. { "Pwd", "lt666888" },
  3694. { "LTOrderId",eid }
  3695. };
  3696. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3697. JObject jsonObjects = JObject.Parse(response);
  3698. string msg = (string)jsonObjects["msg"];
  3699. if (msg != "取消成功")
  3700. {
  3701. returnErrorMsg(msg);
  3702. return;
  3703. }
  3704. bool isNeedUpdateCell2 = false;
  3705. if (entity.OrderState >= 6)
  3706. {
  3707. isNeedUpdateCell2 = true;
  3708. }
  3709. int returnTag = 2;
  3710. if (userpost == "Supplier")
  3711. {
  3712. returnTag = 1;
  3713. }
  3714. if (entity.IsXianHuo == 0)
  3715. {
  3716. if (returnTag == 2)
  3717. {
  3718. int toType = GetPostInt("totype");
  3719. if (toType == 1)
  3720. {
  3721. entity.OrderState = 0;
  3722. entity.ReturnUserType = 1;
  3723. }
  3724. else
  3725. {
  3726. entity.OrderState = 4;
  3727. entity.ReturnUserType = 2;
  3728. }
  3729. entity.IsReadTag = 1;
  3730. }
  3731. else if (returnTag == 1)
  3732. {
  3733. entity.OrderState = 5;
  3734. }
  3735. entity.IsVerifyToSupplier = false;
  3736. }
  3737. entity.UnusualTag = 0;
  3738. entity.UnusualTime = null;
  3739. entity.UnusualCon = "";
  3740. entity.IsReturn = returnTag;
  3741. entity.ReturnTime = DateTime.Now;
  3742. entity.ReturnReason = GetPostString("returnreason");
  3743. entity.Update();
  3744. if (entity.OrderState == 4)
  3745. {
  3746. ApiVo apiVo = new ApiVo();
  3747. apiVo.orderNumber = entity.ctid;
  3748. apiVo.actionName = "rebutDesign";
  3749. apiVo.orderRemarks = entity.ReturnReason;
  3750. designHelper.API_WorkCore(apiVo);//rebutDesign
  3751. }
  3752. CeErpSukuraData.createInfo(entity.ctid, 5);
  3753. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3754. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3755. if (isNeedUpdateCell2)
  3756. {
  3757. if (entity.MakeSupplier.IndexOf(",") != -1)
  3758. {
  3759. StringBuilder sql2 = new StringBuilder();
  3760. 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);
  3761. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3762. }
  3763. else
  3764. {
  3765. StringBuilder sql2 = new StringBuilder();
  3766. 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);
  3767. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3768. }
  3769. }
  3770. returnSuccessMsg("操作成功!");
  3771. return;
  3772. }
  3773. returnErrorMsg("找不到订单记录");
  3774. }
  3775. }
  3776. public void upd_erp_xianhuoreturntag()
  3777. {
  3778. if (UrlPostParmsCheck("ctid"))
  3779. {
  3780. string eids = GetPostString("ctid");
  3781. string[] ctids = eids.Split(',');
  3782. foreach (string ctid in ctids)
  3783. {
  3784. CeErpTradeCell entity = null;
  3785. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3786. if (entity != null)
  3787. {
  3788. entity.IsReturn = 0;
  3789. entity.Update();
  3790. CeErpSukuraData.createInfo(entity.ctid, 5);
  3791. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3792. }
  3793. }
  3794. returnSuccessMsg("操作成功!");
  3795. return;
  3796. }
  3797. }
  3798. public void get_erp_waitdeliverylist()
  3799. {
  3800. DataStruct dStruct = GetPostStruct();
  3801. List<string> lw = new List<string>();
  3802. string tid = GetPostString("ctid");
  3803. if (tid.Length > 0)
  3804. {
  3805. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3806. }
  3807. string shopname = GetPostString("shopname");
  3808. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3809. string buyernick = GetPostString("buyer_nick");
  3810. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3811. //if (tid.Length == 0 && buyernick.Length == 0)
  3812. //{
  3813. // lw.Add(string.Format("IsRefund<={0}", 1));
  3814. //}
  3815. string customer = GetPostString("customer");
  3816. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3817. string design = GetPostString("design");
  3818. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3819. string orderState = GetPostString("orderState");
  3820. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3821. string address = GetPostString("address");
  3822. 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));
  3823. string sellermemo = GetPostString("seller_memo");
  3824. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3825. string supplier = GetPostString("supplier");
  3826. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3827. string OrderArea = GetPostString("order_area");
  3828. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3829. string placedate1 = GetPostString("placedate1");
  3830. string placedate2 = GetPostString("placedate2");
  3831. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3832. if (fdw.Length > 0) lw.Add(fdw);
  3833. string price1 = GetPostString("price1");
  3834. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3835. string price2 = GetPostString("price2");
  3836. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3837. string unusualCon = GetPostString("unusualcon");
  3838. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3839. string otherMemo = GetPostString("otherMemo");
  3840. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3841. string posTag = CurrentUser.UserPost.Post.Code;
  3842. if (posTag == "Supplier")
  3843. {
  3844. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3845. }
  3846. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3847. lw.Add(string.Format("type != 'PDD' "));
  3848. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3849. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3850. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3851. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3852. /*if (tid.Length > 0)
  3853. {
  3854. List<string> tids = new List<string>();
  3855. if (dt != null && dt.Rows.Count > 0)
  3856. {
  3857. foreach (DataRow item in dt.Rows)
  3858. {
  3859. tids.Add("'" + item["tid"] + "'");
  3860. }
  3861. }
  3862. if (tids.Count > 0)
  3863. {
  3864. lw.RemoveAt(0);
  3865. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3866. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3867. dt = WebCache.GetData("view_erptradecell", dStruct);
  3868. }
  3869. }*/
  3870. writeGridDataTableJson(dStruct.TotalCount, dt);
  3871. }
  3872. public void get_erp_changedeliverylist()
  3873. {
  3874. DataStruct dStruct = GetPostStruct();
  3875. List<string> lw = new List<string>();
  3876. string tid = GetPostString("ctid");
  3877. if (tid.Length > 0)
  3878. {
  3879. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3880. }
  3881. string shopname = GetPostString("shopname");
  3882. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3883. string buyernick = GetPostString("buyer_nick");
  3884. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3885. //if (tid.Length == 0 && buyernick.Length == 0)
  3886. //{
  3887. // lw.Add(string.Format("IsRefund<={0}", 1));
  3888. //}
  3889. string customer = GetPostString("customer");
  3890. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3891. string design = GetPostString("design");
  3892. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3893. string orderState = GetPostString("orderState");
  3894. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3895. string address = GetPostString("address");
  3896. 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));
  3897. string sellermemo = GetPostString("seller_memo");
  3898. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3899. string supplier = GetPostString("supplier");
  3900. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3901. string OrderArea = GetPostString("order_area");
  3902. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3903. string placedate1 = GetPostString("placedate1");
  3904. string placedate2 = GetPostString("placedate2");
  3905. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3906. if (fdw.Length > 0) lw.Add(fdw);
  3907. string price1 = GetPostString("price1");
  3908. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3909. string price2 = GetPostString("price2");
  3910. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3911. string unusualCon = GetPostString("unusualcon");
  3912. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3913. string otherMemo = GetPostString("otherMemo");
  3914. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3915. string posTag = CurrentUser.UserPost.Post.Code;
  3916. if (posTag == "Supplier")
  3917. {
  3918. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3919. }
  3920. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3921. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3922. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3923. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3924. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3925. /*if (tid.Length > 0)
  3926. {
  3927. List<string> tids = new List<string>();
  3928. if (dt != null && dt.Rows.Count > 0)
  3929. {
  3930. foreach (DataRow item in dt.Rows)
  3931. {
  3932. tids.Add("'" + item["tid"] + "'");
  3933. }
  3934. }
  3935. if (tids.Count > 0)
  3936. {
  3937. lw.RemoveAt(0);
  3938. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3939. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3940. dt = WebCache.GetData("view_erptradecell", dStruct);
  3941. }
  3942. }*/
  3943. writeGridDataTableJson(dStruct.TotalCount, dt);
  3944. }
  3945. public void get_erp_pddderiving()
  3946. {
  3947. DataStruct dStruct = GetPostStruct();
  3948. List<string> lw = new List<string>();
  3949. string tid = GetPostString("ctid");
  3950. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3951. string shopname = GetPostString("shopname");
  3952. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3953. string buyernick = GetPostString("buyer_nick");
  3954. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3955. //if (tid.Length == 0 && buyernick.Length == 0)
  3956. //{
  3957. // lw.Add(string.Format("IsRefund<={0}", 1));
  3958. //}
  3959. string customer = GetPostString("customer");
  3960. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3961. string design = GetPostString("design");
  3962. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3963. string orderState = GetPostString("orderState");
  3964. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3965. string address = GetPostString("address");
  3966. 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));
  3967. string sellermemo = GetPostString("seller_memo");
  3968. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3969. string supplier = GetPostString("supplier");
  3970. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3971. string OrderArea = GetPostString("order_area");
  3972. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3973. string placedate1 = GetPostString("placedate1");
  3974. string placedate2 = GetPostString("placedate2");
  3975. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3976. if (fdw.Length > 0) lw.Add(fdw);
  3977. string price1 = GetPostString("price1");
  3978. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3979. string price2 = GetPostString("price2");
  3980. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3981. string unusualCon = GetPostString("unusualcon");
  3982. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3983. string posTag = CurrentUser.UserPost.Post.Code;
  3984. if (posTag == "Supplier")
  3985. {
  3986. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3987. }
  3988. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3989. lw.Add(string.Format("type = 'PDD' "));
  3990. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3991. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3992. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3993. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3994. /*if (tid.Length > 0)
  3995. {
  3996. List<string> tids = new List<string>();
  3997. if (dt != null && dt.Rows.Count > 0)
  3998. {
  3999. foreach (DataRow item in dt.Rows)
  4000. {
  4001. tids.Add("'" + item["tid"] + "'");
  4002. }
  4003. }
  4004. if (tids.Count > 0)
  4005. {
  4006. lw.RemoveAt(0);
  4007. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4008. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4009. dt = WebCache.GetData("view_erptradecell", dStruct);
  4010. }
  4011. }*/
  4012. writeGridDataTableJson(dStruct.TotalCount, dt);
  4013. }
  4014. public void get_erp_jdderiving()
  4015. {
  4016. DataStruct dStruct = GetPostStruct();
  4017. List<string> lw = new List<string>();
  4018. string tid = GetPostString("ctid");
  4019. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4020. string shopname = GetPostString("shopname");
  4021. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4022. string buyernick = GetPostString("buyer_nick");
  4023. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4024. //if (tid.Length == 0 && buyernick.Length == 0)
  4025. //{
  4026. // lw.Add(string.Format("IsRefund<={0}", 1));
  4027. //}
  4028. string customer = GetPostString("customer");
  4029. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4030. string design = GetPostString("design");
  4031. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4032. string orderState = GetPostString("orderState");
  4033. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4034. string address = GetPostString("address");
  4035. 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));
  4036. string sellermemo = GetPostString("seller_memo");
  4037. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4038. string supplier = GetPostString("supplier");
  4039. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4040. string OrderArea = GetPostString("order_area");
  4041. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4042. string placedate1 = GetPostString("placedate1");
  4043. string placedate2 = GetPostString("placedate2");
  4044. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4045. if (fdw.Length > 0) lw.Add(fdw);
  4046. string price1 = GetPostString("price1");
  4047. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4048. string price2 = GetPostString("price2");
  4049. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4050. string unusualCon = GetPostString("unusualcon");
  4051. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4052. string posTag = CurrentUser.UserPost.Post.Code;
  4053. if (posTag == "Supplier")
  4054. {
  4055. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4056. }
  4057. lw.Add(string.Format("OrderState = 6 "));
  4058. lw.Add(string.Format("type = 'JD' "));
  4059. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4060. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4061. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4062. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4063. writeGridDataTableJson(dStruct.TotalCount, dt);
  4064. }
  4065. public void get_erp_demoorderlist()
  4066. {
  4067. DataStruct dStruct = GetPostStruct();
  4068. List<string> lw = new List<string>();
  4069. string tid = GetPostString("ctid");
  4070. if (tid.Length > 0)
  4071. {
  4072. string select_tid = getTidByCtid(tid);
  4073. lw.Add(string.Format("tid='{0}'", select_tid));
  4074. }
  4075. string shopname = GetPostString("shopname");
  4076. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4077. string buyernick = GetPostString("buyer_nick");
  4078. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4079. string customer = GetPostString("customer");
  4080. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4081. string design = GetPostString("design");
  4082. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4083. string orderState = GetPostString("orderState");
  4084. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4085. string address = GetPostString("address");
  4086. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4087. string sellermemo = GetPostString("seller_memo");
  4088. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4089. string supplier = GetPostString("supplier");
  4090. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4091. string OrderArea = GetPostString("order_area");
  4092. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4093. string date1 = GetPostString("date1");
  4094. string date2 = GetPostString("date2");
  4095. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4096. if (dw.Length > 0) lw.Add(dw);
  4097. string price1 = GetPostString("price1");
  4098. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4099. string price2 = GetPostString("price2");
  4100. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4101. string posTag = CurrentUser.UserPost.Post.Code;
  4102. if (posTag == "Supplier")
  4103. {
  4104. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4105. }
  4106. //lw.Add(string.Format("OrderState = 6 "));
  4107. lw.Add(string.Format("IsSample={0}", 3));
  4108. lw.Add(string.Format("IsRefund<={0}", 1));
  4109. dStruct.Order = "pay_time desc";
  4110. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4111. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4112. writeGridDataTableJson(dStruct.TotalCount, dt);
  4113. }
  4114. public void save_erp_checkmemo()
  4115. {
  4116. if (UrlPostParmsCheck("ctid"))
  4117. {
  4118. string ctid = GetPostString("ctid");
  4119. CeErpTradeCell entity = null;
  4120. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4121. if (entity != null)
  4122. {
  4123. entity.CheckMemo = GetPostString("CheckMemo");
  4124. entity.Update();
  4125. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4126. if (trade != null)
  4127. {
  4128. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4129. }
  4130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4131. returnSuccessMsg("保存成功!");
  4132. return;
  4133. }
  4134. returnErrorMsg("找不到记录");
  4135. }
  4136. }
  4137. public void get_erp_returnlist()
  4138. {
  4139. DataStruct dStruct = GetPostStruct();
  4140. List<string> lw = new List<string>();
  4141. string tid = GetPostString("ctid");
  4142. if (tid.Length > 0)
  4143. {
  4144. string select_tid = getTidByCtid(tid);
  4145. lw.Add(string.Format("tid='{0}'", select_tid));
  4146. }
  4147. string shopname = GetPostString("shopname");
  4148. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4149. string buyernick = GetPostString("buyer_nick");
  4150. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4151. string customer = GetPostString("customer");
  4152. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4153. string design = GetPostString("design");
  4154. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4155. string orderState = GetPostString("orderState");
  4156. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4157. string address = GetPostString("address");
  4158. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4159. string sellermemo = GetPostString("seller_memo");
  4160. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4161. string supplier = GetPostString("supplier");
  4162. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4163. string date1 = GetPostString("date1");
  4164. string date2 = GetPostString("date2");
  4165. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4166. if (dw.Length > 0) lw.Add(dw);
  4167. string bdate1 = GetPostString("backdate1");
  4168. string bdate2 = GetPostString("backdate2");
  4169. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4170. if (dw_back.Length > 0) lw.Add(dw_back);
  4171. string price1 = GetPostString("price1");
  4172. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4173. string price2 = GetPostString("price2");
  4174. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4175. lw.Add(string.Format("IsReturn>0"));
  4176. lw.Add(string.Format("IsXianHuo=0"));
  4177. lw.Add(string.Format("IsReturn!=3"));
  4178. string backtype = GetPostString("backtype");
  4179. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4180. dStruct.Order = "FinishDesignTime desc";
  4181. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4182. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4183. writeGridDataTableJson(dStruct.TotalCount, dt);
  4184. }
  4185. public void get_erp_today_sumreturn()
  4186. {
  4187. DataStruct dStruct = GetPostStruct();
  4188. List<string> lw = new List<string>();
  4189. string bdate1 = GetPostString("returnTimeS");
  4190. string bdate2 = GetPostString("returnTimeE");
  4191. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4192. if (dw_back.Length > 0) lw.Add(dw_back);
  4193. lw.Add(string.Format("IsReturn=0"));
  4194. lw.Add(string.Format("IsXianHuo=0"));
  4195. string mainWhere = string.Join(" and ", lw.ToArray());
  4196. string sql = "";
  4197. if (dw_back.Length > 0)
  4198. {
  4199. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4200. }
  4201. else
  4202. {
  4203. 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 + "'";
  4204. }
  4205. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4206. decimal total = 0, today_finish = 0;
  4207. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4208. {
  4209. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4210. }
  4211. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4212. {
  4213. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4214. }
  4215. var res = new
  4216. {
  4217. data = total,
  4218. data1 = today_finish,
  4219. };
  4220. string ro_jsond = JsonConvert.SerializeObject(res);
  4221. returnSuccess(ro_jsond);
  4222. return;
  4223. }
  4224. public void get_erp_allreturnlist()
  4225. {
  4226. DataStruct dStruct = GetPostStruct();
  4227. List<string> lw = new List<string>();
  4228. string tid = GetPostString("ctid");
  4229. if (tid.Length > 0)
  4230. {
  4231. string select_tid = getTidByCtid(tid);
  4232. lw.Add(string.Format("tid='{0}'", select_tid));
  4233. }
  4234. string shopname = GetPostString("shopname");
  4235. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4236. string buyernick = GetPostString("buyer_nick");
  4237. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4238. string customer = GetPostString("customer");
  4239. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4240. string design = GetPostString("design");
  4241. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4242. string orderState = GetPostString("orderState");
  4243. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4244. string address = GetPostString("address");
  4245. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4246. string sellermemo = GetPostString("seller_memo");
  4247. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4248. string supplier = GetPostString("supplier");
  4249. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4250. string date1 = GetPostString("date1");
  4251. string date2 = GetPostString("date2");
  4252. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4253. if (dw.Length > 0) lw.Add(dw);
  4254. string bdate1 = GetPostString("backdate1");
  4255. string bdate2 = GetPostString("backdate2");
  4256. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4257. if (dw_back.Length > 0) lw.Add(dw_back);
  4258. string price1 = GetPostString("price1");
  4259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4260. string price2 = GetPostString("price2");
  4261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4262. string backreason = GetPostString("backreason");
  4263. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4264. lw.Add(string.Format("IsXianHuo=0"));
  4265. lw.Add(string.Format("ReturnTime != ''"));
  4266. string backtype = GetPostString("backtype");
  4267. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4268. dStruct.Order = "FinishDesignTime desc";
  4269. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4270. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4271. writeGridDataTableJson(dStruct.TotalCount, dt);
  4272. }
  4273. public void get_erp_aftersalereturnlist()
  4274. {
  4275. DataStruct dStruct = GetPostStruct();
  4276. List<string> lw = new List<string>();
  4277. string tid = GetPostString("ctid");
  4278. if (tid.Length > 0)
  4279. {
  4280. string select_tid = getTidByCtid(tid);
  4281. lw.Add(string.Format("tid='{0}'", select_tid));
  4282. }
  4283. string shopname = GetPostString("shopname");
  4284. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4285. string buyernick = GetPostString("buyer_nick");
  4286. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4287. string customer = GetPostString("customer");
  4288. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4289. string design = GetPostString("design");
  4290. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4291. string orderState = GetPostString("orderState");
  4292. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4293. string address = GetPostString("address");
  4294. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4295. string sellermemo = GetPostString("seller_memo");
  4296. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4297. string supplier = GetPostString("supplier");
  4298. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4299. string date1 = GetPostString("date1");
  4300. string date2 = GetPostString("date2");
  4301. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4302. if (dw.Length > 0) lw.Add(dw);
  4303. string bdate1 = GetPostString("backdate1");
  4304. string bdate2 = GetPostString("backdate2");
  4305. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4306. if (dw_back.Length > 0) lw.Add(dw_back);
  4307. string price1 = GetPostString("price1");
  4308. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4309. string price2 = GetPostString("price2");
  4310. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4311. lw.Add(string.Format("IsReturn=3"));
  4312. string backtype = GetPostString("backtype");
  4313. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4314. string backreason = GetPostString("backreason");
  4315. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4316. dStruct.Order = "ReturnTime desc";
  4317. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4318. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4319. writeGridDataTableJson(dStruct.TotalCount, dt);
  4320. }
  4321. public void get_erp_xianhuoreturnlist()
  4322. {
  4323. DataStruct dStruct = GetPostStruct();
  4324. List<string> lw = new List<string>();
  4325. string tid = GetPostString("ctid");
  4326. if (tid.Length > 0)
  4327. {
  4328. string select_tid = getTidByCtid(tid);
  4329. lw.Add(string.Format("tid='{0}'", select_tid));
  4330. }
  4331. string shopname = GetPostString("shopname");
  4332. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4333. string buyernick = GetPostString("buyer_nick");
  4334. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4335. string customer = GetPostString("customer");
  4336. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4337. string design = GetPostString("design");
  4338. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4339. string orderState = GetPostString("orderState");
  4340. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4341. string address = GetPostString("address");
  4342. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4343. string sellermemo = GetPostString("seller_memo");
  4344. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4345. string supplier = GetPostString("supplier");
  4346. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4347. string OrderArea = GetPostString("order_area");
  4348. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4349. string date1 = GetPostString("date1");
  4350. string date2 = GetPostString("date2");
  4351. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4352. if (dw.Length > 0) lw.Add(dw);
  4353. string price1 = GetPostString("price1");
  4354. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4355. string price2 = GetPostString("price2");
  4356. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4357. string posTag = CurrentUser.UserPost.Post.Code;
  4358. if (posTag == "Supplier")
  4359. {
  4360. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4361. }
  4362. lw.Add(string.Format("OrderState=6 "));
  4363. lw.Add(string.Format("IsXianHuo=1 "));
  4364. lw.Add(string.Format("IsReturn>0 "));
  4365. lw.Add(string.Format("IsReturn!=3"));
  4366. lw.Add(string.Format("IsRefund<={0}", 1));
  4367. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4368. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4369. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4370. writeGridDataTableJson(dStruct.TotalCount, dt);
  4371. }
  4372. public void set_erp_orderdelivery()
  4373. {
  4374. if (UrlPostParmsCheck("ctid"))
  4375. {
  4376. string eid = GetPostString("ctid");
  4377. CeErpTradeCell entity = null;
  4378. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4379. if (entity != null)
  4380. {
  4381. if (entity.OrderState >= 7)
  4382. {
  4383. returnErrorMsg("此单已发货,无需重复发货");
  4384. return;
  4385. }
  4386. if (entity.OrderState != 6)
  4387. {
  4388. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4389. return;
  4390. }
  4391. string shop = GetPostString("seller_nick");
  4392. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4393. string comName = GetPostString("comName");
  4394. string comCode = GetPostString("comCode");
  4395. string outSid = GetPostString("outSid");
  4396. string deliveryType = GetPostString("deliveryType");
  4397. string deliveryMemo = GetPostString("deliveryMemo");
  4398. outSid = outSid.Trim();
  4399. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4400. if (mainEn == null)
  4401. {
  4402. returnErrorMsg("找不到原始订单记录");
  4403. return;
  4404. }
  4405. bool isInitOrderDeliv = false;
  4406. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4407. {
  4408. isInitOrderDeliv = true;
  4409. }
  4410. string apires = "";
  4411. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4412. 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)
  4413. {
  4414. apires = "发货成功true";
  4415. }
  4416. else
  4417. {
  4418. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4419. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4420. }
  4421. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4422. {
  4423. entity.OrderState = 7;//发货后订单已发货
  4424. entity.OutSid = outSid;
  4425. entity.MemoOpt = 0;
  4426. entity.FinishDeliveryTime = DateTime.Now;
  4427. entity.Update();
  4428. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4429. commonHelper.UpdateRelationOrder(entity.ctid);
  4430. //还要插入快递信息到 快递信息表
  4431. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4432. exinfo.tid = eid;
  4433. exinfo.out_sid = outSid;
  4434. exinfo.company_code = comCode;
  4435. exinfo.company_name = comName;
  4436. exinfo.delivery_memo = deliveryMemo;
  4437. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4438. exinfo.deliveryType = deliveryType;
  4439. exinfo.Create();
  4440. returnSuccessMsg("发货操作成功!");
  4441. commonHelper.UpdateRelationOrder(entity.ctid);
  4442. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4443. CeErpSukuraData.createInfo(entity.ctid, 4);
  4444. if (entity.SupplierId == 64)
  4445. {
  4446. commonHelper.sendCytExpress(exinfo);
  4447. }
  4448. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4449. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4450. }
  4451. else
  4452. {
  4453. string errmsg = commonHelper.KeepChinese(apires);
  4454. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4455. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4456. }
  4457. return;
  4458. }
  4459. returnErrorMsg("找不到订单记录");
  4460. }
  4461. }
  4462. public void set_erp_multidelivery()
  4463. {
  4464. string eids = GetPostString("tids");
  4465. string[] eidList = eids.Split(',');
  4466. if (eidList.Length <= 0)
  4467. {
  4468. returnErrorMsg("发货不能为空");
  4469. return;
  4470. }
  4471. foreach (string ctid in eidList)
  4472. {
  4473. if (ctid.Length <= 0) continue;
  4474. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4475. if (expInfo != null)
  4476. {
  4477. StringBuilder sql = new StringBuilder();
  4478. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4479. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4480. if (dt.Rows.Count > 0)
  4481. {
  4482. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4483. {
  4484. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4485. expInfo.state = "异常";
  4486. expInfo.isMultiDelivery = 1;
  4487. expInfo.Update();
  4488. continue;
  4489. }
  4490. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4491. {
  4492. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4493. expInfo.state = "异常";
  4494. expInfo.Update();
  4495. continue;
  4496. }
  4497. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4498. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4499. bool isInitOrderDeliv = false;
  4500. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4501. {
  4502. isInitOrderDeliv = true;
  4503. expInfo.isMultiDelivery = 1;
  4504. }
  4505. if (ctid.IndexOf("N") != -1)
  4506. {
  4507. StringBuilder sqlbucha = new StringBuilder();
  4508. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4509. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4510. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4511. commonHelper.UpdateRelationOrder(ctid);
  4512. expInfo.delivery_memo = "发货成功";
  4513. expInfo.state = "发货成功";
  4514. expInfo.isMultiDelivery = 1;
  4515. expInfo.Update();
  4516. }
  4517. else
  4518. {
  4519. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4520. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4521. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4522. {
  4523. expInfo.delivery_memo = "发货成功";
  4524. expInfo.state = "发货成功";
  4525. expInfo.isMultiDelivery = 1;
  4526. expInfo.Update();
  4527. commonHelper.UpdateRelationOrder(ctid);
  4528. CeErpSukuraData.createInfo(ctid, 4);
  4529. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4530. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4531. }
  4532. else
  4533. {
  4534. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4535. expInfo.state = "异常";
  4536. expInfo.Update();
  4537. }
  4538. }
  4539. }
  4540. }
  4541. }
  4542. returnSuccessMsg("操作完成");
  4543. }
  4544. public void reset_erp_memoopt()
  4545. {
  4546. if (UrlPostParmsCheck("ctid"))
  4547. {
  4548. string eid = GetPostString("ctid");
  4549. CeErpTradeCell entity = null;
  4550. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4551. if (entity != null)
  4552. {
  4553. string stropt = "";
  4554. if (entity.MemoOpt == 1)
  4555. {
  4556. stropt = "“改稿”";
  4557. }
  4558. else if (entity.MemoOpt == 2)
  4559. {
  4560. stropt = "“定稿”";
  4561. }
  4562. else if (entity.MemoOpt == 3)
  4563. {
  4564. stropt = "“完成查货”";
  4565. CeErpSukuraData.createInfo(entity.ctid, 6);
  4566. }
  4567. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4568. entity.MemoOpt = 0;
  4569. entity.Update();
  4570. returnSuccessMsg("操作成功!");
  4571. return;
  4572. }
  4573. returnErrorMsg("找不到记录");
  4574. }
  4575. }
  4576. public void get_erp_deliveryunusual()
  4577. {
  4578. DataStruct dStruct = GetPostStruct();
  4579. List<string> lw = new List<string>();
  4580. string tid = GetPostString("ctid");
  4581. if (tid.Length > 0)
  4582. {
  4583. string select_tid = getTidByCtid(tid);
  4584. lw.Add(string.Format("tid='{0}'", select_tid));
  4585. }
  4586. string shopname = GetPostString("shopname");
  4587. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4588. string buyernick = GetPostString("buyer_nick");
  4589. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4590. string customer = GetPostString("customer");
  4591. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4592. string design = GetPostString("design");
  4593. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4594. string sellermemo = GetPostString("seller_memo");
  4595. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4596. string supplier = GetPostString("supplier");
  4597. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4598. string date1 = GetPostString("date1");
  4599. string date2 = GetPostString("date2");
  4600. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4601. if (dw.Length > 0) lw.Add(dw);
  4602. string placedate1 = GetPostString("placedate1");
  4603. string placedate2 = GetPostString("placedate2");
  4604. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4605. if (dw_place.Length > 0) lw.Add(dw_place);
  4606. string price1 = GetPostString("price1");
  4607. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4608. string price2 = GetPostString("price2");
  4609. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4610. string unusualCon = GetPostString("unusualcon");
  4611. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  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. lw.Add(string.Format("OrderState = 6"));
  4618. lw.Add(string.Format("UnusualTag = 5"));
  4619. lw.Add(string.Format("IsRefund<={0}", 1));
  4620. dStruct.Order = "FinishPlaceTime desc";
  4621. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4622. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4623. writeGridDataTableJson(dStruct.TotalCount, dt);
  4624. }
  4625. public void get_erp_deliveryedlist()
  4626. {
  4627. DataStruct dStruct = GetPostStruct();
  4628. List<string> lw = new List<string>();
  4629. string tid = GetPostString("ctid");
  4630. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4631. string shopname = GetPostString("shopname");
  4632. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4633. string buyernick = GetPostString("buyer_nick");
  4634. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4635. string customer = GetPostString("customer");
  4636. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4637. string design = GetPostString("design");
  4638. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4639. string sellermemo = GetPostString("seller_memo");
  4640. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4641. string logistics = GetPostString("logistics");
  4642. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4643. string date1 = GetPostString("date1");
  4644. string date2 = GetPostString("date2");
  4645. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4646. //if (dw.Length > 0) lw.Add(dw);
  4647. string placedate1 = GetPostString("placedate1");
  4648. string placedate2 = GetPostString("placedate2");
  4649. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4650. if (fdw.Length > 0) lw.Add(fdw);
  4651. string devdate1 = GetPostString("deliverydate1");
  4652. string devdate2 = GetPostString("deliverydate2");
  4653. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4654. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4655. string price1 = GetPostString("price1");
  4656. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4657. string price2 = GetPostString("price2");
  4658. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4659. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4660. {
  4661. if (tid.Length > 0)
  4662. {
  4663. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4664. }
  4665. if (buyernick.Length > 0)
  4666. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4667. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4668. if (dw.Length > 0) lw.Add(dw);
  4669. }
  4670. else
  4671. {
  4672. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4673. }
  4674. string posTag = CurrentUser.UserPost.Post.Code;
  4675. if (posTag == "Supplier")
  4676. {
  4677. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4678. }
  4679. else
  4680. {
  4681. string supplier = GetPostString("supplier");
  4682. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4683. }
  4684. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4685. lw.Add(string.Format("IsRefund!={0}", 2));
  4686. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4687. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4688. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4689. /*if (tid.Length > 0)
  4690. {
  4691. List<string> tids = new List<string>();
  4692. if (dt != null && dt.Rows.Count > 0)
  4693. {
  4694. foreach (DataRow item in dt.Rows)
  4695. {
  4696. tids.Add("'" + item["tid"] + "'");
  4697. }
  4698. }
  4699. if (tids.Count > 0)
  4700. {
  4701. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4702. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4703. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4704. dt = WebCache.GetData("view_erptradecell", dStruct);
  4705. }
  4706. }*/
  4707. if (dt != null)
  4708. {
  4709. foreach (DataRow dr in dt.Rows)
  4710. {
  4711. 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();
  4712. }
  4713. }
  4714. writeGridDataTableJson(dStruct.TotalCount, dt);
  4715. }
  4716. public void get_erp_pdddeliveryed()
  4717. {
  4718. DataStruct dStruct = GetPostStruct();
  4719. List<string> lw = new List<string>();
  4720. string tid = GetPostString("ctid");
  4721. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4722. string shopname = GetPostString("shopname");
  4723. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4724. string buyernick = GetPostString("buyer_nick");
  4725. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4726. string customer = GetPostString("customer");
  4727. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4728. string design = GetPostString("design");
  4729. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4730. string sellermemo = GetPostString("seller_memo");
  4731. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4732. string logistics = GetPostString("logistics");
  4733. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4734. string date1 = GetPostString("date1");
  4735. string date2 = GetPostString("date2");
  4736. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4737. //if (dw.Length > 0) lw.Add(dw);
  4738. string placedate1 = GetPostString("placedate1");
  4739. string placedate2 = GetPostString("placedate2");
  4740. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4741. if (fdw.Length > 0) lw.Add(fdw);
  4742. string devdate1 = GetPostString("deliverydate1");
  4743. string devdate2 = GetPostString("deliverydate2");
  4744. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4745. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4746. string price1 = GetPostString("price1");
  4747. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4748. string price2 = GetPostString("price2");
  4749. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4750. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4751. {
  4752. if (tid.Length > 0)
  4753. {
  4754. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4755. }
  4756. if (buyernick.Length > 0)
  4757. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4758. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4759. if (dw.Length > 0) lw.Add(dw);
  4760. }
  4761. else
  4762. {
  4763. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4764. }
  4765. string posTag = CurrentUser.UserPost.Post.Code;
  4766. if (posTag == "Supplier")
  4767. {
  4768. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4769. }
  4770. else
  4771. {
  4772. string supplier = GetPostString("supplier");
  4773. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4774. }
  4775. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4776. lw.Add(string.Format("type = 'PDD' "));
  4777. lw.Add(string.Format("IsRefund!={0}", 2));
  4778. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4779. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4780. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4781. /* if (tid.Length > 0)
  4782. {
  4783. List<string> tids = new List<string>();
  4784. if (dt != null && dt.Rows.Count > 0)
  4785. {
  4786. foreach (DataRow item in dt.Rows)
  4787. {
  4788. tids.Add("'" + item["tid"] + "'");
  4789. }
  4790. }
  4791. if (tids.Count > 0)
  4792. {
  4793. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4794. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4795. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4796. dt = WebCache.GetData("view_erptradecell", dStruct);
  4797. }
  4798. }*/
  4799. foreach (DataRow dr in dt.Rows)
  4800. {
  4801. 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();
  4802. }
  4803. writeGridDataTableJson(dStruct.TotalCount, dt);
  4804. }
  4805. public void get_erp_jddeliveryed()
  4806. {
  4807. DataStruct dStruct = GetPostStruct();
  4808. List<string> lw = new List<string>();
  4809. string tid = GetPostString("ctid");
  4810. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4811. string shopname = GetPostString("shopname");
  4812. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4813. string buyernick = GetPostString("buyer_nick");
  4814. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4815. string customer = GetPostString("customer");
  4816. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4817. string design = GetPostString("design");
  4818. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4819. string sellermemo = GetPostString("seller_memo");
  4820. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4821. string date1 = GetPostString("date1");
  4822. string date2 = GetPostString("date2");
  4823. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4824. //if (dw.Length > 0) lw.Add(dw);
  4825. string placedate1 = GetPostString("placedate1");
  4826. string placedate2 = GetPostString("placedate2");
  4827. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4828. if (fdw.Length > 0) lw.Add(fdw);
  4829. string devdate1 = GetPostString("deliverydate1");
  4830. string devdate2 = GetPostString("deliverydate2");
  4831. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4832. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4833. string price1 = GetPostString("price1");
  4834. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4835. string price2 = GetPostString("price2");
  4836. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4837. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4838. {
  4839. if (tid.Length > 0)
  4840. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4841. if (buyernick.Length > 0)
  4842. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4843. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4844. if (dw.Length > 0) lw.Add(dw);
  4845. }
  4846. else
  4847. {
  4848. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4849. }
  4850. string posTag = CurrentUser.UserPost.Post.Code;
  4851. if (posTag == "Supplier")
  4852. {
  4853. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4854. }
  4855. else
  4856. {
  4857. string supplier = GetPostString("supplier");
  4858. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4859. }
  4860. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4861. lw.Add(string.Format("type = 'JD' "));
  4862. lw.Add(string.Format("IsRefund!={0}", 2));
  4863. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4864. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4865. DataTable dt = WebCache.GetData("view_erptradecell", 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_allplacelist()
  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 like '%{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 = '{0}'", supplier));
  4890. string date1 = GetPostString("date1");
  4891. string date2 = GetPostString("date2");
  4892. string pldate1 = GetPostString("placedate1");
  4893. string pldate2 = GetPostString("placedate2");
  4894. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4895. //if (dw.Length > 0) lw.Add(dw);
  4896. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4897. {
  4898. if (tid.Length > 0)
  4899. {
  4900. string select_tid = getTidByCtid(tid);
  4901. lw.Add(string.Format("tid='{0}'", select_tid));
  4902. }
  4903. if (buyernick.Length > 0)
  4904. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4905. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4906. if (dw.Length > 0) lw.Add(dw);
  4907. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4908. if (dw_place.Length > 0) lw.Add(dw_place);
  4909. }
  4910. else
  4911. {
  4912. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4913. {
  4914. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4915. }
  4916. }
  4917. string price1 = GetPostString("price1");
  4918. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4919. string price2 = GetPostString("price2");
  4920. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4921. string posTag = CurrentUser.UserPost.Post.Code;
  4922. if (posTag == "Supplier")
  4923. {
  4924. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4925. }
  4926. lw.Add(string.Format("OrderState >= 6"));
  4927. lw.Add(string.Format("IsSample != 2 "));
  4928. lw.Add(string.Format("isDianziOrder = 0 "));
  4929. //lw.Add(string.Format("IsRefund<={0}", 1));
  4930. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4931. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4932. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4933. foreach (DataRow dr in dt.Rows)
  4934. {
  4935. 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();
  4936. }
  4937. writeGridDataTableJson(dStruct.TotalCount, dt);
  4938. }
  4939. public void get_erp_financeallplacelist()
  4940. {
  4941. DataStruct dStruct = GetPostStruct();
  4942. List<string> lw = new List<string>();
  4943. string tid = GetPostString("ctid");
  4944. string shopname = GetPostString("shopname");
  4945. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4946. string buyernick = GetPostString("buyer_nick");
  4947. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4948. string customer = GetPostString("customer");
  4949. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4950. string design = GetPostString("design");
  4951. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4952. string sellermemo = GetPostString("seller_memo");
  4953. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4954. string supplier = GetPostString("supplier");
  4955. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4956. string date1 = GetPostString("date1");
  4957. string date2 = GetPostString("date2");
  4958. string pldate1 = GetPostString("placedate1");
  4959. string pldate2 = GetPostString("placedate2");
  4960. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4961. {
  4962. if (tid.Length > 0)
  4963. {
  4964. string select_tid = getTidByCtid(tid);
  4965. lw.Add(string.Format("tid='{0}'", select_tid));
  4966. }
  4967. if (buyernick.Length > 0)
  4968. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4969. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4970. if (dw.Length > 0) lw.Add(dw);
  4971. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4972. if (dw_place.Length > 0) lw.Add(dw_place);
  4973. }
  4974. else
  4975. {
  4976. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4977. {
  4978. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4979. }
  4980. }
  4981. string price1 = GetPostString("price1");
  4982. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4983. string price2 = GetPostString("price2");
  4984. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4985. string posTag = CurrentUser.UserPost.Post.Code;
  4986. if (posTag == "Supplier")
  4987. {
  4988. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4989. }
  4990. //lw.Add(string.Format("OrderState >= 6"));
  4991. lw.Add(string.Format("IsSample != 2 "));
  4992. lw.Add(string.Format("isDianziOrder = 0 "));
  4993. //lw.Add(string.Format("IsRefund<={0}", 1));
  4994. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4995. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4996. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4997. foreach (DataRow dr in dt.Rows)
  4998. {
  4999. 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();
  5000. }
  5001. writeGridDataTableJson(dStruct.TotalCount, dt);
  5002. }
  5003. public void get_erp_expresslist()
  5004. {
  5005. int listtype = GetInt("ltype");
  5006. DataStruct dStruct = GetPostStruct();
  5007. List<string> lw = new List<string>();
  5008. string tid = GetPostString("tid");
  5009. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5010. string outsid = GetPostString("out_sid");
  5011. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5012. string importer = GetPostString("ImportUserName");
  5013. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5014. string file = GetPostString("import_file");
  5015. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5016. string printman = GetPostString("printman");
  5017. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5018. string date1 = GetPostString("date1");
  5019. string date2 = GetPostString("date2");
  5020. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5021. if (dw.Length > 0) lw.Add(dw);
  5022. string fdate1 = GetPostString("finishdate1");
  5023. string fdate2 = GetPostString("finishdate2");
  5024. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5025. if (fdw.Length > 0) lw.Add(fdw);
  5026. string supplierId = GetPostString("supplierId");
  5027. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5028. if (listtype == 1)
  5029. {
  5030. lw.Add(string.Format("importUserId !=0"));
  5031. }
  5032. string posTag = CurrentUser.UserPost.Post.Code;
  5033. if (posTag == "Supplier")
  5034. {
  5035. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5036. }
  5037. if (dStruct.PageSize != 100000)
  5038. {
  5039. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5040. }
  5041. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5042. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5043. writeGridDataTableJson(dStruct.TotalCount, dt);
  5044. }
  5045. public void set_erp_buchaorderdelivery()
  5046. {
  5047. if (UrlPostParmsCheck("ctid"))
  5048. {
  5049. string eid = GetPostString("ctid");
  5050. CeErpTradeCell entity = null;
  5051. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5052. if (entity != null)
  5053. {
  5054. if (entity.IsSample != 2)
  5055. {
  5056. returnErrorMsg("补差价单才能标记为已发货");
  5057. return;
  5058. }
  5059. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5060. entity.OrderState = 7;
  5061. entity.Update();
  5062. returnSuccessMsg("操作成功!");
  5063. return;
  5064. }
  5065. returnErrorMsg("找不到记录");
  5066. }
  5067. }
  5068. public void get_stdtemplates()
  5069. {
  5070. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5071. //string res = taobaoHelper.test();
  5072. string res = apiHelper.API_PrintTemplate();
  5073. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5074. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5075. {
  5076. int sidx = res.IndexOf("error_code");
  5077. int eidx = res.IndexOf("success");
  5078. string msg = res.Substring(sidx, eidx - sidx);
  5079. returnErrorMsg(msg);
  5080. return;
  5081. }
  5082. if (res.Length <= 0)
  5083. {
  5084. returnErrorMsg("模板数据为空!");
  5085. return;
  5086. }
  5087. ReturnSuccess(res);
  5088. }
  5089. public void cancel_print_order()
  5090. {
  5091. if (UrlPostParmsCheck("ctid"))
  5092. {
  5093. string ctid = GetPostString("ctid");
  5094. CeErpTradeCell entity = null;
  5095. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5096. if (entity != null)
  5097. {
  5098. string res = "";
  5099. string code = entity.LastBillWaybillCode;
  5100. if (code == "")
  5101. {
  5102. code = entity.OutSid;
  5103. }
  5104. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5105. XLog.SaveLog(0, "取消面单" + res);
  5106. }
  5107. }
  5108. }
  5109. public void set_erp_printwaybill()
  5110. {
  5111. if (UrlPostParmsCheck("ctid"))
  5112. {
  5113. string ctid = GetPostString("ctid");
  5114. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5115. string cpName = GetPostString("cpname");
  5116. string isTogether = GetPostString("together");
  5117. //var res_obj = new
  5118. //{
  5119. // restype = 1,
  5120. // 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\"}"
  5121. //};
  5122. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5123. //ReturnSuccess(ro_json);
  5124. //return;
  5125. bool isUseLastWayBillCode = false;
  5126. CeErpTradeCell entity = null;
  5127. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5128. if (entity != null)
  5129. {
  5130. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5131. {
  5132. isUseLastWayBillCode = true;
  5133. }
  5134. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5135. {
  5136. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5137. return;
  5138. }
  5139. }
  5140. string res = "";
  5141. Api_waybill_code_response_Obj fullObj = null;
  5142. string pData_str = "";
  5143. string curUseWayBillCode = "";
  5144. if (isUseLastWayBillCode == false)
  5145. {
  5146. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5147. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5148. if (res.IndexOf("failure") != -1)
  5149. {
  5150. //int idx = res.IndexOf("sub_message");
  5151. //int idx2 = res.IndexOf("flag");
  5152. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5153. string errMsgNeed = commonHelper.KeepChinese(res);
  5154. var res_objd = new
  5155. {
  5156. restype = 0,
  5157. data = "获取面单失败" + errMsgNeed
  5158. };
  5159. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5160. returnSuccess(ro_jsond);
  5161. if (res.IndexOf("停发") != -1)
  5162. {
  5163. entity.UnusualCon = "物流停发";
  5164. entity.Update();
  5165. }
  5166. //returnErrorMsg("获取面单失败,"+emsg);
  5167. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5168. return;
  5169. }
  5170. else if (res.IndexOf("errorMsg") != -1)
  5171. {
  5172. //int idx = res.IndexOf("errorMsg");
  5173. //int idx2 = res.IndexOf("}]}");
  5174. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5175. string errMsgNeed = commonHelper.KeepChinese(res);
  5176. var res_objf = new
  5177. {
  5178. restype = 0,
  5179. data = "获取面单失败2" + errMsgNeed
  5180. };
  5181. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5182. if (res.IndexOf("停发") != -1)
  5183. {
  5184. entity.UnusualCon = "物流停发";
  5185. entity.Update();
  5186. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5187. if (trade != null)
  5188. {
  5189. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5190. }
  5191. }
  5192. returnSuccess(ro_jsonf);
  5193. //returnErrorMsg("获取面单失败," + emsg);
  5194. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5195. return;
  5196. }
  5197. try
  5198. {
  5199. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5200. //res = res.Replace(" ", "");
  5201. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5202. }
  5203. catch (Exception ex)
  5204. {
  5205. XLog.SaveLog(0, "生成fullObj" + res);
  5206. var res_objf = new
  5207. {
  5208. restype = 0,
  5209. data = "生成fullObj发生错误" + ex.Message
  5210. };
  5211. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5212. returnSuccess(ro_jsonf);
  5213. return;
  5214. }
  5215. if (fullObj.response.data.content.Count > 0)
  5216. {
  5217. ContentItem codeObj = fullObj.response.data.content[0];
  5218. if (cpCode.IndexOf("SFFQ-") != -1)
  5219. {
  5220. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5221. }
  5222. else
  5223. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5224. curUseWayBillCode = codeObj.waybillCode;
  5225. }
  5226. else
  5227. {
  5228. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5229. var res_objf = new
  5230. {
  5231. restype = 0,
  5232. data = "生成fullObj找不到快递单号waybillCode"
  5233. };
  5234. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5235. returnSuccess(ro_jsonf);
  5236. return;
  5237. }
  5238. }
  5239. else
  5240. {
  5241. //使用上次打印的快递单号
  5242. if (cpCode == "SFFQ-LY")
  5243. {
  5244. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5245. }
  5246. else
  5247. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5248. curUseWayBillCode = entity.LastBillWaybillCode;
  5249. }
  5250. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5251. {
  5252. var res_obje = new
  5253. {
  5254. restype = 0,
  5255. data = "获取加密打印数据失败"
  5256. };
  5257. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5258. returnSuccess(ro_jsone);
  5259. entity.LastBillCpCode = cpCode;
  5260. entity.LastBillWaybillCode = curUseWayBillCode;
  5261. entity.Update();
  5262. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5263. //returnErrorMsg("获取加密打印数据失败");
  5264. return;
  5265. }
  5266. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5267. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5268. string btnType = "";
  5269. if (entity != null)
  5270. {
  5271. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5272. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5273. //cpcode是 YTO-CAINIAO
  5274. //string comCode = cpCode.Split('-')[0].ToString();
  5275. string apires = "";
  5276. if (ctid.IndexOf("N") != -1)
  5277. {
  5278. apires = "发货成功";
  5279. }
  5280. else
  5281. {
  5282. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5283. }
  5284. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5285. //打单后发货
  5286. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5287. {
  5288. try
  5289. {
  5290. btnType = "待发货";
  5291. entity.OutSid = curUseWayBillCode;
  5292. entity.OrderState = 7;
  5293. entity.IsUrgency = false;
  5294. entity.LastBillCpCode = "";
  5295. entity.LastBillWaybillCode = "";
  5296. entity.FinishDeliveryTime = DateTime.Now;
  5297. entity.IsReturn = 0;
  5298. entity.MemoOpt = 0;
  5299. entity.Update();
  5300. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5301. //还要插入快递信息到 快递信息表
  5302. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5303. exinfo.tid = entity.ctid;
  5304. exinfo.out_sid = entity.OutSid;
  5305. exinfo.company_code = cpCode;
  5306. exinfo.company_name = cpName;
  5307. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5308. exinfo.deliveryType = "发货成功";
  5309. exinfo.print_time = DateTime.Now;
  5310. exinfo.printUser = CurrentUser.UserName;
  5311. exinfo.Create();
  5312. commonHelper.UpdateRelationOrder(entity.ctid);
  5313. CeErpSukuraData.createInfo(ctid, 4);
  5314. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5315. if (entity.SupplierId == 64)
  5316. {
  5317. commonHelper.sendCytExpress(exinfo);
  5318. }
  5319. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5320. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5321. if (isTogether == "1")
  5322. {
  5323. StringBuilder sqlsb = new StringBuilder();
  5324. 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);
  5325. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5326. }
  5327. }
  5328. catch (Exception ex)
  5329. {
  5330. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5331. }
  5332. }
  5333. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5334. {
  5335. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5336. if (entity.OrderState == 6)
  5337. {
  5338. entity.OrderState = 7;
  5339. }
  5340. entity.FinishDeliveryTime = DateTime.Now;
  5341. btnType = "已发货";
  5342. entity.Update();
  5343. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5344. exinfo.tid = entity.ctid;
  5345. exinfo.out_sid = entity.OutSid;
  5346. exinfo.company_code = cpCode;
  5347. exinfo.company_name = cpName;
  5348. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5349. exinfo.deliveryType = "发货成功";
  5350. exinfo.print_time = DateTime.Now;
  5351. exinfo.printUser = CurrentUser.UserName;
  5352. exinfo.Create();
  5353. commonHelper.UpdateRelationOrder(entity.ctid);
  5354. CeErpSukuraData.createInfo(entity.ctid, 4);
  5355. if (entity.SupplierId == 64)
  5356. {
  5357. commonHelper.sendCytExpress(exinfo);
  5358. }
  5359. if (isTogether == "1")
  5360. {
  5361. StringBuilder sqlsb = new StringBuilder();
  5362. 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);
  5363. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5364. }
  5365. //不处理
  5366. }
  5367. else
  5368. {
  5369. entity.LastBillCpCode = cpCode;
  5370. entity.LastBillWaybillCode = curUseWayBillCode;
  5371. entity.Update();
  5372. string errmsg = commonHelper.KeepChinese(apires);
  5373. var res_objz = new
  5374. {
  5375. restype = 0,
  5376. data = "打单后发货失败"
  5377. };
  5378. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5379. returnSuccess(ro_jsonz);
  5380. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5381. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5382. return;
  5383. }
  5384. }
  5385. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5386. var res_obj = new
  5387. {
  5388. restype = 1,
  5389. data = pData_str
  5390. };
  5391. string ro_json = JsonConvert.SerializeObject(res_obj);
  5392. ReturnSuccess(ro_json);
  5393. return;
  5394. }
  5395. }
  5396. private string GetUTF8String(byte[] vs)
  5397. {
  5398. throw new NotImplementedException();
  5399. }
  5400. public void set_erp_printwaybill_cn()
  5401. {
  5402. if (UrlPostParmsCheck("ctid"))
  5403. {
  5404. string ctid = GetPostString("ctid");
  5405. string cpCode = GetPostString("cpcode");
  5406. string cpName = GetPostString("cpname");
  5407. string tempUrl = GetPostString("tempurl");
  5408. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5409. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5410. //string res = taobaoHelper.test();
  5411. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5412. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5413. {
  5414. int sidx = res.IndexOf("errorMsg");
  5415. int eidx = res.IndexOf("}");
  5416. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5417. var res_objzxx = new
  5418. {
  5419. restype = 0,
  5420. data = msg
  5421. };
  5422. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5423. returnSuccess(ro_jsonzxx);
  5424. //returnErrorMsg(msg);
  5425. return;
  5426. }
  5427. int idx = res.IndexOf("waybillCode");
  5428. int idx2 = res.IndexOf("printData");
  5429. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5430. string eid = GetPostString("ctid");
  5431. CeErpTradeCell entity = null;
  5432. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5433. if (entity != null)
  5434. {
  5435. string osid = entity.OutSid;
  5436. entity.OutSid = osid + "," + outsid;
  5437. entity.FinishDeliveryTime = DateTime.Now;
  5438. entity.OrderState = 7;
  5439. entity.IsReturn = 0;
  5440. entity.Update();
  5441. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5442. exinfo.tid = entity.ctid;
  5443. exinfo.out_sid = outsid;
  5444. exinfo.company_code = cpCode;
  5445. exinfo.company_name = cpName;
  5446. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5447. exinfo.deliveryType = "发货成功";
  5448. exinfo.print_time = DateTime.Now;
  5449. exinfo.printUser = CurrentUser.UserName;
  5450. exinfo.Create();
  5451. if (entity.SupplierId == 64)
  5452. {
  5453. commonHelper.sendCytExpress(exinfo);
  5454. }
  5455. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5456. }
  5457. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5458. var res_objz = new
  5459. {
  5460. restype = 1,
  5461. data = res
  5462. };
  5463. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5464. returnSuccess(ro_jsonz);
  5465. //ReturnSuccess(res);
  5466. }
  5467. }
  5468. ////打单,打印面单 获取面单号
  5469. //public void set_erp_printwaybill()
  5470. //{
  5471. // if (UrlPostParmsCheck("ctid"))
  5472. // {
  5473. // string ctid = GetPostString("ctid");
  5474. // string cpCode = GetPostString("cpcode");
  5475. // string tempUrl = GetPostString("tempurl");
  5476. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5477. // //string res = taobaoHelper.test();
  5478. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5479. // if (res.IndexOf("error_response") != -1)
  5480. // {
  5481. // int sidx = res.IndexOf("sub_msg");
  5482. // int eidx = res.IndexOf("request_id");
  5483. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5484. // returnErrorMsg(msg);
  5485. // return;
  5486. // }
  5487. // int idx = res.IndexOf("waybill_code");
  5488. // int idx2 = res.IndexOf("}]}");
  5489. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5490. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5491. // ReturnSuccess(res);
  5492. // }
  5493. //}
  5494. public void cancel_erp_aftersale()
  5495. {
  5496. if (UrlPostParmsCheck("ctid"))
  5497. {
  5498. string eid = GetPostString("ctid");
  5499. CeErpTradeCell entity = null;
  5500. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5501. if (entity != null)
  5502. {
  5503. //有过处理的售后,取消也不能删除 售 字,保留
  5504. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5505. {
  5506. entity.AfterSaleState = 4;
  5507. }
  5508. else
  5509. entity.AfterSaleState = 0;
  5510. entity.Update();
  5511. returnSuccessMsg("操作成功!");
  5512. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5513. return;
  5514. }
  5515. returnErrorMsg("找不到订单记录");
  5516. }
  5517. }
  5518. public void get_erp_aftersalelist()
  5519. {
  5520. DataStruct dStruct = GetPostStruct();
  5521. List<string> lw = new List<string>();
  5522. int st = GetInt("st");
  5523. string tid = GetPostString("ctid");
  5524. if (st == 3)
  5525. {
  5526. if (tid.Length > 0)
  5527. {
  5528. string select_tid = getTidByCtid(tid);
  5529. lw.Add(string.Format("tid='{0}'", select_tid));
  5530. }
  5531. }
  5532. else
  5533. {
  5534. if (tid.Length > 0)
  5535. {
  5536. string select_tid = getTidByCtid(tid);
  5537. lw.Add(string.Format("tid='{0}'", select_tid));
  5538. }
  5539. }
  5540. string shopname = GetPostString("shopname");
  5541. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5542. string buyernick = GetPostString("buyer_nick");
  5543. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5544. string sellermemo = GetPostString("seller_memo");
  5545. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5546. string orderState = GetPostString("orderState");
  5547. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5548. string afterState = GetPostString("afterstate");
  5549. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5550. string date1 = GetPostString("date1");
  5551. string date2 = GetPostString("date2");
  5552. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5553. if (dw.Length > 0) lw.Add(dw);
  5554. string price1 = GetPostString("price1");
  5555. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5556. string price2 = GetPostString("price2");
  5557. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5558. //lw.Add(string.Format("IsRefund!={0}", 1));
  5559. string reason = GetPostString("reason");
  5560. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5561. string method = GetPostString("method");
  5562. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5563. string handler = GetPostString("handler");
  5564. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5565. string handledate1 = GetPostString("handledate1");
  5566. string handledate2 = GetPostString("handledate2");
  5567. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5568. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5569. string finish1 = GetPostString("finishdate1");
  5570. string finish2 = GetPostString("finishdate2");
  5571. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5572. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5573. string afterdate1 = GetPostString("afterdate1");
  5574. string afterdate2 = GetPostString("afterdate2");
  5575. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5576. if (afterDate.Length > 0) lw.Add(afterDate);
  5577. string supplier = GetPostString("supplier");
  5578. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5579. string responsible = GetPostString("responsibleman");
  5580. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5581. string customer = GetPostString("customer");
  5582. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5583. string design = GetPostString("design");
  5584. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5585. string afterMemoType = GetPostString("aftermemotype");
  5586. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5587. string posCode = CurrentUser.UserPost.Post.Code;
  5588. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5589. //{
  5590. // string vstate = GetPostString("vstate");
  5591. // if (vstate.Length > 0)
  5592. // {
  5593. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5594. // }
  5595. // if (posCode == "Supplier")
  5596. // {
  5597. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5598. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5599. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5600. // }
  5601. // else
  5602. // {
  5603. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5604. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5605. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5606. // {
  5607. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5608. // }
  5609. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5610. // {
  5611. // int orgid = CurrentUser.UserPost.OrgID;
  5612. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5613. // }
  5614. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5615. // {
  5616. // string shopid = CurrentUser.User.pemShop;
  5617. // lw.Add(string.Format("shopId in ({0})", shopid));
  5618. // }
  5619. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5620. // //{
  5621. // // int org_id = CurrentUser.UserPost.OrgID;
  5622. // // lw.Add(string.Format("OrgID={0}", org_id));
  5623. // //}
  5624. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5625. // }
  5626. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5627. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5628. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5629. //}
  5630. if (st == 5)
  5631. {
  5632. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5633. {
  5634. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5635. {
  5636. string shopid = CurrentUser.User.pemShop;
  5637. lw.Add(string.Format("shopId in ({0})", shopid));
  5638. }
  5639. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5640. {
  5641. int mrOrgid = CurrentUser.UserPost.OrgID;
  5642. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5643. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5644. }
  5645. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5646. //{
  5647. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5648. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5649. //}
  5650. else
  5651. {
  5652. string userIdStr = "";
  5653. if (posCode == "CustomerService")
  5654. {
  5655. userIdStr = CurrentUser.UserID + "_k";
  5656. }
  5657. else if (posCode == "Designer" || posCode == "wxDesigner")
  5658. {
  5659. userIdStr = CurrentUser.UserID + "_s";
  5660. }
  5661. else if (posCode == "Place")
  5662. {
  5663. userIdStr = CurrentUser.UserID + "_x";
  5664. }
  5665. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5666. }
  5667. }
  5668. string placedate1 = GetPostString("placedate1");
  5669. string placedate2 = GetPostString("placedate2");
  5670. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5671. if (dwplace.Length > 0) lw.Add(dwplace);
  5672. string supState = GetPostString("supState");
  5673. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5674. string searchType = GetPostString("searchType");
  5675. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5676. {
  5677. lw.Add(string.Format("BackNum>1"));
  5678. }
  5679. lw.Add(string.Format("AfterSaleState>0"));
  5680. if (ex_psize > 0)
  5681. {
  5682. if (CurrentUser.UserPost.Post.Code == "Finance")
  5683. dStruct.Order = "pay_time desc";
  5684. else
  5685. dStruct.Order = "HandleTime desc";
  5686. }
  5687. else
  5688. dStruct.Order = "HandleTime desc";
  5689. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5690. DataTable dt = WebCache.GetData("view_test", dStruct);
  5691. writeGridDataTableJson(dStruct.TotalCount, dt);
  5692. }
  5693. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5694. //{
  5695. // lw.Add(string.Format("AfterSaleState=4"));
  5696. // string code = CurrentUser.UserPost.Post.Code;
  5697. // if (code == "CustomerService")
  5698. // {
  5699. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5700. // }
  5701. // else if (code == "Designer" || code == "DesignerMr")
  5702. // {
  5703. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5704. // }
  5705. // else if (code == "Place" || code == "PlaceMr")
  5706. // {
  5707. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5708. // }
  5709. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5710. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5711. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5712. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5713. //}
  5714. //else //处理中的售后,待处理和处理中合并
  5715. //{
  5716. // if (afterState.Length <= 0)
  5717. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5718. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5719. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5720. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5721. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5722. //}
  5723. }
  5724. public void get_erp_disagreeftersalelist()
  5725. {
  5726. DataStruct dStruct = GetPostStruct();
  5727. List<string> lw = new List<string>();
  5728. int st = 2;
  5729. string tid = GetPostString("ctid");
  5730. if (tid.Length > 0)
  5731. {
  5732. string select_tid = getTidByCtid(tid);
  5733. lw.Add(string.Format("tid='{0}'", select_tid));
  5734. }
  5735. string shopname = GetPostString("shopname");
  5736. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5737. string buyernick = GetPostString("buyer_nick");
  5738. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5739. string sellermemo = GetPostString("seller_memo");
  5740. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5741. string orderState = GetPostString("orderState");
  5742. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5743. string afterState = GetPostString("afterstate");
  5744. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5745. string date1 = GetPostString("date1");
  5746. string date2 = GetPostString("date2");
  5747. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5748. if (dw.Length > 0) lw.Add(dw);
  5749. string price1 = GetPostString("price1");
  5750. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5751. string price2 = GetPostString("price2");
  5752. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5753. //lw.Add(string.Format("IsRefund!={0}", 1));
  5754. string reason = GetPostString("reason");
  5755. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5756. string method = GetPostString("method");
  5757. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5758. string handler = GetPostString("handler");
  5759. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5760. string handledate1 = GetPostString("handledate1");
  5761. string handledate2 = GetPostString("handledate2");
  5762. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5763. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5764. string afterdate1 = GetPostString("afterdate1");
  5765. string afterdate2 = GetPostString("afterdate2");
  5766. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5767. if (afterDate.Length > 0) lw.Add(afterDate);
  5768. string backdate1 = GetPostString("backdate1");
  5769. string backdate2 = GetPostString("backdate2");
  5770. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5771. if (backDate.Length > 0) lw.Add(backDate);
  5772. string supplier = GetPostString("supplier");
  5773. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5774. string responsible = GetPostString("responsibleman");
  5775. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5776. string customer = GetPostString("customer");
  5777. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5778. string design = GetPostString("design");
  5779. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5780. string afterSaleMemo = GetPostString("afterSaleMemo");
  5781. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5782. string afterMemoType = GetPostString("aftermemotype");
  5783. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5784. string aftersakereason = GetPostString("aftersakereason");
  5785. if (aftersakereason.Length > 0)
  5786. {
  5787. if (aftersakereason == "1")
  5788. {
  5789. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5790. }
  5791. if (aftersakereason == "2")
  5792. {
  5793. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5794. }
  5795. }
  5796. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5797. string poscode = CurrentUser.UserPost.Post.Code;
  5798. if (poscode != "SysAdmin")
  5799. {
  5800. string shopid = CurrentUser.User.pemShop;
  5801. lw.Add(string.Format("shopId in ({0})", shopid));
  5802. }
  5803. string searchType = GetPostString("searchType");
  5804. if (searchType == "wait")
  5805. {
  5806. lw.Add(string.Format("HandleTime is null"));
  5807. }
  5808. if (searchType == "handling")
  5809. {
  5810. lw.Add(string.Format("HandleTime is not null "));
  5811. }
  5812. if (searchType == "back" || searchType == "puBack")
  5813. {
  5814. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5815. }
  5816. if (searchType == "reBack")
  5817. {
  5818. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5819. }
  5820. if (searchType == "moreBack")
  5821. {
  5822. lw.Add(string.Format("backNum > 1"));
  5823. }
  5824. lw.Add(string.Format("(AfterSaleState=5)"));
  5825. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5826. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5827. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5828. writeGridDataTableJson(dStruct.TotalCount, dt);
  5829. }
  5830. public void get_erp_handlingaftersalelist()
  5831. {
  5832. DataStruct dStruct = GetPostStruct();
  5833. List<string> lw = new List<string>();
  5834. int st = 2;
  5835. string tid = GetPostString("ctid");
  5836. if (tid.Length > 0)
  5837. {
  5838. string select_tid = getTidByCtid(tid);
  5839. lw.Add(string.Format("tid='{0}'", select_tid));
  5840. }
  5841. string shopname = GetPostString("shopname");
  5842. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5843. string buyernick = GetPostString("buyer_nick");
  5844. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5845. string sellermemo = GetPostString("seller_memo");
  5846. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5847. string orderState = GetPostString("orderState");
  5848. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5849. string afterState = GetPostString("afterstate");
  5850. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5851. string date1 = GetPostString("date1");
  5852. string date2 = GetPostString("date2");
  5853. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5854. if (dw.Length > 0) lw.Add(dw);
  5855. string price1 = GetPostString("price1");
  5856. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5857. string price2 = GetPostString("price2");
  5858. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5859. //lw.Add(string.Format("IsRefund!={0}", 1));
  5860. string reason = GetPostString("reason");
  5861. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5862. string method = GetPostString("method");
  5863. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5864. string handler = GetPostString("handler");
  5865. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5866. string handledate1 = GetPostString("handledate1");
  5867. string handledate2 = GetPostString("handledate2");
  5868. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5869. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5870. string afterdate1 = GetPostString("afterdate1");
  5871. string afterdate2 = GetPostString("afterdate2");
  5872. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5873. if (afterDate.Length > 0) lw.Add(afterDate);
  5874. string supplier = GetPostString("supplier");
  5875. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5876. string responsible = GetPostString("responsibleman");
  5877. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5878. string customer = GetPostString("customer");
  5879. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5880. string design = GetPostString("design");
  5881. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5882. string afterSaleMemo = GetPostString("afterSaleMemo");
  5883. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5884. string afterMemoType = GetPostString("aftermemotype");
  5885. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5886. string afterresult = GetPostString("afterresult");
  5887. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5888. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5889. string poscode = CurrentUser.UserPost.Post.Code;
  5890. if (poscode != "SysAdmin")
  5891. {
  5892. string shopid = CurrentUser.User.pemShop;
  5893. lw.Add(string.Format("shopId in ({0})", shopid));
  5894. }
  5895. string searchType = GetPostString("searchType");
  5896. if (searchType == "wait")
  5897. {
  5898. lw.Add(string.Format("HandleTime is null"));
  5899. }
  5900. if (searchType == "documentary")
  5901. {
  5902. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5903. }
  5904. if (searchType == "handling")
  5905. {
  5906. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5907. }
  5908. if (searchType == "back" || searchType == "puBack")
  5909. {
  5910. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5911. }
  5912. if (searchType == "reBack")
  5913. {
  5914. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5915. }
  5916. if (afterState.Length <= 0)
  5917. {
  5918. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5919. }
  5920. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5921. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5922. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5923. writeGridDataTableJson(dStruct.TotalCount, dt);
  5924. }
  5925. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5926. //public void get_erp_back_handlingaftersalelist()
  5927. //{
  5928. // DataStruct dStruct = GetPostStruct();
  5929. // List<string> lw = new List<string>();
  5930. // string tid = GetPostString("ctid");
  5931. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5932. // string shopname = GetPostString("shopname");
  5933. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5934. // string buyernick = GetPostString("buyer_nick");
  5935. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5936. // string sellermemo = GetPostString("seller_memo");
  5937. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5938. // string orderState = GetPostString("orderState");
  5939. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5940. // string afterState = GetPostString("afterstate");
  5941. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5942. // string date1 = GetPostString("date1");
  5943. // string date2 = GetPostString("date2");
  5944. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5945. // if (dw.Length > 0) lw.Add(dw);
  5946. // string price1 = GetPostString("price1");
  5947. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5948. // string price2 = GetPostString("price2");
  5949. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5950. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5951. // string reason = GetPostString("reason");
  5952. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5953. // string method = GetPostString("method");
  5954. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5955. // string handler = GetPostString("handler");
  5956. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5957. // string handledate1 = GetPostString("handledate1");
  5958. // string handledate2 = GetPostString("handledate2");
  5959. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5960. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5961. // string afterdate1 = GetPostString("afterdate1");
  5962. // string afterdate2 = GetPostString("afterdate2");
  5963. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5964. // if (afterDate.Length > 0) lw.Add(afterDate);
  5965. // string supplier = GetPostString("supplier");
  5966. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5967. // string responsible = GetPostString("responsibleman");
  5968. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5969. // string customer = GetPostString("customer");
  5970. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5971. // string design = GetPostString("design");
  5972. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5973. // string afterMemoType = GetPostString("aftermemotype");
  5974. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5975. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5976. // if (afterState.Length <= 0)
  5977. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5978. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5979. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5980. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5981. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5982. //}
  5983. public void get_erp_aftersaleverifylist()
  5984. {
  5985. DataStruct dStruct = GetPostStruct();
  5986. List<string> lw = new List<string>();
  5987. string tid = GetPostString("ctid");
  5988. if (tid.Length > 0)
  5989. {
  5990. string select_tid = getTidByCtid(tid);
  5991. lw.Add(string.Format("tid='{0}'", select_tid));
  5992. }
  5993. string shopname = GetPostString("shopname");
  5994. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5995. string buyernick = GetPostString("buyer_nick");
  5996. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5997. string sellermemo = GetPostString("seller_memo");
  5998. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5999. string orderState = GetPostString("orderState");
  6000. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6001. //lw.Add(string.Format("IsRefund!={0}", 1));
  6002. string reason = GetPostString("reason");
  6003. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6004. string method = GetPostString("method");
  6005. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6006. string handler = GetPostString("handler");
  6007. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6008. string handledate1 = GetPostString("handledate1");
  6009. string handledate2 = GetPostString("handledate2");
  6010. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6011. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6012. string finish1 = GetPostString("finishdate1");
  6013. string finish2 = GetPostString("finishdate2");
  6014. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6015. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6016. string supplier = GetPostString("supplier");
  6017. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6018. string responsible = GetPostString("responsibleman");
  6019. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6020. string posCode = CurrentUser.UserPost.Post.Code;
  6021. string vstate = GetPostString("vstate");
  6022. if (vstate.Length > 0)
  6023. {
  6024. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6025. }
  6026. if (posCode == "Supplier")
  6027. {
  6028. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6029. lw.Add(string.Format("VerifyState = 0"));
  6030. lw.Add("type = 1");
  6031. lw.Add(string.Format("AfterSaleState={0}", 3));
  6032. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6033. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6034. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6035. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6036. writeGridDataTableJson(dStruct.TotalCount, dt);
  6037. }
  6038. else if (posCode == "logistics")
  6039. {
  6040. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6041. lw.Add(string.Format("VerifyState = 0"));
  6042. lw.Add("type = 2");
  6043. lw.Add(string.Format("AfterSaleState={0}", 3));
  6044. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6046. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6047. writeGridDataTableJson(dStruct.TotalCount, dt);
  6048. }
  6049. else
  6050. {
  6051. lw.Add(string.Format("(AfterSaleState = 3)"));
  6052. string reasonState = GetPostString("reasonState");
  6053. lw.Add("type = 0");
  6054. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6055. || posCode == "Summarize" || posCode == "Finance")
  6056. {
  6057. if (reasonState == "2")
  6058. {
  6059. lw.Add("VerifyState = 3");
  6060. }
  6061. else if (reasonState == "1")
  6062. {
  6063. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6064. }
  6065. else
  6066. {
  6067. lw.Add("VerifyState in (0,3)");
  6068. }
  6069. //不加条件,可以看全部
  6070. }
  6071. 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")
  6072. {
  6073. int orgid = CurrentUser.UserPost.OrgID;
  6074. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6075. if (string.IsNullOrEmpty(manageOrgId))
  6076. {
  6077. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6078. }
  6079. else
  6080. {
  6081. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6082. }
  6083. if (reasonState == "1")
  6084. {
  6085. lw.Add("VerifyState = 3");
  6086. }
  6087. else if (reasonState == "2")
  6088. {
  6089. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6090. }
  6091. else
  6092. {
  6093. }
  6094. }
  6095. else
  6096. {
  6097. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6098. }
  6099. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6100. //{
  6101. // int org_id = CurrentUser.UserPost.OrgID;
  6102. // lw.Add(string.Format("OrgID={0}", org_id));
  6103. //}
  6104. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6105. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6106. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6107. writeGridDataTableJson(dStruct.TotalCount, dt);
  6108. }
  6109. }
  6110. public void get_erp_finishaftersalelist()
  6111. {
  6112. DataStruct dStruct = GetPostStruct();
  6113. List<string> lw = new List<string>();
  6114. int st = 4;
  6115. string tid = GetPostString("ctid");
  6116. if (tid.Length > 0)
  6117. {
  6118. string select_tid = getTidByCtid(tid);
  6119. lw.Add(string.Format("tid='{0}'", select_tid));
  6120. }
  6121. string shopname = GetPostString("shopname");
  6122. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6123. //lw.Add(string.Format("IsRefund!={0}", 1));
  6124. string reason = GetPostString("reason");
  6125. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6126. string method = GetPostString("method");
  6127. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6128. string buyernick = GetPostString("buyer_nick");
  6129. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6130. string handler = GetPostString("handler");
  6131. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6132. string handledate1 = GetPostString("handledate1");
  6133. string handledate2 = GetPostString("handledate2");
  6134. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6135. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6136. string finish1 = GetPostString("finishdate1");
  6137. string finish2 = GetPostString("finishdate2");
  6138. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6139. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6140. string supplier = GetPostString("supplier");
  6141. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6142. string responsible = GetPostString("responsibleman");
  6143. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6144. string vstate = GetPostString("vstate");
  6145. if (vstate.Length > 0)
  6146. {
  6147. if ("3".Equals(vstate))
  6148. {
  6149. lw.Add(string.Format("IsTem=1"));
  6150. }
  6151. else
  6152. {
  6153. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6154. }
  6155. }
  6156. lw.Add(string.Format("AfterSaleState=4"));
  6157. string code = CurrentUser.UserPost.Post.Code;
  6158. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6159. {
  6160. //不加条件,可以看全部
  6161. }
  6162. else if (code == "Supplier")
  6163. {
  6164. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6165. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6166. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6167. }
  6168. else if (code == "logistics")
  6169. {
  6170. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6171. lw.Add("type = 2");
  6172. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6173. }
  6174. 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")
  6175. {
  6176. int orgid = CurrentUser.UserPost.OrgID;
  6177. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6178. if (string.IsNullOrEmpty(manageOrgIds))
  6179. {
  6180. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6181. }
  6182. else
  6183. {
  6184. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6185. }
  6186. }
  6187. else
  6188. {
  6189. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6190. }
  6191. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6192. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6193. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6194. writeGridDataTableJson(dStruct.TotalCount, dt);
  6195. }
  6196. public void handle_erp_aftersale()
  6197. {
  6198. if (UrlPostParmsCheck("ctid"))
  6199. {
  6200. string eid = GetPostString("ctid");
  6201. string responStr = GetPostString("AfterSaleResponsible");
  6202. if (responStr.Length <= 0)
  6203. {
  6204. returnErrorMsg("售后责任人不能为空");
  6205. return;
  6206. }
  6207. bool isDesign = false;
  6208. double designFree = 0.00;
  6209. int responsibleId = 0;
  6210. CeErpTradeCell entity = null;
  6211. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6212. if (entity != null)
  6213. {
  6214. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6215. string afterMethod = GetPostString("AfterSaleMethod");
  6216. if (isNeedNewOrder == 1)
  6217. {
  6218. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6219. bool ishav = true;
  6220. if (newentity == null)
  6221. {
  6222. newentity = entity.Clone() as CeErpTradeCell;
  6223. ishav = false;
  6224. newentity.ctid = "S_" + entity.ctid;
  6225. newentity.OrderState = 0;
  6226. //唯一标识
  6227. newentity.OrderSn = newentity.ctid;
  6228. string orderSn = dataHelper.getSaleOrderSn();
  6229. if (orderSn != "")
  6230. {
  6231. newentity.OrderSn = orderSn;
  6232. }
  6233. }
  6234. newentity.AfterSaleState = 0;
  6235. newentity.AfterSaleMethod = afterMethod;
  6236. if (!ishav)
  6237. {
  6238. string memo_str = newentity.seller_memo;
  6239. memo_str = memo_str.Replace("(", "(");
  6240. memo_str = memo_str.Replace(")", ")");
  6241. int sIndex = memo_str.IndexOf("(");
  6242. int eIndex = memo_str.IndexOf(")");
  6243. if (sIndex == -1 || eIndex == -1)
  6244. {
  6245. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6246. return;
  6247. }
  6248. string first = memo_str.Substring(0, sIndex + 1);
  6249. string memoCtid = newentity.OrderSn;
  6250. //if (memoCtid.IndexOf("C") != -1)
  6251. //{
  6252. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6253. //if (CIdx.IndexOf("+") != -1)
  6254. //{
  6255. //CIdx = "C" + CIdx.Split('+')[1];
  6256. //}
  6257. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6258. //}
  6259. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6260. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6261. string newMemo = first + memoCtid + last;
  6262. newentity.seller_memo = newMemo;
  6263. newentity.FinishPlaceTime = null;
  6264. newentity.UnusualTag = 0;
  6265. newentity.UnusualCon = "";
  6266. newentity.UnusualTime = null;
  6267. newentity.AfterSaleMemo = "";
  6268. newentity.AfterSaleMethod = afterMethod;
  6269. newentity.AfterSalePreTime = null;
  6270. newentity.AfterSaleReason = "";
  6271. newentity.AfterSaleResponsible = "";
  6272. newentity.AfterSaleState = 0;
  6273. newentity.AfterSaleTime = null;
  6274. newentity.AfterSaleUserId = 0;
  6275. newentity.AfterSaleSupplierState = 0;
  6276. newentity.LastBillWaybillCode = "";
  6277. newentity.LastBillCpCode = "";
  6278. newentity.FinishAfterSaleTime = null;
  6279. newentity.HandleTime = null;
  6280. newentity.IsSF = 0;
  6281. newentity.IsOldCustomer = 0;
  6282. newentity.UrgencyTime = null;
  6283. newentity.ResponsibleUserId = "";
  6284. newentity.IsVerifyToSupplier = false;
  6285. newentity.payment = 0;
  6286. newentity.CheckMemo = "";
  6287. newentity.OutSid = "";
  6288. newentity.CheckOrderTime = null;
  6289. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6290. }
  6291. newentity.isAfterSaleOrder = 1;
  6292. newentity.IsRefund = 0;
  6293. string receiveMobile = GetPostString("receiver_mobile");
  6294. if (receiveMobile.Length > 0)
  6295. {
  6296. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6297. if (trade != null)
  6298. {
  6299. trade.receiver_name = GetPostString("receiver_name");
  6300. trade.receiver_mobile = receiveMobile;
  6301. trade.receiver_state = GetPostString("receiver_state");
  6302. trade.receiver_city = GetPostString("receiver_city");
  6303. trade.receiver_district = GetPostString("receiver_district");
  6304. trade.receiver_address = GetPostString("receiver_address");
  6305. newentity.IsOffLineOrder = 1;
  6306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6307. }
  6308. }
  6309. string st = GetPostString("ToState");
  6310. if (st.Length > 0)
  6311. {
  6312. if (newentity.OrderState <= 3)
  6313. {
  6314. newentity.WaitDesignTime = DateTime.Now;
  6315. newentity.StartDesignTime = null;
  6316. newentity.FinishDesignTime = null;
  6317. newentity.OrderState = 3;
  6318. if (st == "下单员")
  6319. {
  6320. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6321. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6322. {
  6323. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6324. }
  6325. }
  6326. else
  6327. {
  6328. newentity.WaitDesignTime = DateTime.Now;
  6329. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6330. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6331. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6332. {
  6333. DataRow user = dt1.Rows[0];
  6334. //找主管
  6335. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6337. if (dt != null && dt.Rows.Count > 0)
  6338. {
  6339. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6340. newentity.DesignUserId = designMr;
  6341. string key = "aftersale_order_" + designMr;
  6342. if (RedisHelper.HasKey(key))
  6343. {
  6344. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6345. list.Add(newentity.ctid);
  6346. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6347. }
  6348. }
  6349. //账号正常
  6350. if (user["State"].ToString() == "0")
  6351. {
  6352. newentity.DesignUserId = entity.DesignUserId;
  6353. string key = "aftersale_order_" + entity.DesignUserId;
  6354. if (RedisHelper.HasKey(key))
  6355. {
  6356. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6357. list.Add(newentity.ctid);
  6358. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6359. }
  6360. }
  6361. }
  6362. }
  6363. }
  6364. if (entity.IsXianHuo == 1)
  6365. {
  6366. newentity.OrderState = 6;
  6367. entity.FinishPlaceTime = DateTime.Now;
  6368. }
  6369. }
  6370. if (ishav)
  6371. {
  6372. newentity.Update();
  6373. }
  6374. else
  6375. {
  6376. newentity.Create();
  6377. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6378. newCellExtend.ctid = newentity.ctid;
  6379. newCellExtend.orderFrom = 20;
  6380. newCellExtend.orderType = 30;
  6381. if (st == "下单员")
  6382. {
  6383. }
  6384. else
  6385. {
  6386. newCellExtend.ReprintTime = DateTime.Now;
  6387. }
  6388. newCellExtend.Create();
  6389. }
  6390. if (st != "下单员")
  6391. {
  6392. designHelper.API_GetPrintData_CreateOrder(newentity);
  6393. }
  6394. }
  6395. //处理售后扩展
  6396. string resIdStr = GetPostString("ResponsibleUserId");
  6397. string refundFees = GetPostString("refundFrees");
  6398. int IsComplain = GetPostInt("isComplain");
  6399. int IsBad = GetPostInt("isBad");
  6400. string IsOriginal = GetPostString("isOriginal");
  6401. double diffResultPrice = GetPostDouble("diffResultPrice");
  6402. string textResult = GetPostString("textResult");
  6403. string supplierResponsible = GetPostString("supplierResponsible");
  6404. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6405. if (ceErpTradeAfterSaleExtend == null)
  6406. {
  6407. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6408. ceErpTradeAfterSaleExtend.tid = eid;
  6409. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6410. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6411. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6412. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6413. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6414. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6415. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6416. ceErpTradeAfterSaleExtend.Create();
  6417. }
  6418. else
  6419. {
  6420. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6421. {
  6422. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6423. }
  6424. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6425. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6426. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6427. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6428. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6429. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6430. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6431. ceErpTradeAfterSaleExtend.Update();
  6432. }
  6433. int gysid = GetPostInt("ResponsibleSupId");
  6434. if (entity.AfterSaleUserId == 0)
  6435. {
  6436. entity.AfterSaleUserId = CurrentUser.UserID;
  6437. }
  6438. entity.ResponsibleUserId = resIdStr;
  6439. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6440. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6441. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6442. {
  6443. CeErpTradeResponsible.DelByTid(eid, -1);
  6444. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6445. int backNum = 0;
  6446. if (number != null)
  6447. {
  6448. backNum = number.BackNum;
  6449. }
  6450. char[] separator = { ',' };
  6451. string[] sArray = resIdStr.Split(separator);
  6452. string[] refundFreeList = { };
  6453. if (refundFees.Length > 0)
  6454. {
  6455. refundFreeList = refundFees.Split(separator);
  6456. }
  6457. int index = -1;
  6458. foreach (string i in sArray)
  6459. {
  6460. index++;
  6461. if (i.Length <= 0) continue;
  6462. char[] separator2 = { '_' };
  6463. string idstr = i.Split(separator2)[0];
  6464. string idtype = i.Split(separator2)[1];
  6465. double refudFree = 0;
  6466. if (refundFreeList.Length > 0)
  6467. {
  6468. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6469. }
  6470. if (idtype == "s")
  6471. {
  6472. isDesign = true;
  6473. designFree = refudFree;
  6474. }
  6475. int userId = Convert.ToInt32(idstr);
  6476. int type = 0;
  6477. if (idtype == "g")
  6478. {
  6479. type = 1;
  6480. }
  6481. if (idtype == "w")
  6482. {
  6483. type = 2;
  6484. }
  6485. if (idtype == "t")
  6486. {
  6487. type = 3;
  6488. }
  6489. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6490. if (ceErpTradeResponsible == null)
  6491. {
  6492. ceErpTradeResponsible = new CeErpTradeResponsible();
  6493. ceErpTradeResponsible.tid = eid;
  6494. ceErpTradeResponsible.UserId = userId;
  6495. ceErpTradeResponsible.createdTime = DateTime.Now;
  6496. ceErpTradeResponsible.type = type;
  6497. if (type == 1)
  6498. {
  6499. ceErpTradeResponsible.IsSup = 1;
  6500. }
  6501. if (type == 2)
  6502. {
  6503. ceErpTradeResponsible.IsFlow = 1;
  6504. }
  6505. }
  6506. ceErpTradeResponsible.RefundFee = refudFree;
  6507. ceErpTradeResponsible.VerifyState = 0;
  6508. if (userId == 2125 || idtype == "w")
  6509. {
  6510. ceErpTradeResponsible.VerifyState = 1;
  6511. }
  6512. if (idtype == "w" && userId == 101)
  6513. {
  6514. ceErpTradeResponsible.VerifyState = 0;
  6515. }
  6516. if (ceErpTradeResponsible.ID > 0)
  6517. {
  6518. ceErpTradeResponsible.Update();
  6519. }
  6520. else
  6521. {
  6522. ceErpTradeResponsible.Create();
  6523. }
  6524. if (isDesign)
  6525. {
  6526. responsibleId = ceErpTradeResponsible.ID;
  6527. }
  6528. }
  6529. CeErpTradeResponsible.NumByTid(backNum, eid);
  6530. }
  6531. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6532. if (ceErpTradeCellExtend != null)
  6533. {
  6534. ceErpTradeCellExtend.returnVisit = 0;
  6535. ceErpTradeCellExtend.Update();
  6536. }
  6537. if (entity.HandleTime != null)
  6538. {
  6539. if (entity.AfterSaleState == 1)
  6540. {
  6541. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6542. }
  6543. else
  6544. {
  6545. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6546. }
  6547. }
  6548. else
  6549. {
  6550. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6551. entity.HandleTime = DateTime.Now;
  6552. }
  6553. bool isCompale = false;
  6554. if (entity.AfterSaleState == 5)
  6555. {
  6556. isCompale = true;
  6557. entity.AfterSaleState = 3;
  6558. }
  6559. entity.AfterSaleSupplierState = 0;
  6560. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6561. {
  6562. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6563. }
  6564. string sImgs = GetPostString("img");
  6565. entity.AfterSaleSupplierImg = sImgs;
  6566. entity.supRefundType = GetPostString("supRefundType");
  6567. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6568. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6569. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6570. entity.AfterSaleMemoType = GetPostString("MemoType");
  6571. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6572. {
  6573. //entity.AfterSaleSupplierState = 2;
  6574. }
  6575. string df = GetPostString("DeductFee");
  6576. if (df == "")
  6577. {
  6578. df = "0";
  6579. }
  6580. string rf = GetPostString("RefundFee");
  6581. if (rf == "")
  6582. {
  6583. rf = "0";
  6584. }
  6585. string pm = GetPostString("AfterSalePayment");
  6586. if (pm == "")
  6587. {
  6588. pm = "0";
  6589. }
  6590. entity.AfterSalePayment = Convert.ToDouble(pm);
  6591. entity.DeductFee = Convert.ToDouble(df);
  6592. entity.RefundFee = Convert.ToDouble(rf);
  6593. entity.Update();
  6594. string toState = GetPostString("ToState");
  6595. string original = GetPostString("isOriginal");
  6596. ApiVo apiVo = new ApiVo();
  6597. apiVo.orderNumber = entity.ctid;
  6598. apiVo.actionName = "afterDesign";
  6599. apiVo.orderRemarks = entity.AfterSaleMethod;
  6600. apiVo.reasonRemarks = entity.AfterSaleReason;
  6601. apiVo.isDesign = isDesign;
  6602. apiVo.designFree = designFree;
  6603. apiVo.responsibleId = responsibleId;
  6604. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6605. if (toState == "设计师")
  6606. {
  6607. apiVo.isOriginal = Convert.ToBoolean(original);
  6608. }
  6609. designHelper.API_WorkCore(apiVo);//afterDesign
  6610. CeErpMethod methodSql = new CeErpMethod();
  6611. methodSql.con = entity.AfterSaleMethod;
  6612. methodSql.addTime = DateTime.Now;
  6613. methodSql.Create();
  6614. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6615. CeErpMethod.ExecuteNonQuery(delsql);
  6616. if (isCompale)
  6617. {
  6618. aftersale_data_change(entity.ctid);
  6619. }
  6620. returnSuccessMsg("操作成功!");
  6621. return;
  6622. }
  6623. returnErrorMsg("找不到订单记录");
  6624. }
  6625. }
  6626. public void ins_erp_toresponsible()
  6627. {
  6628. if (UrlPostParmsCheck("ctid"))
  6629. {
  6630. string eid = GetPostString("ctid");
  6631. CeErpTradeCell entity = null;
  6632. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6633. if (entity != null)
  6634. {
  6635. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6636. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6637. {
  6638. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6639. return;
  6640. }
  6641. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6642. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6643. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6644. if (entity.AfterSalePreTime == null)
  6645. {
  6646. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6647. {
  6648. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6649. }
  6650. }
  6651. entity.AfterSalePreTime = DateTime.Now;
  6652. //预完成给售后主管审核客户问题直接完成
  6653. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6654. {
  6655. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6656. {
  6657. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6658. }
  6659. }
  6660. ceErpTradeAfterSaleExtend.Update();
  6661. entity.AfterSaleState = 2;
  6662. entity.Update();
  6663. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6664. aftersale_data_change(entity.ctid);
  6665. returnSuccessMsg("操作成功!");
  6666. return;
  6667. }
  6668. returnErrorMsg("找不到订单记录");
  6669. }
  6670. }
  6671. public void cancel_erp_aftersaleanddelnew()
  6672. {
  6673. if (UrlPostParmsCheck("ctid"))
  6674. {
  6675. string eid = GetPostString("ctid");
  6676. CeErpTradeCell entity = null;
  6677. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6678. if (entity != null)
  6679. {
  6680. entity.AfterSaleState = 0;
  6681. entity.AfterSaleReason = "";
  6682. entity.AfterSaleMethod = "";
  6683. entity.AfterSaleMemo = "";
  6684. entity.AfterSaleResponsible = "";
  6685. entity.ResponsibleUserId = "";
  6686. entity.DeductFee = 0;
  6687. entity.RefundFee = 0;
  6688. entity.IsArbitrate = 0;
  6689. CeErpTradeResponsible.DelByTid(eid, -1);
  6690. entity.Update();
  6691. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6692. if (after != null)
  6693. {
  6694. if (after.OrderState < 5)
  6695. CeErpTradeCell.DelByCtid("S_" + eid);
  6696. }
  6697. returnSuccessMsg("操作成功!");
  6698. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6699. return;
  6700. }
  6701. returnErrorMsg("找不到订单记录");
  6702. }
  6703. }
  6704. public void get_erp_aftersale_pregather()
  6705. {
  6706. List<string> lw = new List<string>();
  6707. int st = GetInt("st");
  6708. string tid = GetPostString("ctid");
  6709. if (tid.Length > 0)
  6710. {
  6711. string select_tid = getTidByCtid(tid);
  6712. lw.Add(string.Format("tid='{0}'", select_tid));
  6713. }
  6714. string shopname = GetPostString("shopname");
  6715. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6716. string buyernick = GetPostString("buyer_nick");
  6717. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6718. string sellermemo = GetPostString("seller_memo");
  6719. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6720. string orderState = GetPostString("orderState");
  6721. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6722. string reason = GetPostString("reason");
  6723. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6724. string method = GetPostString("method");
  6725. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6726. string handler = GetPostString("handler");
  6727. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6728. string handledate1 = GetPostString("handledate1");
  6729. string handledate2 = GetPostString("handledate2");
  6730. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6731. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6732. string supplier = GetPostString("supplier");
  6733. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6734. string responsible = GetPostString("responsibleman");
  6735. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6736. string customer = GetPostString("customer");
  6737. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6738. string design = GetPostString("design");
  6739. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6740. string afterMemoType = GetPostString("aftermemotype");
  6741. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6742. string afterSaleMemo = GetPostString("afterSaleMemo");
  6743. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6744. string afterresult = GetPostString("afterresult");
  6745. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6746. string poscode = CurrentUser.UserPost.Post.Code;
  6747. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6748. {
  6749. string shopid = CurrentUser.User.pemShop;
  6750. lw.Add(string.Format("shopId in ({0})", shopid));
  6751. }
  6752. var mainwhere = string.Join(" and ", lw.ToArray());
  6753. string ro_json = "";
  6754. string type = GetPostString("gather_type");
  6755. int number = 0;
  6756. if (poscode == "AfterSale")
  6757. {
  6758. //处理中
  6759. if (type == "Handling")
  6760. {
  6761. 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) : ""));
  6762. DataTable dt = null;
  6763. try
  6764. {
  6765. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6766. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6767. }
  6768. catch (Exception e)
  6769. {
  6770. dt = new DataTable();
  6771. }
  6772. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6773. return;
  6774. }
  6775. if (type == "Wait")
  6776. {
  6777. //待处理
  6778. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6779. DataTable dt1 = null;
  6780. try
  6781. {
  6782. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6783. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6784. }
  6785. catch (Exception e)
  6786. {
  6787. dt1 = new DataTable();
  6788. }
  6789. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6790. return;
  6791. }
  6792. if (type == "back")
  6793. {
  6794. //打回
  6795. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6796. DataTable dt2 = null;
  6797. try
  6798. {
  6799. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6800. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6801. }
  6802. catch (Exception e)
  6803. {
  6804. dt2 = new DataTable();
  6805. }
  6806. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6807. return;
  6808. }
  6809. if (type == "preCompletion")
  6810. {
  6811. //预完成
  6812. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6813. DataTable dt3 = null;
  6814. try
  6815. {
  6816. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6817. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6818. }
  6819. catch (Exception e)
  6820. {
  6821. dt3 = new DataTable();
  6822. }
  6823. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6824. return;
  6825. }
  6826. if (type == "documentary")
  6827. {
  6828. //跟单中
  6829. 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) : ""));
  6830. DataTable dt4 = null;
  6831. try
  6832. {
  6833. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6834. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6835. }
  6836. catch (Exception e)
  6837. {
  6838. dt4 = new DataTable();
  6839. }
  6840. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6841. return;
  6842. }
  6843. if (type == "reBack")
  6844. {
  6845. //被打回
  6846. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6847. DataTable dt1 = null;
  6848. try
  6849. {
  6850. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6851. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6852. }
  6853. catch (Exception e)
  6854. {
  6855. dt1 = new DataTable();
  6856. }
  6857. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6858. return;
  6859. }
  6860. }
  6861. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6862. {
  6863. if (type == "puBack")
  6864. {
  6865. //退回
  6866. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6867. DataTable dt = null;
  6868. try
  6869. {
  6870. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6871. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6872. }
  6873. catch (Exception e)
  6874. {
  6875. dt = new DataTable();
  6876. }
  6877. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6878. return;
  6879. }
  6880. if (type == "reBack")
  6881. {
  6882. //打回
  6883. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6884. DataTable dt1 = null;
  6885. try
  6886. {
  6887. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6888. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6889. }
  6890. catch (Exception e)
  6891. {
  6892. dt1 = new DataTable();
  6893. }
  6894. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6895. return;
  6896. }
  6897. if (type == "examEd")
  6898. {
  6899. //已审核
  6900. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6901. DataTable dt2 = null;
  6902. try
  6903. {
  6904. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6905. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6906. }
  6907. catch (Exception e)
  6908. {
  6909. dt2 = new DataTable();
  6910. }
  6911. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  6912. return;
  6913. }
  6914. if (type == "waitExam")
  6915. {
  6916. //待审核
  6917. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6918. DataTable dt3 = null;
  6919. try
  6920. {
  6921. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6922. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6923. }
  6924. catch (Exception e)
  6925. {
  6926. dt3 = new DataTable();
  6927. }
  6928. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  6929. return;
  6930. }
  6931. if (type == "Handling")
  6932. {
  6933. //处理中
  6934. 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) : ""));
  6935. DataTable dt4 = null;
  6936. try
  6937. {
  6938. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6939. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6940. }
  6941. catch (Exception e)
  6942. {
  6943. dt4 = new DataTable();
  6944. }
  6945. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6946. return;
  6947. }
  6948. if (type == "Wait")
  6949. {
  6950. //待处理
  6951. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6952. DataTable dt5 = null;
  6953. try
  6954. {
  6955. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6956. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  6957. }
  6958. catch (Exception e)
  6959. {
  6960. dt5 = new DataTable();
  6961. }
  6962. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6963. return;
  6964. }
  6965. if (type == "documentary")
  6966. {
  6967. //跟单中
  6968. 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) : ""));
  6969. DataTable dt6 = null;
  6970. try
  6971. {
  6972. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6973. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  6974. }
  6975. catch (Exception e)
  6976. {
  6977. dt6 = new DataTable();
  6978. }
  6979. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6980. return;
  6981. }
  6982. }
  6983. returnSuccess(ro_json);
  6984. }
  6985. public void end_erp_aftersale()
  6986. {
  6987. if (UrlPostParmsCheck("ctid"))
  6988. {
  6989. string eid = GetPostString("ctid");
  6990. CeErpTradeCell entity = null;
  6991. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6992. if (entity != null)
  6993. {
  6994. string stype = GetPostString("stype");
  6995. string typeStr = stype;
  6996. entity.AfterSaleState = 4;
  6997. entity.FinishAfterSaleTime = DateTime.Now;
  6998. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6999. entity.Update();
  7000. ApiVo apiVo = new ApiVo();
  7001. apiVo.orderNumber = entity.ctid;
  7002. apiVo.actionName = "afterOver";
  7003. designHelper.API_WorkCore(apiVo); //afterOver
  7004. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7005. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7006. CeErpSukuraData.createInfo(entity.ctid, 8);
  7007. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7008. returnSuccessMsg("操作成功!");
  7009. return;
  7010. }
  7011. returnErrorMsg("找不到订单记录");
  7012. }
  7013. }
  7014. public void ins_erp_finishaftersale()
  7015. {
  7016. if (UrlPostParmsCheck("id"))
  7017. {
  7018. string eid = GetPostString("id");
  7019. CeErpTradeResponsible entity = null;
  7020. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7021. if (entity != null)
  7022. {
  7023. entity.VerifyState = 1;
  7024. entity.VerifyTime = DateTime.Now;
  7025. entity.Update();
  7026. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7027. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7028. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7029. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7030. if (dt.Rows.Count <= 0)
  7031. {
  7032. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  7033. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7034. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7035. CeErpSukuraData.createInfo(entity.tid, 8);
  7036. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7037. {
  7038. CeErpDesignerBill.Del(entity.tid);
  7039. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7040. }
  7041. }
  7042. returnSuccessMsg("操作成功!");
  7043. return;
  7044. }
  7045. returnErrorMsg("找不到订单记录");
  7046. }
  7047. }
  7048. public void upd_erp_arbitrateaftersale()
  7049. {
  7050. if (UrlPostParmsCheck("id"))
  7051. {
  7052. string eid = GetPostString("id");
  7053. CeErpTradeResponsible entity = null;
  7054. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7055. if (entity != null)
  7056. {
  7057. entity.IsArbitrate = 1;
  7058. entity.ArbitradeMemo = GetPostString("reason");
  7059. entity.VerifyState = 2;
  7060. entity.Update();
  7061. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7062. if (tradecell != null)
  7063. {
  7064. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7065. tradecell.IsArbitrate = 1;
  7066. tradecell.Update();
  7067. }
  7068. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7069. returnSuccessMsg("操作成功!");
  7070. return;
  7071. }
  7072. returnErrorMsg("找不到订单记录");
  7073. }
  7074. }
  7075. public void upd_erp_backaftersale()
  7076. {
  7077. if (UrlPostParmsCheck("tid"))
  7078. {
  7079. string eid = GetPostString("tid");
  7080. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7081. int backNum = 0;
  7082. if (number != null)
  7083. {
  7084. backNum = number.BackNum;
  7085. }
  7086. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7087. CeErpTradeCell entity = null;
  7088. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7089. if (entity != null)
  7090. {
  7091. entity.AfterSaleBackReason = GetPostString("backreason");
  7092. entity.AfterSaleState = 1;
  7093. entity.AfterSaleSupplierState = 0;
  7094. entity.Update();
  7095. returnSuccessMsg("操作成功!");
  7096. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7097. return;
  7098. }
  7099. returnErrorMsg("找不到订单记录");
  7100. }
  7101. }
  7102. public void get_erp_supplieraftersalelist()
  7103. {
  7104. DataStruct dStruct = GetPostStruct();
  7105. List<string> lw = new List<string>();
  7106. string tid = GetPostString("ctid");
  7107. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7108. string shopname = GetPostString("shopname");
  7109. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7110. string buyernick = GetPostString("buyer_nick");
  7111. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7112. string sellermemo = GetPostString("seller_memo");
  7113. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7114. string orderState = GetPostString("orderState");
  7115. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7116. string afterState = GetPostString("afterstate");
  7117. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7118. string date1 = GetPostString("date1");
  7119. string date2 = GetPostString("date2");
  7120. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7121. if (dw.Length > 0) lw.Add(dw);
  7122. string price1 = GetPostString("price1");
  7123. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7124. string price2 = GetPostString("price2");
  7125. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7126. string reason = GetPostString("reason");
  7127. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7128. string method = GetPostString("method");
  7129. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7130. string handledate1 = GetPostString("handledate1");
  7131. string handledate2 = GetPostString("handledate2");
  7132. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7133. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7134. string handler = GetPostString("handler");
  7135. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7136. string afterdate1 = GetPostString("afterdate1");
  7137. string afterdate2 = GetPostString("afterdate2");
  7138. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7139. if (afterDate.Length > 0) lw.Add(afterDate);
  7140. string customer = GetPostString("customer");
  7141. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7142. string design = GetPostString("design");
  7143. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7144. string afterMemoType = GetPostString("aftermemotype");
  7145. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7146. string vstate = GetPostString("vstate");
  7147. if (vstate.Length > 0)
  7148. {
  7149. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7150. }
  7151. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7152. string supplier = GetPostString("supplier");
  7153. int supid = commonHelper.getSupplierIDByName(supplier);
  7154. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7155. string posCode = CurrentUser.UserPost.Post.Code;
  7156. if (posCode == "Supplier")
  7157. {
  7158. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7159. }
  7160. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7161. {
  7162. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7163. }
  7164. else
  7165. {
  7166. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7167. }
  7168. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7169. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7170. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7171. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7172. writeGridDataTableJson(dStruct.TotalCount, dt);
  7173. }
  7174. public void upd_erp_supverifyaftersale()
  7175. {
  7176. if (UrlPostParmsCheck("id"))
  7177. {
  7178. string id = GetPostString("id");
  7179. int st = GetPostInt("afterstate");
  7180. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7181. CeErpTradeCell entity = null;
  7182. if (ceErpTradeResponsible != null)
  7183. {
  7184. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7185. }
  7186. string afmemo = GetPostString("supmemo");
  7187. string image = GetPostString("image");
  7188. if (entity != null)
  7189. {
  7190. entity.AfterSaleSupplierState = st;
  7191. entity.AfterSaleSupplierMemo = afmemo;
  7192. if (st == 1)
  7193. {
  7194. ceErpTradeResponsible.VerifyState = 1;
  7195. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7196. ceErpTradeResponsible.Update();
  7197. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7198. if (isAll)
  7199. {
  7200. entity.AfterSaleState = 4;
  7201. entity.FinishAfterSaleTime = DateTime.Now;
  7202. }
  7203. }
  7204. else
  7205. {
  7206. CeErpTradeResponsible.dateByTid(entity.ctid);
  7207. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7208. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7209. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7210. if (num <= 1)
  7211. {
  7212. entity.AfterSaleState = 1;
  7213. }
  7214. else
  7215. {
  7216. entity.AfterSaleState = 5;
  7217. }
  7218. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7219. if (ceErpTradeAfterSaleExtend != null)
  7220. {
  7221. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7222. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7223. ceErpTradeAfterSaleExtend.Update();
  7224. }
  7225. else
  7226. {
  7227. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7228. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7229. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7230. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7231. ceErpTradeAfterSaleExtend.Create();
  7232. }
  7233. }
  7234. if (entity.AfterSaleState == 4)
  7235. {
  7236. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7237. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7238. {
  7239. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7240. }
  7241. ApiVo apiVo = new ApiVo();
  7242. apiVo.orderNumber = entity.ctid;
  7243. apiVo.actionName = "afterOver";
  7244. designHelper.API_WorkCore(apiVo); //afterOver
  7245. }
  7246. entity.Update();
  7247. returnSuccessMsg("操作成功!");
  7248. CeErpSukuraData.createInfo(entity.ctid, 8);
  7249. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7250. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7251. return;
  7252. }
  7253. returnErrorMsg("找不到订单记录");
  7254. }
  7255. }
  7256. public void upd_erp_masteraftersale()
  7257. {
  7258. if (UrlPostParmsCheck("id"))
  7259. {
  7260. string id = GetPostString("id");
  7261. int st = GetPostInt("afterstate");
  7262. string afmemo = GetPostString("supmemo");
  7263. string image = GetPostString("image");
  7264. string textResult = GetPostString("textResult");
  7265. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7266. if (ceErpTradeResponsible != null)
  7267. {
  7268. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7269. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7270. ceErpTradeResponsible.Update();
  7271. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7272. if (entity != null)
  7273. {
  7274. entity.AfterSaleSupplierState = st;
  7275. entity.AfterSaleSupplierMemo = afmemo;
  7276. if (st == 1)
  7277. {
  7278. }
  7279. else
  7280. {
  7281. CeErpTradeResponsible.dateByTid(entity.ctid);
  7282. //退回到售后
  7283. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7284. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7285. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7286. if (num <= 1)
  7287. {
  7288. entity.AfterSaleState = 1;
  7289. }
  7290. else
  7291. {
  7292. entity.AfterSaleState = 5;
  7293. }
  7294. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7295. if (ceErpTradeAfterSaleExtend != null)
  7296. {
  7297. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7298. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7299. ceErpTradeAfterSaleExtend.Update();
  7300. }
  7301. else
  7302. {
  7303. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7304. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7305. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7306. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7307. ceErpTradeAfterSaleExtend.Create();
  7308. }
  7309. }
  7310. entity.Update();
  7311. returnSuccessMsg("操作成功!");
  7312. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7313. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7314. return;
  7315. }
  7316. }
  7317. returnErrorMsg("找不到订单记录");
  7318. }
  7319. }
  7320. public void upd_erp_personaftersale()
  7321. {
  7322. if (UrlPostParmsCheck("id"))
  7323. {
  7324. string id = GetPostString("id");
  7325. int st = GetPostInt("afterstate");
  7326. string afmemo = GetPostString("supmemo");
  7327. string image = GetPostString("image");
  7328. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7329. if (ceErpTradeResponsible != null)
  7330. {
  7331. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7332. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7333. ceErpTradeResponsible.Update();
  7334. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7335. if (entity != null)
  7336. {
  7337. entity.AfterSaleSupplierMemo = afmemo;
  7338. entity.AfterSaleSupplierState = st;
  7339. if (st == 1)
  7340. {
  7341. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7342. if (isAll)
  7343. {
  7344. entity.AfterSaleState = 4;
  7345. entity.FinishAfterSaleTime = DateTime.Now;
  7346. }
  7347. }
  7348. else
  7349. {
  7350. CeErpTradeResponsible.dateByTid(entity.ctid);
  7351. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7352. if (ceErpTradeAfterSaleExtend != null)
  7353. {
  7354. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7355. ceErpTradeAfterSaleExtend.Update();
  7356. }
  7357. else
  7358. {
  7359. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7360. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7361. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7362. ceErpTradeAfterSaleExtend.Create();
  7363. }
  7364. //退回到主管
  7365. //entity.AfterSaleState = 2;
  7366. }
  7367. if (entity.AfterSaleState == 4)
  7368. {
  7369. ApiVo apiVo = new ApiVo();
  7370. apiVo.orderNumber = entity.ctid;
  7371. apiVo.actionName = "afterOver";
  7372. designHelper.API_WorkCore(apiVo); //afterOver
  7373. }
  7374. entity.Update();
  7375. returnSuccessMsg("操作成功!");
  7376. CeErpSukuraData.createInfo(entity.ctid, 8);
  7377. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7378. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7379. return;
  7380. }
  7381. }
  7382. returnErrorMsg("找不到订单记录");
  7383. }
  7384. }
  7385. public void set_erp_supplierrefundtag()
  7386. {
  7387. if (UrlPostParmsCheck("ctid"))
  7388. {
  7389. string eid = GetPostString("ctid");
  7390. CeErpTradeCell entity = null;
  7391. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7392. if (entity != null)
  7393. {
  7394. entity.IsSupplierRefund = GetPostInt("tag");
  7395. entity.Update();
  7396. returnSuccessMsg("操作成功!");
  7397. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7398. return;
  7399. }
  7400. returnErrorMsg("找不到订单记录");
  7401. }
  7402. }
  7403. public void get_erp_refundlist()
  7404. {
  7405. DataStruct dStruct = GetPostStruct();
  7406. List<string> lw = new List<string>();
  7407. string tid = GetPostString("tid");
  7408. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7409. //string rid = GetPostString("refund_id");
  7410. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7411. string shopname = GetPostString("shopname");
  7412. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7413. string buyernick = GetPostString("buyer_nick");
  7414. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7415. string customer = GetPostString("customer");
  7416. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7417. string design = GetPostString("design");
  7418. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7419. string sellermemo = GetPostString("seller_memo");
  7420. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7421. //string date1 = GetPostString("date1");
  7422. //string date2 = GetPostString("date2");
  7423. //string dateType = GetPostString("dateType");
  7424. //if (dateType.Length > 0)
  7425. //{
  7426. // if (dateType == "1001") dateType = "0";
  7427. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7428. // if (searchDT.Count == 2)
  7429. // {
  7430. // date1 = searchDT[0].ToString();
  7431. // date2 = searchDT[1].ToString();
  7432. // }
  7433. //}
  7434. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7435. //if (dw.Length > 0) lw.Add(dw);
  7436. string redate1 = GetPostString("refunddate1");
  7437. string redate2 = GetPostString("refunddate2");
  7438. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7439. if (dwdate.Length > 0) lw.Add(dwdate);
  7440. string price1 = GetPostString("price1");
  7441. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7442. string price2 = GetPostString("price2");
  7443. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7444. string ispartrefund = GetPostString("ispartrefund");
  7445. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7446. string refundState = GetPostString("refundvstate");
  7447. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7448. int st = GetInt("st");
  7449. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7450. {
  7451. string responsible = GetPostString("responsibleman");
  7452. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7453. lw.Add(string.Format("RefundState>={0}", st));
  7454. string code = CurrentUser.UserPost.Post.Code;
  7455. if (code == "CustomerService")
  7456. {
  7457. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7458. }
  7459. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7460. {
  7461. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7462. }
  7463. else if (code == "Place" || code == "PlaceMr")
  7464. {
  7465. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7466. }
  7467. dStruct.Order = "RefundState asc,created desc";
  7468. }
  7469. else if (st == 10)
  7470. {
  7471. string responsible = GetPostString("responsibleman");
  7472. if (responsible == "空白")
  7473. {
  7474. lw.Add(string.Format("ResponsibleUserName = ''"));
  7475. }
  7476. else if (responsible.Length > 0)
  7477. {
  7478. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7479. }
  7480. lw.Add(string.Format("RefundState>=0"));
  7481. dStruct.Order = "created desc";
  7482. }
  7483. else
  7484. {
  7485. string responsible = GetPostString("responsibleman");
  7486. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7487. lw.Add(string.Format("RefundState={0}", st));
  7488. dStruct.Order = "created desc";
  7489. }
  7490. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7491. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7492. dt.Columns.Add("refund_fees");
  7493. foreach (DataRow dr in dt.Rows)
  7494. {
  7495. String status = dr["status"].ToString();
  7496. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7497. {
  7498. dr["refund_fees"] = dr["refund_fee"];
  7499. }
  7500. else
  7501. {
  7502. dr["refund_fees"] = "0.0";
  7503. }
  7504. }
  7505. writeGridDataTableJson(dStruct.TotalCount, dt);
  7506. }
  7507. public void get_erp_refunddesignlist()
  7508. {
  7509. DataStruct dStruct = GetPostStruct();
  7510. List<string> lw = new List<string>();
  7511. string tid = GetPostString("tid");
  7512. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7513. string shopname = GetPostString("shopname");
  7514. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7515. string buyernick = GetPostString("buyer_nick");
  7516. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7517. string customer = GetPostString("customer");
  7518. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7519. string design = GetPostString("design");
  7520. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7521. string sellermemo = GetPostString("seller_memo");
  7522. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7523. string redate1 = GetPostString("refunddate1");
  7524. string redate2 = GetPostString("refunddate2");
  7525. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7526. if (dwdate.Length > 0) lw.Add(dwdate);
  7527. string price1 = GetPostString("price1");
  7528. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7529. string price2 = GetPostString("price2");
  7530. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7531. string ispartrefund = GetPostString("ispartrefund");
  7532. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7533. string designerorg = GetPostString("designerorg");
  7534. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7535. string refundState = GetPostString("refundState");
  7536. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7537. int myOrgid = CurrentUser.UserPost.OrgID;
  7538. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7539. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7540. {
  7541. if (CurrentUser.User.TeamIds.Length > 0)
  7542. {
  7543. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7544. }
  7545. else
  7546. {
  7547. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7548. }
  7549. }
  7550. else if ("SysAdmin".Equals(myOrgCode))
  7551. {
  7552. }
  7553. else
  7554. {
  7555. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7556. {
  7557. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7558. }
  7559. else
  7560. {
  7561. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7562. }
  7563. }
  7564. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7565. dStruct.Order = "created desc";
  7566. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7567. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7568. dt.Columns.Add("refund_fees");
  7569. foreach (DataRow dr in dt.Rows)
  7570. {
  7571. String status = dr["status"].ToString();
  7572. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7573. {
  7574. dr["refund_fees"] = dr["refund_fee"];
  7575. }
  7576. else
  7577. {
  7578. dr["refund_fees"] = "0.0";
  7579. }
  7580. }
  7581. writeGridDataTableJson(dStruct.TotalCount, dt);
  7582. }
  7583. public void handle_erp_refundtag()
  7584. {
  7585. if (UrlPostParmsCheck("refund_id"))
  7586. {
  7587. string eid = GetPostString("refund_id");
  7588. string respMan = GetPostString("ResponsibleName");
  7589. if (respMan.Length <= 0)
  7590. {
  7591. returnErrorMsg("责任人不能为空");
  7592. return;
  7593. }
  7594. CeErpTradeRefund entity = null;
  7595. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7596. if (entity != null)
  7597. {
  7598. entity.ResponsibleUserName = respMan;
  7599. string userid = GetPostString("ResponsibleUserId");
  7600. if (userid.Length > 0)
  7601. {
  7602. entity.ResponsibleUserId = userid;
  7603. }
  7604. entity.Memo = GetPostString("Memo");
  7605. if (respMan.IndexOf("客服") != -1 ||
  7606. respMan.IndexOf("设计师") != -1 ||
  7607. respMan.IndexOf("下单员") != -1)
  7608. {
  7609. entity.RefundState = 2;
  7610. }
  7611. else
  7612. {
  7613. entity.RefundState = 3;
  7614. }
  7615. entity.modified = DateTime.Now;
  7616. entity.Update();
  7617. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7618. returnSuccessMsg("操作成功!");
  7619. return;
  7620. }
  7621. returnErrorMsg("找不到订单记录");
  7622. }
  7623. }
  7624. public void handle_erp_designrefundtag()
  7625. {
  7626. if (UrlPostParmsCheck("refund_id"))
  7627. {
  7628. string eid = GetPostString("refund_id");
  7629. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7630. if (ceErpTradeCellExtend == null)
  7631. {
  7632. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7633. ceErpTradeCellExtend.ctid = eid;
  7634. }
  7635. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7636. if (ceErpTradeCellExtend.ID > 0)
  7637. {
  7638. ceErpTradeCellExtend.Update();
  7639. }
  7640. else
  7641. {
  7642. ceErpTradeCellExtend.Create();
  7643. }
  7644. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7645. returnSuccessMsg("操作成功!");
  7646. return;
  7647. }
  7648. returnErrorMsg("找不到订单记录");
  7649. }
  7650. public void upd_erp_refundverify()
  7651. {
  7652. if (UrlPostParmsCheck("refund_id"))
  7653. {
  7654. string eid = GetPostString("refund_id");
  7655. CeErpTradeRefund entity = null;
  7656. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7657. if (entity != null)
  7658. {
  7659. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7660. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7661. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7662. {
  7663. entity.RefundState = 2;
  7664. }
  7665. else
  7666. {
  7667. entity.RefundState = 3;
  7668. }
  7669. entity.Update();
  7670. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7671. returnSuccessMsg("操作成功!");
  7672. return;
  7673. }
  7674. returnErrorMsg("找不到订单记录");
  7675. }
  7676. }
  7677. public void upd_erp_refundapprove()
  7678. {
  7679. if (UrlPostParmsCheck("refund_id"))
  7680. {
  7681. string eid = GetPostString("refund_id");
  7682. CeErpTradeRefund entity = null;
  7683. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7684. if (entity != null)
  7685. {
  7686. int apr = GetPostInt("approve");
  7687. if (apr == 0)
  7688. {
  7689. entity.RefundState = 1;
  7690. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7691. }
  7692. else if (apr == 1)
  7693. {
  7694. entity.RefundState = 3;
  7695. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7696. }
  7697. entity.modified = DateTime.Now;
  7698. entity.Update();
  7699. returnSuccessMsg("操作成功!");
  7700. return;
  7701. }
  7702. returnErrorMsg("找不到订单记录");
  7703. }
  7704. }
  7705. public void get_erp_billlist()
  7706. {
  7707. DataStruct dStruct = GetPostStruct();
  7708. List<string> lw = new List<string>();
  7709. string title = GetPostString("title");
  7710. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7711. string tid = GetPostString("tid");
  7712. string tids = GetPostString("tids");
  7713. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7714. if (tids.Length > 0)
  7715. {
  7716. tids = "'" + tids + "'";
  7717. tids = tids.Replace(",", "','");
  7718. lw.Add(string.Format("tid in ({0})", tids));
  7719. }
  7720. string shopname = GetPostString("shopname");
  7721. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7722. string buyernick = GetPostString("buyer_nick");
  7723. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7724. string customer = GetPostString("customer");
  7725. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7726. string date1 = GetPostString("date1");
  7727. string date2 = GetPostString("date2");
  7728. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7729. if (dw.Length > 0) lw.Add(dw);
  7730. string price1 = GetPostString("price1");
  7731. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7732. string price2 = GetPostString("price2");
  7733. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7734. string returndate1 = GetPostString("returndate1");
  7735. string returndate2 = GetPostString("returndate2");
  7736. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7737. if (dw1.Length > 0) lw.Add(dw1);
  7738. string billtype = GetPostString("billtype");
  7739. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7740. string billstate = GetPostString("billstate");
  7741. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7742. string usershop = CurrentUser.User.pemShop;
  7743. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7744. dStruct.Order = "createTime desc";
  7745. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7746. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7747. //foreach (DataRow dr in dt.Rows)
  7748. //{
  7749. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7750. //}
  7751. writeGridDataTableJson(dStruct.TotalCount, dt);
  7752. }
  7753. public void modify_erp_billinfo()
  7754. {
  7755. if (UrlPostParmsCheck("ID"))
  7756. {
  7757. string eid = GetPostString("ID");
  7758. CeErpBill bill_entity = null;
  7759. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7760. if (bill_entity != null)
  7761. {
  7762. bill_entity.tid = GetPostString("tid");
  7763. bill_entity.title = GetPostString("title");
  7764. bill_entity.tax = GetPostString("tax");
  7765. bill_entity.bank = GetPostString("bank");
  7766. bill_entity.bankac = GetPostString("bankac");
  7767. bill_entity.address = GetPostString("address");
  7768. bill_entity.phone = GetPostString("phone");
  7769. bill_entity.price = GetPostString("price");
  7770. bill_entity.productId = GetPostInt("ProductName");
  7771. bill_entity.num = GetPostInt("num");
  7772. bill_entity.unit = GetPostString("unit");
  7773. bill_entity.type = GetPostString("type");
  7774. bill_entity.sendType = GetPostString("SendType");
  7775. bill_entity.email = GetPostString("email");
  7776. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7777. bill_entity.shopName = GetPostString("ShopName");
  7778. bill_entity.applymemo = GetPostString("applymemo");
  7779. bill_entity.modifyTime = DateTime.Now;
  7780. bill_entity.createTime = DateTime.Now;
  7781. bill_entity.state = 0;
  7782. bill_entity.Update();
  7783. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7784. returnSuccessMsg("发票修改成功!");
  7785. return;
  7786. }
  7787. returnErrorMsg("找不到对应记录");
  7788. }
  7789. }
  7790. public void set_erp_invoicing()
  7791. {
  7792. if (UrlPostParmsCheck("id"))
  7793. {
  7794. try
  7795. {
  7796. string eid = GetPostString("id");
  7797. CeErpBill bill_entity = null;
  7798. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7799. if (bill_entity != null)
  7800. {
  7801. int ComId = GetPostInt("ComId");
  7802. //string memo = GetPostString("Memo");
  7803. int allInfo = GetPostInt("allinfo");
  7804. string clert = CurrentUser.User.Name;
  7805. //string detailValue = GetPostString("detailvalue");
  7806. string billId = bill_entity.billOrderId;
  7807. string[] billIdList = billId.Split(',');
  7808. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7809. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7810. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7811. {
  7812. billCount += 1;
  7813. }
  7814. if (billId.Length <= 0 || billIdList.Length != billCount)
  7815. {
  7816. bill_entity.billOrderId = "";
  7817. string prebill = "ltb";
  7818. for (int idx = 1; idx <= billCount; idx++)
  7819. {
  7820. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7821. string billoid = prebill + idx + dtstr;
  7822. bill_entity.billOrderId += billoid;
  7823. if (idx < billCount)
  7824. {
  7825. bill_entity.billOrderId += ",";
  7826. }
  7827. }
  7828. }
  7829. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7830. if (bill_entity.state == 5)
  7831. {
  7832. string errMsg = bill_entity.failerror;
  7833. string[] errlist = errMsg.Split('|');
  7834. string[] errTags = new string[errlist.Length];
  7835. for (int itag = 0; itag < errlist.Length; itag++)
  7836. {
  7837. if (errlist[itag].Length <= 0) continue;
  7838. errTags[itag] = errlist[itag].Split('&')[0];
  7839. }
  7840. for (int iii = 0; iii < errTags.Length; iii++)
  7841. {
  7842. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7843. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7844. if (billOrderList.Length >= erroBillOrderTag)
  7845. {
  7846. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7847. if (needModifyBillId.Length <= 19)
  7848. {
  7849. needModifyBillId = needModifyBillId + "1";
  7850. }
  7851. else
  7852. {
  7853. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7854. last = last + 1;
  7855. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7856. }
  7857. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7858. }
  7859. }
  7860. }
  7861. bool isHaveBillSucces = false;
  7862. string totalRes = "";
  7863. bill_entity.failerror = "";
  7864. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7865. {
  7866. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7867. totalRes += res;
  7868. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7869. {
  7870. isHaveBillSucces = true;
  7871. bill_entity.comId = ComId;
  7872. bill_entity.state = 1;
  7873. bill_entity.executeTime = DateTime.Now;
  7874. bill_entity.executeUser = clert;
  7875. }
  7876. else
  7877. {
  7878. bill_entity.state = 5;
  7879. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7880. }
  7881. }
  7882. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7883. bill_entity.Update();
  7884. if (isHaveBillSucces)
  7885. {
  7886. StringBuilder sql = new StringBuilder();
  7887. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7888. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7889. }
  7890. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7891. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7892. {
  7893. returnErrorMsg("开票失败");
  7894. }
  7895. else
  7896. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7897. return;
  7898. }
  7899. returnErrorMsg("找不到对应记录");
  7900. }
  7901. catch (Exception ex)
  7902. {
  7903. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7904. returnErrorMsg("操作失败");
  7905. }
  7906. }
  7907. }
  7908. public void get_erp_invoicing_back()
  7909. {
  7910. if (UrlPostParmsCheck("id"))
  7911. {
  7912. try
  7913. {
  7914. string id = GetPostString("id");
  7915. CeErpBill entiy = CeErpBill.Get(id);
  7916. if (entiy != null)
  7917. {
  7918. if (entiy.state == 0)
  7919. {
  7920. returnErrorMsg("发票还未开具");
  7921. return;
  7922. }
  7923. string[] billOrderList = entiy.billOrderId.Split(',');
  7924. int iTag = 0;
  7925. entiy.fplsh = "";
  7926. entiy.fpdm = "";
  7927. entiy.fphm = "";
  7928. foreach (string billOrderId in billOrderList)
  7929. {
  7930. iTag++;
  7931. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7932. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7933. {
  7934. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7935. try
  7936. {
  7937. Invoicing_get_response_Obj iObj = null;
  7938. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7939. if (iObj != null)
  7940. {
  7941. entiy.state = 2;
  7942. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7943. entiy.fpdm += iObj.list[0].c_fpdm;
  7944. entiy.fphm += iObj.list[0].c_fphm;
  7945. if (iTag < billOrderList.Length)
  7946. {
  7947. entiy.fplsh += ",";
  7948. entiy.fpdm += ",";
  7949. entiy.fphm += ",";
  7950. }
  7951. entiy.Update();
  7952. }
  7953. StringBuilder sql = new StringBuilder();
  7954. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7955. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7956. returnSuccessMsg("开票成功");
  7957. }
  7958. catch (Exception ex)
  7959. {
  7960. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7961. }
  7962. return;
  7963. }
  7964. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7965. {
  7966. var res_obj = new
  7967. {
  7968. data = "开票中"
  7969. };
  7970. string ro_json = JsonConvert.SerializeObject(res_obj);
  7971. returnSuccess(ro_json);
  7972. return;
  7973. }
  7974. else
  7975. {
  7976. int eidx = res.IndexOf("c_resultmsg");
  7977. int lidx = res.IndexOf("c_status");
  7978. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7979. entiy.state = 5;
  7980. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7981. entiy.Update();
  7982. returnErrorMsg("开票失败");
  7983. return;
  7984. }
  7985. }
  7986. }
  7987. }
  7988. catch (Exception ex)
  7989. {
  7990. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7991. }
  7992. return;
  7993. }
  7994. }
  7995. public void get_erp_invoicing()
  7996. {
  7997. if (UrlPostParmsCheck("id"))
  7998. {
  7999. try
  8000. {
  8001. string id = GetPostString("id");
  8002. CeErpBill entiy = CeErpBill.Get(id);
  8003. if (entiy != null)
  8004. {
  8005. if (entiy.state == 0)
  8006. {
  8007. returnErrorMsg("发票还未开具");
  8008. return;
  8009. }
  8010. if (entiy.sendType == "纸质发票")
  8011. {
  8012. if (entiy.img.Length <= 0)
  8013. {
  8014. returnErrorMsg("查无纸质发票");
  8015. return;
  8016. }
  8017. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8018. returnSuccess(returnres);
  8019. return;
  8020. }
  8021. string[] billOrderList = entiy.billOrderId.Split(',');
  8022. int iTag = 0;
  8023. string fpUrl = "";
  8024. entiy.fplsh = "";
  8025. entiy.fpdm = "";
  8026. entiy.fphm = "";
  8027. foreach (string billOrderId in billOrderList)
  8028. {
  8029. iTag++;
  8030. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8031. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8032. {
  8033. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8034. Invoicing_get_response_Obj iObj = null;
  8035. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8036. if (iObj != null)
  8037. {
  8038. //entiy.state = 2;
  8039. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8040. entiy.fpdm += iObj.list[0].c_fpdm;
  8041. entiy.fphm += iObj.list[0].c_fphm;
  8042. if (iTag < billOrderList.Length)
  8043. {
  8044. entiy.fplsh += ",";
  8045. entiy.fpdm += ",";
  8046. entiy.fphm += ",";
  8047. }
  8048. entiy.Update();
  8049. fpUrl += iObj.list[0].c_url + ",";
  8050. }
  8051. //returnSuccess(res);
  8052. StringBuilder sql = new StringBuilder();
  8053. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8054. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8055. }
  8056. else
  8057. {
  8058. int eidx = res.IndexOf("c_resultmsg");
  8059. //int lidx = res.IndexOf("c_status");
  8060. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8061. //开票失败
  8062. entiy.state = 5;
  8063. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8064. entiy.Update();
  8065. returnErrorMsg("开票失败");
  8066. return;
  8067. }
  8068. }
  8069. var returnObj = new
  8070. {
  8071. data = fpUrl
  8072. };
  8073. string ro_json = JsonConvert.SerializeObject(returnObj);
  8074. returnSuccess(ro_json);
  8075. }
  8076. }
  8077. catch (Exception ex)
  8078. {
  8079. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8080. }
  8081. return;
  8082. }
  8083. }
  8084. public void save_erp_billimg()
  8085. {
  8086. if (UrlPostParmsCheck("id"))
  8087. {
  8088. string eid = GetPostString("id");
  8089. CeErpBill bill_entity = null;
  8090. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8091. if (bill_entity != null)
  8092. {
  8093. bill_entity.img = GetPostString("img");
  8094. bill_entity.executeTime = DateTime.Now;
  8095. bill_entity.state = 2;
  8096. bill_entity.Update();
  8097. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8098. returnSuccessMsg("保存成功");
  8099. }
  8100. return;
  8101. }
  8102. }
  8103. public void upd_erp_billreturnback()
  8104. {
  8105. if (UrlPostParmsCheck("id"))
  8106. {
  8107. int eid = GetPostInt("id");
  8108. CeErpBill bill_entity = null;
  8109. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8110. if (bill_entity != null)
  8111. {
  8112. bill_entity.state = 3;
  8113. bill_entity.returnReason = GetPostString("reason");
  8114. bill_entity.Update();
  8115. returnSuccessMsg("驳回成功!");
  8116. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8117. }
  8118. return;
  8119. }
  8120. }
  8121. public void cancel_erp_bill()
  8122. {
  8123. if (UrlPostParmsCheck("id"))
  8124. {
  8125. int eid = GetPostInt("id");
  8126. int detailValue = GetPostInt("detailvalue");
  8127. CeErpBill bill_entity = null;
  8128. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8129. string cres = "";
  8130. string gres = "";
  8131. if (bill_entity != null)
  8132. {
  8133. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8134. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8135. {
  8136. int iTag = 0;
  8137. bill_entity.fplsh = "";
  8138. bill_entity.fpdm = "";
  8139. bill_entity.fphm = "";
  8140. foreach (string billOrderId in billOrderList)
  8141. {
  8142. iTag++;
  8143. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8144. if (gres.IndexOf("success") != -1)
  8145. {
  8146. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8147. Invoicing_get_response_Obj iObj = null;
  8148. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8149. if (iObj != null)
  8150. {
  8151. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8152. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8153. bill_entity.fphm += iObj.list[0].c_fphm;
  8154. if (iTag < billOrderList.Length)
  8155. {
  8156. bill_entity.fplsh += ",";
  8157. bill_entity.fpdm += ",";
  8158. bill_entity.fphm += ",";
  8159. }
  8160. bill_entity.Update();
  8161. }
  8162. }
  8163. else
  8164. {
  8165. returnErrorMsg(gres);
  8166. return;
  8167. }
  8168. }
  8169. }
  8170. if (bill_entity.sendType == "纸质发票")
  8171. {
  8172. //作废
  8173. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8174. //if (DateTime.Now.Month == extime.Month)
  8175. //{
  8176. //cres = taobaoHelper.cancel_invoicing(eid);
  8177. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8178. //{
  8179. bill_entity.state = 4;//已作废
  8180. bill_entity.Update();
  8181. returnSuccessMsg("发票已作废");
  8182. return;
  8183. //}
  8184. //else
  8185. //{
  8186. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8187. // bill_entity.Update();
  8188. // returnErrorMsg(cres);
  8189. // return;
  8190. //}
  8191. //}
  8192. //else
  8193. //{
  8194. // returnErrorMsg("纸质发票只能作废本月的发票");
  8195. // return;
  8196. //}
  8197. }
  8198. //红冲
  8199. int redTag = 0;
  8200. string[] fpdmList = bill_entity.fpdm.Split(',');
  8201. string[] fphmList = bill_entity.fphm.Split(',');
  8202. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8203. {
  8204. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8205. return;
  8206. }
  8207. foreach (string billOrderId in billOrderList)
  8208. {
  8209. redTag++;
  8210. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8211. cres += onecres;
  8212. cres += ",";
  8213. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8214. {
  8215. bill_entity.state = 4;//已作废
  8216. //bill_entity.Update();
  8217. //returnSuccessMsg("发票已红冲");
  8218. }
  8219. else if (onecres.IndexOf("重复冲红") != -1)
  8220. {
  8221. bill_entity.state = 4;//已作废
  8222. //bill_entity.Update();
  8223. //returnSuccessMsg("发票已红冲");
  8224. }
  8225. else
  8226. {
  8227. string errmsg = commonHelper.KeepChinese(onecres);
  8228. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8229. }
  8230. }
  8231. bill_entity.Update();
  8232. if (cres.IndexOf("失败") != -1)
  8233. returnErrorMsg("红冲失败");
  8234. else
  8235. returnSuccessMsg("发票已红冲");
  8236. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8237. return;
  8238. }
  8239. return;
  8240. }
  8241. }
  8242. public void del_erp_billorder()
  8243. {
  8244. if (UrlPostParmsCheck("id"))
  8245. {
  8246. string eid = GetPostString("id");
  8247. CeErpBill.Del(eid);
  8248. CeErpBill bill = CeErpBill.Get(eid);
  8249. if (bill != null)
  8250. {
  8251. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8252. }
  8253. returnSuccessMsg("删除成功");
  8254. }
  8255. }
  8256. public void finish_erp_bill()
  8257. {
  8258. if (UrlPostParmsCheck("ids"))
  8259. {
  8260. string eids = GetPostString("ids");
  8261. string[] list = eids.Split(',');
  8262. foreach (string eid in list)
  8263. {
  8264. CeErpBill bill = CeErpBill.Get(eid);
  8265. if (bill != null)
  8266. {
  8267. bill.state = 2;
  8268. bill.Update();
  8269. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8270. }
  8271. }
  8272. returnSuccessMsg("操作成功");
  8273. }
  8274. }
  8275. public void get_erp_returncash()
  8276. {
  8277. DataStruct dStruct = GetPostStruct();
  8278. List<string> lw = new List<string>();
  8279. string tid = GetPostString("tid");
  8280. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8281. string shopname = GetPostString("shopname");
  8282. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8283. string buyernick = GetPostString("buyer_nick");
  8284. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8285. string customer = GetPostString("customer");
  8286. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8287. string returndate1 = GetPostString("returndate1");
  8288. string returndate2 = GetPostString("returndate2");
  8289. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8290. if (dw.Length > 0) lw.Add(dw);
  8291. string finishDate1 = GetPostString("finishdate1");
  8292. string finishDate2 = GetPostString("finishdate2");
  8293. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8294. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8295. string returntype = GetPostString("returntype");
  8296. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8297. string returnvstate = GetPostString("returnvstate");
  8298. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8299. dStruct.Order = "created desc";
  8300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8301. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8302. writeGridDataTableJson(dStruct.TotalCount, dt);
  8303. }
  8304. public void get_erp_staygoods()
  8305. {
  8306. DataStruct dStruct = GetPostStruct();
  8307. List<string> lw = new List<string>();
  8308. string tid = GetPostString("tid");
  8309. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8310. string shopname = GetPostString("shopname");
  8311. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8312. string wangwang = GetPostString("wangwang");
  8313. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8314. string customer = GetPostString("customer");
  8315. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8316. string returndate1 = GetPostString("returndate1");
  8317. string returndate2 = GetPostString("returndate2");
  8318. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8319. if (dw.Length > 0) lw.Add(dw);
  8320. string finishDate1 = GetPostString("finishdate1");
  8321. string finishDate2 = GetPostString("finishdate2");
  8322. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8323. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8324. string returnvstate = GetPostString("returnvstate");
  8325. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8326. string persuadetype = GetPostString("persuadetype");
  8327. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8328. string customerOrg = GetPostString("customerOrg");
  8329. if (customerOrg.Length > 0)
  8330. {
  8331. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8332. }
  8333. dStruct.Order = "creata_time desc";
  8334. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8335. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8336. writeGridDataTableJson(dStruct.TotalCount, dt);
  8337. }
  8338. public void upd_erp_staygoods()
  8339. {
  8340. if (UrlPostParmsCheck("id"))
  8341. {
  8342. int eid = GetPostInt("id");
  8343. CeErpStayGoods entity = null;
  8344. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8345. if (entity != null)
  8346. {
  8347. entity.audit_type = 1;
  8348. entity.audit_time = DateTime.Now;
  8349. entity.audit_u_id = CurrentUser.UserID;
  8350. entity.audit_u_name = CurrentUser.UserName;
  8351. entity.Update();
  8352. returnSuccessMsg("审核成功!");
  8353. return;
  8354. }
  8355. returnErrorMsg("找不到订单记录");
  8356. }
  8357. }
  8358. public void upd_erp_stayGoodsback()
  8359. {
  8360. if (UrlPostParmsCheck("id"))
  8361. {
  8362. int eid = GetPostInt("id");
  8363. CeErpStayGoods entity = null;
  8364. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8365. if (entity != null)
  8366. {
  8367. entity.audit_text = GetPostString("reason");
  8368. entity.audit_type = 2;
  8369. entity.audit_time = DateTime.Now;
  8370. entity.audit_u_id = CurrentUser.UserID;
  8371. entity.audit_u_name = CurrentUser.UserName;
  8372. entity.Update();
  8373. returnSuccessMsg("退回成功!");
  8374. return;
  8375. }
  8376. returnErrorMsg("找不到订单记录");
  8377. }
  8378. }
  8379. public void upd_erp_returncashverify()
  8380. {
  8381. if (UrlPostParmsCheck("ID"))
  8382. {
  8383. int eid = GetPostInt("ID");
  8384. CeErpReturnCash entity = null;
  8385. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8386. if (entity != null)
  8387. {
  8388. entity.cashstate = 1;
  8389. entity.verifytime = DateTime.Now;
  8390. entity.verifyuserid = CurrentUser.UserID;
  8391. entity.Update();
  8392. returnSuccessMsg("审核成功!");
  8393. return;
  8394. }
  8395. returnErrorMsg("找不到订单记录");
  8396. }
  8397. }
  8398. public void upd_all_erp_returncashverify()
  8399. {
  8400. if (UrlPostParmsCheck("ID"))
  8401. {
  8402. String[] list = GetPostString("ID").Split(',');
  8403. CeErpReturnCash entity = null;
  8404. for (int i = 0; i < list.Length; i++)
  8405. {
  8406. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8407. if (entity != null)
  8408. {
  8409. if (entity.cashstate == 1)
  8410. {
  8411. returnErrorMsg("已审核过的订单不需要在审核!");
  8412. return;
  8413. }
  8414. entity.cashstate = 1;
  8415. entity.verifytime = DateTime.Now;
  8416. entity.verifyuserid = CurrentUser.UserID;
  8417. entity.Update();
  8418. }
  8419. }
  8420. returnSuccessMsg("审核成功!");
  8421. return;
  8422. }
  8423. }
  8424. public void upd_erp_returncashback()
  8425. {
  8426. if (UrlPostParmsCheck("ID"))
  8427. {
  8428. int eid = GetPostInt("ID");
  8429. CeErpReturnCash entity = null;
  8430. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8431. if (entity != null)
  8432. {
  8433. entity.backreason = GetPostString("reason");
  8434. entity.cashstate = 2;
  8435. entity.verifytime = DateTime.Now;
  8436. entity.verifyuserid = CurrentUser.UserID;
  8437. entity.Update();
  8438. returnSuccessMsg("退回成功!");
  8439. return;
  8440. }
  8441. returnErrorMsg("找不到订单记录");
  8442. }
  8443. }
  8444. public void upd_erp_returnprice()
  8445. {
  8446. if (UrlPostParmsCheck("ID"))
  8447. {
  8448. int eid = GetPostInt("ID");
  8449. CeErpReturnCash entity = null;
  8450. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8451. if (entity != null)
  8452. {
  8453. if (entity.cashstate == 1)
  8454. {
  8455. returnErrorMsg("审核通过了不能改");
  8456. return;
  8457. }
  8458. entity.returnprice = GetPostDouble("returnprice");
  8459. entity.Update();
  8460. returnSuccessMsg("修改成功!");
  8461. return;
  8462. }
  8463. returnErrorMsg("找不到订单记录");
  8464. }
  8465. }
  8466. public void del_erp_returncash()
  8467. {
  8468. if (UrlPostParmsCheck("ID"))
  8469. {
  8470. int eid = GetPostInt("ID");
  8471. CeErpReturnCash.Del(eid);
  8472. returnSuccessMsg("操作成功");
  8473. return;
  8474. }
  8475. }
  8476. public void test_for_do_sql()
  8477. {
  8478. string sql = GetPostString("sqlstr");
  8479. if (sql.Length > 0)
  8480. {
  8481. try
  8482. {
  8483. DbHelper.DbConn.ExecuteNonQuery(sql);
  8484. var res_obj = new
  8485. {
  8486. data = "成功",
  8487. };
  8488. string ro_json = JsonConvert.SerializeObject(res_obj);
  8489. returnSuccess(ro_json);
  8490. }
  8491. catch (Exception ex)
  8492. {
  8493. var res_obj = new
  8494. {
  8495. data = ex.Message,
  8496. };
  8497. string ro_json = JsonConvert.SerializeObject(res_obj);
  8498. returnSuccess(ro_json);
  8499. }
  8500. }
  8501. }
  8502. public void get_user_info()
  8503. {
  8504. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8505. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8506. }
  8507. public void get_total_data()
  8508. {
  8509. int userId = CurrentUser.UserID;
  8510. string sql = "";
  8511. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8512. {
  8513. 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);
  8514. }
  8515. else
  8516. {
  8517. 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 " +
  8518. "(select ID from CE_ErpUser where ID = {0}) d " +
  8519. "left join " +
  8520. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8521. ") a on d.ID = a.id left join " +
  8522. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8523. ") b on a.id = b.id1 left join" +
  8524. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8525. ") c on a.id = c.id2;", userId);
  8526. }
  8527. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8528. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8529. }
  8530. public void get_date_area_total_data2()
  8531. {
  8532. int userId = CurrentUser.UserID;
  8533. string date_type = GetPostString("timetype");
  8534. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8535. string sql = "";
  8536. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8537. {
  8538. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8539. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8540. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8541. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8542. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8543. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8544. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8545. ") a on e.ID = a.id left join " +
  8546. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8547. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8548. ") b on a.id = b.id1 " +
  8549. "left join " +
  8550. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8551. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8552. ") c on a.id = c.id2 " +
  8553. "left join " +
  8554. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8555. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8556. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8557. }
  8558. else
  8559. {
  8560. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8561. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8562. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8563. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8564. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8565. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8566. ") a on e.ID = a.id left join " +
  8567. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8568. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8569. ") c on a.id = c.id2 " +
  8570. "left join " +
  8571. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8572. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8573. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8574. }
  8575. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8576. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8577. }
  8578. public void get_date_area_total_data()
  8579. {
  8580. int userId = CurrentUser.UserID;
  8581. string date_type = GetPostString("timetype");
  8582. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8583. string date1 = searchDT[0].ToString();
  8584. string date2 = searchDT[1].ToString();
  8585. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8586. {
  8587. SqlParameter[] sqlParameter ={
  8588. new SqlParameter("@userId", SqlDbType.Int,4),
  8589. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8590. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8591. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8592. };
  8593. sqlParameter[0].Value = userId;
  8594. sqlParameter[1].Value = date1;
  8595. sqlParameter[2].Value = date2;
  8596. sqlParameter[3].Direction = ParameterDirection.Output;
  8597. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8598. string res = sqlParameter[3].Value.ToString();
  8599. var res_obj = new
  8600. {
  8601. data = res
  8602. };
  8603. string ro_json = JsonConvert.SerializeObject(res_obj);
  8604. returnSuccess(ro_json);
  8605. }
  8606. else
  8607. {
  8608. SqlParameter[] sqlParameter ={
  8609. new SqlParameter("@userId", SqlDbType.Int,4),
  8610. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8611. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8612. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8613. };
  8614. sqlParameter[0].Value = userId;
  8615. sqlParameter[1].Value = date1;
  8616. sqlParameter[2].Value = date2;
  8617. sqlParameter[3].Direction = ParameterDirection.Output;
  8618. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8619. string res = sqlParameter[3].Value.ToString();
  8620. var res_obj = new
  8621. {
  8622. data = res
  8623. };
  8624. string ro_json = JsonConvert.SerializeObject(res_obj);
  8625. returnSuccess(ro_json);
  8626. }
  8627. //writeGridDataViewJson(dt.Rows.Count, dv);
  8628. }
  8629. public void get_order_list()
  8630. {
  8631. string strFields = GetPostString("paraFields");
  8632. string strOrder = GetPostString("paraOrder");
  8633. string strWhere = GetPostString("paraWhere");
  8634. string strPageSize = GetPostString("paraPageSize");
  8635. DataStruct dStruct = GetPostStruct();
  8636. dStruct.PageSize = int.Parse(strPageSize);
  8637. dStruct.Fileds = strFields;
  8638. dStruct.Order = strOrder;
  8639. dStruct.MainWhere = strWhere;
  8640. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8641. writeGridDataTableJson(dStruct.TotalCount, dt);
  8642. }
  8643. ////获取待开始订单列表
  8644. //public void get_wait_design_order_list()
  8645. //{
  8646. // string date_type = GetPostString("date_type");
  8647. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8648. // DataStruct dStruct = GetPostStruct();
  8649. // dStruct.PageSize = 1000;
  8650. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8651. // List<string> lw = new List<string>();
  8652. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8653. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8654. // dStruct.Order = "WaitDesignTime asc";
  8655. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8656. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8657. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8658. //}
  8659. //获取完成单量排名
  8660. public void get_finish_order_count_ranking()
  8661. {
  8662. /* string date_type = GetPostString("date_type");
  8663. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8664. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8665. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8666. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8667. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8668. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8669. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8670. writeGridDataTableJson(0, new DataTable());
  8671. }
  8672. public void get_finish_order_amount_ranking()
  8673. {
  8674. /*string date_type = GetPostString("date_type");
  8675. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8676. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8677. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8678. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8679. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8680. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8681. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8682. writeGridDataTableJson(0, new DataTable());
  8683. }
  8684. public void get_finish_refund_count_ranking()
  8685. {
  8686. string date_type = GetPostString("date_type");
  8687. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8688. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8689. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8690. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8691. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8692. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8693. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8694. writeGridDataTableJson(dt.Rows.Count, dt);
  8695. }
  8696. public void get_finish_refund_amount_ranking()
  8697. {
  8698. string date_type = GetPostString("date_type");
  8699. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8700. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8701. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8702. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8703. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8704. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8705. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8706. writeGridDataTableJson(dt.Rows.Count, dt);
  8707. }
  8708. public void set_erp_finishorder_director()
  8709. {
  8710. if (UrlPostParmsCheck("ctid"))
  8711. {
  8712. string eid = GetPostString("ctid");
  8713. CeErpTradeCell entity = null;
  8714. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8715. if (entity != null)
  8716. {
  8717. entity.OrderState = 8;
  8718. entity.Update();
  8719. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8720. returnSuccessMsg("操作成功!");
  8721. return;
  8722. }
  8723. returnErrorMsg("找不到记录");
  8724. }
  8725. }
  8726. public void get_erp_placeregistlist()
  8727. {
  8728. DataStruct dStruct = GetPostStruct();
  8729. List<string> lw = new List<string>();
  8730. string outsid = GetPostString("outsid");
  8731. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8732. string memo = GetPostString("memo");
  8733. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8734. string filename = GetPostString("filename");
  8735. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8736. string islate = GetPostString("islate");
  8737. if (islate.Length > 0)
  8738. {
  8739. if (islate == "1")
  8740. lw.Add(string.Format("OutLate>0"));
  8741. else
  8742. lw.Add(string.Format("OutLate=0"));
  8743. }
  8744. string placedate1 = GetPostString("placedate1");
  8745. string placedate2 = GetPostString("placedate2");
  8746. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8747. if (dw.Length > 0) lw.Add(dw);
  8748. string deliveryDate1 = GetPostString("deliverydate1");
  8749. string deliveryDate2 = GetPostString("deliverydate2");
  8750. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8751. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8752. dStruct.Order = "ID desc";
  8753. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8754. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8755. writeGridDataTableJson(dStruct.TotalCount, dt);
  8756. }
  8757. public void ins_erp_placeregist()
  8758. {
  8759. if (UrlPostParmsCheck("id"))
  8760. {
  8761. string eid = GetPostString("id");
  8762. CeErpPlaceRegister entity = null;
  8763. if (eid == "0")//新增
  8764. {
  8765. entity = new CeErpPlaceRegister();
  8766. string xdTime = GetPostString("placeTime");
  8767. if (xdTime.Length > 0)
  8768. {
  8769. entity.PlactTime = Convert.ToDateTime(xdTime);
  8770. }
  8771. string fhTime = GetPostString("deliveryTime");
  8772. if (fhTime.Length > 0)
  8773. {
  8774. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8775. }
  8776. string preTime = GetPostString("preOutTime");
  8777. if (preTime.Length > 0)
  8778. {
  8779. entity.PreOutTime = Convert.ToDateTime(preTime);
  8780. }
  8781. entity.DeliveryCount = GetPostInt("deliveryCount");
  8782. entity.ReceiveCount = GetPostInt("receiveCount");
  8783. entity.OutSid = GetPostString("outSid");
  8784. entity.FileName = GetPostString("fileName");
  8785. entity.Memo = GetPostString("memo");
  8786. entity.AddUserId = CurrentUser.UserID;
  8787. entity.CreateTime = DateTime.Now;
  8788. entity.Img = GetPostString("img");
  8789. entity.Supplier = GetPostInt("supplier");
  8790. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8791. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8792. {
  8793. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8794. DateTime dt2 = (DateTime)entity.PreOutTime;
  8795. TimeSpan span = dt1.Subtract(dt2);
  8796. if (span.Days > 0)
  8797. {
  8798. entity.OutLate = span.Days;
  8799. }
  8800. }
  8801. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8802. entity.Create();
  8803. returnSuccessMsg("添加成功!");
  8804. return;
  8805. }
  8806. else //修改
  8807. {
  8808. entity = CeErpPlaceRegister.Get(eid);
  8809. if (entity != null)
  8810. {
  8811. string xdTime = GetPostString("placeTime");
  8812. if (xdTime.Length > 0)
  8813. {
  8814. entity.PlactTime = Convert.ToDateTime(xdTime);
  8815. }
  8816. string fhTime = GetPostString("deliveryTime");
  8817. if (fhTime.Length > 0)
  8818. {
  8819. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8820. }
  8821. string preTime = GetPostString("preOutTime");
  8822. if (preTime.Length > 0)
  8823. {
  8824. entity.PreOutTime = Convert.ToDateTime(preTime);
  8825. }
  8826. entity.DeliveryCount = GetPostInt("deliveryCount");
  8827. entity.ReceiveCount = GetPostInt("receiveCount");
  8828. if (entity.DeliveryCount == entity.ReceiveCount)
  8829. {
  8830. entity.CurState = "已完成";
  8831. }
  8832. else
  8833. {
  8834. entity.CurState = "未完成";
  8835. }
  8836. entity.OutSid = GetPostString("outSid");
  8837. entity.FileName = GetPostString("fileName");
  8838. entity.Memo = GetPostString("memo");
  8839. entity.Img = GetPostString("img");
  8840. entity.Supplier = GetPostInt("supplier");
  8841. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8842. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8843. {
  8844. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8845. DateTime dt2 = (DateTime)entity.PreOutTime;
  8846. TimeSpan span = dt1.Subtract(dt2);
  8847. if (span.Days > 0)
  8848. {
  8849. entity.OutLate = span.Days;
  8850. }
  8851. }
  8852. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8853. entity.Update();
  8854. returnSuccessMsg("修改成功");
  8855. return;
  8856. }
  8857. returnErrorMsg("找不到对应的记录");
  8858. return;
  8859. }
  8860. }
  8861. returnErrorMsg("缺少必要参数");
  8862. }
  8863. public void del_erp_placeregist()
  8864. {
  8865. string eid = GetPostString("id");
  8866. CeErpPlaceRegister.Del(eid);
  8867. returnSuccessMsg("删除成功!");
  8868. return;
  8869. }
  8870. public void ins_erp_placeregistbyorder()
  8871. {
  8872. string ctid = GetPostString("ctid");
  8873. if (ctid.Length > 0)
  8874. {
  8875. StringBuilder sql = new StringBuilder();
  8876. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8877. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8878. if (dt.Rows.Count > 0)
  8879. {
  8880. foreach (DataRow dr in dt.Rows)
  8881. {
  8882. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8883. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8884. entity.AddUserId = CurrentUser.UserID;
  8885. entity.tid = dr["tid"].ToString();
  8886. entity.Did = Convert.ToString(dr["ctid"]);
  8887. entity.splitTag = dr["SplitTag"].ToString();
  8888. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8889. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8890. if (pre_ctid.Length > 0)
  8891. {
  8892. sellmemo = sellmemo.Replace(pre_ctid, "");
  8893. }
  8894. sellmemo = sellmemo.Replace("[", "");
  8895. sellmemo = sellmemo.Replace("]", "");
  8896. entity.FileName = sellmemo;
  8897. string count = dr["ProductCount"].ToString();
  8898. int usecount = commonHelper.getIntCountFromString(count);
  8899. entity.DeliveryCount = usecount;
  8900. entity.CurState = "未完成";
  8901. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8902. {
  8903. entity.Supplier = 24;//dl手提袋定制
  8904. }
  8905. else
  8906. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8907. entity.CreateTime = DateTime.Now;
  8908. entity.Create();
  8909. }
  8910. returnSuccessMsg("操作成功");
  8911. return;
  8912. }
  8913. returnErrorMsg("没有找到对应订单");
  8914. return;
  8915. }
  8916. returnErrorMsg("缺少订单编号");
  8917. return;
  8918. }
  8919. public void get_erp_persuadelist()
  8920. {
  8921. DataStruct dStruct = GetPostStruct();
  8922. List<string> lw = new List<string>();
  8923. string ctid = GetPostString("ctid");
  8924. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8925. string shopname = GetPostString("shopname");
  8926. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8927. string buyernick = GetPostString("buyer_nick");
  8928. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8929. string customer = GetPostString("customer");
  8930. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8931. string returndate1 = GetPostString("returndate1");
  8932. string returndate2 = GetPostString("returndate2");
  8933. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8934. if (dw.Length > 0) lw.Add(dw);
  8935. string finishDate1 = GetPostString("finishdate1");
  8936. string finishDate2 = GetPostString("finishdate2");
  8937. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8938. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8939. string persuadetype = GetPostString("persuadetype");
  8940. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8941. string returnvstate = GetPostString("returnvstate");
  8942. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8943. dStruct.Order = "created desc";
  8944. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8945. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8946. writeGridDataTableJson(dStruct.TotalCount, dt);
  8947. }
  8948. public void upd_erp_returnpersuadeback()
  8949. {
  8950. if (UrlPostParmsCheck("ID"))
  8951. {
  8952. int eid = GetPostInt("ID");
  8953. CeErpPersuade entity = null;
  8954. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8955. if (entity != null)
  8956. {
  8957. entity.backreason = GetPostString("reason");
  8958. entity.pstate = 2;
  8959. entity.verifytime = DateTime.Now;
  8960. entity.verifyuserid = CurrentUser.UserID;
  8961. entity.Update();
  8962. returnSuccessMsg("退回成功!");
  8963. return;
  8964. }
  8965. returnErrorMsg("找不到订单记录");
  8966. }
  8967. }
  8968. public void upd_erp_returnpersuadeverify()
  8969. {
  8970. if (UrlPostParmsCheck("ID"))
  8971. {
  8972. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8973. {
  8974. returnErrorMsg("暂无权限审核");
  8975. return;
  8976. }
  8977. int eid = GetPostInt("ID");
  8978. CeErpPersuade entity = null;
  8979. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8980. if (entity != null)
  8981. {
  8982. entity.pstate = 1;
  8983. entity.verifytime = DateTime.Now;
  8984. entity.verifyuserid = CurrentUser.UserID;
  8985. entity.Update();
  8986. returnSuccessMsg("审核成功!");
  8987. return;
  8988. }
  8989. returnErrorMsg("找不到订单记录");
  8990. }
  8991. }
  8992. public void del_erp_persuade()
  8993. {
  8994. if (UrlPostParmsCheck("ID"))
  8995. {
  8996. int eid = GetPostInt("ID");
  8997. CeErpPersuade.Del(eid);
  8998. returnSuccessMsg("操作成功");
  8999. return;
  9000. }
  9001. }
  9002. public void get_erp_oldcustoupload()
  9003. {
  9004. DataStruct dStruct = GetPostStruct();
  9005. List<string> lw = new List<string>();
  9006. string buyernick = GetPostString("buyer_nick");
  9007. if (buyernick.Length > 0)
  9008. {
  9009. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9010. }
  9011. else
  9012. return;
  9013. dStruct.Order = "pay_time desc";
  9014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9015. DataTable dt = null;
  9016. dt = WebCache.GetData("view_erptradecell", dStruct);
  9017. writeGridDataTableJson(dStruct.TotalCount, dt);
  9018. }
  9019. public void get_erp_checkorderlist()
  9020. {
  9021. DataStruct dStruct = GetPostStruct();
  9022. List<string> lw = new List<string>();
  9023. string tid = GetPostString("ctid");
  9024. if (tid.Length > 0)
  9025. {
  9026. string select_tid = getTidByCtid(tid);
  9027. lw.Add(string.Format("tid='{0}'", select_tid));
  9028. }
  9029. string shopname = GetPostString("shopname");
  9030. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9031. string buyernick = GetPostString("buyer_nick");
  9032. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9033. string customer = GetPostString("customer");
  9034. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9035. string design = GetPostString("design");
  9036. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9037. string orderState = GetPostString("orderState");
  9038. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9039. string address = GetPostString("address");
  9040. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9041. string sellermemo = GetPostString("seller_memo");
  9042. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9043. string supplier = GetPostString("supplier");
  9044. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9045. {
  9046. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9047. }
  9048. else
  9049. {
  9050. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9051. }
  9052. string date1 = GetPostString("date1");
  9053. string date2 = GetPostString("date2");
  9054. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9055. if (dw.Length > 0) lw.Add(dw);
  9056. string placedate1 = GetPostString("placedate1");
  9057. string placedate2 = GetPostString("placedate2");
  9058. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9059. if (fdw.Length > 0) lw.Add(fdw);
  9060. string price1 = GetPostString("price1");
  9061. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9062. string price2 = GetPostString("price2");
  9063. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9064. string checkst = GetPostString("checkstate");
  9065. if (checkst.Length > 0 && "10".Equals(checkst))
  9066. {
  9067. lw.Add(string.Format("CheckOut>0"));
  9068. }
  9069. else
  9070. {
  9071. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9072. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9073. }
  9074. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9075. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9076. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9077. writeGridDataTableJson(dStruct.TotalCount, dt);
  9078. }
  9079. public void ins_erp_startCheck()
  9080. {
  9081. if (UrlPostParmsCheck("ctid"))
  9082. {
  9083. string eid = GetPostString("ctid");
  9084. CeErpTradeCell entity = null;
  9085. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9086. if (entity != null)
  9087. {
  9088. entity.MemoOpt = 4;
  9089. entity.Update();
  9090. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9091. CeErpSukuraData.createInfo(entity.ctid, 6);
  9092. returnSuccessMsg("操作成功!");
  9093. return;
  9094. }
  9095. returnErrorMsg("找不到记录");
  9096. }
  9097. }
  9098. public void upd_erp_sendXlw()
  9099. {
  9100. if (UrlPostParmsCheck("ctid"))
  9101. {
  9102. string eid = GetPostString("ctid");
  9103. CeErpTradeCell entity = null;
  9104. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9105. if (entity != null)
  9106. {
  9107. if (entity.IsSendGift == 1)
  9108. {
  9109. returnErrorMsg("请勿重复标记");
  9110. return;
  9111. }
  9112. entity.IsSendGift = 1;
  9113. entity.Update();
  9114. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9115. returnSuccessMsg("操作成功!");
  9116. return;
  9117. }
  9118. returnErrorMsg("找不到记录");
  9119. }
  9120. }
  9121. public void cancel_sendXlw()
  9122. {
  9123. if (UrlPostParmsCheck("ctid"))
  9124. {
  9125. string eid = GetPostString("ctid");
  9126. CeErpTradeCell entity = null;
  9127. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9128. if (entity != null)
  9129. {
  9130. if (entity.IsSendGift == 0)
  9131. {
  9132. returnErrorMsg("未标记小礼物");
  9133. return;
  9134. }
  9135. entity.IsSendGift = 0;
  9136. entity.Update();
  9137. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9138. returnSuccessMsg("操作成功!");
  9139. return;
  9140. }
  9141. returnErrorMsg("找不到记录");
  9142. }
  9143. }
  9144. public void get_erp_designbill()
  9145. {
  9146. DataStruct dStruct = GetPostStruct();
  9147. List<string> lw = new List<string>();
  9148. int isMy = GetInt("my");
  9149. if (isMy == 1)
  9150. {
  9151. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9152. }
  9153. string tid = GetPostString("tid");
  9154. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9155. string userName = GetPostString("design");
  9156. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9157. string price1 = GetPostString("price1");
  9158. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9159. string price2 = GetPostString("price2");
  9160. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9161. string rePrice1 = GetPostString("rePrice1");
  9162. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9163. string rePrice2 = GetPostString("rePrice2");
  9164. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9165. string designerType = GetPostString("designerType");
  9166. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9167. string orderState = GetPostString("orderState");
  9168. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9169. string endTime1 = GetPostString("endTime1");
  9170. string endTime2 = GetPostString("endTime2");
  9171. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9172. if (dw.Length > 0) lw.Add(dw);
  9173. string isDk = GetPostString("isDk");
  9174. if (isDk == "1")
  9175. {
  9176. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9177. }
  9178. else if (isDk == "0")
  9179. {
  9180. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9181. }
  9182. dStruct.Order = "oid, create_time desc";
  9183. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9184. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9185. writeGridDataTableJson(dStruct.TotalCount, dt);
  9186. }
  9187. public void upd_erp_designerbill()
  9188. {
  9189. if (UrlPostParmsCheck("ID"))
  9190. {
  9191. string eid = GetPostString("ID");
  9192. CeErpDesignerBill entity = null;
  9193. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9194. if (entity != null)
  9195. {
  9196. if (GetPostDouble("designerpirce") > 0)
  9197. {
  9198. entity.realPrice = GetPostDouble("designerpirce");
  9199. entity.update_time = DateTime.Now;
  9200. entity.update_u_id = CurrentUser.UserID;
  9201. entity.update_u_name = CurrentUser.UserName;
  9202. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9203. entity.Update();
  9204. returnSuccessMsg("操作成功!");
  9205. return;
  9206. }
  9207. else
  9208. {
  9209. entity.price = GetPostDouble("price");
  9210. entity.update_time = DateTime.Now;
  9211. entity.update_u_id = CurrentUser.UserID;
  9212. entity.update_u_name = CurrentUser.UserName;
  9213. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9214. entity.Update();
  9215. returnSuccessMsg("操作成功!");
  9216. return;
  9217. }
  9218. }
  9219. returnErrorMsg("找不到记录");
  9220. }
  9221. }
  9222. public void audit_erp_designerbill()
  9223. {
  9224. if (UrlPostParmsCheck("ID"))
  9225. {
  9226. string eid = GetPostString("ID");
  9227. CeErpDesignerBill entity = null;
  9228. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9229. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9230. if (entity != null)
  9231. {
  9232. entity.realPrice = GetPostDouble("designerpirce");
  9233. entity.update_time = DateTime.Now;
  9234. entity.update_u_id = CurrentUser.UserID;
  9235. entity.update_u_name = CurrentUser.UserName;
  9236. entity.isAudit = 1;
  9237. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9238. entity.Update();
  9239. if (orderEntity != null)
  9240. {
  9241. orderEntity.IsReadTag = 3;
  9242. orderEntity.Update();
  9243. }
  9244. returnSuccessMsg("操作成功!");
  9245. return;
  9246. }
  9247. returnErrorMsg("找不到记录");
  9248. }
  9249. }
  9250. public void all_audit_erp_designerbill()
  9251. {
  9252. if (UrlPostParmsCheck("idList"))
  9253. {
  9254. string[] list = GetPostString("idList").Split(',');
  9255. CeErpDesignerBill entity = null;
  9256. for (int i = 0; i < list.Length; i++)
  9257. {
  9258. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9259. if (entity == null) return;
  9260. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9261. if (orderEntity == null) return;
  9262. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9263. entity.update_time = DateTime.Now;
  9264. entity.update_u_id = CurrentUser.UserID;
  9265. entity.update_u_name = CurrentUser.UserName;
  9266. entity.isAudit = 1;
  9267. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9268. entity.Update();
  9269. orderEntity.IsReadTag = 3;
  9270. orderEntity.Update();
  9271. }
  9272. returnSuccessMsg("操作成功!");
  9273. return;
  9274. }
  9275. }
  9276. public void get_erp_sameorders()
  9277. {
  9278. if (UrlPostParmsCheck("ctid"))
  9279. {
  9280. string eid = GetPostString("ctid");
  9281. CeErpTradeCell entity = null;
  9282. entity = CeErpTradeCell.GetByCtid(eid);
  9283. if (entity != null)
  9284. {
  9285. StringBuilder sql = new StringBuilder();
  9286. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9287. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9288. var res = new
  9289. {
  9290. data = dt.Rows.Count
  9291. };
  9292. string ro_jsond = JsonConvert.SerializeObject(res);
  9293. returnSuccess(ro_jsond);
  9294. return;
  9295. }
  9296. returnErrorMsg("未找到订单");
  9297. return;
  9298. }
  9299. returnErrorMsg("缺少必要的参数");
  9300. }
  9301. public void get_erp_islasthavesameorder()
  9302. {
  9303. if (UrlPostParmsCheck("ctid"))
  9304. {
  9305. string eid = GetPostString("ctid");
  9306. string[] ctidList = eid.Split(',');
  9307. StringBuilder sql = new StringBuilder();
  9308. string tisCtid = "";
  9309. foreach (string ctid in ctidList)
  9310. {
  9311. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9312. if (entity != null)
  9313. {
  9314. sql = new StringBuilder();
  9315. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9316. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9317. if (dth.Rows.Count > 0)
  9318. {
  9319. tisCtid += entity.ctid;
  9320. tisCtid += ",";
  9321. }
  9322. }
  9323. }
  9324. if (tisCtid.Length > 0)
  9325. {
  9326. var res = new
  9327. {
  9328. data = tisCtid
  9329. };
  9330. string ro_jsond = JsonConvert.SerializeObject(res);
  9331. returnSuccess(ro_jsond);
  9332. }
  9333. else
  9334. {
  9335. var res = new
  9336. {
  9337. data = ""
  9338. };
  9339. string ro_jsond = JsonConvert.SerializeObject(res);
  9340. returnSuccess(ro_jsond);
  9341. }
  9342. return;
  9343. }
  9344. returnErrorMsg("缺少必要的参数");
  9345. }
  9346. public void file_client_down_url()
  9347. {
  9348. if (!UrlPostParmsCheck("userId"))
  9349. {
  9350. returnErrorMsg("缺少必要的参数");
  9351. }
  9352. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9353. }
  9354. public void checkout_form_data()
  9355. {
  9356. if (!UrlPostParmsCheck("tid"))
  9357. {
  9358. returnErrorMsg("缺少必要的参数");
  9359. }
  9360. string tid = GetPostString("tid");
  9361. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9362. if (ceErpOrderFormData != null)
  9363. {
  9364. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9365. returnSuccess(ro_jsond);
  9366. return;
  9367. }
  9368. returnErrorMsg("尚未有文件!");
  9369. }
  9370. public void back_supplier_audit()
  9371. {
  9372. int userId = CurrentUser.UserID;
  9373. StringBuilder sql = new StringBuilder();
  9374. 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);
  9375. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9376. if (dt.Rows.Count > 0)
  9377. {
  9378. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9379. }
  9380. else
  9381. {
  9382. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9383. }
  9384. }
  9385. public void back_supplier_query()
  9386. {
  9387. string eid = GetPostString("ctid");
  9388. if (eid != "")
  9389. {
  9390. StringBuilder sql = new StringBuilder();
  9391. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9392. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9393. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9394. }
  9395. else
  9396. {
  9397. returnErrorMsg("找不到订单记录");
  9398. return;
  9399. }
  9400. }
  9401. public void verified_to_order()
  9402. {
  9403. int userId = CurrentUser.UserID;
  9404. StringBuilder sql = new StringBuilder();
  9405. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9406. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9407. if (dt.Rows.Count > 0)
  9408. {
  9409. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9410. }
  9411. else
  9412. {
  9413. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9414. }
  9415. }
  9416. public void upd_supplier_audit()
  9417. {
  9418. if (UrlPostParmsCheck("ctid"))
  9419. {
  9420. string eid = GetPostString("ctid");
  9421. string reason = GetPostString("returnreason");
  9422. CeErpTradeCell entity = null;
  9423. CeWithdraw withdraw = null;
  9424. withdraw = CeWithdraw.GetByTid(eid);
  9425. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9426. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9427. {
  9428. if (withdraw != null)
  9429. {
  9430. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9431. {
  9432. returnSuccessMsg("您没有权限操作!");
  9433. return;
  9434. }
  9435. else
  9436. {
  9437. if (reason.Equals("1"))
  9438. {
  9439. if (entity.OrderState == -1)
  9440. {
  9441. if (entity.FinishPlaceTime == null)
  9442. {
  9443. entity.OrderState = 2;
  9444. }
  9445. else
  9446. {
  9447. entity.OrderState = 6;
  9448. }
  9449. }
  9450. entity.Update();
  9451. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9452. if (withdraw != null)
  9453. {
  9454. withdraw.status = int.Parse(reason);
  9455. withdraw.Update();
  9456. }
  9457. returnSuccessMsg("操作成功!");
  9458. return;
  9459. }
  9460. else
  9461. {
  9462. withdraw.status = int.Parse(reason);
  9463. withdraw.acknowledgingtime = DateTime.Now;
  9464. withdraw.Update();
  9465. returnSuccessMsg("查看详细请点击线下订单查询");
  9466. return;
  9467. }
  9468. }
  9469. }
  9470. // 第一个字符是 'N'
  9471. }
  9472. if (eid[0] != 'N')
  9473. {
  9474. }
  9475. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9476. {
  9477. entity.IsVerifyToSupplier = false;
  9478. entity.IsReturn = 1;
  9479. entity.ReturnTime = DateTime.Now;
  9480. entity.ReturnReason = reason;
  9481. if (entity.OrderState == 6)
  9482. {
  9483. entity.OrderState = 5;
  9484. }
  9485. entity.Update();
  9486. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9487. if (withdraw != null)
  9488. {
  9489. withdraw.status = int.Parse(reason);
  9490. withdraw.Update();
  9491. }
  9492. returnSuccessMsg("操作成功!");
  9493. return;
  9494. }
  9495. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9496. {
  9497. ;
  9498. if (withdraw != null)
  9499. {
  9500. withdraw.status = int.Parse(reason);
  9501. withdraw.acknowledgingtime = DateTime.Now;
  9502. withdraw.Update();
  9503. returnSuccessMsg("供应商取消撤回!");
  9504. return;
  9505. }
  9506. }
  9507. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9508. {
  9509. if (entity.OrderState == -1)
  9510. {
  9511. if (entity.FinishPlaceTime == null)
  9512. {
  9513. entity.OrderState = 2;
  9514. }
  9515. else
  9516. {
  9517. entity.OrderState = 3;
  9518. }
  9519. commonHelper.getCytPrice(entity);
  9520. }
  9521. entity.Update();
  9522. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9523. if (withdraw != null)
  9524. {
  9525. withdraw.status = int.Parse(reason);
  9526. withdraw.Update();
  9527. }
  9528. returnSuccessMsg("操作成功!");
  9529. return;
  9530. }
  9531. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9532. {
  9533. if (withdraw == null)
  9534. {
  9535. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9536. return;
  9537. }
  9538. }
  9539. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9540. {
  9541. if (withdraw != null)
  9542. {
  9543. withdraw.status = int.Parse(reason);
  9544. withdraw.acknowledgingtime = DateTime.Now;
  9545. withdraw.Update();
  9546. returnSuccessMsg("查看详细请点击线下订单查询");
  9547. return;
  9548. }
  9549. }
  9550. return;
  9551. }
  9552. }
  9553. //校验报价
  9554. public void refund_order_tip()
  9555. {
  9556. int userid = CurrentUser.UserID;
  9557. int sectionId = CurrentUser.UserPost.OrgID;
  9558. StringBuilder sql = new StringBuilder();
  9559. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9560. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9561. List<string> ids = new List<string>();
  9562. if (dth.Rows.Count > 0)
  9563. {
  9564. foreach (DataRow dr in dth.Rows)
  9565. {
  9566. ids.Add(dr["ID"].ToString());
  9567. }
  9568. try
  9569. {
  9570. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9571. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9572. }
  9573. catch (Exception ex)
  9574. {
  9575. }
  9576. }
  9577. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9578. }
  9579. public void refund_order_Design()
  9580. {
  9581. int userid = CurrentUser.UserID;
  9582. int sectionId = CurrentUser.UserPost.OrgID;
  9583. StringBuilder sql = new StringBuilder();
  9584. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9585. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9586. List<string> ids = new List<string>();
  9587. if (dth.Rows.Count > 0)
  9588. {
  9589. foreach (DataRow dr in dth.Rows)
  9590. {
  9591. ids.Add(dr["ID"].ToString());
  9592. }
  9593. try
  9594. {
  9595. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9596. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9597. }
  9598. catch (Exception ex)
  9599. {
  9600. }
  9601. }
  9602. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9603. }
  9604. public void change_order_info()
  9605. {
  9606. int userid = CurrentUser.UserID;
  9607. StringBuilder sql = new StringBuilder();
  9608. 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);
  9609. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9610. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9611. }
  9612. public void change_win_mome()
  9613. {
  9614. if (UrlPostParmsCheck("id,ctid"))
  9615. {
  9616. string id = GetPostString("id");
  9617. string ctid = GetPostString("ctid");
  9618. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9619. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9620. if (ce == null || ceErpMessageTip == null)
  9621. {
  9622. returnSuccessMsg("未找到对应的订单!");
  9623. return;
  9624. }
  9625. int type = GetPostInt("type");
  9626. string content = GetPostString("content");
  9627. if (type == 0)
  9628. {
  9629. content = content.Replace("(", "(");
  9630. content = content.Replace(")", ")");
  9631. string check = MidStrEx(content, "(", ")").Trim();
  9632. if (string.IsNullOrEmpty(check))
  9633. {
  9634. returnSuccessMsg("文件名格式不正确");
  9635. return;
  9636. }
  9637. }
  9638. ce.seller_memo = content;
  9639. ce.Update();
  9640. ceErpMessageTip.isVisit = true;
  9641. ceErpMessageTip.Update();
  9642. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9643. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9644. ApiVo apiVo = new ApiVo();
  9645. apiVo.orderNumber = ce.ctid;
  9646. apiVo.actionName = "demandDesign";
  9647. apiVo.orderRemarks = content;
  9648. apiVo.demandExamine = type + 1;
  9649. designHelper.API_WorkCore(apiVo);//demandDesign
  9650. returnSuccessMsg("修改成功!");
  9651. }
  9652. }
  9653. public static string MidStrEx(string sourse, string startstr, string endstr)
  9654. {
  9655. string result = string.Empty;
  9656. int startindex, endindex;
  9657. try
  9658. {
  9659. startindex = sourse.IndexOf(startstr);
  9660. if (startindex == -1)
  9661. return result;
  9662. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9663. endindex = tmpstr.IndexOf(endstr);
  9664. if (endindex == -1)
  9665. return result;
  9666. result = tmpstr.Remove(endindex);
  9667. }
  9668. catch (Exception ex)
  9669. {
  9670. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9671. }
  9672. return result;
  9673. }
  9674. public void refund_order_list()
  9675. {
  9676. int userid = CurrentUser.UserID;
  9677. int sectionId = CurrentUser.UserPost.OrgID;
  9678. StringBuilder sql = new StringBuilder();
  9679. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9680. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9681. DataStruct dStruct = GetPostStruct();
  9682. DataTable dt = null;
  9683. List<string> ids = new List<string>();
  9684. List<string> tids = new List<string>();
  9685. if (dth.Rows.Count > 0)
  9686. {
  9687. foreach (DataRow dr in dth.Rows)
  9688. {
  9689. tids.Add("'" + dr["tid"].ToString() + "'");
  9690. ids.Add(dr["id"].ToString());
  9691. }
  9692. try
  9693. {
  9694. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9695. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9696. List<string> lw = new List<string>();
  9697. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9698. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9699. dt = WebCache.GetData("view_orderlist", dStruct);
  9700. }
  9701. catch (Exception ex)
  9702. {
  9703. }
  9704. }
  9705. writeGridDataTableJson(dStruct.TotalCount, dt);
  9706. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9707. }
  9708. //新增
  9709. public void order_batch_downloads()
  9710. {
  9711. string ceid = GetPostString("tid");
  9712. String[] tid = ceid.Split(',');
  9713. order_batch_caiyingtong(tid);
  9714. /* (string success, string errors) = UploadFiles(tid);
  9715. returnSuccessMsg(success + errors);*/
  9716. return;
  9717. }
  9718. //报价接口
  9719. public void Get_To_Quote()
  9720. {
  9721. string ceid = GetPostString("ctid");
  9722. if (ceid != null)
  9723. {
  9724. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9725. if (entity != null)
  9726. {
  9727. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9728. {
  9729. return;
  9730. }
  9731. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9732. double price = 0;
  9733. if (cp == null)
  9734. {
  9735. JObject jsonObject12 = new JObject
  9736. {
  9737. { "UserId", "77886" },
  9738. { "Pwd", "lt666888" },
  9739. { "Filename", entity.seller_memo }
  9740. };
  9741. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9742. JObject jsonObjects1 = JObject.Parse(response1);
  9743. string ms1g = (string)jsonObjects1["msg"];
  9744. if (ms1g == "报价成功")
  9745. {
  9746. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9747. string data = (string)jsonObject1["price"];
  9748. 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 + "');";
  9749. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9750. returnSuccessMsg("获取报价成功:" + data);
  9751. price = Convert.ToDouble(data);
  9752. }
  9753. else
  9754. {
  9755. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9756. return;
  9757. }
  9758. }
  9759. String[] beizhu = entity.seller_memo.Split('-');
  9760. String chanp = "";
  9761. if (beizhu.Length > 0)
  9762. {
  9763. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9764. }
  9765. else
  9766. {
  9767. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9768. }
  9769. JObject jsonObject = new JObject
  9770. {
  9771. { "UserId", "77886" },
  9772. { "Pwd", "lt666888" },
  9773. { "Filename", chanp }
  9774. };
  9775. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9776. JObject jsonObjects = JObject.Parse(response);
  9777. string msg = (string)jsonObjects["msg"];
  9778. if (msg == "报价成功")
  9779. {
  9780. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9781. string data = (string)jsonObject1["price"];
  9782. 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 + "');";
  9783. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9784. returnSuccessMsg("获取报价成功:" + data);
  9785. price = Convert.ToDouble(data);
  9786. }
  9787. else
  9788. {
  9789. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9790. return;
  9791. }
  9792. if (price > 0)
  9793. {
  9794. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9795. if (ceErpTradeCellExtend == null)
  9796. {
  9797. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9798. ceErpTradeCellExtend.ctid = entity.ctid;
  9799. ceErpTradeCellExtend.payment_cyt = price;
  9800. ceErpTradeCellExtend.Create();
  9801. }
  9802. else
  9803. {
  9804. ceErpTradeCellExtend.payment_cyt = price;
  9805. ceErpTradeCellExtend.Update();
  9806. }
  9807. }
  9808. return;
  9809. }
  9810. }
  9811. else
  9812. {
  9813. returnErrorMsg("请至少选择一条数据");
  9814. return;
  9815. }
  9816. }
  9817. //新增
  9818. public void order_To_Supplier()
  9819. {
  9820. string ceid = GetPostString("tid");
  9821. String[] tid = ceid.Split(',');
  9822. if (tid.Length > 0)
  9823. {
  9824. try
  9825. {
  9826. for (int i = 0; i < tid.Length; i++)
  9827. {
  9828. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9829. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9830. entity.SupplierId = suid;
  9831. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9832. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9833. entity.Update();
  9834. }
  9835. }
  9836. catch (Exception ex)
  9837. {
  9838. returnErrorMsg("自动匹配供应商失败");
  9839. return;
  9840. }
  9841. }
  9842. else
  9843. {
  9844. returnErrorMsg("请至少选择一条数据");
  9845. return;
  9846. }
  9847. returnSuccessMsg("自动匹配供应商成功");
  9848. return;
  9849. }
  9850. public (string, string) UploadFiles(string[] urls)
  9851. {
  9852. string success = "";
  9853. string errors = "";
  9854. int userid = CurrentUser.UserID;
  9855. foreach (string url in urls)
  9856. {
  9857. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9858. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9859. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9860. {
  9861. JObject jsonObject = new JObject
  9862. {
  9863. { "Userid", "77886" },
  9864. { "pwd", "cyt86435015" },
  9865. { "content", base64FileContent },
  9866. { "ext", Path.GetExtension(fileName) }
  9867. };
  9868. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9869. JObject jsonObjects = JObject.Parse(response);
  9870. string msg = (string)jsonObjects["msg"];
  9871. if (msg.Equals("上传成功"))
  9872. {
  9873. success += url + " 上传成功";
  9874. }
  9875. else
  9876. {
  9877. errors += url + " 上传失败";
  9878. }
  9879. }
  9880. else
  9881. {
  9882. errors += url + " 格式出现问题";
  9883. }
  9884. }
  9885. if (urls.Length == 0)
  9886. {
  9887. return (success, errors);
  9888. }
  9889. return (success, errors);
  9890. }
  9891. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9892. {
  9893. return true; //总是接受
  9894. }
  9895. public static string HttpPost(string url, string param = null)
  9896. {
  9897. HttpWebRequest request;
  9898. //如果是发送HTTPS请求
  9899. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9900. {
  9901. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9902. request = WebRequest.Create(url) as HttpWebRequest;
  9903. request.ProtocolVersion = HttpVersion.Version10;
  9904. }
  9905. else
  9906. {
  9907. request = WebRequest.Create(url) as HttpWebRequest;
  9908. }
  9909. request.Method = "POST";
  9910. request.ContentType = "application/json";
  9911. request.Accept = "*/*";
  9912. request.Timeout = 120000;
  9913. request.AllowAutoRedirect = false;
  9914. StreamWriter requestStream = null;
  9915. WebResponse response = null;
  9916. string responseStr = null;
  9917. try
  9918. {
  9919. requestStream = new StreamWriter(request.GetRequestStream());
  9920. requestStream.Write(param);
  9921. requestStream.Close();
  9922. response = request.GetResponse();
  9923. if (response != null)
  9924. {
  9925. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9926. responseStr = reader.ReadToEnd();
  9927. reader.Close();
  9928. }
  9929. }
  9930. catch (Exception ex)
  9931. {
  9932. return ex.Message;
  9933. }
  9934. finally
  9935. {
  9936. request = null;
  9937. requestStream = null;
  9938. response = null;
  9939. }
  9940. return responseStr;
  9941. }
  9942. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9943. {
  9944. string base64FileContent;
  9945. string fileName;
  9946. using (WebClient webClient = new WebClient())
  9947. {
  9948. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9949. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9950. {
  9951. using (Stream stream = response.GetResponseStream())
  9952. {
  9953. using (MemoryStream memoryStream = new MemoryStream())
  9954. {
  9955. stream.CopyTo(memoryStream);
  9956. byte[] fileBytes = memoryStream.ToArray();
  9957. base64FileContent = Convert.ToBase64String(fileBytes);
  9958. fileName = response.Headers["Content-Disposition"];
  9959. if (!string.IsNullOrEmpty(fileName))
  9960. {
  9961. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9962. if (index >= 0)
  9963. {
  9964. fileName = fileName.Substring(index + 9).Trim('\"');
  9965. }
  9966. }
  9967. else
  9968. {
  9969. fileName = Path.GetFileName(downloadUrl);
  9970. }
  9971. }
  9972. }
  9973. }
  9974. }
  9975. return (fileName, base64FileContent);
  9976. }
  9977. //新增
  9978. public void order_batch_caiyingtong(string[] downloadUrls)
  9979. {
  9980. try
  9981. {
  9982. //遍历文件
  9983. DataStruct dStruct = GetPostStruct();
  9984. DataTable dt = null;
  9985. int userid = CurrentUser.UserID;
  9986. List<string> ids = new List<string>();//失败组
  9987. List<string> tids = new List<string>();
  9988. using (WebClient webClient = new WebClient())
  9989. {
  9990. foreach (var url in downloadUrls)
  9991. {
  9992. try
  9993. {
  9994. tids.Add("'" + url + "'");
  9995. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9996. if (entity != null)
  9997. {
  9998. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9999. if (cp == null)
  10000. {
  10001. JObject jsonObject = new JObject
  10002. {
  10003. { "Userid", "77886" },
  10004. { "pwd", "lt666888" },
  10005. { "Filename",entity.seller_memo }
  10006. };
  10007. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10008. JObject jsonObjects = JObject.Parse(response);
  10009. string msg = (string)jsonObjects["msg"];
  10010. if (msg == "报价成功")
  10011. {
  10012. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10013. DownloadAndConvertToBase64(url1);
  10014. }
  10015. else
  10016. {
  10017. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10018. }
  10019. }
  10020. else
  10021. {
  10022. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10023. JObject jsonObject = new JObject
  10024. {
  10025. { "Userid", "77886" },
  10026. { "pwd", "lt666888" },
  10027. { "Filename",chanp }
  10028. };
  10029. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10030. JObject jsonObjects = JObject.Parse(response);
  10031. string msg = (string)jsonObjects["msg"];
  10032. if (msg == "报价成功")
  10033. {
  10034. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10035. DownloadAndConvertToBase64(url1);
  10036. }
  10037. else
  10038. {
  10039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10040. }
  10041. }
  10042. }
  10043. // 上传文件到FTP
  10044. }
  10045. catch (Exception ex)
  10046. {
  10047. Console.WriteLine($"An error occurred: {ex.Message}");
  10048. }
  10049. }
  10050. List<string> lw = new List<string>();
  10051. lw.Add(string.Format("( OrderState < 6 )"));
  10052. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10053. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10054. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10055. if (dt.Rows.Count > 0)
  10056. {
  10057. foreach (DataRow dr in dt.Rows)
  10058. {
  10059. ids.Add(dr["ctid"].ToString());
  10060. }
  10061. }
  10062. String ErrorMsgs = "";
  10063. foreach (String id in ids)
  10064. {
  10065. ErrorMsgs += id + ",";
  10066. }
  10067. if (ErrorMsgs.Length > 1)
  10068. {
  10069. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10070. }
  10071. if (ErrorMsgs.Length < 1)
  10072. {
  10073. ErrorMsgs = "上传成功";
  10074. returnSuccessMsg(ErrorMsgs);
  10075. }
  10076. else
  10077. {
  10078. returnErrorMsg("以下订单" + ErrorMsgs);
  10079. }
  10080. }
  10081. // 删除文件夹及其内容
  10082. /* Directory.Delete(localDirectory, true);*/
  10083. }
  10084. catch { }
  10085. }
  10086. public void get_center_data()
  10087. {
  10088. int userId = CurrentUser.UserID;
  10089. string postCode = CurrentUser.UserPost.Post.Code;
  10090. List<string> lw = new List<string>();
  10091. List<string> ww = new List<string>();
  10092. DateTime currentTime = DateTime.Now;
  10093. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10094. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10095. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10096. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10097. string sql = " SELECT ";
  10098. string startTime = "2023-10-01 11:22:31";
  10099. //设计
  10100. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10101. {
  10102. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10103. 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));
  10104. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10105. 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));
  10106. }
  10107. //客服
  10108. else if (postCode == "CustomerService" || postCode == "Director")
  10109. {
  10110. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10111. 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));
  10112. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10113. 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));
  10114. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10115. 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));
  10116. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10117. 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));
  10118. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10119. 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));
  10120. }
  10121. //售后
  10122. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10123. {
  10124. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10125. 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));
  10126. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10127. 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));
  10128. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10129. 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));
  10130. }
  10131. //下单部
  10132. else if (postCode == "Place" || postCode == "PlaceMr")
  10133. {
  10134. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10135. 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));
  10136. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10137. 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));
  10138. }
  10139. //车间
  10140. else if (postCode == "Supplier")
  10141. {
  10142. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10143. 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));
  10144. }
  10145. DataTable dt = new DataTable();
  10146. if (lw.Count > 0)
  10147. {
  10148. sql += string.Join(" , ", lw);
  10149. sql += " FROM ";
  10150. sql += string.Join(" , ", ww);
  10151. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10152. }
  10153. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10154. }
  10155. public void get_center_data_list()
  10156. {
  10157. int userId = CurrentUser.UserID;
  10158. string postCode = CurrentUser.UserPost.Post.Code;
  10159. string shopIds = CurrentUser.User.pemShop;
  10160. DataStruct dStruct = GetPostStruct();
  10161. List<string> lw = new List<string>();
  10162. DateTime currentTime = DateTime.Now;
  10163. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10164. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10165. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10166. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10167. string startTime = "2023-10-01 11:22:31";
  10168. int order_type = GetPostInt("order_type");
  10169. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10170. {
  10171. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10172. if (order_type == 0)
  10173. {
  10174. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10175. }
  10176. else if (order_type == 3)
  10177. {
  10178. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10179. }
  10180. else
  10181. {
  10182. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10183. }
  10184. }
  10185. //客服
  10186. if (postCode == "CustomerService" || postCode == "Director")
  10187. {
  10188. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10189. if (order_type == 0)
  10190. {
  10191. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10192. }
  10193. else if (order_type == 1)
  10194. {
  10195. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10196. }
  10197. else if (order_type == 2)
  10198. {
  10199. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10200. }
  10201. else if (order_type == 3)
  10202. {
  10203. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10204. }
  10205. else if (order_type == 4)
  10206. {
  10207. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10208. }
  10209. else
  10210. {
  10211. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10212. }
  10213. }
  10214. //售后
  10215. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10216. {
  10217. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10218. if (shopIds != "")
  10219. {
  10220. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10221. }
  10222. if (order_type == 2)
  10223. {
  10224. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10225. }
  10226. else if (order_type == 4)
  10227. {
  10228. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10229. }
  10230. else if (order_type == 5)
  10231. {
  10232. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10233. }
  10234. else
  10235. {
  10236. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10237. }
  10238. }
  10239. //下单部
  10240. if (postCode == "Place" || postCode == "PlaceMr")
  10241. {
  10242. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10243. if (shopIds != "")
  10244. {
  10245. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10246. }
  10247. else if (order_type == 1)
  10248. {
  10249. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10250. }
  10251. else if (order_type == 2)
  10252. {
  10253. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10254. }
  10255. else
  10256. {
  10257. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10258. }
  10259. }
  10260. //车间
  10261. if (postCode == "Supplier")
  10262. {
  10263. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10264. if (order_type == 5)
  10265. {
  10266. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10267. }
  10268. else
  10269. {
  10270. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10271. }
  10272. }
  10273. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10274. dStruct.Fileds = "tid,ctid";
  10275. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10276. writeGridDataTableJson(dStruct.TotalCount, dt);
  10277. }
  10278. public void aftersale_audit_master()
  10279. {
  10280. if (UrlPostParmsCheck("ctid"))
  10281. {
  10282. string ctid = GetPostString("ctid");
  10283. if (ctid.Length > 0)
  10284. {
  10285. bool result = aftersale_data_change(ctid);
  10286. if (result)
  10287. {
  10288. returnSuccessMsg("修改成功!");
  10289. return;
  10290. }
  10291. }
  10292. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10293. }
  10294. }
  10295. public void aftersale_batch_audit_master()
  10296. {
  10297. if (UrlPostParmsCheck("ctids"))
  10298. {
  10299. string ctids = GetPostString("ctids");
  10300. if (ctids.Length > 0)
  10301. {
  10302. List<string> list = new List<string>();
  10303. string[] ctid_list = ctids.Split(',');
  10304. foreach (var item in ctid_list)
  10305. {
  10306. bool result = aftersale_data_change(item);
  10307. if (!result)
  10308. {
  10309. list.Add(item);
  10310. }
  10311. }
  10312. if (list.Count > 0)
  10313. {
  10314. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10315. return;
  10316. }
  10317. returnSuccessMsg("修改成功!");
  10318. return;
  10319. }
  10320. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10321. }
  10322. }
  10323. public bool aftersale_data_change(string ctid)
  10324. {
  10325. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10326. if (ceErpTradeCell != null)
  10327. {
  10328. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10329. ceErpTradeCell.AfterSaleSupplierState = 0;
  10330. StringBuilder sql = new StringBuilder();
  10331. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10332. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10333. CeErpTradeResponsible.DelByTid(ctid, 0);
  10334. 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 == "不理赔")
  10335. {
  10336. CeErpTradeResponsible.DelByTid(ctid, 1);
  10337. ceErpTradeCell.AfterSaleSupplierState = 1;
  10338. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10339. ceErpTradeCell.AfterSaleState = 4;
  10340. }
  10341. else
  10342. {
  10343. ceErpTradeCell.AfterSaleState = 3;
  10344. }
  10345. bool needCyt = false;
  10346. if (dt != null)
  10347. {
  10348. if (dt.Rows.Count == 1)
  10349. {
  10350. bool isEnd = false;
  10351. foreach (DataRow dr in dt.Rows)
  10352. {
  10353. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10354. {
  10355. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10356. isEnd = true;
  10357. }
  10358. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10359. {
  10360. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10361. isEnd = true;
  10362. }
  10363. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10364. {
  10365. needCyt = true;
  10366. }
  10367. }
  10368. if (isEnd)
  10369. {
  10370. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10371. ceErpTradeCell.AfterSaleState = 4;
  10372. ceErpTradeCell.AfterSaleSupplierState = 1;
  10373. }
  10374. }
  10375. else
  10376. {
  10377. bool isAll = true;
  10378. foreach (DataRow dr in dt.Rows)
  10379. {
  10380. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10381. {
  10382. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10383. continue;
  10384. }
  10385. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10386. {
  10387. string path = "";
  10388. int OrgID = 0;
  10389. if (!Convert.IsDBNull(dr["OrgPath"]))
  10390. {
  10391. path = dr["OrgPath"].ToString();
  10392. }
  10393. if (!Convert.IsDBNull(dr["OrgID"]))
  10394. {
  10395. OrgID = Convert.ToInt32(dr["OrgID"]);
  10396. }
  10397. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10398. {
  10399. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10400. continue;
  10401. }
  10402. }
  10403. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10404. {
  10405. needCyt = true;
  10406. }
  10407. isAll = false;
  10408. }
  10409. if (isAll)
  10410. {
  10411. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10412. ceErpTradeCell.AfterSaleState = 4;
  10413. ceErpTradeCell.AfterSaleSupplierState = 1;
  10414. }
  10415. }
  10416. }
  10417. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10418. {
  10419. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10420. }
  10421. if (ceErpTradeCell.AfterSaleState == 4)
  10422. {
  10423. ApiVo apiVo = new ApiVo();
  10424. apiVo.orderNumber = ceErpTradeCell.ctid;
  10425. apiVo.actionName = "afterOver";
  10426. designHelper.API_WorkCore(apiVo); //afterOver
  10427. }
  10428. ceErpTradeCell.Update();
  10429. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10430. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10431. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10432. return true;
  10433. }
  10434. return false;
  10435. }
  10436. public void get_erp_wechatorder()
  10437. {
  10438. DataStruct dStruct = GetPostStruct();
  10439. List<string> lw = new List<string>();
  10440. string tid = GetPostString("tid");
  10441. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10442. string shopname = GetPostString("shopname");
  10443. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10444. string buyernick = GetPostString("buyer_nick");
  10445. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10446. string customer = GetPostString("customer");
  10447. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10448. string returndate1 = GetPostString("returndate1");
  10449. string returndate2 = GetPostString("returndate2");
  10450. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10451. if (dw.Length > 0) lw.Add(dw);
  10452. string finishDate1 = GetPostString("finishdate1");
  10453. string finishDate2 = GetPostString("finishdate2");
  10454. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10455. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10456. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10457. dStruct.Order = "created desc";
  10458. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10459. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10460. writeGridDataTableJson(dStruct.TotalCount, dt);
  10461. }
  10462. public void get_erp_wechatlist_sumprice()
  10463. {
  10464. DataStruct dStruct = GetPostStruct();
  10465. List<string> lw = new List<string>();
  10466. string tid = GetPostString("tid");
  10467. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10468. string shopname = GetPostString("shopname");
  10469. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10470. string buyernick = GetPostString("buyer_nick");
  10471. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10472. string customer = GetPostString("customer");
  10473. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10474. string returndate1 = GetPostString("returndate1");
  10475. string returndate2 = GetPostString("returndate2");
  10476. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10477. if (dw.Length > 0) lw.Add(dw);
  10478. string finishDate1 = GetPostString("finishdate1");
  10479. string finishDate2 = GetPostString("finishdate2");
  10480. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10481. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10482. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10483. string mainWhere = string.Join(" and ", lw.ToArray());
  10484. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10485. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10486. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10487. decimal total = 0;
  10488. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10489. {
  10490. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10491. }
  10492. var res = new
  10493. {
  10494. data = total
  10495. };
  10496. string ro_jsond = JsonConvert.SerializeObject(res);
  10497. returnSuccess(ro_jsond);
  10498. return;
  10499. }
  10500. public void get_erp_qr_waitdeliverylist()
  10501. {
  10502. DataStruct dStruct = GetPostStruct();
  10503. List<string> lw = new List<string>();
  10504. string tid = GetPostString("ctid");
  10505. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10506. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10507. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10508. var res_objz = new
  10509. {
  10510. restype = 1,
  10511. data = dt
  10512. };
  10513. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10514. returnSuccess(ro_jsonz);
  10515. }
  10516. public void get_erp_yield_list()
  10517. {
  10518. DataStruct dStruct = GetPostStruct();
  10519. List<string> lw = new List<string>();
  10520. string tid = GetPostString("ctid");
  10521. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10522. string shopname = GetPostString("shopname");
  10523. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10524. string buyernick = GetPostString("buyer_nick");
  10525. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10526. //if (tid.Length == 0 && buyernick.Length == 0)
  10527. //{
  10528. // lw.Add(string.Format("IsRefund<={0}", 1));
  10529. //}
  10530. string customer = GetPostString("customer");
  10531. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10532. string design = GetPostString("design");
  10533. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10534. string orderState = GetPostString("orderState");
  10535. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10536. string address = GetPostString("address");
  10537. 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));
  10538. string sellermemo = GetPostString("seller_memo");
  10539. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10540. string supplier = GetPostString("supplier");
  10541. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10542. string OrderArea = GetPostString("order_area");
  10543. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10544. string placedate1 = GetPostString("placedate1");
  10545. string placedate2 = GetPostString("placedate2");
  10546. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10547. if (fdw.Length > 0) lw.Add(fdw);
  10548. string price1 = GetPostString("price1");
  10549. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10550. string price2 = GetPostString("price2");
  10551. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10552. string unusualCon = GetPostString("unusualcon");
  10553. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10554. string posTag = CurrentUser.UserPost.Post.Code;
  10555. if (posTag == "Supplier")
  10556. {
  10557. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10558. }
  10559. lw.Add(string.Format("OrderState = 6 "));
  10560. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10561. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10563. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10564. writeGridDataTableJson(dStruct.TotalCount, dt);
  10565. }
  10566. public void change_erp_sup_state()
  10567. {
  10568. if (UrlPostParmsCheck("ctid"))
  10569. {
  10570. string ctid = GetPostString("ctid");
  10571. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10572. if (ceErpTradeCell != null)
  10573. {
  10574. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10575. if (ceErpTradeCellExtend == null)
  10576. {
  10577. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10578. ceErpTradeCellExtend.ctid = ctid;
  10579. ceErpTradeCellExtend.SupState = 1;
  10580. ceErpTradeCellExtend.Create();
  10581. }
  10582. else
  10583. {
  10584. ceErpTradeCellExtend.SupState = 1;
  10585. ceErpTradeCellExtend.Update();
  10586. }
  10587. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10588. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10589. return;
  10590. }
  10591. returnErrorMsg("找不到订单");
  10592. }
  10593. }
  10594. public void supplier_all_downs()
  10595. {
  10596. if (UrlPostParmsCheck("tids"))
  10597. {
  10598. string tids = GetPostString("tids");
  10599. if (tids != null && tids.Length > 0)
  10600. {
  10601. StringBuilder sql = new StringBuilder();
  10602. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10603. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10604. sql = new StringBuilder();
  10605. 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, "下载设计文件");
  10606. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10607. string[] list = tids.Split(',');
  10608. foreach (string ctid in list)
  10609. {
  10610. CeErpSukuraData.createInfo(ctid, 3);
  10611. }
  10612. designHelper.api_approveDesign(tids); //approveDesign
  10613. returnSuccessMsg("下载成功!");
  10614. return;
  10615. }
  10616. returnErrorMsg("下载订单更新失败");
  10617. }
  10618. }
  10619. public void uploaderFileSuccess()
  10620. {
  10621. if (UrlPostParmsCheck("fileName"))
  10622. {
  10623. string fileName = GetPostString("fileName");
  10624. ApiVo apiVo = new ApiVo();
  10625. apiVo.orderNumber = fileName;
  10626. apiVo.actionName = "finishDesign";
  10627. designHelper.API_WorkCore(apiVo);//finishDesign
  10628. returnSuccessMsg("");
  10629. }
  10630. }
  10631. public void get_sample2_order()
  10632. {
  10633. if (UrlPostParmsCheck("ctid"))
  10634. {
  10635. string ctid = GetPostString("ctid");
  10636. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10637. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10638. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10639. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10640. double total = 0.0;
  10641. double order_price = 0.0;
  10642. if (dt_bu.Rows.Count > 0)
  10643. {
  10644. foreach (DataRow dr in dt_bu.Rows)
  10645. {
  10646. total += Convert.ToDouble(dr["payment"]);
  10647. }
  10648. }
  10649. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10650. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10651. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10652. string tid = ctid.Replace("S_", "");
  10653. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10654. double paymant = 0.0;
  10655. if (entity != null)
  10656. {
  10657. paymant = entity.payment;
  10658. }
  10659. string return_reason = "";
  10660. if (dt_after != null && dt_after.Rows.Count > 0)
  10661. {
  10662. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10663. }
  10664. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10665. }
  10666. }
  10667. public void get_erp_design_status()
  10668. {
  10669. string designName = GetPostString("designName");
  10670. DataStruct dStruct = GetPostStruct();
  10671. if (designName.Length > 0)
  10672. {
  10673. 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";
  10674. sql_user += " and Name like '%" + designName + "%'";
  10675. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10676. List<string> ids_list = new List<string>();
  10677. if (user_table.Rows.Count > 0)
  10678. {
  10679. foreach (DataRow item in user_table.Rows)
  10680. {
  10681. ids_list.Add(item["id"].ToString());
  10682. string ids_s = item["TeamIds"].ToString();
  10683. if (ids_s.Length > 0)
  10684. {
  10685. ids_list.AddRange(ids_s.Split(','));
  10686. }
  10687. }
  10688. }
  10689. HashSet<string> set = new HashSet<string>(ids_list);
  10690. ids_list = set.ToList();
  10691. if (ids_list.Count > 0)
  10692. {
  10693. 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));
  10694. dStruct.MainWhere = sql;
  10695. DataTable dt = null;
  10696. dt = WebCache.GetData("view_ErpUser", dStruct);
  10697. writeGridDataTableJson(dStruct.TotalCount, dt);
  10698. }
  10699. }
  10700. }
  10701. public void change_erp_order_price()
  10702. {
  10703. string ctid = GetPostString("ctid");
  10704. double price = GetPostDouble("price");
  10705. if (ctid.Length > 0)
  10706. {
  10707. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10708. if (ceErpTradeCellExtend == null)
  10709. {
  10710. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10711. ceErpTradeCellExtend.ctid = ctid;
  10712. ceErpTradeCellExtend.payment_cyt = price;
  10713. ceErpTradeCellExtend.Create();
  10714. }
  10715. else
  10716. {
  10717. ceErpTradeCellExtend.payment_cyt = price;
  10718. ceErpTradeCellExtend.Update();
  10719. }
  10720. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10721. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10722. {
  10723. ceErpDataSendOrderInfo.isSync = false;
  10724. ceErpDataSendOrderInfo.Update();
  10725. }
  10726. if (ceErpDataSendOrderInfo == null)
  10727. {
  10728. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10729. ceErpDataSendOrderInfo.isSync = false;
  10730. ceErpDataSendOrderInfo.ctid = ctid;
  10731. ceErpDataSendOrderInfo.Create();
  10732. }
  10733. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10734. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10735. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10736. if (dth != null && dth.Rows.Count > 0)
  10737. {
  10738. dataSendOrderBean dataSendOrderBean = null;
  10739. foreach (DataRow item in dth.Rows)
  10740. {
  10741. try
  10742. {
  10743. dataSendOrderBean = new dataSendOrderBean();
  10744. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10745. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10746. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10747. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10748. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10749. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10750. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10751. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10752. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10753. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10754. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10755. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10756. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10757. if (result != null)
  10758. {
  10759. if ("0".Equals(result.errcode))
  10760. {
  10761. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10762. }
  10763. else
  10764. {
  10765. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10766. }
  10767. }
  10768. }
  10769. catch (Exception ex)
  10770. {
  10771. }
  10772. }
  10773. }
  10774. returnSuccessMsg("修改成功!");
  10775. return;
  10776. }
  10777. returnErrorMsg("找不到订单");
  10778. }
  10779. public void find_he_together()
  10780. {
  10781. string ctid = GetPostString("ctid");
  10782. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10783. List<string> list = new List<string>();
  10784. if (ceErpTradeCell != null)
  10785. {
  10786. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10787. {
  10788. 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);
  10789. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10790. if (table != null && table.Rows.Count > 0)
  10791. {
  10792. foreach (TableRow row in table.Rows)
  10793. {
  10794. }
  10795. }
  10796. }
  10797. }
  10798. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10799. }
  10800. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10801. {
  10802. //chy----19
  10803. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10804. //GD-CYT-----64
  10805. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10806. //ZHX----3
  10807. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10808. //JK----97
  10809. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10810. //ZT----70
  10811. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10812. //LHCY-----98
  10813. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10814. //XD-----90
  10815. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10816. //CYCY-----14
  10817. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10818. };
  10819. //其他改名
  10820. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10821. {
  10822. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10823. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10824. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10825. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10826. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10827. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10828. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10829. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10830. };
  10831. //不统计
  10832. List<int> no_suppliers = new List<int>()
  10833. {
  10834. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10835. };
  10836. //配件单
  10837. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10838. {
  10839. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10840. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10841. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10842. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10843. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10844. {"旗杆",new List<string>(){ "班旗" } },
  10845. {"牙签",new List<string>(){ "不干胶" } }
  10846. };
  10847. public void get_place_order_data()
  10848. {
  10849. string date1 = GetPostString("date1");
  10850. string date2 = GetPostString("date2");
  10851. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10852. DateTime start = DateTime.Parse(starttime);
  10853. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10854. DateTime end = DateTime.Parse(endtime);
  10855. if (date1 != null && date1.Length > 0)
  10856. {
  10857. DateTime dateTime = DateTime.Parse(date1);
  10858. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10859. start = DateTime.Parse(starttime);
  10860. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10861. end = DateTime.Parse(endtime);
  10862. }
  10863. if (date2 != null && date2.Length > 0)
  10864. {
  10865. DateTime dateTime = DateTime.Parse(date2);
  10866. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10867. end = DateTime.Parse(endtime);
  10868. }
  10869. 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);
  10870. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10871. //不干胶-----1,卡片-----29
  10872. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10873. foreach (DataRow row in data.Rows)
  10874. {
  10875. int productId = Convert.ToInt32(row["ProductId"]);
  10876. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10877. if (no_suppliers.Contains(supplierId))
  10878. {
  10879. continue;
  10880. }
  10881. string seller_memo = row["seller_memo"].ToString();
  10882. bool ispj = false;//是否配件单
  10883. bool isfirst = true;//第一个配
  10884. maps.Keys.ForEach(key =>
  10885. {
  10886. //备注包含配件
  10887. if (seller_memo.Contains(key) && isfirst)
  10888. {
  10889. List<string> list = maps[key];
  10890. ispj = true;
  10891. isfirst = false;
  10892. for (int i = 0; i < list.Count; i++)
  10893. {
  10894. if (seller_memo.Contains(list[i]))
  10895. {
  10896. ispj = false;
  10897. break;
  10898. }
  10899. }
  10900. }
  10901. });
  10902. if (ispj)
  10903. {
  10904. continue;
  10905. }
  10906. seller_memo = seller_memo.Replace("UV", "uv");
  10907. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10908. //吊牌归到卡片
  10909. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10910. seller_memo = seller_memo.Replace("卡套", "卡片");
  10911. seller_memo = seller_memo.Replace("封套", "卡片");
  10912. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10913. seller_memo = seller_memo.Replace("腰封", "卡片");
  10914. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10915. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10916. seller_memo = seller_memo.Replace("横幅", "条幅");
  10917. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10918. string map_key = "";
  10919. string type = "";
  10920. if (supplierMap.ContainsKey(supplierId))
  10921. {
  10922. foreach (var kvp in supplierMap[supplierId])
  10923. {
  10924. if (seller_memo.Contains(kvp.Key))
  10925. {
  10926. map_key = kvp.Value;
  10927. type = kvp.Value;
  10928. break;
  10929. }
  10930. }
  10931. }
  10932. if (map_key == "")
  10933. {
  10934. type = "其他";
  10935. map_key = "其他";
  10936. }
  10937. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10938. {
  10939. map_key = suppliers[supplierId];
  10940. }
  10941. if (supplierId == 70)
  10942. {
  10943. supplierId = 70;
  10944. }
  10945. map_key += "_" + row["SupplierName"].ToString();
  10946. Dictionary<string, int> map = null;
  10947. if (other_map.ContainsKey(map_key))
  10948. {
  10949. other_map.TryGetValue(map_key, out map);
  10950. }
  10951. else
  10952. {
  10953. map = new Dictionary<string, int>();
  10954. map.Add("dayDev", 0);//当天出货
  10955. map.Add("dayTotal", 0);//下单总数
  10956. map.Add("payTotal", 0);//500以上
  10957. map.Add("today", 0);//当天出货数量
  10958. map.Add("unusua", 0);//异常数
  10959. other_map.Add(map_key, map);
  10960. other_map.TryGetValue(map_key, out map);
  10961. }
  10962. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10963. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10964. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10965. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  10966. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10967. {
  10968. map["dayTotal"]++;
  10969. if (supplierId == 97)
  10970. {
  10971. supplierId = 97;
  10972. }
  10973. }
  10974. if (Convert.ToDecimal(row["payment"]) >= 500)
  10975. {
  10976. map["payTotal"]++;
  10977. }
  10978. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10979. {
  10980. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10981. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10982. {
  10983. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  10984. {
  10985. map["today"]++;
  10986. }
  10987. }
  10988. else
  10989. {
  10990. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10991. {
  10992. map["today"]++;
  10993. }
  10994. }
  10995. }
  10996. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10997. {
  10998. map["unusua"]++;
  10999. }
  11000. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11001. //GD-CYT-----64
  11002. DateTime two = palceTimeStart.AddHours(14);
  11003. DateTime three = palceTimeStart.AddHours(15);
  11004. DateTime four = palceTimeStart.AddHours(16);
  11005. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11006. {
  11007. //下午四点前 500-1000
  11008. string count = row["ProductCount"].ToString();
  11009. if (count != null && count.Length > 0)
  11010. {
  11011. int productCount = commonHelper.getPlaceProductCount(count);
  11012. if (productCount >= 500 && productCount <= 1000)
  11013. {
  11014. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11015. {
  11016. map["dayDev"]++;
  11017. }
  11018. }
  11019. }
  11020. }
  11021. //UV
  11022. else if ("uv".Equals(type))
  11023. {
  11024. //ZT----70
  11025. //ZHX----3
  11026. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11027. {
  11028. map["dayDev"]++;
  11029. }
  11030. //JK----97
  11031. //HZX----105
  11032. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11033. {
  11034. map["dayDev"]++;
  11035. if (supplierId == 97)
  11036. {
  11037. supplierId = 97;
  11038. }
  11039. }
  11040. }
  11041. //帆布---52|条幅---27
  11042. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11043. {
  11044. //LHCY-----98
  11045. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11046. {
  11047. map["dayDev"]++;
  11048. }
  11049. }
  11050. //条幅
  11051. else if ("条幅".Equals(type))
  11052. {
  11053. //XD-----90
  11054. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11055. {
  11056. map["dayDev"]++;
  11057. }
  11058. }
  11059. //桌布
  11060. else if ("桌布".Equals(type))
  11061. {
  11062. //XD-----90
  11063. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11064. {
  11065. map["dayDev"]++;
  11066. }
  11067. }
  11068. //DL---10
  11069. //AYTW---119
  11070. //FS-CYT-DY ----80
  11071. //JK----97
  11072. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11073. {
  11074. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11075. {
  11076. map["dayDev"]++;
  11077. }
  11078. }
  11079. }
  11080. DataTable dt = new DataTable();
  11081. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11082. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11083. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11084. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11085. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11086. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11087. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11088. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11089. other_map.Keys.ForEach(key =>
  11090. {
  11091. DataRow dr = dt.NewRow();
  11092. Dictionary<string, int> map = other_map[key];
  11093. string[] key_list = key.Split('_');
  11094. dr[0] = key_list[0];
  11095. dr[1] = key_list[1];
  11096. if (key_list.Length > 2)
  11097. {
  11098. dr[1] += "(" + key_list[2] + ")";
  11099. }
  11100. dr[2] = map["dayTotal"];
  11101. dr[3] = map["payTotal"];
  11102. dr[4] = map["today"];
  11103. dr[5] = map["unusua"];
  11104. dr[6] = map["dayDev"];
  11105. double rate = 0.00;
  11106. if (map["dayDev"] > 0)
  11107. {
  11108. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11109. }
  11110. dr[7] = rate.ToString();
  11111. dt.Rows.Add(dr);
  11112. });
  11113. DataView dv = new DataView(dt);
  11114. dv.Sort = "SupplierName";
  11115. //dv.Sort = "AllOrder desc";
  11116. DataTable dtNew = dv.ToTable();
  11117. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11118. }
  11119. public void check_order_desing_info()
  11120. {
  11121. string ctid = GetPostString("ctid");
  11122. if (!string.IsNullOrEmpty(ctid))
  11123. {
  11124. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11125. if (ceErpTradeCell != null)
  11126. {
  11127. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11128. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11129. return;
  11130. }
  11131. returnErrorMsg("找不到订单");
  11132. return;
  11133. }
  11134. returnErrorMsg("找不到订单");
  11135. }
  11136. public void get_timeout_detail()
  11137. {
  11138. string poscode = CurrentUser.UserPost.Post.Code;
  11139. DataStruct dStruct = GetPostStruct();
  11140. List<string> lw = new List<string>();
  11141. string id = GetPostString("id");
  11142. string pay_date1 = GetPostString("pay_date1");
  11143. string pay_date2 = GetPostString("pay_date2");
  11144. int type = GetPostInt("type");
  11145. if (type == 0)
  11146. {
  11147. if (pay_date1.Length > 0)
  11148. {
  11149. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11150. }
  11151. if (pay_date2.Length > 0)
  11152. {
  11153. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11154. }
  11155. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11156. }
  11157. if (type == 1)
  11158. {
  11159. if (pay_date1.Length > 0)
  11160. {
  11161. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11162. }
  11163. if (pay_date2.Length > 0)
  11164. {
  11165. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11166. }
  11167. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11168. }
  11169. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11170. DataTable dt = null;
  11171. dt = WebCache.GetData("view_orderlist", dStruct);
  11172. writeGridDataTableJson(dStruct.TotalCount, dt);
  11173. }
  11174. public void saveUrgentChargePrice()
  11175. {
  11176. string ctid = GetPostString("ctid");
  11177. if (!string.IsNullOrEmpty(ctid))
  11178. {
  11179. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11180. if (ceErpTradeCell != null)
  11181. {
  11182. double price = GetPostDouble("price");
  11183. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11184. if (ceErpTradeCellExtend == null)
  11185. {
  11186. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11187. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11188. }
  11189. ceErpTradeCellExtend.urgentCharge = price;
  11190. if (ceErpTradeCellExtend.ID > 0)
  11191. {
  11192. ceErpTradeCellExtend.Update();
  11193. }
  11194. else
  11195. {
  11196. ceErpTradeCellExtend.Save();
  11197. }
  11198. returnSuccessMsg("修改成功!");
  11199. return;
  11200. }
  11201. returnErrorMsg("找不到订单");
  11202. return;
  11203. }
  11204. returnErrorMsg("找不到订单");
  11205. }
  11206. public void finish_erp_order()
  11207. {
  11208. string ctid = GetPostString("ctid");
  11209. if (!string.IsNullOrEmpty(ctid))
  11210. {
  11211. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11212. {
  11213. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11214. if (ceErpTradeCell != null)
  11215. {
  11216. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11217. ceErpTradeCell.Update();
  11218. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11219. returnSuccessMsg("修改成功!");
  11220. return;
  11221. }
  11222. }
  11223. }
  11224. returnErrorMsg("找不到订单");
  11225. }
  11226. public void get_trade_order_list()
  11227. {
  11228. string tid = GetPostString("tid");
  11229. if (!string.IsNullOrEmpty(tid))
  11230. {
  11231. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11232. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11233. writeGridDataTableJson(data.Rows.Count, data);
  11234. return;
  11235. }
  11236. returnErrorMsg("找不到订单");
  11237. }
  11238. public void save_cell_spu()
  11239. {
  11240. string ctid = GetPostString("ctid");
  11241. string spu_id = GetPostString("spu_id");
  11242. if (!string.IsNullOrEmpty(ctid))
  11243. {
  11244. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11245. if (ceErpTradeCellExtend == null)
  11246. {
  11247. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11248. ceErpTradeCellExtend.ctid = ctid;
  11249. }
  11250. ceErpTradeCellExtend.spu_id = spu_id;
  11251. if (ceErpTradeCellExtend.ID == 0)
  11252. {
  11253. ceErpTradeCellExtend.Create();
  11254. }
  11255. else
  11256. {
  11257. ceErpTradeCellExtend.Update();
  11258. }
  11259. returnSuccessMsg("修改成功!");
  11260. return;
  11261. }
  11262. returnErrorMsg("找不到订单");
  11263. }
  11264. public void change_express_info()
  11265. {
  11266. string ctid = GetPostString("ctid");
  11267. string transNo = GetPostString("transNo");
  11268. string transCom = GetPostString("transCom");
  11269. if (!string.IsNullOrEmpty(ctid))
  11270. {
  11271. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11272. if (ceErpTradeCellExtend == null)
  11273. {
  11274. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11275. ceErpTradeCellExtend.ctid = ctid;
  11276. }
  11277. ceErpTradeCellExtend.modExpressNo = transNo;
  11278. ceErpTradeCellExtend.modExpressCom = transCom;
  11279. ceErpTradeCellExtend.readMod = 2;
  11280. if (ceErpTradeCellExtend.ID == 0)
  11281. {
  11282. ceErpTradeCellExtend.Create();
  11283. }
  11284. else
  11285. {
  11286. ceErpTradeCellExtend.Update();
  11287. }
  11288. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11289. returnSuccessMsg("修改成功!");
  11290. return;
  11291. }
  11292. returnErrorMsg("找不到订单");
  11293. }
  11294. public void get_change_express_list()
  11295. {
  11296. DataStruct dStruct = GetPostStruct();
  11297. List<string> lw = new List<string>();
  11298. int st = 2;
  11299. string tid = GetPostString("ctid");
  11300. if (tid.Length > 0)
  11301. {
  11302. string select_tid = getTidByCtid(tid);
  11303. lw.Add(string.Format("tid='{0}'", select_tid));
  11304. }
  11305. string shopname = GetPostString("shopname");
  11306. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11307. string buyernick = GetPostString("buyer_nick");
  11308. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11309. string sellermemo = GetPostString("seller_memo");
  11310. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11311. string supplier = GetPostString("supplier");
  11312. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11313. string customer = GetPostString("customer");
  11314. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11315. string design = GetPostString("design");
  11316. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11317. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11318. string poscode = CurrentUser.UserPost.Post.Code;
  11319. if (poscode != "SysAdmin")
  11320. {
  11321. string shopid = CurrentUser.User.pemShop;
  11322. lw.Add(string.Format("shopId in ({0})", shopid));
  11323. }
  11324. lw.Add("readMod = 2");
  11325. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11326. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11327. writeGridDataTableJson(dStruct.TotalCount, dt);
  11328. }
  11329. public void deal_express_complete()
  11330. {
  11331. string ctid = GetPostString("ctid");
  11332. if (!string.IsNullOrEmpty(ctid))
  11333. {
  11334. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11335. if (ceErpTradeCellExtend == null)
  11336. {
  11337. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11338. ceErpTradeCellExtend.ctid = ctid;
  11339. }
  11340. ceErpTradeCellExtend.readMod = 1;
  11341. if (ceErpTradeCellExtend.ID == 0)
  11342. {
  11343. ceErpTradeCellExtend.Create();
  11344. }
  11345. else
  11346. {
  11347. ceErpTradeCellExtend.Update();
  11348. }
  11349. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11350. returnSuccessMsg("修改成功!");
  11351. return;
  11352. }
  11353. returnErrorMsg("找不到订单");
  11354. }
  11355. public void aftersale_return_visit()
  11356. {
  11357. string ctid = GetPostString("ctid");
  11358. if (!string.IsNullOrEmpty(ctid))
  11359. {
  11360. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11361. if (ceErpTradeCellExtend == null)
  11362. {
  11363. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11364. ceErpTradeCellExtend.ctid = ctid;
  11365. }
  11366. ceErpTradeCellExtend.returnVisit = 1;
  11367. if (ceErpTradeCellExtend.ID == 0)
  11368. {
  11369. ceErpTradeCellExtend.Create();
  11370. }
  11371. else
  11372. {
  11373. ceErpTradeCellExtend.Update();
  11374. }
  11375. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11376. if (ceErpTradeAfterSaleExtend != null)
  11377. {
  11378. ceErpTradeAfterSaleExtend.TextResult = "";
  11379. ceErpTradeAfterSaleExtend.Update();
  11380. }
  11381. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11382. returnSuccessMsg("修改成功!");
  11383. return;
  11384. }
  11385. returnErrorMsg("找不到订单");
  11386. }
  11387. public void orderPlaceInfo()
  11388. {
  11389. string ctids = GetPostString("ctids");
  11390. string[] list = ctids.Split(',');
  11391. foreach (string ctid in list)
  11392. {
  11393. CeErpSukuraData.createInfo(ctid, 3);
  11394. }
  11395. designHelper.api_approveDesign(ctids); //approveDesign
  11396. returnSuccessMsg("");
  11397. }
  11398. public void get_issue_list()
  11399. {
  11400. DataStruct dStruct = GetPostStruct();
  11401. List<string> lw = new List<string>();
  11402. int st = 2;
  11403. string tid = GetPostString("ctid");
  11404. if (tid.Length > 0)
  11405. {
  11406. string select_tid = getTidByCtid(tid);
  11407. lw.Add(string.Format("tid='{0}'", select_tid));
  11408. }
  11409. string shopname = GetPostString("shopname");
  11410. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11411. string buyernick = GetPostString("buyer_nick");
  11412. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11413. string sellermemo = GetPostString("seller_memo");
  11414. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11415. string supplier = GetPostString("supplier");
  11416. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11417. string customer = GetPostString("customer");
  11418. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11419. string design = GetPostString("design");
  11420. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11421. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11422. string poscode = CurrentUser.UserPost.Post.Code;
  11423. if (poscode != "SysAdmin")
  11424. {
  11425. string shopid = CurrentUser.User.pemShop;
  11426. lw.Add(string.Format("shopId in ({0})", shopid));
  11427. }
  11428. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11429. {
  11430. lw.Add("IssueState = 1");
  11431. }
  11432. lw.Add("IssueState > 0");
  11433. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11434. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11435. writeGridDataTableJson(dStruct.TotalCount, dt);
  11436. }
  11437. public void saveIssueContent()
  11438. {
  11439. string ctid = GetPostString("ctid");
  11440. if (!string.IsNullOrEmpty(ctid))
  11441. {
  11442. string content = GetPostString("content");
  11443. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11444. if (ceErpTradeAfterSaleExtend == null)
  11445. {
  11446. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11447. ceErpTradeAfterSaleExtend.tid = ctid;
  11448. }
  11449. ceErpTradeAfterSaleExtend.IssueContent = content;
  11450. ceErpTradeAfterSaleExtend.IssueState = 1;
  11451. if (ceErpTradeAfterSaleExtend.ID > 0)
  11452. {
  11453. ceErpTradeAfterSaleExtend.Update();
  11454. }
  11455. else
  11456. {
  11457. ceErpTradeAfterSaleExtend.Create();
  11458. }
  11459. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11460. returnSuccessMsg("添加成功!");
  11461. return;
  11462. }
  11463. returnErrorMsg("找不到订单");
  11464. }
  11465. public void dealIssueContent()
  11466. {
  11467. string ctid = GetPostString("ctid");
  11468. if (!string.IsNullOrEmpty(ctid))
  11469. {
  11470. string content = GetPostString("content");
  11471. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11472. if (ceErpTradeAfterSaleExtend != null)
  11473. {
  11474. ceErpTradeAfterSaleExtend.IssueState = 2;
  11475. ceErpTradeAfterSaleExtend.Update();
  11476. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11477. returnSuccessMsg("修改完成!");
  11478. return;
  11479. }
  11480. }
  11481. returnErrorMsg("找不到订单");
  11482. }
  11483. public void set_tid_attachments()
  11484. {
  11485. string tid = GetPostString("tid");
  11486. string atta = GetPostString("atta");
  11487. if (!string.IsNullOrEmpty(tid))
  11488. {
  11489. if (string.IsNullOrEmpty(atta))
  11490. {
  11491. returnErrorMsg("文件地址为空");
  11492. return;
  11493. }
  11494. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11495. if (ceErpTradeCell != null)
  11496. {
  11497. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11498. if (ceErpTrade == null)
  11499. {
  11500. returnErrorMsg("找不到订单");
  11501. return;
  11502. }
  11503. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11504. bool isSend = false;
  11505. if (dt != null && dt.Rows.Count > 0)
  11506. {
  11507. foreach (DataRow row in dt.Rows)
  11508. {
  11509. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11510. {
  11511. isSend = true;
  11512. }
  11513. }
  11514. if (isSend)
  11515. {
  11516. returnErrorMsg("已发货无法修改");
  11517. return;
  11518. }
  11519. ceErpTrade.Attachments = atta;
  11520. ceErpTrade.Update();
  11521. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11522. returnSuccessMsg("上传成功!");
  11523. return;
  11524. }
  11525. }
  11526. }
  11527. returnErrorMsg("找不到订单");
  11528. }
  11529. public void get_tid_attachments()
  11530. {
  11531. string tid = GetPostString("tid");
  11532. if (!string.IsNullOrEmpty(tid))
  11533. {
  11534. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11535. if (ceErpTradeCell != null)
  11536. {
  11537. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11538. if (ceErpTrade == null)
  11539. {
  11540. returnErrorMsg("找不到订单");
  11541. return;
  11542. }
  11543. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11544. return;
  11545. }
  11546. }
  11547. returnErrorMsg("找不到订单");
  11548. }
  11549. }
  11550. }