sync.order.cs 711 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069
  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. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. using NPOI.POIFS.Properties;
  51. using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
  52. using static SiteCore.taoObj.Api_tmc_refund_info_Obj;
  53. using System.Threading.Tasks;
  54. using SiteCore.taoObj.WebApi;
  55. namespace SiteCore.Handler
  56. {
  57. public partial class sync
  58. {
  59. public void get_erp_orderlist()
  60. {
  61. string poscode = CurrentUser.UserPost.Post.Code;
  62. DataStruct dStruct = GetPostStruct();
  63. //commonHelper.setDeliveryUnusualOrder2();
  64. //string a = SecurityHelper.DecryptSymmetric("kncY+n90QZs=");
  65. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.autoDistributeToSupplier(CeErpTradeCell.GetByCode("260112211259328680"));
  69. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  70. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  71. //int sid = commonHelper.autoDistributeToSupplier(entity);
  72. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  73. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1769473929000,\"deliveryType\":\"OFFLINE\",\"discountFee\":88.8,\"flag\":\"NONE\",\"latestDeliveryTime\":1769646723000,\"lines\":[{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":2,\"outerId\":\"QZB_1\",\"payment\":71.2,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i1/2209098428402/O1CN014lFiOR2BwAlLj73pn_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323534103881\",\"refSkuId\":\"5676891964027\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-好运120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":71.2,\"totalPrice\":81.0,\"totalSellPrice\":71.2},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":43.8,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2209098428402/O1CN018Wkqi22BwAlJzJCsN_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":49.8,\"refOlId\":\"32103763323544103881\",\"refSkuId\":\"5676891964037\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":43.8,\"singleFee\":43.8,\"spuOuterId\":\"QZB_1\",\"standards\":\"款式四-【五条装】-条幅-缝筒-送绳子\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":43.8,\"totalPrice\":49.8,\"totalSellPrice\":43.8},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":2,\"outerId\":\"QZB_1\",\"payment\":43.2,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2209098428402/O1CN01RnBV0A2BwAlKIJfa7_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":24.6,\"refOlId\":\"32103763323554103881\",\"refSkuId\":\"5676891964016\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":21.6,\"singleFee\":21.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-福到160x80cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":43.2,\"totalPrice\":49.2,\"totalSellPrice\":43.2},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":35.6,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2209098428402/O1CN01nxyqK62BwAlGPAQSL_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323564103881\",\"refSkuId\":\"5681379297700\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-万事顺120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":35.6,\"totalPrice\":40.5,\"totalSellPrice\":35.6},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":2,\"outerId\":\"QZB_1\",\"payment\":43.2,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2209098428402/O1CN01D2zZO22BwAlMiuBcu_!!2209098428402.png\",\"platServiceFee\":0.0,\"price\":24.6,\"refOlId\":\"32103763323574103881\",\"refSkuId\":\"5681379297697\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":21.6,\"singleFee\":21.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-福来160x80cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":43.2,\"totalPrice\":49.2,\"totalSellPrice\":43.2},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":2,\"outerId\":\"QZB_1\",\"payment\":71.2,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2209098428402/O1CN01odXukd2BwAlMiF0Li_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323584103881\",\"refSkuId\":\"5676891964031\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-发财120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":71.2,\"totalPrice\":81.0,\"totalSellPrice\":71.2},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":35.6,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2209098428402/O1CN01f4HKJm2BwAlKyCeeJ_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323594103881\",\"refSkuId\":\"5676891964017\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-福到120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":35.6,\"totalPrice\":40.5,\"totalSellPrice\":35.6},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":35.6,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2209098428402/O1CN01ycsFfI2BwAlKdCqcx_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323604103881\",\"refSkuId\":\"5676891964019\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-钱来120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":35.6,\"totalPrice\":40.5,\"totalSellPrice\":35.6},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":35.6,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2209098428402/O1CN01jC9Fda2BwAlLfWEmv_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323614103881\",\"refSkuId\":\"5676891964021\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-喜乐120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":35.6,\"totalPrice\":40.5,\"totalSellPrice\":35.6},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":43.8,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2209098428402/O1CN01IiOKnv2BwAlJz5e9z_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":49.8,\"refOlId\":\"32103763323624103881\",\"refSkuId\":\"5676891964036\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":43.8,\"singleFee\":43.8,\"spuOuterId\":\"QZB_1\",\"standards\":\"款式三【五条装】-条幅-缝筒-送绳子\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":43.8,\"totalPrice\":49.8,\"totalSellPrice\":43.8},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":2,\"outerId\":\"QZB_1\",\"payment\":43.2,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2209098428402/O1CN01DNwVBD2BwAlPrsRI5_!!2209098428402.png\",\"platServiceFee\":0.0,\"price\":24.6,\"refOlId\":\"32103763323634103881\",\"refSkuId\":\"5681379297699\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":21.6,\"singleFee\":21.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-万事顺160x80cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":43.2,\"totalPrice\":49.2,\"totalSellPrice\":43.2},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":2,\"outerId\":\"QZB_1\",\"payment\":71.2,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2209098428402/O1CN01S0IogQ2BwAlN8vq4B_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323644103881\",\"refSkuId\":\"5681379297698\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-福来120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":71.2,\"totalPrice\":81.0,\"totalSellPrice\":71.2},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":35.6,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i1/2209098428402/O1CN01HXQ0VP2BwAlKdHwvM_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323654103881\",\"refSkuId\":\"5676891964025\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-如意120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":35.6,\"totalPrice\":40.5,\"totalSellPrice\":35.6},{\"dividePostFee\":0.0,\"latestDeliveryTime\":1769646723000,\"mark2\":[],\"num\":1,\"outerId\":\"QZB_1\",\"payment\":35.6,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2209098428402/O1CN01DP994m2BwAlJYJGxF_!!2209098428402.jpg\",\"platServiceFee\":0.0,\"price\":40.5,\"refOlId\":\"32103763323664103881\",\"refSkuId\":\"5676891964033\",\"refSpuId\":\"860739190401\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":35.6,\"singleFee\":35.6,\"spuOuterId\":\"QZB_1\",\"standards\":\"现货-暴富120x240cm-条幅-四角打孔-送挂钩\",\"status\":\"NOT_SHIPPED\",\"title\":\"新年装饰挂布定制2025蛇年氛围感背景布元旦网红拍照书法旗帜布置\",\"totalFee\":35.6,\"totalPrice\":40.5,\"totalSellPrice\":35.6}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1769474375000,\"openBuyerId\":\"AAG0RHraABkUZRPgSx3LCGSA\",\"openBuyerNick\":\"f**\",\"openSellerNick\":\"鼎怡旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1769473877000,\"payTime\":1769473923000,\"payment\":644.4,\"platServiceFee\":0.0,\"posCode\":\"dingyi\",\"posId\":598810,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"上海市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"黄浦区\",\"receiverId\":\"64eedcf615544863ccce8b2194d7cb4c$\",\"receiverState\":\"上海\",\"receiverTown\":\"淮海中路街道\",\"refOid\":\"32103763323524103881\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"sysTags\":[],\"totalFee\":644.4,\"totalPrice\":733.2,\"totalSellPrice\":644.4,\"type\":\"SALE\"}}");
  74. //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}}");
  75. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  76. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  77. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  78. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  79. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  80. string tids = File.ReadAllText(path);
  81. List<string> list = tids.Split(',').ToList();
  82. int index = 0;
  83. foreach (string item in list)
  84. {
  85. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  86. try
  87. {
  88. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  89. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  90. {
  91. sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  92. }
  93. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  94. List<string> tidList = new List<string>();
  95. if (dataTable != null && dataTable.Rows.Count > 0)
  96. {
  97. foreach (DataRow row in dataTable.Rows)
  98. {
  99. tidList.Add("'" + row["tid"].ToString() + "'");
  100. }
  101. }
  102. if (tidList.Count > 0)
  103. {
  104. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  105. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  106. if (dataTable != null && dataTable.Rows.Count > 0)
  107. {
  108. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  109. if (count > 0)
  110. {
  111. Debug.WriteLine(index++);
  112. continue;
  113. }
  114. }
  115. }
  116. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  117. }
  118. catch (Exception e)
  119. {
  120. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  121. }
  122. Debug.WriteLine(index++);
  123. }*/
  124. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  125. List<string> lw = new List<string>();
  126. string tid = GetPostString("ctid");
  127. string date1 = GetPostString("date1");
  128. //12-1 修改
  129. string urgent = GetPostString("urgent");
  130. string back = GetPostString("back");
  131. string offlineSearch = GetPostString("offlineSearch");
  132. int paramsCount = 0;
  133. if (!string.IsNullOrWhiteSpace(urgent))
  134. {
  135. if (urgent.Equals("true"))
  136. {
  137. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  138. }
  139. }
  140. if (!string.IsNullOrWhiteSpace(back))
  141. {
  142. if (back.Equals("true"))
  143. {
  144. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  145. }
  146. }
  147. if (!string.IsNullOrWhiteSpace(offlineSearch))
  148. {
  149. if (offlineSearch.Equals("true"))
  150. {
  151. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  152. }
  153. }
  154. //end
  155. string date2 = GetPostString("date2");
  156. string buyernick = GetPostString("buyer_nick");
  157. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  158. {
  159. if (tid.Length <= 0 && buyernick.Length <= 0)
  160. {
  161. return;
  162. }
  163. }
  164. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  165. {
  166. if (tid.Length > 0)
  167. {
  168. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  169. if (ceErpTradeCell != null)
  170. {
  171. tid = ceErpTradeCell.tid;
  172. }
  173. List<string> select_tid = getTidByCtidMore(tid);
  174. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  175. }
  176. if (buyernick.Length > 0)
  177. {
  178. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  179. }
  180. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  181. if (dw.Length > 0)
  182. {
  183. lw.Add(dw);
  184. }
  185. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  186. {
  187. string usershop = "0," + CurrentUser.User.pemShop;
  188. lw.Add(string.Format("ShopId in ({0})", usershop));
  189. }
  190. }
  191. else
  192. {
  193. if (ex_psize == 0)
  194. {
  195. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  196. }
  197. if (PKey != "admin" && poscode != "SysAdmin")
  198. {
  199. string usershop = "0," + CurrentUser.User.pemShop;
  200. lw.Add(string.Format("ShopId in ({0})", usershop));
  201. paramsCount++;
  202. }
  203. }
  204. string uploaddate1 = GetPostString("uploaddate1");
  205. string uploaddate2 = GetPostString("uploaddate2");
  206. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  207. if (update.Length > 0) lw.Add(update);
  208. string deliverydate1 = GetPostString("deliverydate1");
  209. string deliverydate2 = GetPostString("deliverydate2");
  210. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  211. if (deliverydate.Length > 0)
  212. {
  213. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  214. };
  215. string shopname = GetPostString("shopname");
  216. if (shopname.Length > 0)
  217. {
  218. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  219. if (ceErpShop != null)
  220. {
  221. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  222. }
  223. }
  224. string addwechat = GetPostString("addwechat");
  225. if (addwechat.Length > 0)
  226. {
  227. int addWt = Convert.ToInt32(addwechat);
  228. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  229. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  230. }
  231. string customer = GetPostString("customer");
  232. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  233. string design = GetPostString("design");
  234. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  235. string orderState = GetPostString("orderState");
  236. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  237. string address = GetPostString("address");
  238. 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));
  239. string sellermemo = GetPostString("seller_memo");
  240. if (sellermemo.Length > 0)
  241. {
  242. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  243. }
  244. string otherMemo = GetPostString("otherMemo");
  245. if (otherMemo.Length > 0)
  246. {
  247. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  248. }
  249. string backReason = GetPostString("backReason");
  250. if (backReason.Length > 0)
  251. {
  252. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  253. }
  254. string apdate1 = GetPostString("apdate1");
  255. string apdate2 = GetPostString("apdate2");
  256. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  257. if (dwap.Length > 0) lw.Add(dwap);
  258. string price1 = GetPostString("price1");
  259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  260. string price2 = GetPostString("price2");
  261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  262. string isoldcustomer = GetPostString("isoldcus");
  263. string buyer_id = GetPostString("buyer_id");
  264. if (buyer_id.Length > 0) lw.Add(string.Format("buyer_id = '{0}'", buyer_id));
  265. string spudata = GetPostString("spudata");
  266. if ("0".Equals(spudata))
  267. {
  268. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  269. }
  270. if ("1".Equals(spudata))
  271. {
  272. lw.Add(string.Format("spu_id <> ''"));
  273. }
  274. string finishdate1 = GetPostString("finishdate1");
  275. string finishdate2 = GetPostString("finishdate2");
  276. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  277. bool isFinish = false;
  278. if (finishdate.Length > 0)
  279. {
  280. lw.Add(finishdate);
  281. isFinish = true;
  282. paramsCount++;
  283. }
  284. if (isoldcustomer.Length > 0)
  285. {
  286. if ("2".Equals(isoldcustomer))
  287. {
  288. lw.Add(string.Format("VipCustomer=1"));
  289. }
  290. else
  291. {
  292. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  293. }
  294. }
  295. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  296. if (ex_psize > 0)
  297. {
  298. int UserID = CurrentUser.UserID;
  299. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  300. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  301. {
  302. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  303. }
  304. dStruct.Order = "pay_time desc";
  305. }
  306. string isNew = GetPostString("isNew");
  307. if (isNew == "true")
  308. {
  309. lw.Add(string.Format("IsNew = {0}", 1));
  310. }
  311. string overtime = GetPostString("overtime");
  312. if (overtime == "1")
  313. {
  314. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  315. }
  316. String usePost = CurrentUser.UserPost.Post.Code;
  317. if (usePost.Equals("Operation") == true)
  318. {
  319. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  320. }
  321. else
  322. {
  323. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  324. }
  325. //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";
  326. if (dStruct.PageSize == 100000)
  327. {
  328. dStruct.Order = "";
  329. }
  330. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  331. DataTable dt = null;
  332. string tablename = "view_orderlist";
  333. if (isFinish)
  334. {
  335. tablename = "view_orderlist_end";
  336. }
  337. dt = WebCache.GetData(tablename, dStruct);
  338. if (dt != null && dt.Rows.Count > 0)
  339. {
  340. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  341. foreach (DataRow dr in dt.Rows)
  342. {
  343. try
  344. {
  345. if (dr["refund_fees"] != null)
  346. {
  347. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  348. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  349. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  350. if (payment == refund_fees)
  351. {
  352. dr["refund_fees"] = Math.Round(refund_fees, 2);
  353. }
  354. else if (refund_fees == total_fee)
  355. {
  356. dr["refund_fees"] = payment;
  357. }
  358. else
  359. {
  360. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  361. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  362. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  363. }
  364. }
  365. // 对象操作
  366. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  367. ceErpTradeCell.ctid = dr["ctid"].ToString();
  368. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  369. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  370. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  371. if (dStruct.PageSize != 100000)
  372. {
  373. if (dr["DispatchSort"].ToString() == "2")
  374. {
  375. dr["gongchuang"] = 200;
  376. }
  377. else if ("外协".Equals(dr["ToType"].ToString()))
  378. {
  379. dr["gongchuang"] = 200;
  380. }
  381. else if ("内部".Equals(dr["ToType"].ToString()))
  382. {
  383. dr["gongchuang"] = -1;
  384. }
  385. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  386. {
  387. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  388. dr["gongchuang"] = response.code;
  389. }
  390. }
  391. }
  392. catch (NullReferenceException ex)
  393. {
  394. // 处理空引用异常
  395. dr["refund_fees"] = "0.00";
  396. }
  397. }
  398. }
  399. writeGridDataTableJson(dStruct.TotalCount, dt);
  400. }
  401. public void get_erp_orderlist_sumprice()
  402. {
  403. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  404. return;
  405. List<string> lw = new List<string>();
  406. string tid = GetPostString("ctid");
  407. string date1 = GetPostString("date1");
  408. string date2 = GetPostString("date2");
  409. if (tid.Length > 0 || date1.Length > 0)
  410. {
  411. lw.Add(string.Format("ctid like '%{0}%'", tid));
  412. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  413. if (dw.Length > 0) lw.Add(dw);
  414. }
  415. else
  416. {
  417. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  418. }
  419. string shopname = GetPostString("shopname");
  420. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  421. string buyernick = GetPostString("buyer_nick");
  422. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  423. string customer = GetPostString("customer");
  424. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  425. string design = GetPostString("design");
  426. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  427. string orderState = GetPostString("orderState");
  428. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  429. string address = GetPostString("address");
  430. 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));
  431. string sellermemo = GetPostString("seller_memo");
  432. if (sellermemo.Length > 0)
  433. {
  434. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  435. }
  436. string apdate1 = GetPostString("apdate1");
  437. string apdate2 = GetPostString("apdate2");
  438. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  439. if (dwap.Length > 0) lw.Add(dwap);
  440. string price1 = GetPostString("price1");
  441. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  442. string price2 = GetPostString("price2");
  443. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  444. string isoldcustomer = GetPostString("isoldcus");
  445. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  446. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  447. if (PKey != "admin")
  448. {
  449. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  450. lw.Add(string.Format("shopId in ({0})", usershop));
  451. }
  452. //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";
  453. string mainWhere = string.Join(" and ", lw.ToArray());
  454. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  455. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  456. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  457. decimal total = 0;
  458. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  459. {
  460. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  461. }
  462. var res = new
  463. {
  464. data = total
  465. };
  466. string ro_jsond = JsonConvert.SerializeObject(res);
  467. returnSuccess(ro_jsond);
  468. return;
  469. }
  470. public void get_erp_CustomerServiceGather()
  471. {
  472. string userWhere = "", orderWhere = "";
  473. List<string> lw = new List<string>();
  474. string customer = GetPostString("customer");
  475. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  476. string shopname = GetPostString("shopname");
  477. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  478. string date1 = GetPostString("date1");
  479. string date2 = GetPostString("date2");
  480. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  481. if (dw.Length > 0) lw.Add(dw);
  482. orderWhere = string.Join(" and ", lw.ToArray());
  483. 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 " +
  484. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  485. "left join " +
  486. "( " +
  487. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  488. ") as b on a.ID = b.CustomerUserId " +
  489. "left join " +
  490. "( " +
  491. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  492. ") as d on a.ID = d.CustomerUserId " +
  493. "left join " +
  494. "( " +
  495. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  496. ") as e on a.ID = e.CustomerUserId " +
  497. "left join " +
  498. "( " +
  499. " select CustomerUserId, RefundCount, RefundSum from " +
  500. " ( " +
  501. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  502. " from CE_ErpTradeRefund a " +
  503. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  504. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  505. " group by CustomerUserId " +
  506. " ) as a " +
  507. ") as f on a.ID = f.CustomerUserId " +
  508. "where a.PostCode = 'CustomerService'",
  509. userWhere, orderWhere);
  510. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  511. writeGridDataTableJson(dt.Rows.Count, dt);
  512. //writeGridDataTableJson(dt.Rows.Count, dt);
  513. }
  514. //设计汇总
  515. public void get_erp_DesignerGather()
  516. {
  517. string userWhere = "", orderWhere = "";
  518. List<string> lw = new List<string>();
  519. string Designer = GetPostString("designer");
  520. int org = GetPostInt("org");
  521. if (Designer.Length > 0)
  522. {
  523. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  524. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  525. }
  526. else if (org > 0)
  527. {
  528. userWhere = string.Format(" where OrgID ={0}", org);
  529. }
  530. string shopname = GetPostString("shopname");
  531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  532. string state = GetPostString("state");
  533. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  534. string OrderArea = GetPostString("order_area");
  535. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  536. string date1 = GetPostString("date1");
  537. string date2 = GetPostString("date2");
  538. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  539. if (dw.Length > 0) lw.Add(dw);
  540. string UpDate1 = GetPostString("UpDate1");
  541. string UpDate2 = GetPostString("UpDate2");
  542. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  543. if (dw.Length > 0) lw.Add(dw);
  544. orderWhere = string.Join(" and ", lw.ToArray());
  545. 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 (" +
  546. "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 " +
  547. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  548. "left join " +
  549. "( " +
  550. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  551. ") as b on a.ID = b.DesignUserId " +
  552. "left join " +
  553. "( " +
  554. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  555. ") as d on a.ID = d.DesignUserId " +
  556. "left join " +
  557. "( " +
  558. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  559. ") as e on a.ID = e.DesignUserId " +
  560. "left join " +
  561. "( " +
  562. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  563. ") as g on a.ID = g.DesignUserId " +
  564. "left join " +
  565. "( " +
  566. " select CustomerUserId, RefundCount, RefundSum from " +
  567. " ( " +
  568. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  569. " from CE_ErpTradeRefund a " +
  570. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  571. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  572. " group by CustomerUserId " +
  573. " ) as a " +
  574. ") as f on a.ID = f.CustomerUserId " +
  575. "where a.PostCode = 'Designer') as z",
  576. userWhere, orderWhere);
  577. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  578. writeGridDataTableJson(dt.Rows.Count, dt);
  579. }
  580. //删除tradecell的订单
  581. public void del_erp_cellorder()
  582. {
  583. if (UrlPostParmsCheck("ctid"))
  584. {
  585. string eid = GetPostString("ctid");
  586. CeErpTradeCell.DelByCtid(eid);
  587. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  588. returnSuccessMsg("删除成功");
  589. }
  590. }
  591. public void clear_erp_refundstate()
  592. {
  593. if (UrlPostParmsCheck("ids"))
  594. {
  595. string eids = GetPostString("ids");
  596. string[] ctidList = eids.Split(',');
  597. foreach (string ctid in ctidList)
  598. {
  599. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  600. if (entity != null)
  601. {
  602. entity.IsRefund = 0;
  603. entity.Update();
  604. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  605. }
  606. else
  607. continue;
  608. }
  609. returnSuccessMsg("操作成功");
  610. return;
  611. }
  612. returnErrorMsg("缺少必要参数");
  613. }
  614. public void set_erp_urgency()
  615. {
  616. if (UrlPostParmsCheck("ctid"))
  617. {
  618. string eid = GetPostString("ctid");
  619. CeErpTradeCell entity = null;
  620. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  621. if (entity != null)
  622. {
  623. double prices = commonHelper.calculationPrice(entity);
  624. if (prices <= 100)
  625. {
  626. returnErrorMsg("此订单金额不足100元,无法加急。");
  627. return;
  628. }
  629. string utime = GetPostString("urgencytime");
  630. if (utime.Length > 0)
  631. {
  632. entity.UrgencyTime = Convert.ToDateTime(utime);
  633. }
  634. else
  635. {
  636. returnErrorMsg("请选择加急时间");
  637. return;
  638. }
  639. if (entity.OrderState <= 4)
  640. {
  641. //entity.seller_memo = entity.seller_memo + "-加急";
  642. string smemo = entity.seller_memo;
  643. int kindex = smemo.IndexOf(")");
  644. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  645. if (lastoneStr != "-")
  646. {
  647. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  648. }
  649. string prememo = smemo.Substring(0, kindex + 2);
  650. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  651. int lastkindex = lastmemo.IndexOf("(");
  652. DateTime urgtime = Convert.ToDateTime(utime);
  653. string newlastmemo = "";
  654. if (lastkindex == 0)
  655. {
  656. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  657. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  658. }
  659. else
  660. {
  661. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  662. }
  663. entity.seller_memo = prememo + newlastmemo;
  664. }
  665. entity.IsUrgency = true;
  666. entity.UpdateTime = DateTime.Now;
  667. entity.Update();
  668. ApiVo apiVo = new ApiVo();
  669. apiVo.orderNumber = entity.ctid;
  670. apiVo.actionName = "changeDesign";
  671. apiVo.orderRemarks = entity.seller_memo;
  672. apiVo.remarkSign = 3;
  673. designHelper.API_WorkCore(apiVo); //changeDesign
  674. CeErpSukuraData.createInfo(entity.ctid, 7);
  675. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  676. returnSuccessMsg("设置成功!");
  677. return;
  678. }
  679. returnErrorMsg("找不到记录");
  680. }
  681. }
  682. public void set_erp_reset()
  683. {
  684. if (UrlPostParmsCheck("ctid"))
  685. {
  686. string eid = GetPostString("ctid");
  687. CeErpTradeCell entity = null;
  688. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  689. if (entity != null)
  690. {
  691. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  692. {
  693. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  694. {
  695. returnErrorMsg("财务要求已下单已发货无法重置");
  696. return;
  697. }
  698. }
  699. entity.IsUrgency = false;
  700. entity.seller_memo = "";
  701. entity.OtherMemo = "";
  702. entity.OrderState = 0;
  703. entity.IsReturn = 0;
  704. //entity.IsRefund = 0;
  705. entity.MemoOpt = 0;
  706. entity.AfterSaleState = 0;
  707. entity.AfterSaleResponsible = "";
  708. entity.AfterSaleUserId = 0;
  709. entity.IsNeedBill = 0;
  710. entity.CustomerUserId = 0;
  711. entity.DesignUserId = 0;
  712. entity.SupplierId = 0;
  713. entity.PlaceUserId = 0;
  714. entity.ptid = "";
  715. entity.IsSample = 0;
  716. entity.IsXianHuo = 0;
  717. entity.isDianziOrder = 0;
  718. entity.DispatchSort = 0;
  719. entity.IsVerifyToSupplier = false;
  720. entity.FinishPlaceTime = null;
  721. entity.Update();
  722. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  723. if (trade != null)
  724. {
  725. trade.seller_memo = "";
  726. trade.Update();
  727. }
  728. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  729. returnSuccessMsg("重置成功!");
  730. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  731. if (desginBill != null)
  732. {
  733. desginBill.isDel = 1;
  734. desginBill.Update();
  735. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  736. }
  737. ApiVo apiVo = new ApiVo();
  738. apiVo.orderNumber = entity.ctid;
  739. apiVo.actionName = "resetDesign";
  740. designHelper.API_WorkCore(apiVo);//resetDesign
  741. return;
  742. }
  743. returnErrorMsg("找不到记录");
  744. }
  745. }
  746. public void save_erp_sellermemo()
  747. {
  748. if (UrlPostParmsCheck("ctid"))
  749. {
  750. string ctid = GetPostString("ctid");
  751. CeErpTradeCell entity = null;
  752. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  753. if (entity != null)
  754. {
  755. string memo = GetPostString("seller_memo");
  756. string qn_memo = GetPostString("qn_memo");
  757. memo = memo.Replace(" ", "");
  758. if (memo.Contains("补差"))
  759. {
  760. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  761. return;
  762. }
  763. List<string> bitList = new List<string>
  764. {
  765. "\\","/",":","*","?", "\"","<" ,">","|"
  766. };
  767. bool isIn = false;
  768. foreach (string bit in bitList)
  769. {
  770. if (memo.Contains(bit))
  771. {
  772. isIn = true;
  773. }
  774. }
  775. if (isIn)
  776. {
  777. returnErrorMsg("不能使用 一些符合作为文件名");
  778. return;
  779. }
  780. if (entity.seller_memo != memo)
  781. {
  782. if (entity.IsSample == 2)
  783. {
  784. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  785. return;
  786. }
  787. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  788. {
  789. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  790. {
  791. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  792. return;
  793. }
  794. /*if (CurrentUser.UserPost.Post.Code != "Place")
  795. {
  796. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  797. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  798. {
  799. returnErrorMsg("售前系统订单无法再此修改!");
  800. return;
  801. }
  802. }*/
  803. }
  804. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  805. }
  806. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  807. {
  808. if (entity.OrderState >= 5)
  809. {
  810. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  811. return;
  812. }
  813. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  814. if (string.IsNullOrEmpty(delMemo))
  815. {
  816. returnErrorMsg("备注不规范,无法识别");
  817. return;
  818. }
  819. memo = delMemo;
  820. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  821. }
  822. //commonHelper.getCytPrice(entity);
  823. int memoopt = GetPostInt("MemoOpt");
  824. Boolean ismemoopt = false;
  825. if (memoopt > 0)
  826. {
  827. string stropt = "";
  828. if (memoopt == 1)
  829. {
  830. stropt = "“改稿”";
  831. ismemoopt = true;
  832. }
  833. else if (memoopt == 2)
  834. {
  835. stropt = "“定稿”";
  836. }
  837. else if (memoopt == 3)
  838. {
  839. stropt = "“查货”";
  840. CeErpSukuraData.createInfo(entity.ctid, 6);
  841. }
  842. entity.MemoOpt = Convert.ToInt32(memoopt);
  843. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  844. }
  845. if (entity.OrderState < 5)
  846. {
  847. memo = memo.Replace("(", "(");
  848. memo = memo.Replace(")", ")");
  849. }
  850. /* if (entity.OrderState < 3)
  851. {
  852. entity.DispatchSort = 0;
  853. }*/
  854. entity.seller_memo = memo;
  855. entity.UpdateTime = DateTime.Now;
  856. entity.Update();
  857. ApiVo apiVo = new ApiVo();
  858. apiVo.orderNumber = entity.ctid;
  859. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  860. apiVo.orderRemarks = memo;
  861. apiVo.remarkSign = memoopt;
  862. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  863. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  864. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  865. {
  866. //dataHelper.api_orderBack(entity.ctid, "0", "");
  867. }
  868. if (entity.seller_memo.Contains("改稿"))
  869. {
  870. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  871. }
  872. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  873. returnSuccessMsg("保存成功!");
  874. return;
  875. }
  876. returnErrorMsg("找不到记录");
  877. }
  878. }
  879. public void ins_erp_checkorder()
  880. {
  881. if (UrlPostParmsCheck("ctid"))
  882. {
  883. string ctid = GetPostString("ctid");
  884. CeErpTradeCell entity = null;
  885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  886. if (entity != null)
  887. {
  888. if (entity.OrderState < 6)
  889. {
  890. returnErrorMsg("下单完成后才可查货");
  891. return;
  892. }
  893. /*if (entity.OrderState > 6)
  894. {
  895. returnErrorMsg("订单已发货");
  896. return;
  897. }*/
  898. if (entity.FinishPlaceTime != null)
  899. {
  900. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  901. {
  902. returnErrorMsg("下单时间不足,无法查货");
  903. return;
  904. }
  905. }
  906. entity.MemoOpt = 3;
  907. entity.CheckOrderTime = DateTime.Now;
  908. entity.UpdateTime = DateTime.Now;
  909. entity.Update();
  910. CeErpSukuraData.createInfo(entity.ctid, 6);
  911. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  912. returnSuccessMsg("操作成功!");
  913. return;
  914. }
  915. returnErrorMsg("找不到记录");
  916. }
  917. }
  918. public void save_erp_othermemo()
  919. {
  920. if (UrlPostParmsCheck("ctid"))
  921. {
  922. string ctid = GetPostString("ctid");
  923. CeErpTradeCell entity = null;
  924. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  925. if (entity != null)
  926. {
  927. entity.OtherMemo = GetPostString("otherMemo");
  928. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  929. {
  930. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  931. StringBuilder sql = new StringBuilder();
  932. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  933. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  934. if (dt != null && dt.Rows.Count > 0)
  935. {
  936. foreach (DataRow dr in dt.Rows)
  937. {
  938. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  939. {
  940. //品类一直
  941. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  942. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  943. if (ceErpSampleCustomer == null)
  944. {
  945. ceErpSampleCustomer = new CeErpSampleCustomer();
  946. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  947. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  948. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  949. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  950. ceErpSampleCustomer.shopId = entity.ShopId;
  951. }
  952. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  953. ceErpSampleCustomer.lastTid = entity.tid;
  954. if (ceErpSampleCustomer.ID > 0)
  955. {
  956. ceErpSampleCustomer.Update();
  957. }
  958. else
  959. {
  960. ceErpSampleCustomer.Create();
  961. }
  962. }
  963. }
  964. }
  965. }
  966. //if (entity.IsOldCustomer == 1)
  967. //{
  968. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  969. //{
  970. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  971. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  972. //}
  973. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  974. //{
  975. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  976. // {
  977. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  978. // {
  979. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  980. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  981. // }
  982. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  983. // {
  984. // entity.OrderState = 2;
  985. // entity.DesignUserId = 0;
  986. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  987. // }
  988. // else
  989. // {
  990. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  991. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  992. // }
  993. // }
  994. //}
  995. //}
  996. entity.UpdateTime = DateTime.Now;
  997. entity.Update();
  998. returnSuccessMsg("保存成功!");
  999. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  1000. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  1001. if (entity.OtherMemo.Contains("改稿"))
  1002. {
  1003. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1004. }
  1005. return;
  1006. }
  1007. returnErrorMsg("找不到记录");
  1008. }
  1009. }
  1010. public void save_erp_customermemo()
  1011. {
  1012. if (UrlPostParmsCheck("ctid"))
  1013. {
  1014. string ctid = GetPostString("ctid");
  1015. CeErpTradeCell entity = null;
  1016. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1017. if (entity != null)
  1018. {
  1019. entity.UpdateTime = DateTime.Now;
  1020. entity.CustomerMemo = GetPostString("CustomerMemo");
  1021. entity.Update();
  1022. ApiVo apiVo = new ApiVo();
  1023. apiVo.orderNumber = entity.ctid;
  1024. apiVo.actionName = "followRemarks";
  1025. apiVo.orderRemarks = entity.CustomerMemo;
  1026. designHelper.API_WorkCore(apiVo);//followRemarks
  1027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1028. returnSuccessMsg("保存成功!");
  1029. return;
  1030. }
  1031. returnErrorMsg("找不到记录");
  1032. }
  1033. }
  1034. public void upd_erp_addmemotag()
  1035. {
  1036. if (UrlPostParmsCheck("ctid"))
  1037. {
  1038. ;
  1039. string eid = GetPostString("ctid");
  1040. string sfTagstr = GetPostString("memotag");
  1041. CeErpTradeCell entity = null;
  1042. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1043. if (entity != null)
  1044. {
  1045. ApiVo apiVo = new ApiVo();
  1046. if (entity.OrderState == 0)
  1047. {
  1048. returnErrorMsg("请先领单");
  1049. return;
  1050. }
  1051. //撤销顺丰
  1052. if (sfTagstr == "撤销顺丰")
  1053. {
  1054. entity.IsSF = 0;
  1055. string reMsg = "";
  1056. string oldmemo = entity.seller_memo;
  1057. if (entity.OrderState < 5)
  1058. {
  1059. oldmemo = oldmemo.Replace("顺丰到付", "");
  1060. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1061. entity.seller_memo = oldmemo;
  1062. }
  1063. else
  1064. {
  1065. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1066. {
  1067. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1068. }
  1069. }
  1070. entity.Update();
  1071. apiVo.orderNumber = entity.ctid;
  1072. apiVo.actionName = "orderRemarks";
  1073. apiVo.orderRemarks = entity.seller_memo;
  1074. apiVo.isSf = entity.IsSF.ToString();
  1075. designHelper.API_WorkCore(apiVo);//orderRemarks
  1076. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1077. returnSuccessMsg("撤销成功!" + reMsg);
  1078. return;
  1079. }
  1080. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1081. {
  1082. //string oldmemo = entity.seller_memo;
  1083. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1084. string sfStr = GetPostString("memotag");
  1085. string smemo = entity.seller_memo;
  1086. int kindex = smemo.IndexOf(")");
  1087. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1088. if (lastoneStr != "-")
  1089. {
  1090. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1091. }
  1092. string prememo = smemo.Substring(0, kindex + 2);
  1093. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1094. int lastkindex = lastmemo.IndexOf("(");
  1095. string newlastmemo = "";
  1096. if (lastkindex == 0)
  1097. {
  1098. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1099. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1100. }
  1101. else
  1102. {
  1103. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1104. }
  1105. entity.seller_memo = prememo + newlastmemo;
  1106. }
  1107. string sfTagMSg = "";
  1108. if (sfTagstr == "顺丰寄付")
  1109. {
  1110. entity.IsSF = 1;
  1111. sfTagMSg = "顺丰寄付";
  1112. }
  1113. else if (sfTagstr == "顺丰到付")
  1114. {
  1115. entity.IsSF = 2;
  1116. sfTagMSg = "顺丰到付";
  1117. }
  1118. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1119. {
  1120. string deliveryWayName = "";
  1121. if (sfTagstr == "撤销顺丰")
  1122. {
  1123. sfTagstr = "普通快递";
  1124. }
  1125. if (sfTagstr == "顺丰寄付")
  1126. {
  1127. sfTagstr = "顺丰特快寄付";
  1128. }
  1129. if (sfTagstr == "顺丰到付")
  1130. {
  1131. sfTagstr = "顺丰特快到付";
  1132. }
  1133. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1134. if ("修改失败".Equals(result))
  1135. {
  1136. returnErrorMsg("修改失败");
  1137. return;
  1138. }
  1139. }
  1140. entity.Update();
  1141. apiVo = new ApiVo();
  1142. apiVo.orderNumber = entity.ctid;
  1143. apiVo.actionName = "orderRemarks";
  1144. apiVo.orderRemarks = entity.seller_memo;
  1145. apiVo.isSf = entity.IsSF.ToString();
  1146. designHelper.API_WorkCore(apiVo);//orderRemarks
  1147. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1148. returnSuccessMsg("标记成功!");
  1149. return;
  1150. }
  1151. returnErrorMsg("找不到记录");
  1152. }
  1153. }
  1154. public void upd_erp_ordertag()
  1155. {
  1156. if (UrlPostParmsCheck("ctid"))
  1157. {
  1158. string eid = GetPostString("ctid");
  1159. CeErpTradeCell entity = null;
  1160. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1161. if (entity != null)
  1162. {
  1163. int tag = GetPostInt("wechattag");
  1164. //if(tag==4 && entity.IsSample == 2)
  1165. //{
  1166. // returnErrorMsg("补差价单不能标记微信单");
  1167. // return;
  1168. //}
  1169. entity.wechatTag = tag;
  1170. entity.Update();
  1171. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1172. if (tag == 1)
  1173. {
  1174. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1175. if (cash == null)
  1176. {
  1177. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1178. cash = new CeErpReturnCash();
  1179. cash.tid = entity.tid;
  1180. cash.seller_nick = main.seller_nick;
  1181. cash.payment = trade.payment;
  1182. cash.buyer_nick = main.buyer_nick;
  1183. cash.cashstate = 0;
  1184. cash.rtype = "微信返现";
  1185. cash.returnprice = 0;
  1186. cash.created = DateTime.Now;
  1187. cash.con = "订单标记微信单";
  1188. cash.img = "";
  1189. cash.applyuserid = CurrentUser.UserID;
  1190. cash.Create();
  1191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1192. }
  1193. else
  1194. {
  1195. cash.cashstate = 0;
  1196. cash.Update();
  1197. }
  1198. CeErpSukuraData.createInfo(entity.ctid, 9);
  1199. }
  1200. else if (tag == 2)
  1201. {
  1202. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1203. if (cash == null)
  1204. {
  1205. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1206. cash = new CeErpReturnCash();
  1207. cash.tid = entity.tid;
  1208. cash.seller_nick = main.seller_nick;
  1209. cash.payment = trade.payment;
  1210. cash.buyer_nick = main.buyer_nick;
  1211. cash.cashstate = 0;
  1212. cash.rtype = "推购返现";
  1213. cash.returnprice = 5;
  1214. cash.created = DateTime.Now;
  1215. cash.con = "订单标记推购单";
  1216. cash.img = "";
  1217. cash.applyuserid = CurrentUser.UserID;
  1218. cash.Create();
  1219. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1220. }
  1221. else
  1222. {
  1223. cash.cashstate = 0;
  1224. cash.Update();
  1225. }
  1226. CeErpSukuraData.createInfo(entity.ctid, 9);
  1227. }
  1228. else if (tag == 3)
  1229. {
  1230. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1231. if (pers == null)
  1232. {
  1233. pers = new CeErpPersuade();
  1234. pers.ctid = entity.ctid;
  1235. pers.pstate = 0;
  1236. pers.created = DateTime.Now;
  1237. pers.applyuserid = CurrentUser.UserID;
  1238. pers.Create();
  1239. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1240. }
  1241. else
  1242. {
  1243. pers.pstate = 0;
  1244. pers.Update();
  1245. }
  1246. }
  1247. else if (tag == 4 || tag == 5)
  1248. {
  1249. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1250. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1251. if (pers == null)
  1252. {
  1253. pers = CeErpStayGoods.GetByTid(entity.tid);
  1254. }
  1255. if (pers == null)
  1256. {
  1257. pers = new CeErpStayGoods();
  1258. pers.t_id = entity.tid;
  1259. pers.ctid = entity.ctid;
  1260. pers.status = "待审核";
  1261. pers.audit_type = 0;
  1262. if (tag == 4)
  1263. {
  1264. pers.stay_type = "微信推购";
  1265. }
  1266. else
  1267. {
  1268. pers.stay_type = "旺旺推购";
  1269. }
  1270. if (entity.IsXianHuo == 0)
  1271. {
  1272. pers.product_id = entity.ProductId;
  1273. }
  1274. pers.wangwang = main.buyer_nick;
  1275. pers.shop_name = main.seller_nick;
  1276. pers.creata_time = DateTime.Now;
  1277. pers.create_u_id = CurrentUser.UserID;
  1278. pers.create_u_name = CurrentUser.UserName;
  1279. pers.Create();
  1280. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1281. }
  1282. else
  1283. {
  1284. pers.ctid = entity.ctid;
  1285. pers.audit_type = 0;
  1286. pers.Update();
  1287. }
  1288. CeErpSukuraData.createInfo(entity.ctid, 10);
  1289. }
  1290. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1291. returnSuccessMsg("标记成功!");
  1292. return;
  1293. }
  1294. returnErrorMsg("找不到记录");
  1295. }
  1296. }
  1297. public void upd_erp_ordertag_cancel()
  1298. {
  1299. if (UrlPostParmsCheck("ctid"))
  1300. {
  1301. string eid = GetPostString("ctid");
  1302. CeErpTradeCell entity = null;
  1303. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1304. if (entity != null)
  1305. {
  1306. entity.wechatTag = 0;
  1307. entity.Update();
  1308. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1309. if (pers != null)
  1310. {
  1311. pers.status = "取消推购";
  1312. pers.audit_type = 3;
  1313. pers.Update();
  1314. }
  1315. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1316. returnSuccessMsg("标记成功!");
  1317. return;
  1318. }
  1319. returnErrorMsg("找不到记录");
  1320. }
  1321. }
  1322. public void upd_erp_addweichattag()
  1323. {
  1324. if (UrlPostParmsCheck("ctid"))
  1325. {
  1326. ;
  1327. string eid = GetPostString("ctid");
  1328. CeErpTradeCell entity = null;
  1329. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1330. if (entity != null)
  1331. {
  1332. if (entity.IsAddWechat > 0)
  1333. {
  1334. returnErrorMsg("此单已经标记过了");
  1335. return;
  1336. }
  1337. 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);
  1338. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1339. if (dt.Rows.Count > 0)
  1340. {
  1341. entity.IsAddWechat = 2;
  1342. }
  1343. else
  1344. {
  1345. entity.IsAddWechat = 1;
  1346. }
  1347. entity.Update();
  1348. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1349. returnSuccessMsg("标记成功!");
  1350. return;
  1351. }
  1352. returnErrorMsg("找不到记录");
  1353. }
  1354. }
  1355. public void upd_erp_getmyorder()
  1356. {
  1357. if (UrlPostParmsCheck("ctid"))
  1358. {
  1359. string eid = GetPostString("ctid");
  1360. CeErpTradeCell entity = null;
  1361. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1362. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1363. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1364. {
  1365. returnErrorMsg("台湾客户需填写身份证号!");
  1366. return;
  1367. }
  1368. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1369. {
  1370. returnErrorMsg("偏远地区需要填写物流费!");
  1371. return;
  1372. }
  1373. if (entity != null)
  1374. {
  1375. if (entity.ctid.IndexOf("C") != -1)
  1376. {
  1377. StringBuilder sql = new StringBuilder();
  1378. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1379. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1380. if (dt.Rows.Count > 0)
  1381. {
  1382. decimal total = 0;
  1383. foreach (DataRow dr in dt.Rows)
  1384. {
  1385. total += Convert.ToDecimal(dr["payment"]);
  1386. }
  1387. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1388. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1389. {
  1390. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1391. return;
  1392. }
  1393. }
  1394. }
  1395. if (entity.OrderState == -1)
  1396. {
  1397. returnErrorMsg("待审核订单无法领取!");
  1398. return;
  1399. }
  1400. entity.CustomerUserId = CurrentUser.UserID;
  1401. if (entity.OrderState < 2)
  1402. {
  1403. entity.OrderState = 2;
  1404. if (entity.ShopId != 0)
  1405. {
  1406. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1407. }
  1408. }
  1409. entity.UpdateTime = DateTime.Now;
  1410. entity.Update();
  1411. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1412. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1413. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1414. {
  1415. //dataHelper.api_orderBack(entity.ctid, "0", "");
  1416. }
  1417. returnSuccessMsg("领单成功!");
  1418. return;
  1419. }
  1420. returnErrorMsg("找不到记录");
  1421. }
  1422. }
  1423. public void getmyorder_from_init()
  1424. {
  1425. if (UrlPostParmsCheck("ctid"))
  1426. {
  1427. string eid = GetPostString("ctid");
  1428. CeErpTradeCell entity = null;
  1429. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1430. if (entity != null)
  1431. {
  1432. string sellerMemo = GetPostString("sellerMemo");
  1433. if (sellerMemo.Length > 0)
  1434. {
  1435. entity.seller_memo = sellerMemo;
  1436. }
  1437. string oterhMemo = GetPostString("otherMemo");
  1438. if (oterhMemo.Length > 0)
  1439. {
  1440. entity.OtherMemo = oterhMemo;
  1441. }
  1442. int urg = GetPostInt("urgency");
  1443. entity.IsUrgency = (urg == 1 ? true : false);
  1444. int wechat = GetPostInt("wechat");
  1445. int command = GetPostInt("command");
  1446. if (wechat == 1)
  1447. {
  1448. entity.wechatTag = 1;
  1449. }
  1450. if (command == 1)
  1451. {
  1452. entity.wechatTag = 2;
  1453. }
  1454. string pPro = GetPostString("pprofession");
  1455. if (pPro.Length > 0)
  1456. {
  1457. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1458. string spro = GetPostString("profession");
  1459. if (spro.Length > 0)
  1460. {
  1461. entity.ProfessionId = Convert.ToInt32(spro);
  1462. }
  1463. }
  1464. string proId = GetPostString("productId");
  1465. if (proId.Length > 0)
  1466. {
  1467. entity.ProductId = Convert.ToInt32(proId);
  1468. }
  1469. entity.Material = GetPostString("material");
  1470. entity.Craft = GetPostString("craft");
  1471. entity.CustomerUserId = CurrentUser.UserID;
  1472. if (entity.OrderState < 2)
  1473. {
  1474. entity.OrderState = 2;
  1475. if (entity.ShopId != 0)
  1476. {
  1477. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1478. }
  1479. }
  1480. entity.Update();
  1481. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1482. returnSuccessMsg("领单成功!");
  1483. return;
  1484. }
  1485. returnErrorMsg("找不到记录");
  1486. }
  1487. }
  1488. public void upd_erp_setrelationorder()
  1489. {
  1490. if (UrlPostParmsCheck("ctid"))
  1491. {
  1492. ;
  1493. string eid = GetPostString("ctid");
  1494. string ftid = GetPostString("ftid");
  1495. CeErpTradeCell entity = null;
  1496. CeErpTradeCell fentity = null;
  1497. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1498. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1499. if (fentity == null)
  1500. {
  1501. returnErrorMsg("找不到关联的主订单");
  1502. return;
  1503. }
  1504. if (entity != null)
  1505. {
  1506. if (entity.OrderState >= 5)
  1507. {
  1508. returnErrorMsg("本单已经设计完成无法关联");
  1509. return;
  1510. }
  1511. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1512. {
  1513. returnErrorMsg("线下单续审核后才能关联!");
  1514. return;
  1515. }
  1516. entity.ptid = ftid;
  1517. entity.OrderState = fentity.OrderState;
  1518. //entity.status = fentity.status;
  1519. entity.CustomerUserId = fentity.CustomerUserId;
  1520. entity.DesignUserId = fentity.DesignUserId;
  1521. entity.seller_memo = "补差价单:" + ftid;
  1522. entity.IsSample = 2;
  1523. entity.Update();
  1524. ApiVo apiVo = new ApiVo();
  1525. apiVo.orderNumber = ftid;
  1526. apiVo.payment = entity.payment;
  1527. apiVo.actionName = "repairDesign";
  1528. designHelper.API_WorkCore(apiVo);//repairDesign
  1529. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1530. returnSuccessMsg("关联成功!");
  1531. return;
  1532. }
  1533. else
  1534. returnErrorMsg("找不到记录");
  1535. }
  1536. }
  1537. public void download_erp_neworder()
  1538. {
  1539. string seller = GetPostString("seller_nick");
  1540. string tid = GetPostString("tid");
  1541. if (seller.Length <= 0 || tid.Length <= 0)
  1542. {
  1543. returnErrorMsg("数据错误");
  1544. }
  1545. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1546. //{
  1547. // returnErrorMsg("找不到店铺Sessionkey");
  1548. //}
  1549. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1550. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1551. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1552. if (res.IndexOf("refOid") == -1)
  1553. {
  1554. returnErrorMsg("下载订单数据失败");
  1555. return;
  1556. }
  1557. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1558. returnSuccessMsg("下载完成");
  1559. //tmcHelper.createNewOrder(res);
  1560. //CeErpTrade entr = null;
  1561. //entr = CeErpTrade.Get(tid);
  1562. //if (entr != null)
  1563. //{
  1564. // returnSuccess("下载成功");
  1565. // //下载成功之后,Cell表生成对应的订单;
  1566. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1567. //}
  1568. //else
  1569. //{
  1570. // returnErrorMsg("下载失败或者创建订单失败");
  1571. //}
  1572. }
  1573. public void set_erp_atersale()
  1574. {
  1575. if (UrlPostParmsCheck("ctid"))
  1576. {
  1577. string eid = GetPostString("ctid");
  1578. string reason = GetPostString("AfterSaleReason");
  1579. CeErpTradeCell entity = null;
  1580. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1581. if (entity != null)
  1582. {
  1583. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1584. {
  1585. returnErrorMsg("此订单已经在售后");
  1586. return;
  1587. }*/
  1588. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1589. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1590. entity.AfterSaleTime = DateTime.Now;
  1591. entity.HandleTime = null;
  1592. entity.Update();
  1593. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1594. returnSuccessMsg("转售后成功!");
  1595. return;
  1596. }
  1597. returnErrorMsg("找不到记录");
  1598. }
  1599. }
  1600. public void set_erp_withdraw()
  1601. {
  1602. if (UrlPostParmsCheck("ctid"))
  1603. {
  1604. try
  1605. {
  1606. string eid = GetPostString("ctid");//商品id
  1607. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1608. CeWithdraw ceWithdrawSelect = null;
  1609. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1610. if (ceWithdrawSelect != null)
  1611. {
  1612. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1613. {
  1614. ceWithdrawSelect.status = -1;
  1615. ceWithdrawSelect.Update();
  1616. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1617. returnSuccessMsg("重新发起审核成功");
  1618. return;
  1619. }
  1620. else
  1621. {
  1622. returnSuccessMsg("请勿重复申请!");
  1623. return;
  1624. }
  1625. }
  1626. else
  1627. {
  1628. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1629. if (string.IsNullOrEmpty(CustomerUserId))
  1630. {
  1631. CustomerUserId = "-1";
  1632. }
  1633. int Userid = CurrentUser.UserID;//用户id
  1634. CeWithdraw ceWithdraw = new CeWithdraw();
  1635. ceWithdraw.tid = eid;
  1636. ceWithdraw.userid = Userid;
  1637. ceWithdraw.providerid = CustomerUserId;
  1638. ceWithdraw.status = 3;
  1639. ceWithdraw.creationtime = DateTime.Now;
  1640. ceWithdraw.Create();
  1641. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1642. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1643. return;
  1644. }
  1645. }
  1646. catch
  1647. {
  1648. returnErrorMsg("申请撤回订单失败");
  1649. return;
  1650. }
  1651. }
  1652. }
  1653. public void ins_erp_billinfo()
  1654. {
  1655. if (UrlPostParmsCheck("ctid"))
  1656. {
  1657. string eid = GetPostString("ctid");
  1658. CeErpTradeCell entity = null;
  1659. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1660. if (entity != null)
  1661. {
  1662. CeErpBill bill = CeErpBill.GetByTid(eid);
  1663. bool isHave = false;
  1664. if (bill != null)
  1665. {
  1666. isHave = true;
  1667. if (bill.state != 4)
  1668. {
  1669. returnErrorMsg("此单已经申请过发票了");
  1670. return;
  1671. }
  1672. }
  1673. if (entity.IsNeedBill == 0)
  1674. {
  1675. entity.IsNeedBill = 1;
  1676. }
  1677. entity.Update();
  1678. string errjson = "";
  1679. try
  1680. {
  1681. CeErpBill bill_entity = new CeErpBill();
  1682. bill_entity.tid = entity.tid;
  1683. bill_entity.title = GetPostString("title");
  1684. string taxstr = GetPostString("tax");
  1685. taxstr = taxstr.Replace(" ", "");
  1686. bill_entity.tax = taxstr;
  1687. bill_entity.bank = GetPostString("bank");
  1688. string bankacstr = GetPostString("bankac");
  1689. bankacstr = bankacstr.Replace(" ", "");
  1690. bill_entity.bankac = bankacstr;
  1691. bill_entity.address = GetPostString("address");
  1692. bill_entity.phone = GetPostString("phone");
  1693. bill_entity.price = GetPostString("price");
  1694. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1695. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1696. {
  1697. billCount += 1;
  1698. }
  1699. string prebill = "ltb";
  1700. for (int idx = 1; idx <= 1; idx++)
  1701. {
  1702. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1703. string billoid = prebill + idx + dtstr;
  1704. bill_entity.billOrderId += billoid;
  1705. if (idx < billCount)
  1706. {
  1707. bill_entity.billOrderId += ",";
  1708. }
  1709. }
  1710. bill_entity.productId = GetPostInt("ProductName");
  1711. bill_entity.num = GetPostInt("num");
  1712. bill_entity.unit = GetPostString("unit");
  1713. bill_entity.type = GetPostString("type");
  1714. bill_entity.sendType = GetPostString("SendType");
  1715. bill_entity.email = GetPostString("email");
  1716. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1717. bill_entity.shopName = GetPostString("ShopName");
  1718. bill_entity.applymemo = GetPostString("applyMemo");
  1719. bill_entity.createTime = DateTime.Now;
  1720. bill_entity.state = 0;
  1721. bill_entity.userId = CurrentUser.UserID;
  1722. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1723. bill_entity.Create();
  1724. }
  1725. catch (Exception ex)
  1726. {
  1727. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1728. returnErrorMsg("创建发票出错!");
  1729. return;
  1730. }
  1731. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1732. returnSuccessMsg("发票申请成功!");
  1733. return;
  1734. }
  1735. returnErrorMsg("找不到记录");
  1736. }
  1737. }
  1738. public void ins_erp_neworder()
  1739. {
  1740. if (UrlPostParmsCheck("receiver_name"))
  1741. {
  1742. CeErpTrade entity = new CeErpTrade();
  1743. string plat_form = GetPostString("platform");
  1744. string preStr = "N_";
  1745. if (plat_form == "拼多多")
  1746. {
  1747. preStr = "P_";
  1748. }
  1749. else if (plat_form == "阿里巴巴")
  1750. {
  1751. preStr = "A_";
  1752. }
  1753. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1754. entity.seller_nick = GetPostString("seller_nick");
  1755. entity.buyer_nick = GetPostString("buyer_nick");
  1756. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1757. entity.total_fee = entity.payment;
  1758. entity.pay_time = DateTime.Now;
  1759. entity.status = "NOT_SHIPPED";
  1760. entity.receiver_name = GetPostString("receiver_name");
  1761. entity.receiver_mobile = GetPostString("receiver_mobile");
  1762. entity.receiver_state = GetPostString("receiver_state");
  1763. entity.receiver_city = GetPostString("receiver_city");
  1764. entity.receiver_district = GetPostString("receiver_district");
  1765. entity.receiver_address = GetPostString("receiver_address");
  1766. if (entity.receiver_state == "" || entity.receiver_city == "")
  1767. {
  1768. returnErrorMsg("收件地址不能为空");
  1769. return;
  1770. }
  1771. int shopId = 0;
  1772. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1773. if (nShop != null)
  1774. {
  1775. shopId = nShop.ID;
  1776. }
  1777. if (shopId != 34 && entity.payment == 0)
  1778. {
  1779. returnErrorMsg("公司自用的单金额才能为0");
  1780. return;
  1781. }
  1782. entity.Create();
  1783. CeErpTradeCell entitycell = new CeErpTradeCell();
  1784. entitycell.ctid = entity.tid;
  1785. entitycell.tid = entity.tid;
  1786. entitycell.ShopId = shopId;
  1787. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1788. entitycell.OrderState = 0;
  1789. entitycell.pay_time = entity.pay_time;
  1790. entitycell.IsOffLineOrder = 1;
  1791. entitycell.Create();
  1792. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1793. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1794. return;
  1795. }
  1796. }
  1797. public void ins_erp_neworder2()
  1798. {
  1799. if (UrlPostParmsCheck("receiver_name"))
  1800. {
  1801. //string plat_form = GetPostString("platform");
  1802. string preStr = "X_";
  1803. string memo = GetPostString("memo");
  1804. string productId = GetPostString("productId");
  1805. string primg = GetPostString("proofimg");
  1806. string sellerNick = GetPostString("seller_nick");
  1807. string addFrom = GetPostString("addfrom");
  1808. if (addFrom == "1")
  1809. {
  1810. preStr = "N_";
  1811. }
  1812. int shopId = 0;
  1813. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1814. if (nShop != null)
  1815. {
  1816. shopId = nShop.ID;
  1817. }
  1818. else
  1819. {
  1820. returnErrorMsg("找不到对应店铺");
  1821. return;
  1822. }
  1823. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1824. {
  1825. returnErrorMsg("必须上传付款凭证");
  1826. return;
  1827. }
  1828. CeErpTrade entity = new CeErpTrade();
  1829. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1830. entity.seller_nick = sellerNick;
  1831. entity.buyer_nick = GetPostString("buyer_nick");
  1832. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1833. entity.total_fee = entity.payment;
  1834. entity.pay_time = DateTime.Now;
  1835. entity.status = "NOT_SHIPPED";
  1836. entity.receiver_name = GetPostString("receiver_name");
  1837. entity.receiver_mobile = GetPostString("receiver_mobile");
  1838. entity.receiver_state = GetPostString("receiver_state");
  1839. entity.receiver_city = GetPostString("receiver_city");
  1840. entity.receiver_district = GetPostString("receiver_district");
  1841. entity.receiver_address = GetPostString("receiver_address");
  1842. entity.seller_memo = memo;
  1843. entity.orderFrom = 20;
  1844. entity.orderType = 15;
  1845. if (entity.receiver_state == "" || entity.receiver_city == "")
  1846. {
  1847. returnErrorMsg("收件地址不能为空");
  1848. return;
  1849. }
  1850. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1851. {
  1852. returnErrorMsg("公司自用的单金额才能为0");
  1853. return;
  1854. }
  1855. entity.Create();
  1856. string toWhere = GetPostString("towhere");
  1857. string oldOrder = GetPostString("oldOrder");
  1858. CeErpTradeCell entitycell = new CeErpTradeCell();
  1859. entitycell.ctid = entity.tid;
  1860. //唯一标识
  1861. entitycell.OrderSn = entity.tid;
  1862. string orderSn = commonHelper.generateDateTimeRandomNos();
  1863. if (orderSn != "")
  1864. {
  1865. entitycell.OrderSn = orderSn;
  1866. }
  1867. entitycell.tid = entity.tid;
  1868. //if (preStr == "X_")
  1869. //{
  1870. entitycell.IsOffLineOrder = 1;
  1871. if ("1".Equals(oldOrder))
  1872. {
  1873. entitycell.IsOldCustomer = 1;
  1874. }
  1875. //}
  1876. entitycell.CustomerUserId = CurrentUser.UserID;
  1877. entitycell.PayProofImg = primg;
  1878. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1879. entitycell.ProductId = Convert.ToInt32(productId);
  1880. entitycell.ShopId = shopId;
  1881. entitycell.UpdateTime = DateTime.Now;
  1882. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1883. if (entitycell.ProductId > 0)
  1884. {
  1885. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1886. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1887. {
  1888. entitycell.NewProduct = 1;
  1889. }
  1890. }
  1891. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1892. {
  1893. entitycell.IsXianHuo = 1;
  1894. }
  1895. entitycell.pay_time = entity.pay_time;
  1896. if (toWhere == "1")
  1897. {
  1898. entitycell.OrderState = 2;
  1899. }
  1900. else
  1901. {
  1902. entitycell.OrderState = 6;
  1903. entitycell.FinishPlaceTime = entitycell.pay_time;
  1904. }
  1905. if (shopId == 94)
  1906. {
  1907. entitycell.OrderState = 4;
  1908. entitycell.WaitDesignTime = entitycell.pay_time;
  1909. entitycell.StartDesignTime = entitycell.pay_time;
  1910. entitycell.DesignUserId = 218;
  1911. }
  1912. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114 && shopId != 158))
  1913. {
  1914. entitycell.OrderState = -1;//修改12-5
  1915. CeWithdraw ceWithdraw = new CeWithdraw();
  1916. ceWithdraw.tid = entity.tid;
  1917. ceWithdraw.providerid = "-1";
  1918. ceWithdraw.status = -1;
  1919. ceWithdraw.creationtime = DateTime.Now;
  1920. ceWithdraw.userid = 4634;
  1921. ceWithdraw.Create();
  1922. }
  1923. entitycell.Create();
  1924. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1925. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1926. {
  1927. addPlaceRegist(entitycell, CurrentUser.UserID);
  1928. }
  1929. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1930. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1931. return;
  1932. }
  1933. }
  1934. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1935. {
  1936. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1937. entity.PlactTime = tradecell.pay_time;
  1938. entity.AddUserId = userid;
  1939. entity.FileName = tradecell.seller_memo;
  1940. entity.Supplier = 24;
  1941. entity.CreateTime = DateTime.Now;
  1942. entity.Did = tradecell.ctid;
  1943. entity.tid = tradecell.tid;
  1944. entity.splitTag = tradecell.SplitTag;
  1945. entity.CurState = "未完成";
  1946. entity.Create();
  1947. }
  1948. public void get_erp_offlinelist()
  1949. {
  1950. DataStruct dStruct = GetPostStruct();
  1951. List<string> lw = new List<string>();
  1952. string tid = GetPostString("ctid");
  1953. string date1 = GetPostString("date1");
  1954. string date2 = GetPostString("date2");
  1955. if (tid.Length > 0 || date1.Length > 0)
  1956. {
  1957. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1958. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1959. if (dw.Length > 0) lw.Add(dw);
  1960. }
  1961. else
  1962. {
  1963. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1964. }
  1965. string shopname = GetPostString("shopname");
  1966. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1967. string buyernick = GetPostString("buyer_nick");
  1968. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1969. string customer = GetPostString("customer");
  1970. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1971. string design = GetPostString("design");
  1972. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1973. string orderState = GetPostString("orderState");
  1974. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1975. string address = GetPostString("address");
  1976. 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));
  1977. string sellermemo = GetPostString("seller_memo");
  1978. if (sellermemo.Length > 0)
  1979. {
  1980. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1981. }
  1982. string price1 = GetPostString("price1");
  1983. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1984. string price2 = GetPostString("price2");
  1985. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1986. //if (PKey != "admin")
  1987. //{
  1988. // string usershop = CurrentUser.User.pemShop;
  1989. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1990. //}
  1991. //if (ex_psize > 0)
  1992. //{
  1993. dStruct.Order = "pay_time desc";
  1994. //}
  1995. //else
  1996. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1997. lw.Add(string.Format("IsOffLineOrder=1"));
  1998. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1999. DataTable dt = null;
  2000. dt = WebCache.GetData("view_erptradecell", dStruct);
  2001. writeGridDataTableJson(dStruct.TotalCount, dt);
  2002. }
  2003. public void get_erp_returncashrecord()
  2004. {
  2005. DataStruct dStruct = GetPostStruct();
  2006. List<string> lw = new List<string>();
  2007. string tid = GetPostString("ctid");
  2008. if (tid.Length > 0)
  2009. {
  2010. lw.Add(string.Format("tid like '%{0}%'", tid));
  2011. dStruct.Order = "id desc";
  2012. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2013. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2014. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2015. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2016. return;
  2017. }
  2018. returnErrorMsg("id数据错误!");
  2019. }
  2020. public void ins_erp_returncashrecord()
  2021. {
  2022. if (UrlPostParmsCheck("tid"))
  2023. {
  2024. string tid = GetPostString("tid");
  2025. string retype = GetPostString("type");
  2026. StringBuilder sql = new StringBuilder();
  2027. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2028. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2029. if (dt.Rows.Count > 0)
  2030. {
  2031. returnErrorMsg("相同返现类型记录已存在");
  2032. return;
  2033. }
  2034. CeErpReturnCash entity = new CeErpReturnCash();
  2035. entity.tid = tid;
  2036. entity.seller_nick = GetPostString("seller_nick");
  2037. string pment = GetPostString("payment");
  2038. if (pment.Length > 0)
  2039. {
  2040. entity.payment = Convert.ToDouble(pment);
  2041. }
  2042. entity.buyer_nick = GetPostString("buyer_nick");
  2043. entity.cashstate = 0;
  2044. entity.rtype = retype;
  2045. string rPrice = GetPostString("returnprice");
  2046. if (rPrice.Length > 0)
  2047. {
  2048. entity.returnprice = Convert.ToDouble(rPrice);
  2049. }
  2050. entity.created = DateTime.Now;
  2051. entity.con = GetPostString("con");
  2052. entity.img = GetPostString("img");
  2053. entity.applyuserid = CurrentUser.UserID;
  2054. entity.Create();
  2055. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2056. returnSuccessMsg("操作成功!");
  2057. return;
  2058. }
  2059. }
  2060. public void set_erp_predelivery()
  2061. {
  2062. if (UrlPostParmsCheck("ctid"))
  2063. {
  2064. string eid = GetPostString("ctid");
  2065. CeErpTradeCell entity = null;
  2066. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2067. if (entity != null)
  2068. {
  2069. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2070. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2071. //{
  2072. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2073. // return;
  2074. //}
  2075. entity.IsPreDelivery = 1;
  2076. entity.Update();
  2077. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2078. returnSuccessMsg("预发货成功!");
  2079. return;
  2080. //string shop = GetPostString("seller_nick");
  2081. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2082. //string comName = GetPostString("comName");
  2083. //string comCode = GetPostString("comCode");
  2084. //string outSid = GetPostString("outSid");//运单号
  2085. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2086. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2087. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2088. //string apires = "";
  2089. //if (deliveryType == "虚拟发货")
  2090. //{
  2091. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2092. //}
  2093. //else
  2094. //{
  2095. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2096. //}
  2097. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2098. ////{
  2099. //if (apires.IndexOf("发货成功") != -1)
  2100. //{
  2101. // if (deliveryType != "虚拟发货")
  2102. // {
  2103. // //还要插入快递信息到 快递信息表
  2104. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2105. // exinfo.tid = eid;
  2106. // exinfo.out_sid = outSid;
  2107. // exinfo.company_code = comCode;
  2108. // exinfo.company_name = comName;
  2109. // exinfo.delivery_memo = deliveryMemo;
  2110. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2111. // exinfo.deliveryType = deliveryType;
  2112. // exinfo.Create();
  2113. // }
  2114. // returnSuccessMsg("发货成功!");
  2115. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2116. //}
  2117. //else
  2118. //{
  2119. // returnErrorMsg("淘宝发货失败!!");
  2120. //}
  2121. //return;
  2122. }
  2123. returnErrorMsg("找不到订单记录");
  2124. }
  2125. }
  2126. public void get_erp_unusuallist()
  2127. {
  2128. DataStruct dStruct = GetPostStruct();
  2129. List<string> lw = new List<string>();
  2130. string tid = GetPostString("ctid");
  2131. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2132. string shopname = GetPostString("shopname");
  2133. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2134. string buyernick = GetPostString("buyer_nick");
  2135. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2136. string ResponsibleMan = GetPostString("responsible");
  2137. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2138. string date1 = GetPostString("date1");
  2139. string date2 = GetPostString("date2");
  2140. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2141. if (dw.Length > 0) lw.Add(dw);
  2142. string price1 = GetPostString("price1");
  2143. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2144. string price2 = GetPostString("price2");
  2145. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2146. string orderState = GetPostString("orderState");
  2147. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2148. string sellermemo = GetPostString("seller_memo");
  2149. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2150. lw.Add(string.Format("UnusualTag > 0"));
  2151. lw.Add(string.Format("IsRefund<={0}", 1));
  2152. dStruct.Order = "pay_time desc";
  2153. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2154. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2155. writeGridDataTableJson(dStruct.TotalCount, dt);
  2156. }
  2157. public void set_erp_unusualtonomal()
  2158. {
  2159. if (UrlPostParmsCheck("ctid"))
  2160. {
  2161. string eid = GetPostString("ctid");
  2162. CeErpTradeCell entity = null;
  2163. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2164. if (entity != null)
  2165. {
  2166. entity.UnusualTag = -1;
  2167. entity.Update();
  2168. returnSuccessMsg("忽略成功!");
  2169. return;
  2170. }
  2171. returnErrorMsg("找不到记录");
  2172. }
  2173. }
  2174. public void ins_erp_unusualreason()
  2175. {
  2176. if (UrlPostParmsCheck("ctid"))
  2177. {
  2178. string eid = GetPostString("ctid");
  2179. CeErpTradeCell entity = null;
  2180. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2181. if (entity != null)
  2182. {
  2183. entity.MemoOpt = 4;
  2184. entity.UnusualCon = GetPostString("con");
  2185. entity.Update();
  2186. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2187. if (trade != null)
  2188. {
  2189. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2190. }
  2191. //查货是否超时
  2192. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2193. if (ceErpTradeCellExtend == null)
  2194. {
  2195. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2196. ceErpTradeCellExtend.ctid = entity.ctid;
  2197. }
  2198. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2199. {
  2200. ceErpTradeCellExtend.CheckOut += 1;
  2201. }
  2202. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2203. if (ceErpTradeCellExtend.ID > 0)
  2204. {
  2205. ceErpTradeCellExtend.Update();
  2206. }
  2207. else
  2208. {
  2209. ceErpTradeCellExtend.Create();
  2210. }
  2211. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2212. returnSuccessMsg("操作成功!");
  2213. return;
  2214. }
  2215. returnErrorMsg("找不到记录");
  2216. }
  2217. }
  2218. public void upd_erp_sampleorder()
  2219. {
  2220. if (UrlPostParmsCheck("ctid"))
  2221. {
  2222. string eid = GetPostString("ctid");
  2223. string[] eArr = eid.Split(',');
  2224. if (eArr.Length > 1)
  2225. {
  2226. List<string> eLst = new List<string>();
  2227. for (int i = 0; i < eArr.Length; i++)
  2228. {
  2229. eLst.Add("'" + eArr[i] + "'");
  2230. }
  2231. eid = string.Join(",", eLst.ToArray());
  2232. }
  2233. else
  2234. {
  2235. eid = "'" + eid + "'";
  2236. }
  2237. StringBuilder sql = new StringBuilder();
  2238. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2239. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2240. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2241. if (dt.Rows.Count > 0)
  2242. {
  2243. string errmsg = "";
  2244. foreach (DataRow dr in dt.Rows)
  2245. {
  2246. StringBuilder sqlsb = new StringBuilder();
  2247. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2248. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2249. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2250. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2251. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2252. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2253. {
  2254. continue;
  2255. }
  2256. else
  2257. {
  2258. string emsg = commonHelper.KeepChinese(apires);
  2259. errmsg += emsg;
  2260. }*/
  2261. }
  2262. if (errmsg.Length > 0)
  2263. {
  2264. returnErrorMsg(errmsg);
  2265. return;
  2266. }
  2267. returnSuccessMsg("操作成功");
  2268. return;
  2269. }
  2270. returnErrorMsg("找不到记录");
  2271. }
  2272. }
  2273. public void upd_erp_transcustomer()
  2274. {
  2275. if (UrlPostParmsCheck("ctid"))
  2276. {
  2277. string eid = GetPostString("ctid");
  2278. int userid = GetPostInt("CustomerUserId");
  2279. CeErpTradeCell entity = null;
  2280. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2281. if (entity != null)
  2282. {
  2283. //string[] mlist = entity.seller_memo.Split('-');
  2284. //string sql = "select * from view_erpuser where id=" + userid;
  2285. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2286. //if (dt != null && dt.Rows.Count > 0)
  2287. //{
  2288. // string nmemo = "";
  2289. // for(int i = 0; i < mlist.Length - 1; i++)
  2290. // {
  2291. // nmemo += mlist[i];
  2292. // nmemo += "-";
  2293. // }
  2294. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2295. // entity.seller_memo = nmemo;
  2296. //}
  2297. entity.CustomerUserId = userid;
  2298. entity.Update();
  2299. returnSuccessMsg("操作成功!");
  2300. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2301. return;
  2302. }
  2303. returnErrorMsg("找不到记录");
  2304. }
  2305. }
  2306. public void upd_erp_transdesigner()
  2307. {
  2308. if (UrlPostParmsCheck("ctid"))
  2309. {
  2310. string eids = GetPostString("ctid");
  2311. string[] ctidList = eids.Split(',');
  2312. int userid = GetPostInt("DesignUserId");
  2313. foreach (string ctid in ctidList)
  2314. {
  2315. CeErpTradeCell entity = null;
  2316. CeErpDesignerBill entitys = null;
  2317. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2318. entitys = CeErpDesignerBill.GetByTid(ctid);
  2319. if (entity != null)
  2320. {
  2321. if (entity.OrderState > 4)
  2322. {
  2323. continue;
  2324. }
  2325. //存在退款不能流转
  2326. if (entity.IsRefund > 0)
  2327. {
  2328. continue;
  2329. }
  2330. entity.DesignUserId = userid;
  2331. entity.WaitDesignTime = DateTime.Now;
  2332. entity.Update();
  2333. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2334. }
  2335. }
  2336. returnSuccessMsg("操作成功!");
  2337. }
  2338. }
  2339. public void upd_erp_distributedesigner()
  2340. {
  2341. if (UrlPostParmsCheck("ctid"))
  2342. {
  2343. string eid = GetPostString("ctid");
  2344. int userid = GetPostInt("DesignUserId");
  2345. string[] idlist = eid.Split(',');
  2346. if (idlist.Length <= 0)
  2347. {
  2348. returnErrorMsg("订单不能为空");
  2349. return;
  2350. }
  2351. foreach (string ctid in idlist)
  2352. {
  2353. CeErpTradeCell entity = null;
  2354. CeErpDesignerBill entitys = null;
  2355. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2356. else continue;
  2357. if (entity != null)
  2358. {
  2359. if (userid == 2125 || userid == 3542)
  2360. { }
  2361. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2362. {
  2363. returnErrorMsg("金额错误的订单无法指派");
  2364. return;
  2365. }
  2366. if (entity.OrderState >= 5)
  2367. {
  2368. returnErrorMsg("已经设计完成无法指派");
  2369. return;
  2370. }
  2371. if (entity.OrderState == -1)
  2372. {
  2373. returnErrorMsg("审核中的订单无法指派");
  2374. return;
  2375. }
  2376. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2377. {
  2378. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2379. return;
  2380. }
  2381. //157赖橙帆 159林晨 73 静之颖
  2382. 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 && CurrentUser.UserID != 73)
  2383. {
  2384. returnErrorMsg("指派设计共创无法再次指派!");
  2385. return;
  2386. }
  2387. entity.OrderState = 3;
  2388. if (entity.SupplierId == 0)
  2389. {
  2390. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2391. entity.SupplierId = suid;
  2392. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2393. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2394. }
  2395. if (userid == 2125 && entity.seller_memo != "")
  2396. {
  2397. //apiDesign.API_GetPrintData_CreateOrder(entity);
  2398. }
  2399. List<int> shopIds = new List<int>() { 17, 21, 52, 54, 64, 63, 66, 49, 67, 105, 35, 57, 53, 65, 87, 140, 26, 45, 2, 77, 122, 121, 153, 154, 158 };
  2400. if (userid == 3542 && entity.seller_memo != "")
  2401. {
  2402. string userPost = CurrentUser.UserPost.Post.Code;
  2403. if (CurrentUser.UserID == 4516 || CurrentUser.UserID == 73 || shopIds.Contains(entity.ShopId))
  2404. {
  2405. userPost = "SysAdmin";
  2406. }
  2407. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2408. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2409. if (response.msg != "设计共创:成功")
  2410. {
  2411. returnErrorMsg(response.msg);
  2412. return;
  2413. }
  2414. entity.DispatchSort = 2;
  2415. }
  2416. else
  2417. {
  2418. if (entity.DispatchSort == 2)
  2419. {
  2420. ApiVo apiVo = new ApiVo();
  2421. apiVo.actionName = "closeDesign";
  2422. apiVo.orderNumber = entity.ctid;
  2423. designHelper.API_WorkCore(apiVo);//closeDesign
  2424. }
  2425. entity.DispatchSort = 0;
  2426. }
  2427. entity.DesignUserId = userid;
  2428. entity.WaitDesignTime = DateTime.Now;
  2429. entity.UpdateTime = DateTime.Now;
  2430. entity.Update();
  2431. string name = commonHelper.getUserNameById(userid);
  2432. commonHelper.UpdateRelationOrder(entity.ctid);
  2433. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2434. }
  2435. }
  2436. returnSuccessMsg("操作成功!");
  2437. return;
  2438. }
  2439. }
  2440. public string getTidByCtid(string ctid)
  2441. {
  2442. string tid = "";
  2443. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2444. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2445. if (dataTable != null && dataTable.Rows.Count > 0)
  2446. {
  2447. tid = dataTable.Rows[0]["tid"].ToString();
  2448. }
  2449. return tid;
  2450. }
  2451. public List<string> getTidByCtidMore(string ctid)
  2452. {
  2453. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2454. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2455. List<string> list = new List<string>();
  2456. if (dataTable != null && dataTable.Rows.Count > 0)
  2457. {
  2458. foreach (DataRow item in dataTable.Rows)
  2459. {
  2460. list.Add("'" + item["tid"].ToString() + "'");
  2461. }
  2462. }
  2463. return list;
  2464. }
  2465. public List<string> getTidByCtidLike(string ctid)
  2466. {
  2467. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2468. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2469. List<string> list = new List<string>();
  2470. if (dataTable != null && dataTable.Rows.Count > 0)
  2471. {
  2472. foreach (DataRow item in dataTable.Rows)
  2473. {
  2474. list.Add("'" + item["tid"].ToString() + "'");
  2475. }
  2476. }
  2477. return list;
  2478. }
  2479. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2480. {
  2481. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2482. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2483. List<string> list = new List<string>();
  2484. if (dataTable != null && dataTable.Rows.Count > 0)
  2485. {
  2486. foreach (DataRow item in dataTable.Rows)
  2487. {
  2488. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2489. {
  2490. continue;
  2491. }
  2492. list.Add("'" + item["receiverId"].ToString() + "'");
  2493. }
  2494. }
  2495. return list;
  2496. }
  2497. public void get_erp_myorderlist()
  2498. {
  2499. DataStruct dStruct = GetPostStruct();
  2500. List<string> lw = new List<string>();
  2501. string tid = GetPostString("ctid");
  2502. if (tid.Length > 0)
  2503. {
  2504. string select_tid = getTidByCtid(tid);
  2505. lw.Add(string.Format("tid='{0}'", select_tid));
  2506. }
  2507. else
  2508. {
  2509. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2510. }
  2511. //12-1 修改
  2512. string urgent = GetPostString("urgent");
  2513. string back = GetPostString("back");
  2514. string offlineSearch = GetPostString("offlineSearch");
  2515. if (!string.IsNullOrWhiteSpace(urgent))
  2516. {
  2517. if (urgent.Equals("true"))
  2518. {
  2519. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2520. }
  2521. }
  2522. if (!string.IsNullOrWhiteSpace(back))
  2523. {
  2524. if (back.Equals("true"))
  2525. {
  2526. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2527. }
  2528. }
  2529. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2530. {
  2531. if (offlineSearch.Equals("true"))
  2532. {
  2533. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2534. }
  2535. }
  2536. //end
  2537. string shopname = GetPostString("shopname");
  2538. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2539. string buyernick = GetPostString("buyer_nick");
  2540. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2541. string design = GetPostString("design");
  2542. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2543. string orderState = GetPostString("orderState");
  2544. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2545. string sellermemo = GetPostString("seller_memo");
  2546. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2547. string date1 = GetPostString("date1");
  2548. string date2 = GetPostString("date2");
  2549. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2550. if (dw.Length > 0) lw.Add(dw);
  2551. string price1 = GetPostString("price1");
  2552. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2553. string price2 = GetPostString("price2");
  2554. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2555. string urgency = GetPostString("urgency");
  2556. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2557. string after = GetPostString("after");
  2558. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2559. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2560. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2561. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2563. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2564. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2565. if (dt != null && dt.Rows.Count > 0)
  2566. {
  2567. foreach (DataRow dr in dt.Rows)
  2568. {
  2569. try
  2570. {
  2571. // 对象操作
  2572. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2573. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2574. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2575. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2576. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2577. if (dStruct.PageSize != 100000)
  2578. {
  2579. if (dr["DispatchSort"].ToString() == "2")
  2580. {
  2581. dr["gongchuang"] = 200;
  2582. }
  2583. else if ("外协".Equals(dr["ToType"].ToString()))
  2584. {
  2585. dr["gongchuang"] = 200;
  2586. }
  2587. else if ("内部".Equals(dr["ToType"].ToString()))
  2588. {
  2589. dr["gongchuang"] = -1;
  2590. }
  2591. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2592. {
  2593. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2594. dr["gongchuang"] = response.code;
  2595. }
  2596. }
  2597. }
  2598. catch (NullReferenceException ex)
  2599. {
  2600. }
  2601. }
  2602. }
  2603. writeGridDataTableJson(dStruct.TotalCount, dt);
  2604. }
  2605. public void get_erp_myreturnorderlist()
  2606. {
  2607. DataStruct dStruct = GetPostStruct();
  2608. List<string> lw = new List<string>();
  2609. string tid = GetPostString("ctid");
  2610. if (tid.Length > 0)
  2611. {
  2612. string select_tid = getTidByCtid(tid);
  2613. lw.Add(string.Format("tid='{0}'", select_tid));
  2614. }
  2615. else
  2616. {
  2617. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2618. }
  2619. string shopname = GetPostString("shopname");
  2620. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2621. string buyernick = GetPostString("buyer_nick");
  2622. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2623. string design = GetPostString("design");
  2624. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2625. string orderState = GetPostString("orderState");
  2626. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2627. string sellermemo = GetPostString("seller_memo");
  2628. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2629. string date1 = GetPostString("date1");
  2630. string date2 = GetPostString("date2");
  2631. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2632. if (dw.Length > 0) lw.Add(dw);
  2633. string price1 = GetPostString("price1");
  2634. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2635. string price2 = GetPostString("price2");
  2636. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2637. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2638. {
  2639. lw.Add(string.Format("CusOrgID = 94"));
  2640. }
  2641. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2642. {
  2643. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2644. }
  2645. else
  2646. {
  2647. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2648. }
  2649. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2650. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2651. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2652. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2653. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2654. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2655. if (dt != null && dt.Rows.Count > 0)
  2656. {
  2657. foreach (DataRow dr in dt.Rows)
  2658. {
  2659. try
  2660. {
  2661. // 对象操作
  2662. if (dStruct.PageSize != 100000)
  2663. {
  2664. if (dr["DispatchSort"].ToString() == "2")
  2665. {
  2666. dr["gongchuang"] = 200;
  2667. }
  2668. else if ("外协".Equals(dr["ToType"].ToString()))
  2669. {
  2670. dr["gongchuang"] = 200;
  2671. }
  2672. else if ("内部".Equals(dr["ToType"].ToString()))
  2673. {
  2674. dr["gongchuang"] = -1;
  2675. }
  2676. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2677. {
  2678. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2679. dr["gongchuang"] = response.code;
  2680. }
  2681. }
  2682. }
  2683. catch (NullReferenceException ex)
  2684. {
  2685. // 处理空引用异常
  2686. }
  2687. }
  2688. }
  2689. writeGridDataTableJson(dStruct.TotalCount, dt);
  2690. }
  2691. public void get_erp_myorderlist_pregather()
  2692. {
  2693. string date1 = GetPostString("date1");
  2694. string date2 = GetPostString("date2");
  2695. int userId = CurrentUser.UserID; //客服id
  2696. string orderWhere = "";
  2697. List<string> lw = new List<string>();
  2698. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2699. if (dw.Length > 0) lw.Add(dw);
  2700. lw.Add(string.Format("CustomerUserId={0}", userId));
  2701. lw.Add(string.Format("OrderState<9"));
  2702. orderWhere = string.Join(" and ", lw.ToArray());
  2703. string orderWhere2 = "";
  2704. List<string> lw2 = new List<string>();
  2705. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2706. if (dw2.Length > 0) lw2.Add(dw2);
  2707. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2708. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2709. string sql = string.Format("select *" +
  2710. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2711. "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 " +
  2712. "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 " +
  2713. "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");
  2714. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2715. //writeGridDataTableJson(dt.Rows.Count, dt);
  2716. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2717. }
  2718. public void upd_erp_publishorder()
  2719. {
  2720. if (UrlPostParmsCheck("ctid"))
  2721. {
  2722. string eid = GetPostString("ctid");
  2723. CeErpTradeCell entity = null;
  2724. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2725. if (entity != null)
  2726. {
  2727. entity.OrderState = 0; //发布后,变为待抢单
  2728. entity.Update();
  2729. commonHelper.UpdateRelationOrder(entity.ctid);
  2730. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2731. returnSuccessMsg("发布成功!");
  2732. return;
  2733. }
  2734. returnErrorMsg("找不到记录");
  2735. }
  2736. }
  2737. public void get_erp_my_tiporder()
  2738. {
  2739. StringBuilder sql = new StringBuilder();
  2740. int userId = 0;
  2741. if (CurrentUser != null) userId = CurrentUser.UserID;
  2742. string posCode = CurrentUser.UserPost.Post.Code;
  2743. string isTipedAfterSaleVerify = GetPostString("af");
  2744. DataTable dt = new DataTable();
  2745. if (posCode != "Supplier")
  2746. {
  2747. if (posCode == "CustomerService" || posCode == "Director")
  2748. {
  2749. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2750. }
  2751. else if (posCode == "Place" || posCode == "PlaceMr")
  2752. {
  2753. }
  2754. else
  2755. {
  2756. string teamIds = CurrentUser.User.TeamIds;
  2757. if (teamIds == "")
  2758. {
  2759. teamIds = "0";
  2760. }
  2761. 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);
  2762. }
  2763. if (sql.Length > 0)
  2764. {
  2765. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2766. }
  2767. }
  2768. if (dt.Rows.Count <= 0)
  2769. {
  2770. string key = "aftersale_order_" + userId;
  2771. if (RedisHelper.HasKey(key))
  2772. {
  2773. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2774. dt.Columns.Add("ctid", typeof(string));
  2775. dt.Columns.Add("IsReadTag", typeof(int));
  2776. foreach (var i in list)
  2777. {
  2778. DataRow data = dt.NewRow();
  2779. data["ctid"] = i;
  2780. data["IsReadTag"] = 4;
  2781. dt.Rows.Add(data);
  2782. }
  2783. RedisHelper.StringDelete(key);
  2784. }
  2785. }
  2786. if (dt.Rows.Count <= 0)
  2787. {
  2788. sql = new StringBuilder();
  2789. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2790. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2791. }
  2792. if (posCode == "Supplier")
  2793. {
  2794. string ids = CurrentUser.User.pemVend;
  2795. if (ids != null && ids.Length > 0)
  2796. {
  2797. string[] ids_list = ids.Split(',');
  2798. foreach (var item in ids_list)
  2799. {
  2800. string key = "return_order_" + item;
  2801. if (RedisHelper.HasKey(key))
  2802. {
  2803. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2804. dt.Columns.Add("ctid", typeof(string));
  2805. dt.Columns.Add("IsReadTag", typeof(int));
  2806. foreach (var i in list)
  2807. {
  2808. DataRow data = dt.NewRow();
  2809. data["ctid"] = i;
  2810. data["IsReadTag"] = 1;
  2811. dt.Rows.Add(data);
  2812. }
  2813. RedisHelper.StringDelete(key);
  2814. }
  2815. }
  2816. }
  2817. if (dt.Rows.Count <= 0)
  2818. {
  2819. sql = new StringBuilder();
  2820. 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);
  2821. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2822. }
  2823. }
  2824. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2825. }
  2826. public void reset_erp_tiporder()
  2827. {
  2828. string ids = GetPostString("ids");
  2829. string[] ctidList = ids.Split(',');
  2830. foreach (string ctid in ctidList)
  2831. {
  2832. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2833. if (enty != null)
  2834. {
  2835. enty.IsReadTag = 0;
  2836. enty.Update();
  2837. }
  2838. }
  2839. returnSuccessMsg("成功!");
  2840. return;
  2841. }
  2842. public void get_erp_designlist()
  2843. {
  2844. DataStruct dStruct = GetPostStruct();
  2845. List<string> lw = new List<string>();
  2846. string tid = GetPostString("ctid");
  2847. if (tid.Length > 0)
  2848. {
  2849. string select_tid = getTidByCtid(tid);
  2850. lw.Add(string.Format("tid='{0}'", select_tid));
  2851. }
  2852. string shopname = GetPostString("shopname");
  2853. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2854. string buyernick = GetPostString("buyer_nick");
  2855. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2856. string customer = GetPostString("customer");
  2857. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2858. string design = GetPostString("design");
  2859. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2860. string orderState = GetPostString("orderState");
  2861. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2862. lw.Add(string.Format("OrderState<6"));
  2863. string address = GetPostString("address");
  2864. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2865. string sellermemo = GetPostString("seller_memo");
  2866. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2867. string date1 = GetPostString("date1");
  2868. string date2 = GetPostString("date2");
  2869. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2870. if (dw.Length > 0) lw.Add(dw);
  2871. string apdate1 = GetPostString("apdate1");
  2872. string apdate2 = GetPostString("apdate2");
  2873. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2874. if (dwap.Length > 0) lw.Add(dwap);
  2875. string price1 = GetPostString("price1");
  2876. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2877. string price2 = GetPostString("price2");
  2878. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2879. string designTime = GetPostString("designtime");
  2880. if (designTime.Length > 0)
  2881. {
  2882. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2883. }
  2884. string usershop = CurrentUser.User.pemShop;
  2885. if (usershop.Length > 0)
  2886. {
  2887. lw.Add(string.Format("shopId in ({0})", usershop));
  2888. }
  2889. int myOrgid = CurrentUser.UserPost.OrgID;
  2890. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2891. if (myOrgCode.IndexOf("Designer") != -1)
  2892. {
  2893. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2894. {
  2895. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2896. }
  2897. else
  2898. {
  2899. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2900. }
  2901. }
  2902. else
  2903. {
  2904. string orgId = GetPostString("designerhd");
  2905. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2906. }
  2907. if (tid.Length > 0 || buyernick.Length > 0)
  2908. {
  2909. lw.Add(string.Format("OrderState >= 3"));
  2910. }
  2911. else
  2912. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2913. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2914. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2915. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2916. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2917. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2918. if (dt != null && dt.Rows.Count > 0)
  2919. {
  2920. foreach (DataRow dr in dt.Rows)
  2921. {
  2922. try
  2923. {
  2924. // 对象操作
  2925. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2926. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2927. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2928. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2929. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2930. if (dStruct.PageSize != 100000)
  2931. {
  2932. if (dr["DispatchSort"].ToString() == "2")
  2933. {
  2934. dr["gongchuang"] = 200;
  2935. }
  2936. else if ("外协".Equals(dr["ToType"].ToString()))
  2937. {
  2938. dr["gongchuang"] = 200;
  2939. }
  2940. else if ("内部".Equals(dr["ToType"].ToString()))
  2941. {
  2942. dr["gongchuang"] = -1;
  2943. }
  2944. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2945. {
  2946. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2947. dr["gongchuang"] = response.code;
  2948. }
  2949. }
  2950. }
  2951. catch (NullReferenceException ex)
  2952. {
  2953. }
  2954. }
  2955. }
  2956. writeGridDataTableJson(dStruct.TotalCount, dt);
  2957. }
  2958. public void get_erp_mydesignlist()
  2959. {
  2960. DataStruct dStruct = GetPostStruct();
  2961. List<string> lw = new List<string>();
  2962. string tid = GetPostString("ctid");
  2963. if (tid.Length > 0)
  2964. {
  2965. string select_tid = getTidByCtid(tid);
  2966. lw.Add(string.Format("tid='{0}'", select_tid));
  2967. }
  2968. string shopname = GetPostString("shopname");
  2969. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2970. string buyernick = GetPostString("buyer_nick");
  2971. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2972. string customer = GetPostString("customer");
  2973. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2974. string orderState = GetPostString("orderState");
  2975. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2976. //lw.Add(string.Format("OrderState<6"));
  2977. string date1 = GetPostString("date1");
  2978. string date2 = GetPostString("date2");
  2979. string dw = GetDateWhere("pay_time", date1, date2);
  2980. if (dw.Length > 0) lw.Add(dw);
  2981. string apdate1 = GetPostString("apdate1");
  2982. string apdate2 = GetPostString("apdate2");
  2983. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2984. if (dwap.Length > 0) lw.Add(dwap);
  2985. string price1 = GetPostString("price1");
  2986. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2987. string price2 = GetPostString("price2");
  2988. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2989. string olddownload = GetPostString("olddown");
  2990. if (olddownload == "1")
  2991. {
  2992. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2993. }
  2994. else if (olddownload == "2")
  2995. {
  2996. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2997. }
  2998. string sellermemo = GetPostString("seller_memo");
  2999. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3000. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  3001. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  3002. {
  3003. if (CurrentUser.User.TeamIds.Length > 0)
  3004. {
  3005. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  3006. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3007. else
  3008. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3009. }
  3010. else
  3011. {
  3012. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3013. }
  3014. }
  3015. if (tid.Length <= 0)
  3016. {
  3017. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3018. }
  3019. lw.Add(string.Format("IsReturn!=3"));
  3020. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3021. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3022. string teamids = CurrentUser.User.TeamIds.ToString();
  3023. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3024. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3025. if (dt != null && dt.Rows.Count > 0)
  3026. {
  3027. foreach (DataRow dr in dt.Rows)
  3028. {
  3029. try
  3030. {
  3031. // 对象操作
  3032. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3033. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3034. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3035. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3036. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3037. if (dStruct.PageSize != 100000)
  3038. {
  3039. if (dr["DispatchSort"].ToString() == "2")
  3040. {
  3041. dr["gongchuang"] = 200;
  3042. }
  3043. else if ("外协".Equals(dr["ToType"].ToString()))
  3044. {
  3045. dr["gongchuang"] = 200;
  3046. }
  3047. else if ("内部".Equals(dr["ToType"].ToString()))
  3048. {
  3049. dr["gongchuang"] = -1;
  3050. }
  3051. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3052. {
  3053. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3054. dr["gongchuang"] = response.code;
  3055. }
  3056. }
  3057. }
  3058. catch (NullReferenceException ex)
  3059. {
  3060. }
  3061. }
  3062. }
  3063. writeGridDataTableJson(dStruct.TotalCount, dt);
  3064. }
  3065. public void set_erp_startdesign()
  3066. {
  3067. if (UrlPostParmsCheck("ctid"))
  3068. {
  3069. string eid = GetPostString("ctid");
  3070. CeErpTradeCell entity = null;
  3071. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3072. if (entity != null)
  3073. {
  3074. if (entity.OrderState != 3)
  3075. {
  3076. returnErrorMsg("请刷新,订单已经设计了");
  3077. return;
  3078. }
  3079. entity.StartDesignTime = DateTime.Now;
  3080. entity.OrderState = 4;
  3081. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3082. {
  3083. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3084. entity.SupplierId = suid;
  3085. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3086. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3087. }
  3088. entity.UpdateTime = DateTime.Now;
  3089. //entity.MakeSupplier = suname;
  3090. entity.Update();
  3091. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3092. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3093. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3094. commonHelper.getCytPrice(entity);
  3095. returnSuccessMsg("操作成功!");
  3096. return;
  3097. }
  3098. returnErrorMsg("找不到记录");
  3099. }
  3100. }
  3101. public void ins_erp_designselfmemo()
  3102. {
  3103. if (UrlPostParmsCheck("ctid"))
  3104. {
  3105. string eid = GetPostString("ctid");
  3106. string con = GetPostString("con");
  3107. CeErpTradeCell entity = null;
  3108. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3109. if (entity != null)
  3110. {
  3111. entity.DesignSelfMemo = con;
  3112. entity.Update();
  3113. returnSuccessMsg("操作成功!");
  3114. return;
  3115. }
  3116. returnErrorMsg("找不到记录");
  3117. }
  3118. }
  3119. public void ins_erp_designprice()
  3120. {
  3121. if (UrlPostParmsCheck("ctid"))
  3122. {
  3123. string eid = GetPostString("ctid");
  3124. int uid = CurrentUser.UserID;
  3125. string userName = CurrentUser.UserName;
  3126. CeErpTradeCell entity = null;
  3127. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3128. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3129. if (entitys == null)
  3130. {
  3131. entitys = new CeErpDesignerBill();
  3132. }
  3133. if (entity != null)
  3134. {
  3135. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3136. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3137. entity.StartDesignTime = DateTime.Now;
  3138. entity.OrderState = 4;
  3139. string suname = "";
  3140. if (entity.SupplierId == 0)
  3141. {
  3142. int sid = commonHelper.autoDistributeToSupplier(entity);
  3143. entity.SupplierId = sid;
  3144. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3145. }
  3146. entity.Update();
  3147. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3148. if (ceErpUserPost != null)
  3149. {
  3150. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3151. if (ceErpPost != null)
  3152. {
  3153. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3154. {
  3155. entitys.tid = entity.ctid;
  3156. entitys.oid = entity.tid;
  3157. entitys.uid = uid;
  3158. entitys.userName = userName;
  3159. entitys.designerType = 1;
  3160. entitys.designerTypeText = "内部设计师";
  3161. entitys.price = Convert.ToDouble(GetPostString("price"));
  3162. entitys.designNum = GetPostInt("designNum");
  3163. entitys.modifyNum = GetPostInt("modifyNum");
  3164. entitys.designSize = GetPostString("designSize");
  3165. entitys.modifySize = GetPostString("modifySize");
  3166. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3167. {
  3168. entitys.create_time = DateTime.Now;
  3169. entitys.create_u_id = uid;
  3170. entitys.create_u_name = userName;
  3171. entitys.Save();
  3172. }
  3173. else
  3174. {
  3175. entitys.update_time = DateTime.Now;
  3176. entitys.update_u_id = uid;
  3177. entitys.update_u_name = userName;
  3178. entitys.Update();
  3179. }
  3180. }
  3181. }
  3182. }
  3183. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3184. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3185. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3186. if (suname != "")
  3187. {
  3188. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3189. }
  3190. commonHelper.getCytPrice(entity);
  3191. returnSuccessMsg("操作成功!");
  3192. return;
  3193. }
  3194. returnErrorMsg("找不到记录");
  3195. }
  3196. }
  3197. public void upload_erp_filecomplete()
  3198. {
  3199. if (UrlPostParmsCheck("ctid"))
  3200. {
  3201. string eid = GetPostString("ctid");
  3202. CeErpTradeCell entity = null;
  3203. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3204. if (entity != null)
  3205. {
  3206. entity.OrderState = 5; //设计完成
  3207. entity.Update();
  3208. returnSuccessMsg(eid + "上传成功,设计完成!");
  3209. return;
  3210. }
  3211. returnErrorMsg("找不到订单记录");
  3212. }
  3213. }
  3214. public void get_erp_designovertimelist()
  3215. {
  3216. DataStruct dStruct = GetPostStruct();
  3217. List<string> lw = new List<string>();
  3218. string tid = GetPostString("ctid");
  3219. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3220. string shopname = GetPostString("shopname");
  3221. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3222. string buyernick = GetPostString("buyer_nick");
  3223. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3224. string ResponsibleMan = GetPostString("responsible");
  3225. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3226. string date1 = GetPostString("date1");
  3227. string date2 = GetPostString("date2");
  3228. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3229. if (dw.Length > 0) lw.Add(dw);
  3230. string price1 = GetPostString("price1");
  3231. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3232. string price2 = GetPostString("price2");
  3233. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3234. string orderState = GetPostString("orderState");
  3235. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3236. string sellermemo = GetPostString("seller_memo");
  3237. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3238. lw.Add(string.Format("UnusualTag=3"));
  3239. lw.Add(string.Format("IsRefund<={0}", 1));
  3240. dStruct.Order = "WaitDesignTime desc";
  3241. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3242. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3243. writeGridDataTableJson(dStruct.TotalCount, dt);
  3244. }
  3245. //设计管理 获取抢单大厅列表
  3246. public void get_erp_grabinglist()
  3247. {
  3248. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3249. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3250. bool oldOrder = false;
  3251. if (org != null)
  3252. {
  3253. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3254. }
  3255. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3256. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3257. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3258. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3259. //先处理订单数据
  3260. if (dt.Rows.Count > 0)
  3261. {
  3262. Dictionary<string, int> design = null;
  3263. int count = 0;
  3264. foreach (DataRow row in dt.Rows)
  3265. {
  3266. if (map.ContainsKey(row["ShopId"].ToString()))
  3267. {
  3268. map.TryGetValue(row["ShopId"].ToString(), out design);
  3269. }
  3270. else
  3271. {
  3272. design = new Dictionary<string, int>();
  3273. }
  3274. if (design.ContainsKey(row["ProductId"].ToString()))
  3275. {
  3276. design.TryGetValue(row["ProductId"].ToString(), out count);
  3277. }
  3278. count++;
  3279. design[row["ProductId"].ToString()] = count;
  3280. map[row["ShopId"].ToString()] = design;
  3281. }
  3282. }
  3283. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3284. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3285. //把店铺排序和技能排序分类
  3286. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3287. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3288. if (design_dt.Rows.Count > 0)
  3289. {
  3290. Dictionary<string, string> design = null;
  3291. List<string> shopIds = null;
  3292. foreach (DataRow row in design_dt.Rows)
  3293. {
  3294. if ("0".Equals(row["designId"].ToString()))
  3295. {
  3296. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3297. {
  3298. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3299. }
  3300. else
  3301. {
  3302. shopIds = new List<string>();
  3303. }
  3304. shopIds.Add(row["shopId"].ToString());
  3305. shop_orders[row["orders"].ToString()] = shopIds;
  3306. }
  3307. else
  3308. {
  3309. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3310. {
  3311. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3312. }
  3313. else
  3314. {
  3315. design = new Dictionary<string, string>();
  3316. }
  3317. design[row["orders"].ToString()] = row["designId"].ToString();
  3318. design_orders[row["shopId"].ToString()] = design;
  3319. }
  3320. }
  3321. //处理成key value后根据key排序
  3322. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3323. foreach (List<string> val in shop_orders.Values)
  3324. {
  3325. if (val != null)
  3326. {
  3327. foreach (string key in val)
  3328. {
  3329. if (design_orders.ContainsKey(key.ToString()))
  3330. {
  3331. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3332. }
  3333. }
  3334. }
  3335. }
  3336. }
  3337. //校验哪个优先级有订单
  3338. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3339. foreach (string key in shop_orders.Keys)
  3340. {
  3341. List<string> ids = null;
  3342. shop_orders.TryGetValue(key, out ids);
  3343. //id为shopid
  3344. foreach (string id in ids)
  3345. {
  3346. Dictionary<string, int> list = null;
  3347. Dictionary<string, string> desing = null;
  3348. map.TryGetValue(id, out list);
  3349. design_orders.TryGetValue(id, out desing);
  3350. if (list != null && desing != null)
  3351. {
  3352. foreach (var item in desing)
  3353. {
  3354. int count = 0;
  3355. if (list.ContainsKey(item.Value))
  3356. {
  3357. list.TryGetValue(item.Value, out count);
  3358. if (count > 0)
  3359. {
  3360. designIds[id] = item.Value;
  3361. break;
  3362. }
  3363. }
  3364. }
  3365. }
  3366. }
  3367. if (designIds.Count > 0)
  3368. {
  3369. break;
  3370. }
  3371. }
  3372. DataTable table = new DataTable();
  3373. table.Columns.Add("tid", typeof(string));
  3374. table.Columns.Add("ctid", typeof(string));
  3375. table.Columns.Add("seller_nick", typeof(string));
  3376. table.Columns.Add("productName", typeof(string));
  3377. table.Columns.Add("pay_time", typeof(string));
  3378. table.Columns.Add("seller_memo", typeof(string));
  3379. if (designIds.Count > 0)
  3380. {
  3381. string shopId = "";
  3382. string productId = "";
  3383. foreach (var designInfo in designIds)
  3384. {
  3385. shopId = designInfo.Key;
  3386. productId = designInfo.Value;
  3387. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3388. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3389. if (dt.Rows.Count > 0)
  3390. {
  3391. foreach (DataRow row in dt.Rows)
  3392. {
  3393. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3394. {
  3395. DataRow data = table.NewRow();
  3396. data["ctid"] = row["ctid"].ToString();
  3397. data["tid"] = row["tid"].ToString();
  3398. data["seller_nick"] = ceErpShop.ShopName;
  3399. data["pay_time"] = row["pay_time"].ToString();
  3400. data["seller_memo"] = row["seller_memo"].ToString();
  3401. data["productName"] = ceErpProduct.PType;
  3402. table.Rows.Add(data);
  3403. }
  3404. }
  3405. }
  3406. }
  3407. }
  3408. writeGridDataTableJson(table.Rows.Count, table);
  3409. }
  3410. private object rushLockObject = new object();
  3411. public void set_erp_grabingorder()
  3412. {
  3413. if (UrlPostParmsCheck("ctid"))
  3414. {
  3415. int total = CurrentUser.User.Person.Total;
  3416. int userId = CurrentUser.User.ID;
  3417. int noFinish = CurrentUser.User.Person.NoFinish;
  3418. int finalization = CurrentUser.User.Person.Finalization;
  3419. string eids = GetPostString("ctid");
  3420. string key = "RushKey_" + userId;
  3421. int count = 0;
  3422. if (erpRedis.RedisHelper.KeyExists(key))
  3423. {
  3424. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3425. if (redisCount != null)
  3426. {
  3427. count = Convert.ToInt32(redisCount);
  3428. }
  3429. }
  3430. if (count >= total)
  3431. {
  3432. returnErrorMsg("半小时内已经抢" + total + "单");
  3433. return;
  3434. }
  3435. string[] ctidlist = eids.Split(',');
  3436. if (count + ctidlist.Length > total)
  3437. {
  3438. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3439. return;
  3440. }
  3441. int itag = 0;
  3442. lock (rushLockObject)
  3443. {
  3444. if (ctidlist.Length > 0)
  3445. {
  3446. string[] dtList = new string[ctidlist.Length];
  3447. for (int i = 0; i < ctidlist.Length; i++)
  3448. {
  3449. dtList[i] = "'" + ctidlist[i] + "'";
  3450. }
  3451. 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"));
  3452. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3453. if (dt_user.Rows.Count > 0)
  3454. {
  3455. int doing = 0;//未定稿
  3456. int finish = 0;//已完成
  3457. foreach (DataRow dr in dt_user.Rows)
  3458. {
  3459. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3460. {
  3461. doing++;
  3462. }
  3463. else
  3464. {
  3465. finish++;
  3466. }
  3467. }
  3468. if (doing >= noFinish)
  3469. {
  3470. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3471. return;
  3472. }
  3473. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3474. {
  3475. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3476. return;
  3477. }
  3478. }
  3479. //校验选择单子状态
  3480. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3481. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3482. if (dt.Rows.Count > 0)
  3483. {
  3484. List<string> list = new List<string>();
  3485. foreach (DataRow dr in dt.Rows)
  3486. {
  3487. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3488. {
  3489. list.Add(dr["ctid"].ToString());
  3490. }
  3491. }
  3492. if (list.Count > 0)
  3493. {
  3494. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3495. return;
  3496. }
  3497. }
  3498. foreach (string ctid in ctidlist)
  3499. {
  3500. CeErpTradeCell entity = null;
  3501. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3502. if (entity != null)
  3503. {
  3504. entity.OrderState = 3;
  3505. entity.DesignUserId = CurrentUser.UserID;
  3506. entity.WaitDesignTime = DateTime.Now;
  3507. entity.StartDesignTime = DateTime.Now;
  3508. entity.Update();
  3509. commonHelper.UpdateRelationOrder(entity.ctid);
  3510. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3511. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3512. itag++;
  3513. }
  3514. }
  3515. }
  3516. }
  3517. count += ctidlist.Length;
  3518. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3519. if (itag == 0)
  3520. returnErrorMsg("没有找到相关订单");
  3521. else
  3522. returnSuccessMsg("抢单成功!");
  3523. return;
  3524. }
  3525. }
  3526. public void get_erp_waitorderlist()
  3527. {
  3528. DataStruct dStruct = GetPostStruct();
  3529. List<string> lw = new List<string>();
  3530. string tid = GetPostString("ctid");
  3531. if (tid.Length > 0)
  3532. {
  3533. string select_tid = getTidByCtid(tid);
  3534. lw.Add(string.Format("tid='{0}'", select_tid));
  3535. }
  3536. string shopname = GetPostString("shopname");
  3537. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3538. string buyernick = GetPostString("buyer_nick");
  3539. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3540. string customer = GetPostString("customer");
  3541. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3542. string design = GetPostString("design");
  3543. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3544. string orderState = GetPostString("orderState");
  3545. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3546. string supplier = GetPostString("supplier");
  3547. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3548. string sellermemo = GetPostString("seller_memo");
  3549. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3550. string otherMemo = GetPostString("otherMemo");
  3551. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3552. string address = GetPostString("address");
  3553. 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));
  3554. string date1 = GetPostString("date1");
  3555. string date2 = GetPostString("date2");
  3556. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3557. if (dw.Length > 0) lw.Add(dw);
  3558. string price1 = GetPostString("price1");
  3559. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3560. string price2 = GetPostString("price2");
  3561. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3562. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3563. lw.Add(string.Format("IsSample != 2 "));
  3564. lw.Add(string.Format("OrderState = 5 "));
  3565. lw.Add(string.Format("IsRefund<={0}", 1));
  3566. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3567. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3568. string pagesize = GetPostString("pagesize");
  3569. if (pagesize != null)
  3570. {
  3571. dStruct.PageSize = 200;
  3572. }
  3573. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3574. List<string> tids = new List<string>();
  3575. if (dt != null)
  3576. {
  3577. dt.Columns.Add("compenPrice", typeof(double));
  3578. foreach (DataRow dr in dt.Rows)
  3579. {
  3580. if (Convert.IsDBNull(dr["compenPrice"]))
  3581. {
  3582. dr["compenPrice"] = 0;
  3583. }
  3584. tids.Add("'" + dr["tid"].ToString() + "'");
  3585. 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();
  3586. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3587. {
  3588. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3589. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3590. entity.SupplierId = suid;
  3591. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3592. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3593. entity.Update();
  3594. }
  3595. }
  3596. }
  3597. if (tids.Count > 0)
  3598. {
  3599. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3600. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3601. if (dt_price != null && dt_price.Rows.Count > 0)
  3602. {
  3603. foreach (DataRow dr in dt_price.Rows)
  3604. {
  3605. foreach (DataRow row in dt.Rows)
  3606. {
  3607. if (row["tid"].Equals(dr["ptid"]))
  3608. {
  3609. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3610. break;
  3611. }
  3612. }
  3613. }
  3614. }
  3615. }
  3616. writeGridDataTableJson(dStruct.TotalCount, dt);
  3617. }
  3618. public void get_erp_supplierwaitorderlist()
  3619. {
  3620. DataStruct dStruct = GetPostStruct();
  3621. List<string> lw = new List<string>();
  3622. string tid = GetPostString("ctid");
  3623. if (tid.Length > 0)
  3624. {
  3625. string select_tid = getTidByCtid(tid);
  3626. lw.Add(string.Format("tid='{0}'", select_tid));
  3627. }
  3628. string shopname = GetPostString("shopname");
  3629. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3630. string sellermemo = GetPostString("seller_memo");
  3631. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3632. string date1 = GetPostString("date1");
  3633. string date2 = GetPostString("date2");
  3634. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3635. if (dw.Length > 0) lw.Add(dw);
  3636. lw.Add(string.Format("OrderState = 5 "));
  3637. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3638. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3639. {
  3640. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3641. }
  3642. string supplier = GetPostString("supplier");
  3643. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3644. {
  3645. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3646. }
  3647. lw.Add(string.Format("IsRefund<={0}", 1));
  3648. dStruct.Order = "FinishDesignTime desc";
  3649. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3650. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3651. if (dt != null)
  3652. {
  3653. foreach (DataRow dr in dt.Rows)
  3654. {
  3655. 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();
  3656. }
  3657. }
  3658. writeGridDataTableJson(dStruct.TotalCount, dt);
  3659. }
  3660. public void upd_erp_verifytosupplier()
  3661. {
  3662. if (UrlPostParmsCheck("ctid"))
  3663. {
  3664. string eids = GetPostString("ctid");
  3665. CeErpTradeCell entity = null;
  3666. string[] eidsList = eids.Split(',');
  3667. if (eidsList.Length <= 0)
  3668. {
  3669. returnErrorMsg("订单号不能空");
  3670. return;
  3671. }
  3672. List<string> tLst = new List<string>();
  3673. foreach (string ctidstr in eidsList)
  3674. {
  3675. tLst.Add("'" + ctidstr + "'");
  3676. CeErpDataSendOrderInfo.createObject(ctidstr);
  3677. }
  3678. string needtids = string.Join(",", tLst.ToArray());
  3679. StringBuilder sql = new StringBuilder();
  3680. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3681. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 AND OrderState = 5 and ctid in ({0});", needtids, CurrentUser.UserID);
  3682. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3683. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3684. returnSuccessMsg("操作成功!");
  3685. return;
  3686. /**foreach (string ctidstr in eidsList)
  3687. {
  3688. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3689. if (entity != null)
  3690. {
  3691. if (entity.SupplierId == 0)
  3692. {
  3693. continue;
  3694. }
  3695. entity.IsVerifyToSupplier = true;
  3696. if (entity.IsReturn == 1) //1是供应商打回
  3697. {
  3698. entity.IsReturn = 0;
  3699. }
  3700. entity.FinishPlaceTime = DateTime.Now;
  3701. entity.PlaceUserId = CurrentUser.UserID;
  3702. entity.Update();
  3703. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3704. }
  3705. }
  3706. returnSuccessMsg("操作成功!");
  3707. return;**/
  3708. }
  3709. }
  3710. public void upd_erp_supplierback()
  3711. {
  3712. if (UrlPostParmsCheck("ctid"))
  3713. {
  3714. string eid = GetPostString("ctid");
  3715. string reason = GetPostString("returnreason");
  3716. CeErpTradeCell entity = null;
  3717. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3718. if (entity != null)
  3719. {
  3720. string message = "操作成功!";
  3721. string isDown = "";
  3722. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3723. {
  3724. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3725. isDown = "被点击下载";
  3726. }
  3727. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3728. {
  3729. string key = "return_order_" + entity.SupplierId;
  3730. List<string> list = new List<string>();
  3731. if (RedisHelper.HasKey(key))
  3732. {
  3733. object data = RedisHelper.StringGet(key);
  3734. list = Convert.ToString(data).Split(',').ToList();
  3735. }
  3736. list.Add(eid);
  3737. RedisHelper.StringSet(key, string.Join(",", list));
  3738. }
  3739. entity.IsVerifyToSupplier = false;
  3740. entity.IsReturn = 1;
  3741. entity.IsHaveNewOrder = 0;
  3742. entity.ReturnTime = DateTime.Now;
  3743. entity.ReturnReason = reason;
  3744. if (entity.OrderState == 6)
  3745. {
  3746. entity.OrderState = 5;
  3747. }
  3748. entity.Update();
  3749. CeErpSukuraData.createInfo(entity.ctid, 5);
  3750. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3751. returnSuccessMsg(message);
  3752. return;
  3753. }
  3754. returnErrorMsg("找不到订单记录");
  3755. }
  3756. }
  3757. public void upd_erp_toaftersaleorder()
  3758. {
  3759. if (UrlPostParmsCheck("ctid"))
  3760. {
  3761. string eid = GetPostString("ctid");
  3762. string reason = GetPostString("returnreason");
  3763. CeErpTradeCell entity = null;
  3764. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3765. if (entity != null)
  3766. {
  3767. if (entity.isAfterSaleOrder != 1)
  3768. {
  3769. returnErrorMsg("带S的售后单才能打回给售后");
  3770. return;
  3771. }
  3772. if (entity.OrderState >= 5)
  3773. {
  3774. returnErrorMsg("已经设计完成了不能打回给售后");
  3775. return;
  3776. }
  3777. entity.OrderState = 0;
  3778. entity.IsReturn = 3;
  3779. entity.ReturnTime = DateTime.Now;
  3780. entity.UpdateTime = DateTime.Now;
  3781. entity.ReturnReason = reason;
  3782. entity.Update();
  3783. CeErpSukuraData.createInfo(entity.ctid, 5);
  3784. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3785. returnSuccessMsg("操作成功!");
  3786. return;
  3787. }
  3788. returnErrorMsg("找不到订单记录");
  3789. }
  3790. }
  3791. public void upd_erp_aftersaletodesign()
  3792. {
  3793. if (UrlPostParmsCheck("ctid"))
  3794. {
  3795. string eid = GetPostString("ctid");
  3796. CeErpTradeCell entity = null;
  3797. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3798. if (entity != null)
  3799. {
  3800. entity.OrderState = 3;
  3801. entity.IsReturn = 0;
  3802. entity.UpdateTime = DateTime.Now;
  3803. entity.Update();
  3804. CeErpSukuraData.createInfo(entity.ctid, 5);
  3805. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3806. returnSuccessMsg("操作成功!");
  3807. return;
  3808. }
  3809. returnErrorMsg("找不到订单记录");
  3810. }
  3811. }
  3812. public void assign_erp_supplier()
  3813. {
  3814. if (UrlPostParmsCheck("ctid"))
  3815. {
  3816. string eids = GetPostString("ctid");
  3817. int sid = GetPostInt("SupplierName");
  3818. string fromTag = GetPostString("tag");
  3819. string[] eidList = eids.Split(',');
  3820. if (eidList.Length <= 0)
  3821. {
  3822. returnErrorMsg("指派不能为空");
  3823. return;
  3824. }
  3825. string errMsg = "";
  3826. string suname = commonHelper.getSupplierNameById(sid);
  3827. foreach (string ctid in eidList)
  3828. {
  3829. CeErpTradeCell entity = null;
  3830. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3831. if (entity != null)
  3832. {
  3833. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3834. {
  3835. errMsg += (ctid + "指派失败!!!");
  3836. continue;
  3837. }
  3838. entity.SupplierId = sid;
  3839. entity.Update();
  3840. commonHelper.UpdateRelationOrder(entity.ctid);
  3841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3842. if (entity.OrderState >= 6)
  3843. {
  3844. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3845. //{
  3846. // string msl = entity.MakeSupplier;
  3847. // string[] mslist = msl.Split(',');
  3848. // 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);
  3849. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3850. //}
  3851. //else
  3852. //{
  3853. StringBuilder sql = new StringBuilder();
  3854. 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);
  3855. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3856. //}
  3857. }
  3858. }
  3859. else
  3860. {
  3861. continue;
  3862. }
  3863. }
  3864. if (errMsg.Length > 0)
  3865. {
  3866. returnErrorMsg(errMsg);
  3867. return;
  3868. }
  3869. returnSuccessMsg("操作成功!");
  3870. return;
  3871. }
  3872. }
  3873. public void assign_erp_makesupplier()
  3874. {
  3875. if (UrlPostParmsCheck("ctid"))
  3876. {
  3877. string eids = GetPostString("ctid");
  3878. string sname = GetPostString("SupplierName");
  3879. string[] eidList = eids.Split(',');
  3880. if (eidList.Length <= 0)
  3881. {
  3882. returnErrorMsg("指派不能为空");
  3883. return;
  3884. }
  3885. List<string> tLst = new List<string>();
  3886. foreach (string ctid in eidList)
  3887. {
  3888. CeErpTradeCell entity = null;
  3889. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3890. if (entity != null)
  3891. {
  3892. entity.MakeSupplier = sname;
  3893. entity.Update();
  3894. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3895. tLst.Add("'" + ctid + "'");
  3896. }
  3897. else
  3898. {
  3899. continue;
  3900. }
  3901. }
  3902. string ctids = string.Join(",", tLst.ToArray());
  3903. StringBuilder sql2 = new StringBuilder();
  3904. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3905. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3906. returnSuccessMsg("操作成功!");
  3907. return;
  3908. }
  3909. }
  3910. public void ins_erp_returnreason()
  3911. {
  3912. if (UrlPostParmsCheck("ctid"))
  3913. {
  3914. string eid = GetPostString("ctid");
  3915. CeErpTradeCell entity = null;
  3916. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3917. string userpost = CurrentUser.UserPost.Post.Code;
  3918. if (entity != null)
  3919. {
  3920. bool isPlace = false;
  3921. if (entity.OrderState > 6)
  3922. {
  3923. returnErrorMsg("已发货无法打回!");
  3924. return;
  3925. }
  3926. if (entity.OrderState == 6)
  3927. {
  3928. isPlace = true;
  3929. }
  3930. bool isNeedUpdateCell2 = false;
  3931. if (entity.OrderState >= 6)
  3932. {
  3933. isNeedUpdateCell2 = true;
  3934. }
  3935. int returnTag = 2;
  3936. if (userpost == "Supplier")
  3937. {
  3938. returnTag = 1;
  3939. }
  3940. int toType = GetPostInt("totype");
  3941. string fromType = "3";
  3942. if (entity.OrderState < 5)
  3943. {
  3944. fromType = "3";
  3945. }
  3946. else
  3947. {
  3948. fromType = "4";
  3949. }
  3950. if (entity.IsXianHuo == 0)
  3951. {
  3952. if (returnTag == 2)
  3953. {
  3954. if (toType == 1)
  3955. {
  3956. entity.OrderState = 0;
  3957. entity.ReturnUserType = 1;
  3958. string clearman = GetPostString("clearman");
  3959. if (!string.IsNullOrEmpty(clearman))
  3960. {
  3961. entity.DesignUserId = 0;
  3962. }
  3963. }
  3964. else
  3965. {
  3966. entity.OrderState = 3;
  3967. entity.ReturnUserType = 2;
  3968. }
  3969. entity.IsReadTag = 1;
  3970. }
  3971. else if (returnTag == 1)
  3972. {
  3973. entity.OrderState = 5;
  3974. }
  3975. entity.IsVerifyToSupplier = false;
  3976. }
  3977. if (entity.IsXianHuo == 1)
  3978. {
  3979. entity.OrderState = 5;
  3980. }
  3981. entity.UnusualTag = 0;
  3982. entity.UnusualTime = null;
  3983. entity.UnusualCon = "";
  3984. entity.IsReturn = returnTag;
  3985. entity.ReturnTime = DateTime.Now;
  3986. entity.UpdateTime = DateTime.Now;
  3987. entity.ReturnReason = GetPostString("returnreason");
  3988. entity.Update();
  3989. if (entity.OrderState == 3)
  3990. {
  3991. ApiVo apiVo = new ApiVo();
  3992. apiVo.orderNumber = entity.ctid;
  3993. apiVo.actionName = "rebutDesign";
  3994. apiVo.orderRemarks = entity.ReturnReason;
  3995. designHelper.API_WorkCore(apiVo);//rebutDesign
  3996. }
  3997. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3998. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3999. {
  4000. //dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  4001. }
  4002. //CeErpSukuraData.createInfo(entity.ctid, 5);
  4003. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4004. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4005. if (isPlace)
  4006. {
  4007. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4008. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4009. if (dth != null && dth.Rows.Count > 0)
  4010. {
  4011. dataSendOrderBean dataSendOrderBean = null;
  4012. foreach (DataRow item in dth.Rows)
  4013. {
  4014. try
  4015. {
  4016. dataSendOrderBean = new dataSendOrderBean();
  4017. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4018. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4019. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4020. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4021. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4022. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4023. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4024. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4025. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4026. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4027. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4028. dataSendOrderBean.Radio1723534706288 = "打回";
  4029. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4030. if (result != null)
  4031. {
  4032. if ("0".Equals(result.errcode))
  4033. {
  4034. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4035. }
  4036. else
  4037. {
  4038. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4039. }
  4040. }
  4041. }
  4042. catch (Exception ex)
  4043. {
  4044. }
  4045. }
  4046. }
  4047. }
  4048. returnSuccessMsg("操作成功!");
  4049. return;
  4050. }
  4051. returnErrorMsg("找不到订单记录");
  4052. }
  4053. }
  4054. public void cyt_erp_returnreason()
  4055. {
  4056. if (UrlPostParmsCheck("ctid"))
  4057. {
  4058. string eid = GetPostString("ctid");
  4059. CeErpTradeCell entity = null;
  4060. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4061. string userpost = CurrentUser.UserPost.Post.Code;
  4062. if (entity != null)
  4063. {
  4064. if (entity.OrderState > 6)
  4065. {
  4066. returnErrorMsg("已发货无法打回!");
  4067. return;
  4068. }
  4069. JObject jsonObject = new JObject
  4070. {
  4071. { "Userid", "77886" },
  4072. { "Pwd", "lt666888" },
  4073. { "LTOrderId",eid }
  4074. };
  4075. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4076. JObject jsonObjects = JObject.Parse(response);
  4077. string msg = (string)jsonObjects["msg"];
  4078. if (msg != "取消成功")
  4079. {
  4080. returnErrorMsg(msg);
  4081. return;
  4082. }
  4083. bool isNeedUpdateCell2 = false;
  4084. if (entity.OrderState >= 6)
  4085. {
  4086. isNeedUpdateCell2 = true;
  4087. }
  4088. int returnTag = 2;
  4089. if (userpost == "Supplier")
  4090. {
  4091. returnTag = 1;
  4092. }
  4093. if (entity.IsXianHuo == 0)
  4094. {
  4095. if (returnTag == 2)
  4096. {
  4097. int toType = GetPostInt("totype");
  4098. if (toType == 1)
  4099. {
  4100. entity.OrderState = 0;
  4101. entity.ReturnUserType = 1;
  4102. }
  4103. else
  4104. {
  4105. entity.OrderState = 4;
  4106. entity.ReturnUserType = 2;
  4107. }
  4108. entity.IsReadTag = 1;
  4109. }
  4110. else if (returnTag == 1)
  4111. {
  4112. entity.OrderState = 5;
  4113. }
  4114. entity.IsVerifyToSupplier = false;
  4115. }
  4116. entity.UnusualTag = 0;
  4117. entity.UnusualTime = null;
  4118. entity.UnusualCon = "";
  4119. entity.IsReturn = returnTag;
  4120. entity.ReturnTime = DateTime.Now;
  4121. entity.ReturnReason = GetPostString("returnreason");
  4122. entity.Update();
  4123. if (entity.OrderState == 4)
  4124. {
  4125. ApiVo apiVo = new ApiVo();
  4126. apiVo.orderNumber = entity.ctid;
  4127. apiVo.actionName = "rebutDesign";
  4128. apiVo.orderRemarks = entity.ReturnReason;
  4129. designHelper.API_WorkCore(apiVo);//rebutDesign
  4130. }
  4131. CeErpSukuraData.createInfo(entity.ctid, 5);
  4132. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4133. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4134. if (isNeedUpdateCell2)
  4135. {
  4136. if (entity.MakeSupplier.IndexOf(",") != -1)
  4137. {
  4138. StringBuilder sql2 = new StringBuilder();
  4139. 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);
  4140. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4141. }
  4142. else
  4143. {
  4144. StringBuilder sql2 = new StringBuilder();
  4145. 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);
  4146. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4147. }
  4148. }
  4149. returnSuccessMsg("操作成功!");
  4150. return;
  4151. }
  4152. returnErrorMsg("找不到订单记录");
  4153. }
  4154. }
  4155. public void upd_erp_xianhuoreturntag()
  4156. {
  4157. if (UrlPostParmsCheck("ctid"))
  4158. {
  4159. string eids = GetPostString("ctid");
  4160. string[] ctids = eids.Split(',');
  4161. foreach (string ctid in ctids)
  4162. {
  4163. CeErpTradeCell entity = null;
  4164. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4165. if (entity != null)
  4166. {
  4167. entity.IsReturn = 0;
  4168. entity.Update();
  4169. CeErpSukuraData.createInfo(entity.ctid, 5);
  4170. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4171. }
  4172. }
  4173. returnSuccessMsg("操作成功!");
  4174. return;
  4175. }
  4176. }
  4177. public void get_erp_waitdeliverylist()
  4178. {
  4179. DataStruct dStruct = GetPostStruct();
  4180. List<string> lw = new List<string>();
  4181. string tid = GetPostString("ctid");
  4182. if (tid.Length > 0)
  4183. {
  4184. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4185. if (tid.Length > 5)
  4186. {
  4187. List<string> tids = getTidByCtidLike(tid);
  4188. if (tids.Count > 0 && tids.Count < 10)
  4189. {
  4190. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4191. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4192. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4193. {
  4194. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4195. }*/
  4196. }
  4197. }
  4198. lw.Add(tid_sql);
  4199. }
  4200. string shopname = GetPostString("shopname");
  4201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4202. string buyernick = GetPostString("buyer_nick");
  4203. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4204. //if (tid.Length == 0 && buyernick.Length == 0)
  4205. //{
  4206. // lw.Add(string.Format("IsRefund<={0}", 1));
  4207. //}
  4208. string customer = GetPostString("customer");
  4209. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4210. string design = GetPostString("design");
  4211. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4212. string orderState = GetPostString("orderState");
  4213. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4214. string address = GetPostString("address");
  4215. 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));
  4216. string sellermemo = GetPostString("seller_memo");
  4217. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4218. string supplier = GetPostString("supplier");
  4219. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4220. string OrderArea = GetPostString("order_area");
  4221. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4222. string placedate1 = GetPostString("placedate1");
  4223. string placedate2 = GetPostString("placedate2");
  4224. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4225. if (fdw.Length > 0) lw.Add(fdw);
  4226. string price1 = GetPostString("price1");
  4227. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4228. string price2 = GetPostString("price2");
  4229. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4230. string unusualCon = GetPostString("unusualcon");
  4231. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4232. string otherMemo = GetPostString("otherMemo");
  4233. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4234. string posTag = CurrentUser.UserPost.Post.Code;
  4235. if (posTag == "Supplier")
  4236. {
  4237. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4238. }
  4239. else
  4240. {
  4241. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4242. {
  4243. string usershop = CurrentUser.User.pemShop;
  4244. lw.Add(string.Format("ShopId in ({0})", usershop));
  4245. }
  4246. }
  4247. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4248. lw.Add(string.Format("type != 'PDD' "));
  4249. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4250. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4251. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4252. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4253. writeGridDataTableJson(dStruct.TotalCount, dt);
  4254. }
  4255. public void get_erp_changedeliverylist()
  4256. {
  4257. DataStruct dStruct = GetPostStruct();
  4258. List<string> lw = new List<string>();
  4259. string tid = GetPostString("ctid");
  4260. if (tid.Length > 0)
  4261. {
  4262. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4263. if (tid.Length > 5)
  4264. {
  4265. List<string> tids = getTidByCtidLike(tid);
  4266. if (tids.Count > 0 && tids.Count < 10)
  4267. {
  4268. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4269. }
  4270. }
  4271. lw.Add(tid_sql);
  4272. }
  4273. string shopname = GetPostString("shopname");
  4274. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4275. string buyernick = GetPostString("buyer_nick");
  4276. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4277. //if (tid.Length == 0 && buyernick.Length == 0)
  4278. //{
  4279. // lw.Add(string.Format("IsRefund<={0}", 1));
  4280. //}
  4281. string customer = GetPostString("customer");
  4282. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4283. string design = GetPostString("design");
  4284. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4285. string orderState = GetPostString("orderState");
  4286. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4287. string address = GetPostString("address");
  4288. 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));
  4289. string sellermemo = GetPostString("seller_memo");
  4290. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4291. string supplier = GetPostString("supplier");
  4292. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4293. string OrderArea = GetPostString("order_area");
  4294. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4295. string placedate1 = GetPostString("placedate1");
  4296. string placedate2 = GetPostString("placedate2");
  4297. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4298. if (fdw.Length > 0) lw.Add(fdw);
  4299. string price1 = GetPostString("price1");
  4300. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4301. string price2 = GetPostString("price2");
  4302. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4303. string unusualCon = GetPostString("unusualcon");
  4304. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4305. string otherMemo = GetPostString("otherMemo");
  4306. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4307. string posTag = CurrentUser.UserPost.Post.Code;
  4308. if (posTag == "Supplier")
  4309. {
  4310. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4311. }
  4312. else
  4313. {
  4314. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4315. {
  4316. string usershop = CurrentUser.User.pemShop;
  4317. lw.Add(string.Format("ShopId in ({0})", usershop));
  4318. }
  4319. }
  4320. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4321. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4322. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4323. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4324. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4325. /*if (tid.Length > 0)
  4326. {
  4327. List<string> tids = new List<string>();
  4328. if (dt != null && dt.Rows.Count > 0)
  4329. {
  4330. foreach (DataRow item in dt.Rows)
  4331. {
  4332. tids.Add("'" + item["tid"] + "'");
  4333. }
  4334. }
  4335. if (tids.Count > 0)
  4336. {
  4337. lw.RemoveAt(0);
  4338. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4339. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4340. dt = WebCache.GetData("view_erptradecell", dStruct);
  4341. }
  4342. }*/
  4343. writeGridDataTableJson(dStruct.TotalCount, dt);
  4344. }
  4345. public void get_erp_pddderiving()
  4346. {
  4347. DataStruct dStruct = GetPostStruct();
  4348. List<string> lw = new List<string>();
  4349. string tid = GetPostString("ctid");
  4350. if (tid.Length > 0)
  4351. {
  4352. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4353. if (tid.Length > 5)
  4354. {
  4355. List<string> tids = getTidByCtidLike(tid);
  4356. if (tids.Count > 0 && tids.Count < 10)
  4357. {
  4358. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4359. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4360. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4361. {
  4362. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4363. }*/
  4364. }
  4365. }
  4366. lw.Add(tid_sql);
  4367. }
  4368. string shopname = GetPostString("shopname");
  4369. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4370. string buyernick = GetPostString("buyer_nick");
  4371. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4372. //if (tid.Length == 0 && buyernick.Length == 0)
  4373. //{
  4374. // lw.Add(string.Format("IsRefund<={0}", 1));
  4375. //}
  4376. string customer = GetPostString("customer");
  4377. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4378. string design = GetPostString("design");
  4379. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4380. string orderState = GetPostString("orderState");
  4381. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4382. string address = GetPostString("address");
  4383. 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));
  4384. string sellermemo = GetPostString("seller_memo");
  4385. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4386. string supplier = GetPostString("supplier");
  4387. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4388. string OrderArea = GetPostString("order_area");
  4389. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4390. string placedate1 = GetPostString("placedate1");
  4391. string placedate2 = GetPostString("placedate2");
  4392. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4393. if (fdw.Length > 0) lw.Add(fdw);
  4394. string price1 = GetPostString("price1");
  4395. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4396. string price2 = GetPostString("price2");
  4397. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4398. string unusualCon = GetPostString("unusualcon");
  4399. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4400. string posTag = CurrentUser.UserPost.Post.Code;
  4401. if (posTag == "Supplier")
  4402. {
  4403. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4404. }
  4405. else
  4406. {
  4407. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4408. {
  4409. string usershop = CurrentUser.User.pemShop;
  4410. lw.Add(string.Format("ShopId in ({0})", usershop));
  4411. }
  4412. }
  4413. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4414. lw.Add(string.Format("type = 'PDD' "));
  4415. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4416. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4417. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4418. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4419. /*if (tid.Length > 0)
  4420. {
  4421. List<string> tids = new List<string>();
  4422. if (dt != null && dt.Rows.Count > 0)
  4423. {
  4424. foreach (DataRow item in dt.Rows)
  4425. {
  4426. tids.Add("'" + item["tid"] + "'");
  4427. }
  4428. }
  4429. if (tids.Count > 0)
  4430. {
  4431. lw.RemoveAt(0);
  4432. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4433. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4434. dt = WebCache.GetData("view_erptradecell", dStruct);
  4435. }
  4436. }*/
  4437. writeGridDataTableJson(dStruct.TotalCount, dt);
  4438. }
  4439. public void get_erp_jdderiving()
  4440. {
  4441. DataStruct dStruct = GetPostStruct();
  4442. List<string> lw = new List<string>();
  4443. string tid = GetPostString("ctid");
  4444. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4445. string shopname = GetPostString("shopname");
  4446. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4447. string buyernick = GetPostString("buyer_nick");
  4448. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4449. //if (tid.Length == 0 && buyernick.Length == 0)
  4450. //{
  4451. // lw.Add(string.Format("IsRefund<={0}", 1));
  4452. //}
  4453. string customer = GetPostString("customer");
  4454. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4455. string design = GetPostString("design");
  4456. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4457. string orderState = GetPostString("orderState");
  4458. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4459. string address = GetPostString("address");
  4460. 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));
  4461. string sellermemo = GetPostString("seller_memo");
  4462. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4463. string supplier = GetPostString("supplier");
  4464. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4465. string OrderArea = GetPostString("order_area");
  4466. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4467. string placedate1 = GetPostString("placedate1");
  4468. string placedate2 = GetPostString("placedate2");
  4469. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4470. if (fdw.Length > 0) lw.Add(fdw);
  4471. string price1 = GetPostString("price1");
  4472. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4473. string price2 = GetPostString("price2");
  4474. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4475. string unusualCon = GetPostString("unusualcon");
  4476. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4477. string posTag = CurrentUser.UserPost.Post.Code;
  4478. if (posTag == "Supplier")
  4479. {
  4480. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4481. }
  4482. lw.Add(string.Format("OrderState = 6 "));
  4483. lw.Add(string.Format("type = 'JD' "));
  4484. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4485. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4486. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4487. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4488. writeGridDataTableJson(dStruct.TotalCount, dt);
  4489. }
  4490. public void get_erp_demoorderlist()
  4491. {
  4492. DataStruct dStruct = GetPostStruct();
  4493. List<string> lw = new List<string>();
  4494. string tid = GetPostString("ctid");
  4495. if (tid.Length > 0)
  4496. {
  4497. string select_tid = getTidByCtid(tid);
  4498. lw.Add(string.Format("tid='{0}'", select_tid));
  4499. }
  4500. string shopname = GetPostString("shopname");
  4501. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4502. string buyernick = GetPostString("buyer_nick");
  4503. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4504. string customer = GetPostString("customer");
  4505. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4506. string design = GetPostString("design");
  4507. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4508. string orderState = GetPostString("orderState");
  4509. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4510. string address = GetPostString("address");
  4511. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4512. string sellermemo = GetPostString("seller_memo");
  4513. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4514. string supplier = GetPostString("supplier");
  4515. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4516. string OrderArea = GetPostString("order_area");
  4517. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4518. string date1 = GetPostString("date1");
  4519. string date2 = GetPostString("date2");
  4520. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4521. if (dw.Length > 0) lw.Add(dw);
  4522. string price1 = GetPostString("price1");
  4523. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4524. string price2 = GetPostString("price2");
  4525. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4526. string posTag = CurrentUser.UserPost.Post.Code;
  4527. if (posTag == "Supplier")
  4528. {
  4529. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4530. }
  4531. //lw.Add(string.Format("OrderState = 6 "));
  4532. lw.Add(string.Format("IsSample={0}", 3));
  4533. lw.Add(string.Format("IsRefund<={0}", 1));
  4534. dStruct.Order = "pay_time desc";
  4535. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4536. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4537. writeGridDataTableJson(dStruct.TotalCount, dt);
  4538. }
  4539. public void save_erp_checkmemo()
  4540. {
  4541. if (UrlPostParmsCheck("ctid"))
  4542. {
  4543. string ctid = GetPostString("ctid");
  4544. CeErpTradeCell entity = null;
  4545. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4546. if (entity != null)
  4547. {
  4548. entity.CheckMemo = GetPostString("CheckMemo");
  4549. entity.Update();
  4550. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4551. if (trade != null)
  4552. {
  4553. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4554. }
  4555. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4556. returnSuccessMsg("保存成功!");
  4557. return;
  4558. }
  4559. returnErrorMsg("找不到记录");
  4560. }
  4561. }
  4562. public void get_erp_returnlist()
  4563. {
  4564. DataStruct dStruct = GetPostStruct();
  4565. List<string> lw = new List<string>();
  4566. string tid = GetPostString("ctid");
  4567. if (tid.Length > 0)
  4568. {
  4569. string select_tid = getTidByCtid(tid);
  4570. lw.Add(string.Format("tid='{0}'", select_tid));
  4571. }
  4572. string shopname = GetPostString("shopname");
  4573. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4574. string buyernick = GetPostString("buyer_nick");
  4575. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4576. string customer = GetPostString("customer");
  4577. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4578. string design = GetPostString("design");
  4579. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4580. string orderState = GetPostString("orderState");
  4581. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4582. string address = GetPostString("address");
  4583. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4584. string sellermemo = GetPostString("seller_memo");
  4585. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4586. string supplier = GetPostString("supplier");
  4587. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4588. string date1 = GetPostString("date1");
  4589. string date2 = GetPostString("date2");
  4590. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4591. if (dw.Length > 0) lw.Add(dw);
  4592. string bdate1 = GetPostString("backdate1");
  4593. string bdate2 = GetPostString("backdate2");
  4594. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4595. if (dw_back.Length > 0) lw.Add(dw_back);
  4596. string price1 = GetPostString("price1");
  4597. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4598. string price2 = GetPostString("price2");
  4599. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4600. lw.Add(string.Format("IsReturn>0"));
  4601. lw.Add(string.Format("IsXianHuo=0"));
  4602. lw.Add(string.Format("IsReturn!=3"));
  4603. string backtype = GetPostString("backtype");
  4604. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4605. dStruct.Order = "FinishDesignTime desc";
  4606. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4607. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4608. writeGridDataTableJson(dStruct.TotalCount, dt);
  4609. }
  4610. public void get_erp_today_sumreturn()
  4611. {
  4612. DataStruct dStruct = GetPostStruct();
  4613. List<string> lw = new List<string>();
  4614. string bdate1 = GetPostString("returnTimeS");
  4615. string bdate2 = GetPostString("returnTimeE");
  4616. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4617. if (dw_back.Length > 0) lw.Add(dw_back);
  4618. lw.Add(string.Format("IsReturn=0"));
  4619. lw.Add(string.Format("IsXianHuo=0"));
  4620. string mainWhere = string.Join(" and ", lw.ToArray());
  4621. string sql = "";
  4622. if (dw_back.Length > 0)
  4623. {
  4624. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4625. }
  4626. else
  4627. {
  4628. 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 + "'";
  4629. }
  4630. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4631. decimal total = 0, today_finish = 0;
  4632. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4633. {
  4634. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4635. }
  4636. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4637. {
  4638. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4639. }
  4640. var res = new
  4641. {
  4642. data = total,
  4643. data1 = today_finish,
  4644. };
  4645. string ro_jsond = JsonConvert.SerializeObject(res);
  4646. returnSuccess(ro_jsond);
  4647. return;
  4648. }
  4649. public void get_erp_allreturnlist()
  4650. {
  4651. DataStruct dStruct = GetPostStruct();
  4652. List<string> lw = new List<string>();
  4653. string tid = GetPostString("ctid");
  4654. if (tid.Length > 0)
  4655. {
  4656. string select_tid = getTidByCtid(tid);
  4657. lw.Add(string.Format("tid='{0}'", select_tid));
  4658. }
  4659. string shopname = GetPostString("shopname");
  4660. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4661. string buyernick = GetPostString("buyer_nick");
  4662. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4663. string customer = GetPostString("customer");
  4664. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4665. string design = GetPostString("design");
  4666. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4667. string orderState = GetPostString("orderState");
  4668. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4669. string address = GetPostString("address");
  4670. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4671. string sellermemo = GetPostString("seller_memo");
  4672. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4673. string supplier = GetPostString("supplier");
  4674. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4675. string date1 = GetPostString("date1");
  4676. string date2 = GetPostString("date2");
  4677. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4678. if (dw.Length > 0) lw.Add(dw);
  4679. string bdate1 = GetPostString("backdate1");
  4680. string bdate2 = GetPostString("backdate2");
  4681. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4682. if (dw_back.Length > 0) lw.Add(dw_back);
  4683. string price1 = GetPostString("price1");
  4684. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4685. string price2 = GetPostString("price2");
  4686. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4687. string backreason = GetPostString("backreason");
  4688. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4689. lw.Add(string.Format("IsXianHuo=0"));
  4690. lw.Add(string.Format("ReturnTime != ''"));
  4691. string backtype = GetPostString("backtype");
  4692. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4693. string posTag = CurrentUser.UserPost.Post.Code;
  4694. if (posTag == "Supplier")
  4695. {
  4696. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4697. }
  4698. else
  4699. {
  4700. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4701. {
  4702. string usershop = CurrentUser.User.pemShop;
  4703. lw.Add(string.Format("ShopId in ({0})", usershop));
  4704. }
  4705. }
  4706. dStruct.Order = "FinishDesignTime desc";
  4707. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4708. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4709. writeGridDataTableJson(dStruct.TotalCount, dt);
  4710. }
  4711. public void get_erp_aftersalereturnlist()
  4712. {
  4713. DataStruct dStruct = GetPostStruct();
  4714. List<string> lw = new List<string>();
  4715. string tid = GetPostString("ctid");
  4716. if (tid.Length > 0)
  4717. {
  4718. string select_tid = getTidByCtid(tid);
  4719. lw.Add(string.Format("tid='{0}'", select_tid));
  4720. }
  4721. string shopname = GetPostString("shopname");
  4722. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4723. string buyernick = GetPostString("buyer_nick");
  4724. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4725. string customer = GetPostString("customer");
  4726. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4727. string design = GetPostString("design");
  4728. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4729. string orderState = GetPostString("orderState");
  4730. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4731. string address = GetPostString("address");
  4732. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4733. string sellermemo = GetPostString("seller_memo");
  4734. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4735. string supplier = GetPostString("supplier");
  4736. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4737. string date1 = GetPostString("date1");
  4738. string date2 = GetPostString("date2");
  4739. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4740. if (dw.Length > 0) lw.Add(dw);
  4741. string bdate1 = GetPostString("backdate1");
  4742. string bdate2 = GetPostString("backdate2");
  4743. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4744. if (dw_back.Length > 0) lw.Add(dw_back);
  4745. string price1 = GetPostString("price1");
  4746. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4747. string price2 = GetPostString("price2");
  4748. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4749. lw.Add(string.Format("IsReturn=3"));
  4750. string backtype = GetPostString("backtype");
  4751. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4752. string backreason = GetPostString("backreason");
  4753. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4754. dStruct.Order = "ReturnTime desc";
  4755. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4756. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4757. writeGridDataTableJson(dStruct.TotalCount, dt);
  4758. }
  4759. public void get_erp_xianhuoreturnlist()
  4760. {
  4761. DataStruct dStruct = GetPostStruct();
  4762. List<string> lw = new List<string>();
  4763. string tid = GetPostString("ctid");
  4764. if (tid.Length > 0)
  4765. {
  4766. string select_tid = getTidByCtid(tid);
  4767. lw.Add(string.Format("tid='{0}'", select_tid));
  4768. }
  4769. string shopname = GetPostString("shopname");
  4770. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4771. string buyernick = GetPostString("buyer_nick");
  4772. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4773. string customer = GetPostString("customer");
  4774. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4775. string design = GetPostString("design");
  4776. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4777. string orderState = GetPostString("orderState");
  4778. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4779. string address = GetPostString("address");
  4780. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4781. string sellermemo = GetPostString("seller_memo");
  4782. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4783. string supplier = GetPostString("supplier");
  4784. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4785. string OrderArea = GetPostString("order_area");
  4786. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4787. string date1 = GetPostString("date1");
  4788. string date2 = GetPostString("date2");
  4789. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4790. if (dw.Length > 0) lw.Add(dw);
  4791. string price1 = GetPostString("price1");
  4792. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4793. string price2 = GetPostString("price2");
  4794. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4795. string posTag = CurrentUser.UserPost.Post.Code;
  4796. if (posTag == "Supplier")
  4797. {
  4798. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4799. }
  4800. lw.Add(string.Format("OrderState=6 "));
  4801. lw.Add(string.Format("IsXianHuo=1 "));
  4802. lw.Add(string.Format("IsReturn>0 "));
  4803. lw.Add(string.Format("IsReturn < 3"));
  4804. lw.Add(string.Format("IsRefund<={0}", 1));
  4805. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4806. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4807. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4808. writeGridDataTableJson(dStruct.TotalCount, dt);
  4809. }
  4810. public void set_erp_orderdelivery()
  4811. {
  4812. if (UrlPostParmsCheck("ctid"))
  4813. {
  4814. string eid = GetPostString("ctid");
  4815. CeErpTradeCell entity = null;
  4816. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4817. if (entity != null)
  4818. {
  4819. if (entity.OrderState >= 7)
  4820. {
  4821. returnErrorMsg("此单已发货,无需重复发货");
  4822. return;
  4823. }
  4824. if (entity.OrderState != 6)
  4825. {
  4826. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4827. return;
  4828. }
  4829. string shop = GetPostString("seller_nick");
  4830. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4831. string comName = GetPostString("comName");
  4832. string comCode = GetPostString("comCode");
  4833. string outSid = GetPostString("outSid");
  4834. string deliveryType = GetPostString("deliveryType");
  4835. string deliveryMemo = GetPostString("deliveryMemo");
  4836. outSid = outSid.Trim();
  4837. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4838. if (mainEn == null)
  4839. {
  4840. returnErrorMsg("找不到原始订单记录");
  4841. return;
  4842. }
  4843. bool isInitOrderDeliv = false;
  4844. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4845. {
  4846. isInitOrderDeliv = true;
  4847. }
  4848. string apires = "";
  4849. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4850. 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)
  4851. {
  4852. apires = "发货成功true";
  4853. }
  4854. else
  4855. {
  4856. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4857. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid, entity.ctid);
  4858. }
  4859. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4860. {
  4861. entity.OrderState = 7;//发货后订单已发货
  4862. entity.OutSid = outSid;
  4863. entity.MemoOpt = 0;
  4864. entity.UpdateTime = DateTime.Now;
  4865. entity.FinishDeliveryTime = DateTime.Now;
  4866. entity.Update();
  4867. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4868. commonHelper.UpdateRelationOrder(entity.ctid);
  4869. //还要插入快递信息到 快递信息表
  4870. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4871. exinfo.tid = eid;
  4872. exinfo.out_sid = outSid;
  4873. exinfo.company_code = comCode;
  4874. exinfo.company_name = comName;
  4875. exinfo.delivery_memo = deliveryMemo;
  4876. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4877. exinfo.deliveryType = deliveryType;
  4878. exinfo.printUser = CurrentUser.UserName;
  4879. exinfo.print_time = DateTime.Now;
  4880. exinfo.Create();
  4881. returnSuccessMsg("发货操作成功!");
  4882. commonHelper.UpdateRelationOrder(entity.ctid);
  4883. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4884. CeErpSukuraData.createInfo(entity.ctid, 4);
  4885. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4886. {
  4887. commonHelper.sendCytExpress(exinfo);
  4888. }
  4889. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4890. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4891. }
  4892. else
  4893. {
  4894. string errmsg = commonHelper.KeepChinese(apires);
  4895. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4896. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4897. }
  4898. return;
  4899. }
  4900. returnErrorMsg("找不到订单记录");
  4901. }
  4902. }
  4903. public void set_erp_multidelivery()
  4904. {
  4905. string eids = GetPostString("tids");
  4906. string[] eidList = eids.Split(',');
  4907. if (eidList.Length <= 0)
  4908. {
  4909. returnErrorMsg("发货不能为空");
  4910. return;
  4911. }
  4912. foreach (string ctid in eidList)
  4913. {
  4914. if (ctid.Length <= 0) continue;
  4915. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4916. if (expInfo != null)
  4917. {
  4918. StringBuilder sql = new StringBuilder();
  4919. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4920. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4921. if (dt.Rows.Count > 0)
  4922. {
  4923. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4924. {
  4925. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4926. expInfo.state = "异常";
  4927. expInfo.isMultiDelivery = 1;
  4928. expInfo.Update();
  4929. continue;
  4930. }
  4931. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4932. {
  4933. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4934. expInfo.state = "异常";
  4935. expInfo.Update();
  4936. continue;
  4937. }
  4938. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4939. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4940. bool isInitOrderDeliv = false;
  4941. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4942. {
  4943. isInitOrderDeliv = true;
  4944. expInfo.isMultiDelivery = 1;
  4945. }
  4946. if (ctid.IndexOf("N") != -1)
  4947. {
  4948. StringBuilder sqlbucha = new StringBuilder();
  4949. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4950. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4951. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4952. commonHelper.UpdateRelationOrder(ctid);
  4953. expInfo.delivery_memo = "发货成功";
  4954. expInfo.state = "发货成功";
  4955. expInfo.isMultiDelivery = 1;
  4956. expInfo.Update();
  4957. }
  4958. else
  4959. {
  4960. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4961. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid, ctid);
  4962. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4963. {
  4964. expInfo.delivery_memo = "发货成功";
  4965. expInfo.state = "发货成功";
  4966. expInfo.isMultiDelivery = 1;
  4967. expInfo.Update();
  4968. commonHelper.UpdateRelationOrder(ctid);
  4969. CeErpSukuraData.createInfo(ctid, 4);
  4970. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4971. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4972. }
  4973. else
  4974. {
  4975. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4976. expInfo.state = "异常";
  4977. expInfo.Update();
  4978. }
  4979. }
  4980. }
  4981. }
  4982. }
  4983. returnSuccessMsg("操作完成");
  4984. }
  4985. public void reset_erp_memoopt()
  4986. {
  4987. if (UrlPostParmsCheck("ctid"))
  4988. {
  4989. string eid = GetPostString("ctid");
  4990. CeErpTradeCell entity = null;
  4991. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4992. if (entity != null)
  4993. {
  4994. string stropt = "";
  4995. if (entity.MemoOpt == 1)
  4996. {
  4997. stropt = "“改稿”";
  4998. }
  4999. else if (entity.MemoOpt == 2)
  5000. {
  5001. stropt = "“定稿”";
  5002. }
  5003. else if (entity.MemoOpt == 3)
  5004. {
  5005. stropt = "“完成查货”";
  5006. CeErpSukuraData.createInfo(entity.ctid, 6);
  5007. }
  5008. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  5009. entity.UpdateTime = DateTime.Now;
  5010. entity.MemoOpt = 0;
  5011. entity.Update();
  5012. returnSuccessMsg("操作成功!");
  5013. return;
  5014. }
  5015. returnErrorMsg("找不到记录");
  5016. }
  5017. }
  5018. public void get_erp_deliveryunusual()
  5019. {
  5020. DataStruct dStruct = GetPostStruct();
  5021. List<string> lw = new List<string>();
  5022. string tid = GetPostString("ctid");
  5023. if (tid.Length > 0)
  5024. {
  5025. string select_tid = getTidByCtid(tid);
  5026. lw.Add(string.Format("tid='{0}'", select_tid));
  5027. }
  5028. string shopname = GetPostString("shopname");
  5029. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5030. string buyernick = GetPostString("buyer_nick");
  5031. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5032. string customer = GetPostString("customer");
  5033. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5034. string design = GetPostString("design");
  5035. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5036. string sellermemo = GetPostString("seller_memo");
  5037. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5038. string supplier = GetPostString("supplier");
  5039. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5040. string date1 = GetPostString("date1");
  5041. string date2 = GetPostString("date2");
  5042. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5043. if (dw.Length > 0) lw.Add(dw);
  5044. string placedate1 = GetPostString("placedate1");
  5045. string placedate2 = GetPostString("placedate2");
  5046. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5047. if (dw_place.Length > 0) lw.Add(dw_place);
  5048. string price1 = GetPostString("price1");
  5049. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5050. string price2 = GetPostString("price2");
  5051. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5052. string unusualCon = GetPostString("unusualcon");
  5053. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5054. string posTag = CurrentUser.UserPost.Post.Code;
  5055. if (posTag == "Supplier")
  5056. {
  5057. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5058. }
  5059. lw.Add(string.Format("OrderState = 6"));
  5060. lw.Add(string.Format("UnusualTag = 5"));
  5061. lw.Add(string.Format("IsRefund<={0}", 1));
  5062. dStruct.Order = "FinishPlaceTime desc";
  5063. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5064. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5065. writeGridDataTableJson(dStruct.TotalCount, dt);
  5066. }
  5067. public void get_erp_deliveryedlist()
  5068. {
  5069. DataStruct dStruct = GetPostStruct();
  5070. List<string> lw = new List<string>();
  5071. string tid = GetPostString("ctid");
  5072. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5073. string shopname = GetPostString("shopname");
  5074. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5075. string buyernick = GetPostString("buyer_nick");
  5076. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5077. string customer = GetPostString("customer");
  5078. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5079. string design = GetPostString("design");
  5080. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5081. string sellermemo = GetPostString("seller_memo");
  5082. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5083. string logistics = GetPostString("logistics");
  5084. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5085. string date1 = GetPostString("date1");
  5086. string date2 = GetPostString("date2");
  5087. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5088. //if (dw.Length > 0) lw.Add(dw);
  5089. string placedate1 = GetPostString("placedate1");
  5090. string placedate2 = GetPostString("placedate2");
  5091. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5092. if (fdw.Length > 0) lw.Add(fdw);
  5093. string devdate1 = GetPostString("deliverydate1");
  5094. string devdate2 = GetPostString("deliverydate2");
  5095. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5096. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5097. string price1 = GetPostString("price1");
  5098. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5099. string price2 = GetPostString("price2");
  5100. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5101. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5102. {
  5103. if (tid.Length > 0)
  5104. {
  5105. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5106. if (tid.Length > 5)
  5107. {
  5108. List<string> tids = getTidByCtidLike(tid);
  5109. if (tids.Count > 0 && tids.Count < 10)
  5110. {
  5111. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5112. }
  5113. }
  5114. lw.Add(tid_sql);
  5115. }
  5116. if (buyernick.Length > 0)
  5117. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5118. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5119. if (dw.Length > 0) lw.Add(dw);
  5120. }
  5121. else
  5122. {
  5123. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5124. }
  5125. string posTag = CurrentUser.UserPost.Post.Code;
  5126. if (posTag == "Supplier")
  5127. {
  5128. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5129. }
  5130. else
  5131. {
  5132. string supplier = GetPostString("supplier");
  5133. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5134. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5135. {
  5136. string usershop = CurrentUser.User.pemShop;
  5137. lw.Add(string.Format("ShopId in ({0})", usershop));
  5138. }
  5139. }
  5140. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5141. lw.Add(string.Format("type != 'PDD' "));
  5142. lw.Add(string.Format("IsRefund!={0}", 2));
  5143. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5144. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5145. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5146. /*if (tid.Length > 0)
  5147. {
  5148. List<string> tids = new List<string>();
  5149. if (dt != null && dt.Rows.Count > 0)
  5150. {
  5151. foreach (DataRow item in dt.Rows)
  5152. {
  5153. tids.Add("'" + item["tid"] + "'");
  5154. }
  5155. }
  5156. if (tids.Count > 0)
  5157. {
  5158. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5159. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5160. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5161. dt = WebCache.GetData("view_erptradecell", dStruct);
  5162. }
  5163. }*/
  5164. if (dt != null)
  5165. {
  5166. foreach (DataRow dr in dt.Rows)
  5167. {
  5168. 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();
  5169. }
  5170. }
  5171. writeGridDataTableJson(dStruct.TotalCount, dt);
  5172. }
  5173. public void get_erp_pdddeliveryed()
  5174. {
  5175. DataStruct dStruct = GetPostStruct();
  5176. List<string> lw = new List<string>();
  5177. string tid = GetPostString("ctid");
  5178. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5179. string shopname = GetPostString("shopname");
  5180. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5181. string buyernick = GetPostString("buyer_nick");
  5182. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5183. string customer = GetPostString("customer");
  5184. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5185. string design = GetPostString("design");
  5186. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5187. string sellermemo = GetPostString("seller_memo");
  5188. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5189. string logistics = GetPostString("logistics");
  5190. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5191. string date1 = GetPostString("date1");
  5192. string date2 = GetPostString("date2");
  5193. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5194. //if (dw.Length > 0) lw.Add(dw);
  5195. string placedate1 = GetPostString("placedate1");
  5196. string placedate2 = GetPostString("placedate2");
  5197. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5198. if (fdw.Length > 0) lw.Add(fdw);
  5199. string devdate1 = GetPostString("deliverydate1");
  5200. string devdate2 = GetPostString("deliverydate2");
  5201. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5202. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5203. string price1 = GetPostString("price1");
  5204. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5205. string price2 = GetPostString("price2");
  5206. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5207. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5208. {
  5209. if (tid.Length > 0)
  5210. {
  5211. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5212. if (tid.Length > 5)
  5213. {
  5214. List<string> tids = getTidByCtidLike(tid);
  5215. if (tids.Count > 0 && tids.Count < 10)
  5216. {
  5217. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5218. }
  5219. }
  5220. lw.Add(tid_sql);
  5221. }
  5222. if (buyernick.Length > 0)
  5223. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5224. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5225. if (dw.Length > 0) lw.Add(dw);
  5226. }
  5227. else
  5228. {
  5229. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5230. }
  5231. string posTag = CurrentUser.UserPost.Post.Code;
  5232. if (posTag == "Supplier")
  5233. {
  5234. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5235. }
  5236. else
  5237. {
  5238. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5239. {
  5240. string usershop = CurrentUser.User.pemShop;
  5241. lw.Add(string.Format("ShopId in ({0})", usershop));
  5242. }
  5243. string supplier = GetPostString("supplier");
  5244. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5245. }
  5246. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5247. lw.Add(string.Format("type = 'PDD' "));
  5248. lw.Add(string.Format("IsRefund!={0}", 2));
  5249. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5250. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5251. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5252. /* if (tid.Length > 0)
  5253. {
  5254. List<string> tids = new List<string>();
  5255. if (dt != null && dt.Rows.Count > 0)
  5256. {
  5257. foreach (DataRow item in dt.Rows)
  5258. {
  5259. tids.Add("'" + item["tid"] + "'");
  5260. }
  5261. }
  5262. if (tids.Count > 0)
  5263. {
  5264. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5265. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5266. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5267. dt = WebCache.GetData("view_erptradecell", dStruct);
  5268. }
  5269. }*/
  5270. foreach (DataRow dr in dt.Rows)
  5271. {
  5272. 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();
  5273. }
  5274. writeGridDataTableJson(dStruct.TotalCount, dt);
  5275. }
  5276. public void get_erp_jddeliveryed()
  5277. {
  5278. DataStruct dStruct = GetPostStruct();
  5279. List<string> lw = new List<string>();
  5280. string tid = GetPostString("ctid");
  5281. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5282. string shopname = GetPostString("shopname");
  5283. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5284. string buyernick = GetPostString("buyer_nick");
  5285. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5286. string customer = GetPostString("customer");
  5287. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5288. string design = GetPostString("design");
  5289. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5290. string sellermemo = GetPostString("seller_memo");
  5291. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5292. string date1 = GetPostString("date1");
  5293. string date2 = GetPostString("date2");
  5294. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5295. //if (dw.Length > 0) lw.Add(dw);
  5296. string placedate1 = GetPostString("placedate1");
  5297. string placedate2 = GetPostString("placedate2");
  5298. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5299. if (fdw.Length > 0) lw.Add(fdw);
  5300. string devdate1 = GetPostString("deliverydate1");
  5301. string devdate2 = GetPostString("deliverydate2");
  5302. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5303. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5304. string price1 = GetPostString("price1");
  5305. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5306. string price2 = GetPostString("price2");
  5307. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5308. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5309. {
  5310. if (tid.Length > 0)
  5311. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5312. if (buyernick.Length > 0)
  5313. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5314. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5315. if (dw.Length > 0) lw.Add(dw);
  5316. }
  5317. else
  5318. {
  5319. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5320. }
  5321. string posTag = CurrentUser.UserPost.Post.Code;
  5322. if (posTag == "Supplier")
  5323. {
  5324. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5325. }
  5326. else
  5327. {
  5328. string supplier = GetPostString("supplier");
  5329. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5330. }
  5331. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5332. lw.Add(string.Format("type = 'JD' "));
  5333. lw.Add(string.Format("IsRefund!={0}", 2));
  5334. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5335. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5336. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5337. foreach (DataRow dr in dt.Rows)
  5338. {
  5339. 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();
  5340. }
  5341. writeGridDataTableJson(dStruct.TotalCount, dt);
  5342. }
  5343. public void get_erp_allplacelist()
  5344. {
  5345. DataStruct dStruct = GetPostStruct();
  5346. List<string> lw = new List<string>();
  5347. string tid = GetPostString("ctid");
  5348. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5349. string shopname = GetPostString("shopname");
  5350. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5351. string buyernick = GetPostString("buyer_nick");
  5352. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5353. string customer = GetPostString("customer");
  5354. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5355. string design = GetPostString("design");
  5356. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5357. string sellermemo = GetPostString("seller_memo");
  5358. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5359. string supplier = GetPostString("supplier");
  5360. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5361. string date1 = GetPostString("date1");
  5362. string date2 = GetPostString("date2");
  5363. string pldate1 = GetPostString("placedate1");
  5364. string pldate2 = GetPostString("placedate2");
  5365. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5366. //if (dw.Length > 0) lw.Add(dw);
  5367. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5368. {
  5369. if (tid.Length > 0)
  5370. {
  5371. string select_tid = getTidByCtid(tid);
  5372. lw.Add(string.Format("tid='{0}'", select_tid));
  5373. }
  5374. if (buyernick.Length > 0)
  5375. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5376. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5377. if (dw.Length > 0) lw.Add(dw);
  5378. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5379. if (dw_place.Length > 0) lw.Add(dw_place);
  5380. }
  5381. else
  5382. {
  5383. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5384. {
  5385. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5386. }
  5387. }
  5388. string price1 = GetPostString("price1");
  5389. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5390. string price2 = GetPostString("price2");
  5391. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5392. string posTag = CurrentUser.UserPost.Post.Code;
  5393. if (posTag == "Supplier")
  5394. {
  5395. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5396. }
  5397. lw.Add(string.Format("OrderState >= 6"));
  5398. lw.Add(string.Format("IsSample != 2 "));
  5399. //lw.Add(string.Format("isDianziOrder = 0 "));
  5400. lw.Add(string.Format("SupplierId > 0 "));
  5401. //lw.Add(string.Format("IsRefund<={0}", 1));
  5402. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5403. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5404. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5405. foreach (DataRow dr in dt.Rows)
  5406. {
  5407. 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();
  5408. }
  5409. writeGridDataTableJson(dStruct.TotalCount, dt);
  5410. }
  5411. public void get_erp_financeallplacelist()
  5412. {
  5413. DataStruct dStruct = GetPostStruct();
  5414. List<string> lw = new List<string>();
  5415. string tid = GetPostString("ctid");
  5416. string shopname = GetPostString("shopname");
  5417. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5418. string buyernick = GetPostString("buyer_nick");
  5419. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5420. string customer = GetPostString("customer");
  5421. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5422. string design = GetPostString("design");
  5423. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5424. string sellermemo = GetPostString("seller_memo");
  5425. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5426. string supplier = GetPostString("supplier");
  5427. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5428. string date1 = GetPostString("date1");
  5429. string date2 = GetPostString("date2");
  5430. string pldate1 = GetPostString("placedate1");
  5431. string pldate2 = GetPostString("placedate2");
  5432. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5433. {
  5434. if (tid.Length > 0)
  5435. {
  5436. string select_tid = getTidByCtid(tid);
  5437. lw.Add(string.Format("tid='{0}'", select_tid));
  5438. }
  5439. if (buyernick.Length > 0)
  5440. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5441. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5442. if (dw.Length > 0) lw.Add(dw);
  5443. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5444. if (dw_place.Length > 0) lw.Add(dw_place);
  5445. }
  5446. else
  5447. {
  5448. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5449. {
  5450. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5451. }
  5452. }
  5453. string price1 = GetPostString("price1");
  5454. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5455. string price2 = GetPostString("price2");
  5456. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5457. string posTag = CurrentUser.UserPost.Post.Code;
  5458. if (posTag == "Supplier")
  5459. {
  5460. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5461. }
  5462. //lw.Add(string.Format("OrderState >= 6"));
  5463. lw.Add(string.Format("IsSample != 2 "));
  5464. lw.Add(string.Format("isDianziOrder = 0 "));
  5465. //lw.Add(string.Format("IsRefund<={0}", 1));
  5466. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5467. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5468. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5469. foreach (DataRow dr in dt.Rows)
  5470. {
  5471. 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();
  5472. }
  5473. writeGridDataTableJson(dStruct.TotalCount, dt);
  5474. }
  5475. public void get_erp_expresslist()
  5476. {
  5477. int listtype = GetInt("ltype");
  5478. DataStruct dStruct = GetPostStruct();
  5479. List<string> lw = new List<string>();
  5480. string tid = GetPostString("tid");
  5481. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5482. string outsid = GetPostString("out_sid");
  5483. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5484. string importer = GetPostString("ImportUserName");
  5485. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5486. string file = GetPostString("import_file");
  5487. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5488. string printman = GetPostString("printman");
  5489. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5490. string date1 = GetPostString("date1");
  5491. string date2 = GetPostString("date2");
  5492. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5493. if (dw.Length > 0) lw.Add(dw);
  5494. string fdate1 = GetPostString("finishdate1");
  5495. string fdate2 = GetPostString("finishdate2");
  5496. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5497. if (fdw.Length > 0) lw.Add(fdw);
  5498. string supplierId = GetPostString("supplierId");
  5499. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5500. if (listtype == 1)
  5501. {
  5502. lw.Add(string.Format("importUserId !=0"));
  5503. }
  5504. string posTag = CurrentUser.UserPost.Post.Code;
  5505. if (posTag == "Supplier")
  5506. {
  5507. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5508. }
  5509. if (dStruct.PageSize != 100000)
  5510. {
  5511. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5512. }
  5513. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5514. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5515. writeGridDataTableJson(dStruct.TotalCount, dt);
  5516. }
  5517. public void set_erp_buchaorderdelivery()
  5518. {
  5519. if (UrlPostParmsCheck("ctid"))
  5520. {
  5521. string eid = GetPostString("ctid");
  5522. CeErpTradeCell entity = null;
  5523. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5524. if (entity != null)
  5525. {
  5526. if (entity.IsSample != 2)
  5527. {
  5528. returnErrorMsg("补差价单才能标记为已发货");
  5529. return;
  5530. }
  5531. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5532. entity.OrderState = 7;
  5533. entity.Update();
  5534. returnSuccessMsg("操作成功!");
  5535. return;
  5536. }
  5537. returnErrorMsg("找不到记录");
  5538. }
  5539. }
  5540. public void get_stdtemplates()
  5541. {
  5542. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5543. //string res = taobaoHelper.test();
  5544. string res = apiHelper.API_PrintTemplate();
  5545. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5546. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5547. {
  5548. int sidx = res.IndexOf("error_code");
  5549. int eidx = res.IndexOf("success");
  5550. string msg = res.Substring(sidx, eidx - sidx);
  5551. returnErrorMsg(msg);
  5552. return;
  5553. }
  5554. if (res.Length <= 0)
  5555. {
  5556. returnErrorMsg("模板数据为空!");
  5557. return;
  5558. }
  5559. ReturnSuccess(res);
  5560. }
  5561. public void cancel_print_order()
  5562. {
  5563. if (UrlPostParmsCheck("ctid"))
  5564. {
  5565. string ctid = GetPostString("ctid");
  5566. CeErpTradeCell entity = null;
  5567. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5568. if (entity != null)
  5569. {
  5570. string res = "";
  5571. string code = entity.LastBillWaybillCode;
  5572. if (code == "")
  5573. {
  5574. code = entity.OutSid;
  5575. }
  5576. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5577. XLog.SaveLog(0, "取消面单" + res);
  5578. }
  5579. }
  5580. }
  5581. public void set_erp_printwaybill()
  5582. {
  5583. if (UrlPostParmsCheck("ctid"))
  5584. {
  5585. string ctid = GetPostString("ctid");
  5586. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5587. string cpName = GetPostString("cpname");
  5588. string isTogether = GetPostString("together");
  5589. string printType = GetPostString("printType");
  5590. //var res_obj = new
  5591. //{
  5592. // restype = 1,
  5593. // 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\"}"
  5594. //};
  5595. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5596. //ReturnSuccess(ro_json);
  5597. //return;
  5598. bool isUseLastWayBillCode = false;
  5599. CeErpTradeCell entity = null;
  5600. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5601. if (entity != null)
  5602. {
  5603. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5604. {
  5605. isUseLastWayBillCode = true;
  5606. }
  5607. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5608. {
  5609. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5610. return;
  5611. }
  5612. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5613. {
  5614. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5615. return;
  5616. }
  5617. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5618. {
  5619. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5620. return;
  5621. }
  5622. }
  5623. string res = "";
  5624. Api_waybill_code_response_Obj fullObj = null;
  5625. string pData_str = "";
  5626. string curUseWayBillCode = "";
  5627. if (isUseLastWayBillCode == false)
  5628. {
  5629. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5630. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5631. if (res.IndexOf("failure") != -1)
  5632. {
  5633. //int idx = res.IndexOf("sub_message");
  5634. //int idx2 = res.IndexOf("flag");
  5635. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5636. string errMsgNeed = commonHelper.KeepChinese(res);
  5637. var res_objd = new
  5638. {
  5639. restype = 0,
  5640. data = "获取面单失败" + errMsgNeed
  5641. };
  5642. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5643. returnSuccess(ro_jsond);
  5644. if (res.IndexOf("停发") != -1)
  5645. {
  5646. entity.UnusualCon = "物流停发";
  5647. entity.Update();
  5648. }
  5649. //returnErrorMsg("获取面单失败,"+emsg);
  5650. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5651. return;
  5652. }
  5653. else if (res.IndexOf("errorMsg") != -1)
  5654. {
  5655. //int idx = res.IndexOf("errorMsg");
  5656. //int idx2 = res.IndexOf("}]}");
  5657. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5658. string errMsgNeed = commonHelper.KeepChinese(res);
  5659. var res_objf = new
  5660. {
  5661. restype = 0,
  5662. data = "获取面单失败2" + errMsgNeed
  5663. };
  5664. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5665. if (res.IndexOf("停发") != -1)
  5666. {
  5667. entity.UnusualCon = "物流停发";
  5668. entity.Update();
  5669. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5670. if (trade != null)
  5671. {
  5672. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5673. }
  5674. }
  5675. returnSuccess(ro_jsonf);
  5676. //returnErrorMsg("获取面单失败," + emsg);
  5677. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5678. return;
  5679. }
  5680. try
  5681. {
  5682. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5683. //res = res.Replace(" ", "");
  5684. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5685. }
  5686. catch (Exception ex)
  5687. {
  5688. XLog.SaveLog(0, "生成fullObj" + res);
  5689. var res_objf = new
  5690. {
  5691. restype = 0,
  5692. data = "生成fullObj发生错误" + ex.Message
  5693. };
  5694. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5695. returnSuccess(ro_jsonf);
  5696. return;
  5697. }
  5698. if (fullObj.response.data.content.Count > 0)
  5699. {
  5700. ContentItem codeObj = fullObj.response.data.content[0];
  5701. if (cpCode.IndexOf("SFFQ-") != -1)
  5702. {
  5703. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5704. }
  5705. else
  5706. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5707. curUseWayBillCode = codeObj.waybillCode;
  5708. }
  5709. else
  5710. {
  5711. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5712. var res_objf = new
  5713. {
  5714. restype = 0,
  5715. data = "生成fullObj找不到快递单号waybillCode"
  5716. };
  5717. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5718. returnSuccess(ro_jsonf);
  5719. return;
  5720. }
  5721. }
  5722. else
  5723. {
  5724. //使用上次打印的快递单号
  5725. if (cpCode == "SFFQ-LY")
  5726. {
  5727. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5728. }
  5729. else
  5730. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5731. curUseWayBillCode = entity.LastBillWaybillCode;
  5732. }
  5733. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5734. {
  5735. var res_obje = new
  5736. {
  5737. restype = 0,
  5738. data = "获取加密打印数据失败"
  5739. };
  5740. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5741. returnSuccess(ro_jsone);
  5742. entity.LastBillCpCode = cpCode;
  5743. entity.LastBillWaybillCode = curUseWayBillCode;
  5744. entity.Update();
  5745. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5746. //returnErrorMsg("获取加密打印数据失败");
  5747. return;
  5748. }
  5749. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5750. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5751. string btnType = "";
  5752. string errorMsg = "";
  5753. if (entity != null)
  5754. {
  5755. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5756. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5757. //cpcode是 YTO-CAINIAO
  5758. //string comCode = cpCode.Split('-')[0].ToString();
  5759. string apires = "";
  5760. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5761. //isTogether=2是新的合包弹窗
  5762. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5763. {
  5764. if (ctid.IndexOf("N") != -1)
  5765. {
  5766. apires = "发货成功";
  5767. }
  5768. else
  5769. {
  5770. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode, entity.ctid);
  5771. }
  5772. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5773. //打单后发货
  5774. StringBuilder sql = new StringBuilder();
  5775. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5776. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5777. {
  5778. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5779. }
  5780. else
  5781. {
  5782. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5783. }
  5784. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5785. foreach (DataRow row in dt.Rows)
  5786. {
  5787. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5788. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5789. {
  5790. try
  5791. {
  5792. btnType = "待发货";
  5793. entity.OutSid = curUseWayBillCode;
  5794. entity.OrderState = 7;
  5795. entity.IsUrgency = false;
  5796. entity.LastBillCpCode = "";
  5797. entity.LastBillWaybillCode = "";
  5798. entity.FinishDeliveryTime = DateTime.Now;
  5799. entity.IsReturn = 0;
  5800. entity.MemoOpt = 0;
  5801. entity.UpdateTime = DateTime.Now;
  5802. entity.Update();
  5803. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5804. //还要插入快递信息到 快递信息表
  5805. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5806. exinfo.tid = entity.ctid;
  5807. exinfo.out_sid = curUseWayBillCode;
  5808. exinfo.company_code = cpCode;
  5809. exinfo.company_name = cpName;
  5810. exinfo.supplierUserName = supplierName;
  5811. exinfo.deliveryType = "发货成功";
  5812. exinfo.print_time = DateTime.Now;
  5813. exinfo.printUser = CurrentUser.UserName;
  5814. exinfo.postData = pData_str;
  5815. exinfo.Create();
  5816. commonHelper.UpdateRelationOrder(entity.ctid);
  5817. CeErpSukuraData.createInfo(ctid, 4);
  5818. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5819. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5820. {
  5821. commonHelper.sendCytExpress(exinfo);
  5822. }
  5823. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5824. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5825. }
  5826. catch (Exception ex)
  5827. {
  5828. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5829. }
  5830. }
  5831. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5832. {
  5833. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5834. if (entity.OrderState == 6)
  5835. {
  5836. entity.OrderState = 7;
  5837. }
  5838. entity.UpdateTime = DateTime.Now;
  5839. entity.FinishDeliveryTime = DateTime.Now;
  5840. btnType = "已发货";
  5841. entity.Update();
  5842. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5843. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5844. exinfo.tid = entity.ctid;
  5845. exinfo.out_sid = curUseWayBillCode;
  5846. exinfo.company_code = cpCode;
  5847. exinfo.company_name = cpName;
  5848. exinfo.supplierUserName = supplierName;
  5849. exinfo.deliveryType = "发货成功";
  5850. exinfo.print_time = DateTime.Now;
  5851. exinfo.printUser = CurrentUser.UserName;
  5852. exinfo.postData = pData_str;
  5853. exinfo.Create();
  5854. commonHelper.UpdateRelationOrder(entity.ctid);
  5855. CeErpSukuraData.createInfo(entity.ctid, 4);
  5856. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5857. {
  5858. commonHelper.sendCytExpress(exinfo);
  5859. }
  5860. //不处理
  5861. }
  5862. else
  5863. {
  5864. entity.UpdateTime = DateTime.Now;
  5865. entity.LastBillCpCode = cpCode;
  5866. entity.LastBillWaybillCode = curUseWayBillCode;
  5867. entity.Update();
  5868. string errmsg = commonHelper.KeepChinese(apires);
  5869. var res_objz = new
  5870. {
  5871. restype = 0,
  5872. data = "打单后发货失败"
  5873. };
  5874. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5875. returnSuccess(ro_jsonz);
  5876. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5877. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5878. return;
  5879. }
  5880. }
  5881. }
  5882. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5883. {
  5884. string ctids = GetPostString("ctids");
  5885. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5886. List<string> list = new List<string>();
  5887. List<string> send_list = new List<string>();
  5888. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5889. CeErpTrade ceErpTrade = new CeErpTrade();
  5890. //可合包的合并一起发货
  5891. if (dt == null && string.IsNullOrEmpty(ctids))
  5892. {
  5893. var res_objz = new
  5894. {
  5895. restype = 0,
  5896. data = "打单后发货失败"
  5897. };
  5898. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5899. returnSuccess(ro_jsonz);
  5900. return;
  5901. }
  5902. if (!string.IsNullOrEmpty(ctids))
  5903. {
  5904. StringBuilder sql = new StringBuilder();
  5905. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5906. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5907. }
  5908. foreach (DataRow row in dt.Rows)
  5909. {
  5910. list.Add("'" + row["ctid"] + "'");
  5911. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5912. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5913. if (ctid.IndexOf("N") != -1)
  5914. {
  5915. apires = "发货成功";
  5916. }
  5917. else
  5918. {
  5919. if (!send_list.Contains(ceErpTrade.tid))
  5920. {
  5921. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode, ctid);
  5922. }
  5923. else
  5924. {
  5925. apires = "发货成功";
  5926. }
  5927. }
  5928. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5929. {
  5930. send_list.Add(ceErpTrade.tid);
  5931. try
  5932. {
  5933. btnType = "待发货";
  5934. ceErpTradeCell.OutSid = curUseWayBillCode;
  5935. ceErpTradeCell.OrderState = 7;
  5936. ceErpTradeCell.IsUrgency = false;
  5937. ceErpTradeCell.LastBillCpCode = "";
  5938. ceErpTradeCell.LastBillWaybillCode = "";
  5939. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5940. ceErpTradeCell.IsReturn = 0;
  5941. ceErpTradeCell.MemoOpt = 0;
  5942. ceErpTradeCell.UpdateTime = DateTime.Now;
  5943. ceErpTradeCell.Update();
  5944. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5945. //还要插入快递信息到 快递信息表
  5946. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5947. exinfo.tid = ceErpTradeCell.ctid;
  5948. exinfo.out_sid = curUseWayBillCode;
  5949. exinfo.company_code = cpCode;
  5950. exinfo.company_name = cpName;
  5951. exinfo.supplierUserName = supplierName;
  5952. exinfo.deliveryType = "发货成功";
  5953. exinfo.print_time = DateTime.Now;
  5954. exinfo.printUser = CurrentUser.UserName;
  5955. exinfo.postData = pData_str;
  5956. exinfo.Create();
  5957. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5958. CeErpSukuraData.createInfo(ctid, 4);
  5959. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5960. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5961. {
  5962. commonHelper.sendCytExpress(exinfo);
  5963. }
  5964. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5965. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5966. }
  5967. catch (Exception ex)
  5968. {
  5969. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5970. }
  5971. }
  5972. else
  5973. {
  5974. ceErpTradeCell.UpdateTime = DateTime.Now;
  5975. ceErpTradeCell.LastBillCpCode = cpCode;
  5976. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5977. ceErpTradeCell.Update();
  5978. string errmsg = commonHelper.KeepChinese(apires);
  5979. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5980. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5981. }
  5982. }
  5983. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5984. }
  5985. }
  5986. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5987. var res_obj = new
  5988. {
  5989. restype = 1,
  5990. data = pData_str,
  5991. errorMsg
  5992. };
  5993. string ro_json = JsonConvert.SerializeObject(res_obj);
  5994. ReturnSuccess(ro_json);
  5995. return;
  5996. }
  5997. }
  5998. private string GetUTF8String(byte[] vs)
  5999. {
  6000. throw new NotImplementedException();
  6001. }
  6002. public void set_erp_printwaybill_cn()
  6003. {
  6004. if (UrlPostParmsCheck("ctid"))
  6005. {
  6006. string ctid = GetPostString("ctid");
  6007. string cpCode = GetPostString("cpcode");
  6008. string cpName = GetPostString("cpname");
  6009. string tempUrl = GetPostString("tempurl");
  6010. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6011. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  6012. //string res = taobaoHelper.test();
  6013. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6014. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  6015. {
  6016. int sidx = res.IndexOf("errorMsg");
  6017. int eidx = res.IndexOf("}");
  6018. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  6019. var res_objzxx = new
  6020. {
  6021. restype = 0,
  6022. data = msg
  6023. };
  6024. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  6025. returnSuccess(ro_jsonzxx);
  6026. //returnErrorMsg(msg);
  6027. return;
  6028. }
  6029. int idx = res.IndexOf("waybillCode");
  6030. int idx2 = res.IndexOf("printData");
  6031. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  6032. string eid = GetPostString("ctid");
  6033. CeErpTradeCell entity = null;
  6034. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6035. if (entity != null)
  6036. {
  6037. string osid = entity.OutSid;
  6038. entity.OutSid = osid + "," + outsid;
  6039. entity.FinishDeliveryTime = DateTime.Now;
  6040. entity.OrderState = 7;
  6041. entity.UpdateTime = DateTime.Now;
  6042. entity.IsReturn = 0;
  6043. entity.Update();
  6044. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6045. exinfo.tid = entity.ctid;
  6046. exinfo.out_sid = outsid;
  6047. exinfo.company_code = cpCode;
  6048. exinfo.company_name = cpName;
  6049. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6050. exinfo.deliveryType = "发货成功";
  6051. exinfo.print_time = DateTime.Now;
  6052. exinfo.printUser = CurrentUser.UserName;
  6053. exinfo.Create();
  6054. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6055. {
  6056. commonHelper.sendCytExpress(exinfo);
  6057. }
  6058. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6059. }
  6060. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6061. var res_objz = new
  6062. {
  6063. restype = 1,
  6064. data = res
  6065. };
  6066. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6067. returnSuccess(ro_jsonz);
  6068. //ReturnSuccess(res);
  6069. }
  6070. }
  6071. ////打单,打印面单 获取面单号
  6072. //public void set_erp_printwaybill()
  6073. //{
  6074. // if (UrlPostParmsCheck("ctid"))
  6075. // {
  6076. // string ctid = GetPostString("ctid");
  6077. // string cpCode = GetPostString("cpcode");
  6078. // string tempUrl = GetPostString("tempurl");
  6079. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6080. // //string res = taobaoHelper.test();
  6081. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6082. // if (res.IndexOf("error_response") != -1)
  6083. // {
  6084. // int sidx = res.IndexOf("sub_msg");
  6085. // int eidx = res.IndexOf("request_id");
  6086. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6087. // returnErrorMsg(msg);
  6088. // return;
  6089. // }
  6090. // int idx = res.IndexOf("waybill_code");
  6091. // int idx2 = res.IndexOf("}]}");
  6092. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6093. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6094. // ReturnSuccess(res);
  6095. // }
  6096. //}
  6097. public void cancel_erp_aftersale()
  6098. {
  6099. if (UrlPostParmsCheck("ctid"))
  6100. {
  6101. string eid = GetPostString("ctid");
  6102. CeErpTradeCell entity = null;
  6103. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6104. if (entity != null)
  6105. {
  6106. //有过处理的售后,取消也不能删除 售 字,保留
  6107. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6108. {
  6109. entity.AfterSaleState = 4;
  6110. }
  6111. else
  6112. entity.AfterSaleState = 0;
  6113. entity.UpdateTime = DateTime.Now;
  6114. entity.Update();
  6115. returnSuccessMsg("操作成功!");
  6116. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6117. return;
  6118. }
  6119. returnErrorMsg("找不到订单记录");
  6120. }
  6121. }
  6122. public void get_erp_aftersalelist()
  6123. {
  6124. DataStruct dStruct = GetPostStruct();
  6125. List<string> lw = new List<string>();
  6126. int st = GetInt("st");
  6127. string tid = GetPostString("ctid");
  6128. if (st == 3)
  6129. {
  6130. if (tid.Length > 0)
  6131. {
  6132. string select_tid = getTidByCtid(tid);
  6133. lw.Add(string.Format("tid='{0}'", select_tid));
  6134. }
  6135. }
  6136. else
  6137. {
  6138. if (tid.Length > 0)
  6139. {
  6140. string select_tid = getTidByCtid(tid);
  6141. lw.Add(string.Format("tid='{0}'", select_tid));
  6142. }
  6143. }
  6144. string shopname = GetPostString("shopname");
  6145. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6146. string buyernick = GetPostString("buyer_nick");
  6147. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6148. string sellermemo = GetPostString("seller_memo");
  6149. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6150. string orderState = GetPostString("orderState");
  6151. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6152. string afterState = GetPostString("afterstate");
  6153. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6154. string date1 = GetPostString("date1");
  6155. string date2 = GetPostString("date2");
  6156. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6157. if (dw.Length > 0) lw.Add(dw);
  6158. string price1 = GetPostString("price1");
  6159. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6160. string price2 = GetPostString("price2");
  6161. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6162. //lw.Add(string.Format("IsRefund!={0}", 1));
  6163. string reason = GetPostString("reason");
  6164. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6165. string method = GetPostString("method");
  6166. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6167. string handler = GetPostString("handler");
  6168. if (handler.Length > 0)
  6169. {
  6170. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6171. }
  6172. string handledate1 = GetPostString("handledate1");
  6173. string handledate2 = GetPostString("handledate2");
  6174. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6175. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6176. string finish1 = GetPostString("finishdate1");
  6177. string finish2 = GetPostString("finishdate2");
  6178. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6179. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6180. string afterdate1 = GetPostString("afterdate1");
  6181. string afterdate2 = GetPostString("afterdate2");
  6182. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6183. if (afterDate.Length > 0) lw.Add(afterDate);
  6184. string supplier = GetPostString("supplier");
  6185. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6186. string responsible = GetPostString("responsibleman");
  6187. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6188. string customer = GetPostString("customer");
  6189. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6190. string design = GetPostString("design");
  6191. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6192. string afterMemoType = GetPostString("aftermemotype");
  6193. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6194. string posCode = CurrentUser.UserPost.Post.Code;
  6195. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6196. //{
  6197. // string vstate = GetPostString("vstate");
  6198. // if (vstate.Length > 0)
  6199. // {
  6200. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6201. // }
  6202. // if (posCode == "Supplier")
  6203. // {
  6204. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6205. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6206. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6207. // }
  6208. // else
  6209. // {
  6210. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6211. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6212. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6213. // {
  6214. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6215. // }
  6216. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6217. // {
  6218. // int orgid = CurrentUser.UserPost.OrgID;
  6219. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6220. // }
  6221. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6222. // {
  6223. // string shopid = CurrentUser.User.pemShop;
  6224. // lw.Add(string.Format("shopId in ({0})", shopid));
  6225. // }
  6226. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6227. // //{
  6228. // // int org_id = CurrentUser.UserPost.OrgID;
  6229. // // lw.Add(string.Format("OrgID={0}", org_id));
  6230. // //}
  6231. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6232. // }
  6233. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6234. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6235. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6236. //}
  6237. if (st == 5)
  6238. {
  6239. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6240. {
  6241. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6242. {
  6243. string shopid = CurrentUser.User.pemShop;
  6244. lw.Add(string.Format("shopId in ({0})", shopid));
  6245. }
  6246. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6247. {
  6248. int mrOrgid = CurrentUser.UserPost.OrgID;
  6249. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6250. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6251. }
  6252. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6253. //{
  6254. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6255. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6256. //}
  6257. else
  6258. {
  6259. string userIdStr = "";
  6260. if (posCode == "CustomerService")
  6261. {
  6262. userIdStr = CurrentUser.UserID + "_k";
  6263. }
  6264. else if (posCode == "Designer" || posCode == "wxDesigner")
  6265. {
  6266. userIdStr = CurrentUser.UserID + "_s";
  6267. }
  6268. else if (posCode == "Place")
  6269. {
  6270. userIdStr = CurrentUser.UserID + "_x";
  6271. }
  6272. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6273. }
  6274. }
  6275. string placedate1 = GetPostString("placedate1");
  6276. string placedate2 = GetPostString("placedate2");
  6277. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6278. if (dwplace.Length > 0) lw.Add(dwplace);
  6279. string supState = GetPostString("supState");
  6280. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6281. string searchType = GetPostString("searchType");
  6282. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6283. {
  6284. lw.Add(string.Format("BackNum>1"));
  6285. }
  6286. lw.Add(string.Format("AfterSaleState>0"));
  6287. if (ex_psize > 0)
  6288. {
  6289. if (CurrentUser.UserPost.Post.Code == "Finance")
  6290. dStruct.Order = "pay_time desc";
  6291. else
  6292. dStruct.Order = "HandleTime desc";
  6293. }
  6294. else
  6295. dStruct.Order = "HandleTime desc";
  6296. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6297. DataTable dt = WebCache.GetData("view_test", dStruct);
  6298. writeGridDataTableJson(dStruct.TotalCount, dt);
  6299. }
  6300. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6301. //{
  6302. // lw.Add(string.Format("AfterSaleState=4"));
  6303. // string code = CurrentUser.UserPost.Post.Code;
  6304. // if (code == "CustomerService")
  6305. // {
  6306. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6307. // }
  6308. // else if (code == "Designer" || code == "DesignerMr")
  6309. // {
  6310. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6311. // }
  6312. // else if (code == "Place" || code == "PlaceMr")
  6313. // {
  6314. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6315. // }
  6316. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6317. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6318. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6319. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6320. //}
  6321. //else //处理中的售后,待处理和处理中合并
  6322. //{
  6323. // if (afterState.Length <= 0)
  6324. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6325. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6326. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6327. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6328. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6329. //}
  6330. }
  6331. public void get_erp_disagreeftersalelist()
  6332. {
  6333. DataStruct dStruct = GetPostStruct();
  6334. List<string> lw = new List<string>();
  6335. int st = 2;
  6336. string tid = GetPostString("ctid");
  6337. if (tid.Length > 0)
  6338. {
  6339. string select_tid = getTidByCtid(tid);
  6340. lw.Add(string.Format("tid='{0}'", select_tid));
  6341. }
  6342. string shopname = GetPostString("shopname");
  6343. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6344. string buyernick = GetPostString("buyer_nick");
  6345. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6346. string sellermemo = GetPostString("seller_memo");
  6347. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6348. string orderState = GetPostString("orderState");
  6349. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6350. string afterState = GetPostString("afterstate");
  6351. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6352. string date1 = GetPostString("date1");
  6353. string date2 = GetPostString("date2");
  6354. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6355. if (dw.Length > 0) lw.Add(dw);
  6356. string price1 = GetPostString("price1");
  6357. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6358. string price2 = GetPostString("price2");
  6359. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6360. //lw.Add(string.Format("IsRefund!={0}", 1));
  6361. string reason = GetPostString("reason");
  6362. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6363. string method = GetPostString("method");
  6364. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6365. string handler = GetPostString("handler");
  6366. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6367. string handledate1 = GetPostString("handledate1");
  6368. string handledate2 = GetPostString("handledate2");
  6369. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6370. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6371. string afterdate1 = GetPostString("afterdate1");
  6372. string afterdate2 = GetPostString("afterdate2");
  6373. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6374. if (afterDate.Length > 0) lw.Add(afterDate);
  6375. string backdate1 = GetPostString("backdate1");
  6376. string backdate2 = GetPostString("backdate2");
  6377. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6378. if (backDate.Length > 0) lw.Add(backDate);
  6379. string supplier = GetPostString("supplier");
  6380. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6381. string responsible = GetPostString("responsibleman");
  6382. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6383. string customer = GetPostString("customer");
  6384. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6385. string design = GetPostString("design");
  6386. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6387. string afterSaleMemo = GetPostString("afterSaleMemo");
  6388. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6389. string afterMemoType = GetPostString("aftermemotype");
  6390. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6391. string aftersakereason = GetPostString("aftersakereason");
  6392. if (aftersakereason.Length > 0)
  6393. {
  6394. if (aftersakereason == "1")
  6395. {
  6396. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6397. }
  6398. if (aftersakereason == "2")
  6399. {
  6400. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6401. }
  6402. }
  6403. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6404. string poscode = CurrentUser.UserPost.Post.Code;
  6405. if (poscode != "SysAdmin")
  6406. {
  6407. string shopid = CurrentUser.User.pemShop;
  6408. lw.Add(string.Format("shopId in ({0})", shopid));
  6409. }
  6410. string searchType = GetPostString("searchType");
  6411. if (searchType == "wait")
  6412. {
  6413. lw.Add(string.Format("HandleTime is null"));
  6414. }
  6415. if (searchType == "handling")
  6416. {
  6417. lw.Add(string.Format("HandleTime is not null "));
  6418. }
  6419. if (searchType == "back" || searchType == "puBack")
  6420. {
  6421. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6422. }
  6423. if (searchType == "reBack")
  6424. {
  6425. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6426. }
  6427. if (searchType == "moreBack")
  6428. {
  6429. lw.Add(string.Format("backNum > 1"));
  6430. }
  6431. lw.Add(string.Format("(AfterSaleState=5)"));
  6432. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6433. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6434. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6435. writeGridDataTableJson(dStruct.TotalCount, dt);
  6436. }
  6437. public void get_erp_handlingaftersalelist()
  6438. {
  6439. DataStruct dStruct = GetPostStruct();
  6440. List<string> lw = new List<string>();
  6441. int st = 2;
  6442. string tid = GetPostString("ctid");
  6443. if (tid.Length > 0)
  6444. {
  6445. string select_tid = getTidByCtid(tid);
  6446. lw.Add(string.Format("tid='{0}'", select_tid));
  6447. }
  6448. string shopname = GetPostString("shopname");
  6449. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6450. string buyernick = GetPostString("buyer_nick");
  6451. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6452. string sellermemo = GetPostString("seller_memo");
  6453. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6454. string orderState = GetPostString("orderState");
  6455. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6456. string searchType = GetPostString("searchType");
  6457. string afterState = GetPostString("afterstate");
  6458. if (searchType != "documentary")
  6459. {
  6460. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6461. }
  6462. string date1 = GetPostString("date1");
  6463. string date2 = GetPostString("date2");
  6464. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6465. if (dw.Length > 0) lw.Add(dw);
  6466. string price1 = GetPostString("price1");
  6467. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6468. string price2 = GetPostString("price2");
  6469. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6470. //lw.Add(string.Format("IsRefund!={0}", 1));
  6471. string reason = GetPostString("reason");
  6472. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6473. string method = GetPostString("method");
  6474. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6475. string handler = GetPostString("handler");
  6476. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6477. string handledate1 = GetPostString("handledate1");
  6478. string handledate2 = GetPostString("handledate2");
  6479. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6480. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6481. string afterdate1 = GetPostString("afterdate1");
  6482. string afterdate2 = GetPostString("afterdate2");
  6483. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6484. if (afterDate.Length > 0) lw.Add(afterDate);
  6485. string supplier = GetPostString("supplier");
  6486. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6487. string responsible = GetPostString("responsibleman");
  6488. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6489. string customer = GetPostString("customer");
  6490. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6491. string design = GetPostString("design");
  6492. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6493. string afterSaleMemo = GetPostString("afterSaleMemo");
  6494. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6495. string afterMemoType = GetPostString("aftermemotype");
  6496. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6497. string afterresult = GetPostString("afterresult");
  6498. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6499. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6500. string poscode = CurrentUser.UserPost.Post.Code;
  6501. if (poscode != "SysAdmin")
  6502. {
  6503. string shopid = CurrentUser.User.pemShop;
  6504. lw.Add(string.Format("shopId in ({0})", shopid));
  6505. }
  6506. if (searchType == "wait")
  6507. {
  6508. lw.Add(string.Format("HandleTime is null"));
  6509. }
  6510. if (searchType == "documentary")
  6511. {
  6512. lw.Add(string.Format(" AfterSaleState > 2 AND HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' AND AfterSalSend = 0 "));
  6513. afterState = "2";
  6514. }
  6515. if (searchType == "handling")
  6516. {
  6517. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6518. }
  6519. if (searchType == "back" || searchType == "puBack")
  6520. {
  6521. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6522. }
  6523. if (searchType == "reBack")
  6524. {
  6525. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6526. }
  6527. if (afterState.Length <= 0)
  6528. {
  6529. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6530. }
  6531. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6532. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6533. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6534. writeGridDataTableJson(dStruct.TotalCount, dt);
  6535. }
  6536. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6537. //public void get_erp_back_handlingaftersalelist()
  6538. //{
  6539. // DataStruct dStruct = GetPostStruct();
  6540. // List<string> lw = new List<string>();
  6541. // string tid = GetPostString("ctid");
  6542. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6543. // string shopname = GetPostString("shopname");
  6544. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6545. // string buyernick = GetPostString("buyer_nick");
  6546. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6547. // string sellermemo = GetPostString("seller_memo");
  6548. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6549. // string orderState = GetPostString("orderState");
  6550. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6551. // string afterState = GetPostString("afterstate");
  6552. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6553. // string date1 = GetPostString("date1");
  6554. // string date2 = GetPostString("date2");
  6555. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6556. // if (dw.Length > 0) lw.Add(dw);
  6557. // string price1 = GetPostString("price1");
  6558. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6559. // string price2 = GetPostString("price2");
  6560. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6561. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6562. // string reason = GetPostString("reason");
  6563. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6564. // string method = GetPostString("method");
  6565. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6566. // string handler = GetPostString("handler");
  6567. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6568. // string handledate1 = GetPostString("handledate1");
  6569. // string handledate2 = GetPostString("handledate2");
  6570. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6571. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6572. // string afterdate1 = GetPostString("afterdate1");
  6573. // string afterdate2 = GetPostString("afterdate2");
  6574. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6575. // if (afterDate.Length > 0) lw.Add(afterDate);
  6576. // string supplier = GetPostString("supplier");
  6577. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6578. // string responsible = GetPostString("responsibleman");
  6579. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6580. // string customer = GetPostString("customer");
  6581. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6582. // string design = GetPostString("design");
  6583. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6584. // string afterMemoType = GetPostString("aftermemotype");
  6585. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6586. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6587. // if (afterState.Length <= 0)
  6588. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6589. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6590. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6591. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6592. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6593. //}
  6594. public void get_erp_aftersaleverifylist()
  6595. {
  6596. DataStruct dStruct = GetPostStruct();
  6597. List<string> lw = new List<string>();
  6598. string tid = GetPostString("ctid");
  6599. if (tid.Length > 0)
  6600. {
  6601. string select_tid = getTidByCtid(tid);
  6602. lw.Add(string.Format("otid='{0}'", select_tid));
  6603. }
  6604. string shopname = GetPostString("shopname");
  6605. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6606. string buyernick = GetPostString("buyer_nick");
  6607. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6608. string sellermemo = GetPostString("seller_memo");
  6609. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6610. string orderState = GetPostString("orderState");
  6611. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6612. //lw.Add(string.Format("IsRefund!={0}", 1));
  6613. string reason = GetPostString("reason");
  6614. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6615. string method = GetPostString("method");
  6616. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6617. string handler = GetPostString("handler");
  6618. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6619. string handledate1 = GetPostString("handledate1");
  6620. string handledate2 = GetPostString("handledate2");
  6621. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6622. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6623. string finish1 = GetPostString("finishdate1");
  6624. string finish2 = GetPostString("finishdate2");
  6625. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6626. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6627. string supplier = GetPostString("supplier");
  6628. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6629. string responsible = GetPostString("responsibleman");
  6630. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6631. string posCode = CurrentUser.UserPost.Post.Code;
  6632. string vstate = GetPostString("vstate");
  6633. if (vstate.Length > 0)
  6634. {
  6635. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6636. }
  6637. if (posCode == "Supplier")
  6638. {
  6639. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6640. lw.Add(string.Format("VerifyState = 0"));
  6641. lw.Add("type = 1");
  6642. lw.Add(string.Format("AfterSaleState={0}", 3));
  6643. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6644. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6645. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6646. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6647. writeGridDataTableJson(dStruct.TotalCount, dt);
  6648. }
  6649. else if (posCode == "logistics")
  6650. {
  6651. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6652. lw.Add(string.Format("VerifyState = 0"));
  6653. lw.Add("type = 2");
  6654. lw.Add(string.Format("AfterSaleState={0}", 3));
  6655. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6656. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6657. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6658. writeGridDataTableJson(dStruct.TotalCount, dt);
  6659. }
  6660. else
  6661. {
  6662. lw.Add(string.Format("(AfterSaleState = 3)"));
  6663. lw.Add("type = 0");
  6664. string reasonState = GetPostString("reasonState");
  6665. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6666. {
  6667. if (reasonState == "2")
  6668. {
  6669. lw.Add("VerifyState = 3");
  6670. }
  6671. else if (reasonState == "1")
  6672. {
  6673. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6674. }
  6675. else
  6676. {
  6677. lw.Add("VerifyState in (0,3)");
  6678. }
  6679. //不加条件,可以看全部
  6680. }
  6681. 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")
  6682. {
  6683. int orgid = CurrentUser.UserPost.OrgID;
  6684. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6685. if (string.IsNullOrEmpty(manageOrgId))
  6686. {
  6687. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6688. }
  6689. else
  6690. {
  6691. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6692. }
  6693. if (reasonState == "1")
  6694. {
  6695. lw.Add("VerifyState = 3");
  6696. }
  6697. else if (reasonState == "2")
  6698. {
  6699. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6700. }
  6701. else
  6702. {
  6703. }
  6704. }
  6705. else
  6706. {
  6707. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6708. }
  6709. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6710. //{
  6711. // int org_id = CurrentUser.UserPost.OrgID;
  6712. // lw.Add(string.Format("OrgID={0}", org_id));
  6713. //}
  6714. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6715. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6716. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6717. writeGridDataTableJson(dStruct.TotalCount, dt);
  6718. }
  6719. }
  6720. public void get_erp_finishaftersalelist()
  6721. {
  6722. DataStruct dStruct = GetPostStruct();
  6723. List<string> lw = new List<string>();
  6724. int st = 4;
  6725. string tid = GetPostString("ctid");
  6726. if (tid.Length > 0)
  6727. {
  6728. string select_tid = getTidByCtid(tid);
  6729. lw.Add(string.Format("otid='{0}'", select_tid));
  6730. }
  6731. string shopname = GetPostString("shopname");
  6732. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6733. //lw.Add(string.Format("IsRefund!={0}", 1));
  6734. string reason = GetPostString("reason");
  6735. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6736. string method = GetPostString("method");
  6737. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6738. string buyernick = GetPostString("buyer_nick");
  6739. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6740. string handler = GetPostString("handler");
  6741. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6742. string handledate1 = GetPostString("handledate1");
  6743. string handledate2 = GetPostString("handledate2");
  6744. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6745. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6746. string finish1 = GetPostString("finishdate1");
  6747. string finish2 = GetPostString("finishdate2");
  6748. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6749. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6750. string supplier = GetPostString("supplier");
  6751. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6752. string responsible = GetPostString("responsibleman");
  6753. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6754. string vstate = GetPostString("vstate");
  6755. if (vstate.Length > 0)
  6756. {
  6757. if ("3".Equals(vstate))
  6758. {
  6759. lw.Add(string.Format("IsTem=1"));
  6760. }
  6761. else
  6762. {
  6763. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6764. }
  6765. }
  6766. lw.Add(string.Format("AfterSaleState=4"));
  6767. string code = CurrentUser.UserPost.Post.Code;
  6768. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6769. {
  6770. //不加条件,可以看全部
  6771. }
  6772. else if (code == "Supplier")
  6773. {
  6774. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6775. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6776. lw.Add("type = 1");
  6777. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6778. }
  6779. else if (code == "logistics")
  6780. {
  6781. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6782. lw.Add("type = 2");
  6783. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6784. }
  6785. 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")
  6786. {
  6787. lw.Add("type = 0");
  6788. int orgid = CurrentUser.UserPost.OrgID;
  6789. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6790. if (string.IsNullOrEmpty(manageOrgIds))
  6791. {
  6792. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6793. }
  6794. else
  6795. {
  6796. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6797. }
  6798. }
  6799. else
  6800. {
  6801. lw.Add("type = 0");
  6802. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6803. }
  6804. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6805. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6806. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6807. writeGridDataTableJson(dStruct.TotalCount, dt);
  6808. }
  6809. public void handle_erp_aftersale()
  6810. {
  6811. if (UrlPostParmsCheck("ctid"))
  6812. {
  6813. string eid = GetPostString("ctid");
  6814. string responStr = GetPostString("AfterSaleResponsible");
  6815. if (responStr.Length <= 0)
  6816. {
  6817. returnErrorMsg("售后责任人不能为空");
  6818. return;
  6819. }
  6820. bool isDesign = false;
  6821. double designFree = 0.00;
  6822. int responsibleId = 0;
  6823. CeErpTradeCell entity = null;
  6824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6825. if (entity != null)
  6826. {
  6827. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6828. string afterMethod = GetPostString("AfterSaleMethod");
  6829. if (isNeedNewOrder == 1)
  6830. {
  6831. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6832. bool ishav = true;
  6833. if (newentity == null)
  6834. {
  6835. newentity = entity.Clone() as CeErpTradeCell;
  6836. ishav = false;
  6837. newentity.ctid = "S_" + entity.ctid;
  6838. newentity.OrderState = 0;
  6839. //唯一标识
  6840. newentity.OrderSn = newentity.ctid;
  6841. string orderSn = commonHelper.generateDateTimeRandomNos();
  6842. if (orderSn != "")
  6843. {
  6844. newentity.OrderSn = orderSn;
  6845. }
  6846. }
  6847. newentity.UpdateTime = DateTime.Now;
  6848. newentity.AfterSaleState = 0;
  6849. newentity.AfterSaleMethod = afterMethod;
  6850. if (!ishav)
  6851. {
  6852. string memo_str = newentity.seller_memo;
  6853. memo_str = memo_str.Replace("(", "(");
  6854. memo_str = memo_str.Replace(")", ")");
  6855. int sIndex = memo_str.IndexOf("(");
  6856. int eIndex = memo_str.IndexOf(")");
  6857. if (sIndex == -1 || eIndex == -1)
  6858. {
  6859. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6860. return;
  6861. }
  6862. string first = memo_str.Substring(0, sIndex + 1);
  6863. string memoCtid = newentity.OrderSn;
  6864. //if (memoCtid.IndexOf("C") != -1)
  6865. //{
  6866. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6867. //if (CIdx.IndexOf("+") != -1)
  6868. //{
  6869. //CIdx = "C" + CIdx.Split('+')[1];
  6870. //}
  6871. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6872. //}
  6873. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6874. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6875. string newMemo = first + memoCtid + last;
  6876. newentity.seller_memo = newMemo;
  6877. newentity.FinishPlaceTime = null;
  6878. newentity.UnusualTag = 0;
  6879. newentity.UnusualCon = "";
  6880. newentity.UnusualTime = null;
  6881. newentity.AfterSaleMemo = "";
  6882. newentity.AfterSaleMethod = afterMethod;
  6883. newentity.AfterSalePreTime = null;
  6884. newentity.AfterSaleReason = "";
  6885. newentity.AfterSaleResponsible = "";
  6886. newentity.AfterSaleState = 0;
  6887. newentity.AfterSaleTime = null;
  6888. newentity.AfterSaleUserId = 0;
  6889. newentity.AfterSaleSupplierState = 0;
  6890. newentity.LastBillWaybillCode = "";
  6891. newentity.LastBillCpCode = "";
  6892. newentity.FinishAfterSaleTime = null;
  6893. newentity.HandleTime = null;
  6894. newentity.IsSF = 0;
  6895. newentity.IsOldCustomer = 0;
  6896. newentity.UrgencyTime = null;
  6897. newentity.ResponsibleUserId = "";
  6898. newentity.IsVerifyToSupplier = false;
  6899. newentity.payment = 0;
  6900. newentity.CheckMemo = "";
  6901. newentity.OutSid = "";
  6902. newentity.CheckOrderTime = null;
  6903. newentity.MemoOpt = 0;
  6904. newentity.IsReturn = 0;
  6905. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6906. }
  6907. newentity.isAfterSaleOrder = 1;
  6908. newentity.IsRefund = 0;
  6909. string receiveMobile = GetPostString("receiver_mobile");
  6910. if (receiveMobile.Length > 0)
  6911. {
  6912. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6913. if (trade != null)
  6914. {
  6915. trade.receiver_name = GetPostString("receiver_name");
  6916. trade.receiver_mobile = receiveMobile;
  6917. trade.receiver_state = GetPostString("receiver_state");
  6918. trade.receiver_city = GetPostString("receiver_city");
  6919. trade.receiver_district = GetPostString("receiver_district");
  6920. trade.receiver_address = GetPostString("receiver_address");
  6921. newentity.IsOffLineOrder = 1;
  6922. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6923. }
  6924. }
  6925. string st = GetPostString("ToState");
  6926. if (st.Length > 0)
  6927. {
  6928. if (newentity.OrderState <= 3)
  6929. {
  6930. newentity.WaitDesignTime = DateTime.Now;
  6931. newentity.StartDesignTime = null;
  6932. newentity.FinishDesignTime = null;
  6933. newentity.OrderState = 3;
  6934. if (st == "下单员")
  6935. {
  6936. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6937. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6938. {
  6939. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6940. }
  6941. }
  6942. else
  6943. {
  6944. newentity.WaitDesignTime = DateTime.Now;
  6945. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6946. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6947. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6948. {
  6949. DataRow user = dt1.Rows[0];
  6950. //找主管
  6951. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6952. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6953. if (dt != null && dt.Rows.Count > 0)
  6954. {
  6955. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6956. newentity.DesignUserId = designMr;
  6957. string key = "aftersale_order_" + designMr;
  6958. if (RedisHelper.HasKey(key))
  6959. {
  6960. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6961. list.Add(newentity.ctid);
  6962. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6963. }
  6964. }
  6965. //账号正常
  6966. if (user["State"].ToString() == "0")
  6967. {
  6968. newentity.DesignUserId = entity.DesignUserId;
  6969. string key = "aftersale_order_" + entity.DesignUserId;
  6970. if (RedisHelper.HasKey(key))
  6971. {
  6972. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6973. list.Add(newentity.ctid);
  6974. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6975. }
  6976. }
  6977. }
  6978. }
  6979. }
  6980. if (entity.IsXianHuo == 1)
  6981. {
  6982. newentity.OrderState = 6;
  6983. entity.FinishPlaceTime = DateTime.Now;
  6984. }
  6985. }
  6986. if (ishav)
  6987. {
  6988. newentity.Update();
  6989. }
  6990. else
  6991. {
  6992. newentity.Create();
  6993. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6994. newCellExtend.ctid = newentity.ctid;
  6995. newCellExtend.orderFrom = 20;
  6996. newCellExtend.orderType = 30;
  6997. if (st == "下单员")
  6998. {
  6999. }
  7000. else
  7001. {
  7002. newCellExtend.ReprintTime = DateTime.Now;
  7003. }
  7004. newCellExtend.Create();
  7005. }
  7006. if (st != "下单员")
  7007. {
  7008. if (entity.DispatchSort == 2)
  7009. {
  7010. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  7011. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  7012. }
  7013. }
  7014. }
  7015. //处理售后扩展
  7016. string resIdStr = GetPostString("ResponsibleUserId");
  7017. string refundFees = GetPostString("refundFrees");
  7018. int IsComplain = GetPostInt("isComplain");
  7019. int IsBad = GetPostInt("isBad");
  7020. string IsOriginal = GetPostString("isOriginal");
  7021. double diffResultPrice = GetPostDouble("diffResultPrice");
  7022. string textResult = GetPostString("textResult");
  7023. string supplierResponsible = GetPostString("supplierResponsible");
  7024. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  7025. if (ceErpTradeAfterSaleExtend == null)
  7026. {
  7027. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7028. ceErpTradeAfterSaleExtend.tid = eid;
  7029. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7030. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7031. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7032. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7033. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7034. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7035. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7036. ceErpTradeAfterSaleExtend.Create();
  7037. }
  7038. else
  7039. {
  7040. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  7041. {
  7042. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  7043. }
  7044. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7045. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7046. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7047. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7048. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7049. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7050. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7051. ceErpTradeAfterSaleExtend.Update();
  7052. }
  7053. int gysid = GetPostInt("ResponsibleSupId");
  7054. if (entity.AfterSaleUserId == 0)
  7055. {
  7056. entity.AfterSaleUserId = CurrentUser.UserID;
  7057. }
  7058. entity.ResponsibleUserId = resIdStr;
  7059. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7060. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7061. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7062. {
  7063. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7064. int backNum = 0;
  7065. if (number != null)
  7066. {
  7067. backNum = number.BackNum;
  7068. }
  7069. char[] separator = { ',' };
  7070. string[] sArray = resIdStr.Split(separator);
  7071. string[] refundFreeList = { };
  7072. if (refundFees.Length > 0)
  7073. {
  7074. refundFreeList = refundFees.Split(separator);
  7075. }
  7076. int index = -1;
  7077. List<int> responsibleIds = new List<int>();
  7078. foreach (string i in sArray)
  7079. {
  7080. index++;
  7081. if (i.Length <= 0) continue;
  7082. char[] separator2 = { '_' };
  7083. string idstr = i.Split(separator2)[0];
  7084. string idtype = i.Split(separator2)[1];
  7085. double refudFree = 0;
  7086. if (refundFreeList.Length > 0)
  7087. {
  7088. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7089. }
  7090. if (idtype == "s")
  7091. {
  7092. isDesign = true;
  7093. designFree = refudFree;
  7094. }
  7095. int userId = Convert.ToInt32(idstr);
  7096. int type = 0;
  7097. if (idtype == "g")
  7098. {
  7099. type = 1;
  7100. }
  7101. if (idtype == "w")
  7102. {
  7103. type = 2;
  7104. }
  7105. if (idtype == "t")
  7106. {
  7107. type = 3;
  7108. }
  7109. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7110. if (ceErpTradeResponsible == null)
  7111. {
  7112. ceErpTradeResponsible = new CeErpTradeResponsible();
  7113. ceErpTradeResponsible.tid = eid;
  7114. ceErpTradeResponsible.UserId = userId;
  7115. ceErpTradeResponsible.createdTime = DateTime.Now;
  7116. ceErpTradeResponsible.type = type;
  7117. if (type == 1)
  7118. {
  7119. ceErpTradeResponsible.IsSup = 1;
  7120. }
  7121. if (type == 2)
  7122. {
  7123. ceErpTradeResponsible.IsFlow = 1;
  7124. }
  7125. }
  7126. int state = 0;
  7127. //已认可的不需要再次认可
  7128. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7129. {
  7130. state = 1;
  7131. }
  7132. ceErpTradeResponsible.RefundFee = refudFree;
  7133. ceErpTradeResponsible.VerifyState = state;
  7134. if (userId == 2125 || idtype == "w")
  7135. {
  7136. ceErpTradeResponsible.VerifyState = 1;
  7137. }
  7138. if (idtype == "w" && userId == 101)
  7139. {
  7140. ceErpTradeResponsible.VerifyState = state;
  7141. }
  7142. if (ceErpTradeResponsible.ID > 0)
  7143. {
  7144. ceErpTradeResponsible.Update();
  7145. }
  7146. else
  7147. {
  7148. ceErpTradeResponsible.Create();
  7149. }
  7150. if (isDesign)
  7151. {
  7152. responsibleId = ceErpTradeResponsible.ID;
  7153. }
  7154. responsibleIds.Add(ceErpTradeResponsible.ID);
  7155. }
  7156. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7157. CeErpTradeResponsible.NumByTid(backNum, eid);
  7158. }
  7159. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7160. if (ceErpTradeCellExtend != null)
  7161. {
  7162. ceErpTradeCellExtend.returnVisit = 0;
  7163. ceErpTradeCellExtend.Update();
  7164. }
  7165. if (entity.HandleTime != null)
  7166. {
  7167. if (entity.AfterSaleState == 1)
  7168. {
  7169. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7170. }
  7171. else
  7172. {
  7173. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7174. }
  7175. }
  7176. else
  7177. {
  7178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7179. entity.HandleTime = DateTime.Now;
  7180. }
  7181. bool isCompale = false;
  7182. if (entity.AfterSaleState == 5)
  7183. {
  7184. isCompale = true;
  7185. entity.AfterSaleState = 3;
  7186. }
  7187. entity.AfterSaleSupplierState = 0;
  7188. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7189. {
  7190. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7191. }
  7192. string sImgs = GetPostString("img");
  7193. entity.AfterSaleSupplierImg = sImgs;
  7194. entity.supRefundType = GetPostString("supRefundType");
  7195. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7196. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7197. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7198. entity.AfterSaleMemoType = GetPostString("MemoType");
  7199. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7200. {
  7201. //entity.AfterSaleSupplierState = 2;
  7202. }
  7203. string df = GetPostString("DeductFee");
  7204. if (df == "")
  7205. {
  7206. df = "0";
  7207. }
  7208. string rf = GetPostString("RefundFee");
  7209. if (rf == "")
  7210. {
  7211. rf = "0";
  7212. }
  7213. string pm = GetPostString("AfterSalePayment");
  7214. if (pm == "")
  7215. {
  7216. pm = "0";
  7217. }
  7218. entity.AfterSalePayment = Convert.ToDouble(pm);
  7219. entity.DeductFee = Convert.ToDouble(df);
  7220. entity.RefundFee = Convert.ToDouble(rf);
  7221. entity.UpdateTime = DateTime.Now;
  7222. entity.Update();
  7223. string toState = GetPostString("ToState");
  7224. string original = GetPostString("isOriginal");
  7225. ApiVo apiVo = new ApiVo();
  7226. apiVo.orderNumber = entity.ctid;
  7227. apiVo.actionName = "afterDesign";
  7228. apiVo.orderRemarks = entity.AfterSaleMethod;
  7229. apiVo.reasonRemarks = entity.AfterSaleReason;
  7230. apiVo.isDesign = isDesign;
  7231. apiVo.designFree = designFree;
  7232. apiVo.responsibleId = responsibleId;
  7233. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7234. if (toState == "设计师")
  7235. {
  7236. apiVo.isOriginal = Convert.ToBoolean(original);
  7237. }
  7238. designHelper.API_WorkCore(apiVo);//afterDesign
  7239. CeErpMethod methodSql = new CeErpMethod();
  7240. methodSql.con = entity.AfterSaleMethod;
  7241. methodSql.addTime = DateTime.Now;
  7242. methodSql.Create();
  7243. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7244. CeErpMethod.ExecuteNonQuery(delsql);
  7245. if (isCompale)
  7246. {
  7247. aftersale_data_change(entity.ctid);
  7248. }
  7249. returnSuccessMsg("操作成功!");
  7250. return;
  7251. }
  7252. returnErrorMsg("找不到订单记录");
  7253. }
  7254. }
  7255. public void ins_erp_toresponsible()
  7256. {
  7257. if (UrlPostParmsCheck("ctid"))
  7258. {
  7259. string eid = GetPostString("ctid");
  7260. CeErpTradeCell entity = null;
  7261. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7262. if (entity != null)
  7263. {
  7264. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7265. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7266. {
  7267. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7268. return;
  7269. }
  7270. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7271. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7272. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7273. if (entity.AfterSalePreTime == null)
  7274. {
  7275. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7276. {
  7277. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7278. }
  7279. }
  7280. entity.AfterSalePreTime = DateTime.Now;
  7281. //预完成给售后主管审核客户问题直接完成
  7282. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7283. {
  7284. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7285. {
  7286. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7287. }
  7288. }
  7289. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7290. ceErpTradeAfterSaleExtend.Update();
  7291. entity.AfterSaleState = 2;
  7292. entity.UpdateTime = DateTime.Now;
  7293. entity.Update();
  7294. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7295. aftersale_data_change(entity.ctid);
  7296. returnSuccessMsg("操作成功!");
  7297. return;
  7298. }
  7299. returnErrorMsg("找不到订单记录");
  7300. }
  7301. }
  7302. public void cancel_erp_aftersaleanddelnew()
  7303. {
  7304. if (UrlPostParmsCheck("ctid"))
  7305. {
  7306. string eid = GetPostString("ctid");
  7307. CeErpTradeCell entity = null;
  7308. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7309. if (entity != null)
  7310. {
  7311. entity.AfterSaleState = 0;
  7312. entity.AfterSaleReason = "";
  7313. entity.AfterSaleMethod = "";
  7314. entity.AfterSaleMemo = "";
  7315. entity.AfterSaleResponsible = "";
  7316. entity.ResponsibleUserId = "";
  7317. entity.DeductFee = 0;
  7318. entity.RefundFee = 0;
  7319. entity.IsArbitrate = 0;
  7320. CeErpTradeResponsible.DelByTid(eid, -1);
  7321. entity.Update();
  7322. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7323. if (after != null)
  7324. {
  7325. if (after.OrderState < 5)
  7326. CeErpTradeCell.DelByCtid("S_" + eid);
  7327. }
  7328. returnSuccessMsg("操作成功!");
  7329. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7330. return;
  7331. }
  7332. returnErrorMsg("找不到订单记录");
  7333. }
  7334. }
  7335. public void get_erp_aftersale_pregather()
  7336. {
  7337. List<string> lw = new List<string>();
  7338. int st = GetInt("st");
  7339. string tid = GetPostString("ctid");
  7340. if (tid.Length > 0)
  7341. {
  7342. string select_tid = getTidByCtid(tid);
  7343. lw.Add(string.Format("tid='{0}'", select_tid));
  7344. }
  7345. string shopname = GetPostString("shopname");
  7346. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7347. string buyernick = GetPostString("buyer_nick");
  7348. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7349. string sellermemo = GetPostString("seller_memo");
  7350. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7351. string orderState = GetPostString("orderState");
  7352. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7353. string reason = GetPostString("reason");
  7354. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7355. string method = GetPostString("method");
  7356. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7357. string handler = GetPostString("handler");
  7358. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7359. string handledate1 = GetPostString("handledate1");
  7360. string handledate2 = GetPostString("handledate2");
  7361. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7362. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7363. string supplier = GetPostString("supplier");
  7364. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7365. string responsible = GetPostString("responsibleman");
  7366. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7367. string customer = GetPostString("customer");
  7368. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7369. string design = GetPostString("design");
  7370. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7371. string afterMemoType = GetPostString("aftermemotype");
  7372. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7373. string afterSaleMemo = GetPostString("afterSaleMemo");
  7374. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7375. string afterresult = GetPostString("afterresult");
  7376. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7377. string poscode = CurrentUser.UserPost.Post.Code;
  7378. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7379. {
  7380. string shopid = CurrentUser.User.pemShop;
  7381. lw.Add(string.Format("shopId in ({0})", shopid));
  7382. }
  7383. var mainwhere = string.Join(" and ", lw.ToArray());
  7384. string ro_json = "";
  7385. string type = GetPostString("gather_type");
  7386. int number = 0;
  7387. if (poscode == "AfterSale")
  7388. {
  7389. //处理中
  7390. if (type == "Handling")
  7391. {
  7392. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7393. DataTable dt = null;
  7394. try
  7395. {
  7396. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7397. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7398. }
  7399. catch (Exception e)
  7400. {
  7401. dt = new DataTable();
  7402. }
  7403. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7404. return;
  7405. }
  7406. if (type == "Wait")
  7407. {
  7408. //待处理
  7409. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7410. DataTable dt1 = null;
  7411. try
  7412. {
  7413. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7414. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7415. }
  7416. catch (Exception e)
  7417. {
  7418. dt1 = new DataTable();
  7419. }
  7420. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7421. return;
  7422. }
  7423. if (type == "back")
  7424. {
  7425. //打回
  7426. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7427. DataTable dt2 = null;
  7428. try
  7429. {
  7430. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7431. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7432. }
  7433. catch (Exception e)
  7434. {
  7435. dt2 = new DataTable();
  7436. }
  7437. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7438. return;
  7439. }
  7440. if (type == "preCompletion")
  7441. {
  7442. //预完成
  7443. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7444. DataTable dt3 = null;
  7445. try
  7446. {
  7447. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7448. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7449. }
  7450. catch (Exception e)
  7451. {
  7452. dt3 = new DataTable();
  7453. }
  7454. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7455. return;
  7456. }
  7457. if (type == "documentary")
  7458. {
  7459. //跟单中
  7460. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate > 2 and HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSalSend = 0 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7461. DataTable dt4 = null;
  7462. try
  7463. {
  7464. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7465. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7466. }
  7467. catch (Exception e)
  7468. {
  7469. dt4 = new DataTable();
  7470. }
  7471. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7472. return;
  7473. }
  7474. if (type == "reBack")
  7475. {
  7476. //被打回
  7477. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7478. DataTable dt1 = null;
  7479. try
  7480. {
  7481. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7482. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7483. }
  7484. catch (Exception e)
  7485. {
  7486. dt1 = new DataTable();
  7487. }
  7488. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7489. return;
  7490. }
  7491. }
  7492. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7493. {
  7494. if (type == "puBack")
  7495. {
  7496. //退回
  7497. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7498. DataTable dt = null;
  7499. try
  7500. {
  7501. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7502. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7503. }
  7504. catch (Exception e)
  7505. {
  7506. dt = new DataTable();
  7507. }
  7508. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7509. return;
  7510. }
  7511. if (type == "reBack")
  7512. {
  7513. //打回
  7514. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7515. DataTable dt1 = null;
  7516. try
  7517. {
  7518. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7519. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7520. }
  7521. catch (Exception e)
  7522. {
  7523. dt1 = new DataTable();
  7524. }
  7525. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7526. return;
  7527. }
  7528. if (type == "examEd")
  7529. {
  7530. //已审核
  7531. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7532. DataTable dt2 = null;
  7533. try
  7534. {
  7535. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7536. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7537. }
  7538. catch (Exception e)
  7539. {
  7540. dt2 = new DataTable();
  7541. }
  7542. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7543. return;
  7544. }
  7545. if (type == "waitExam")
  7546. {
  7547. //待审核
  7548. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7549. DataTable dt3 = null;
  7550. try
  7551. {
  7552. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7553. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7554. }
  7555. catch (Exception e)
  7556. {
  7557. dt3 = new DataTable();
  7558. }
  7559. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7560. return;
  7561. }
  7562. if (type == "Handling")
  7563. {
  7564. //处理中
  7565. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7566. DataTable dt4 = null;
  7567. try
  7568. {
  7569. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7570. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7571. }
  7572. catch (Exception e)
  7573. {
  7574. dt4 = new DataTable();
  7575. }
  7576. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7577. return;
  7578. }
  7579. if (type == "Wait")
  7580. {
  7581. //待处理
  7582. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7583. DataTable dt5 = null;
  7584. try
  7585. {
  7586. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7587. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7588. }
  7589. catch (Exception e)
  7590. {
  7591. dt5 = new DataTable();
  7592. }
  7593. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7594. return;
  7595. }
  7596. if (type == "documentary")
  7597. {
  7598. //跟单中
  7599. string sql6 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate > 2 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSalSend = 0 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7600. DataTable dt6 = null;
  7601. try
  7602. {
  7603. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7604. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7605. }
  7606. catch (Exception e)
  7607. {
  7608. dt6 = new DataTable();
  7609. }
  7610. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7611. return;
  7612. }
  7613. }
  7614. returnSuccess(ro_json);
  7615. }
  7616. public void end_erp_aftersale()
  7617. {
  7618. if (UrlPostParmsCheck("ctid"))
  7619. {
  7620. string eid = GetPostString("ctid");
  7621. CeErpTradeCell entity = null;
  7622. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7623. if (entity != null)
  7624. {
  7625. string stype = GetPostString("stype");
  7626. string typeStr = stype;
  7627. entity.AfterSaleState = 4;
  7628. entity.FinishAfterSaleTime = DateTime.Now;
  7629. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7630. entity.Update();
  7631. ApiVo apiVo = new ApiVo();
  7632. apiVo.orderNumber = entity.ctid;
  7633. apiVo.actionName = "afterOver";
  7634. designHelper.API_WorkCore(apiVo); //afterOver
  7635. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7636. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7637. CeErpSukuraData.createInfo(entity.ctid, 8);
  7638. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7639. returnSuccessMsg("操作成功!");
  7640. return;
  7641. }
  7642. returnErrorMsg("找不到订单记录");
  7643. }
  7644. }
  7645. public void ins_erp_finishaftersale()
  7646. {
  7647. if (UrlPostParmsCheck("id"))
  7648. {
  7649. string eid = GetPostString("id");
  7650. CeErpTradeResponsible entity = null;
  7651. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7652. if (entity != null)
  7653. {
  7654. entity.VerifyState = 1;
  7655. entity.VerifyTime = DateTime.Now;
  7656. entity.Update();
  7657. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7658. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7659. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7660. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7661. if (dt.Rows.Count <= 0)
  7662. {
  7663. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7664. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7665. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7666. CeErpSukuraData.createInfo(entity.tid, 8);
  7667. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7668. {
  7669. CeErpDesignerBill.Del(entity.tid);
  7670. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7671. }
  7672. }
  7673. returnSuccessMsg("操作成功!");
  7674. return;
  7675. }
  7676. returnErrorMsg("找不到订单记录");
  7677. }
  7678. }
  7679. public void upd_erp_arbitrateaftersale()
  7680. {
  7681. if (UrlPostParmsCheck("id"))
  7682. {
  7683. string eid = GetPostString("id");
  7684. CeErpTradeResponsible entity = null;
  7685. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7686. if (entity != null)
  7687. {
  7688. entity.IsArbitrate = 1;
  7689. entity.ArbitradeMemo = GetPostString("reason");
  7690. entity.VerifyState = 2;
  7691. entity.Update();
  7692. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7693. if (tradecell != null)
  7694. {
  7695. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7696. tradecell.IsArbitrate = 1;
  7697. tradecell.Update();
  7698. }
  7699. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7700. returnSuccessMsg("操作成功!");
  7701. return;
  7702. }
  7703. returnErrorMsg("找不到订单记录");
  7704. }
  7705. }
  7706. public void upd_erp_backaftersale()
  7707. {
  7708. if (UrlPostParmsCheck("tid"))
  7709. {
  7710. string eid = GetPostString("tid");
  7711. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7712. int backNum = 0;
  7713. if (number != null)
  7714. {
  7715. backNum = number.BackNum;
  7716. }
  7717. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7718. CeErpTradeCell entity = null;
  7719. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7720. if (entity != null)
  7721. {
  7722. entity.AfterSaleBackReason = GetPostString("backreason");
  7723. entity.AfterSaleState = 1;
  7724. entity.AfterSaleSupplierState = 0;
  7725. entity.UpdateTime = DateTime.Now;
  7726. entity.Update();
  7727. returnSuccessMsg("操作成功!");
  7728. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7729. return;
  7730. }
  7731. returnErrorMsg("找不到订单记录");
  7732. }
  7733. }
  7734. public void get_erp_supplieraftersalelist()
  7735. {
  7736. DataStruct dStruct = GetPostStruct();
  7737. List<string> lw = new List<string>();
  7738. string tid = GetPostString("ctid");
  7739. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7740. string shopname = GetPostString("shopname");
  7741. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7742. string buyernick = GetPostString("buyer_nick");
  7743. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7744. string sellermemo = GetPostString("seller_memo");
  7745. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7746. string orderState = GetPostString("orderState");
  7747. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7748. string afterState = GetPostString("afterstate");
  7749. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7750. string date1 = GetPostString("date1");
  7751. string date2 = GetPostString("date2");
  7752. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7753. if (dw.Length > 0) lw.Add(dw);
  7754. string price1 = GetPostString("price1");
  7755. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7756. string price2 = GetPostString("price2");
  7757. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7758. string reason = GetPostString("reason");
  7759. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7760. string method = GetPostString("method");
  7761. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7762. string handledate1 = GetPostString("handledate1");
  7763. string handledate2 = GetPostString("handledate2");
  7764. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7765. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7766. string handler = GetPostString("handler");
  7767. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7768. string afterdate1 = GetPostString("afterdate1");
  7769. string afterdate2 = GetPostString("afterdate2");
  7770. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7771. if (afterDate.Length > 0) lw.Add(afterDate);
  7772. string customer = GetPostString("customer");
  7773. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7774. string design = GetPostString("design");
  7775. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7776. string afterMemoType = GetPostString("aftermemotype");
  7777. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7778. string vstate = GetPostString("vstate");
  7779. if (vstate.Length > 0)
  7780. {
  7781. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7782. }
  7783. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7784. string supplier = GetPostString("supplier");
  7785. int supid = commonHelper.getSupplierIDByName(supplier);
  7786. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7787. string posCode = CurrentUser.UserPost.Post.Code;
  7788. if (posCode == "Supplier")
  7789. {
  7790. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7791. }
  7792. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7793. {
  7794. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7795. }
  7796. else
  7797. {
  7798. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7799. }
  7800. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7801. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7802. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7803. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7804. writeGridDataTableJson(dStruct.TotalCount, dt);
  7805. }
  7806. public void upd_erp_supverifyaftersale()
  7807. {
  7808. if (UrlPostParmsCheck("id"))
  7809. {
  7810. string id = GetPostString("id");
  7811. int st = GetPostInt("afterstate");
  7812. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7813. CeErpTradeCell entity = null;
  7814. if (ceErpTradeResponsible != null)
  7815. {
  7816. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7817. }
  7818. string afmemo = GetPostString("supmemo");
  7819. string image = GetPostString("image");
  7820. if (entity != null)
  7821. {
  7822. entity.AfterSaleSupplierState = st;
  7823. entity.AfterSaleSupplierMemo = afmemo;
  7824. if (st == 1)
  7825. {
  7826. ceErpTradeResponsible.VerifyState = 1;
  7827. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7828. ceErpTradeResponsible.Update();
  7829. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7830. if (isAll)
  7831. {
  7832. entity.AfterSaleState = 4;
  7833. entity.FinishAfterSaleTime = DateTime.Now;
  7834. }
  7835. }
  7836. else
  7837. {
  7838. CeErpTradeResponsible.dateByTid(entity.ctid);
  7839. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7840. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7841. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7842. if (num <= 1)
  7843. {
  7844. entity.AfterSaleState = 1;
  7845. }
  7846. else
  7847. {
  7848. entity.AfterSaleState = 5;
  7849. }
  7850. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7851. if (ceErpTradeAfterSaleExtend != null)
  7852. {
  7853. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7854. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7855. ceErpTradeAfterSaleExtend.Update();
  7856. }
  7857. else
  7858. {
  7859. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7860. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7861. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7862. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7863. ceErpTradeAfterSaleExtend.Create();
  7864. }
  7865. }
  7866. if (entity.AfterSaleState == 4)
  7867. {
  7868. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7869. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7870. {
  7871. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7872. }
  7873. ApiVo apiVo = new ApiVo();
  7874. apiVo.orderNumber = entity.ctid;
  7875. apiVo.actionName = "afterOver";
  7876. designHelper.API_WorkCore(apiVo); //afterOver
  7877. }
  7878. entity.UpdateTime = DateTime.Now;
  7879. entity.Update();
  7880. returnSuccessMsg("操作成功!");
  7881. CeErpSukuraData.createInfo(entity.ctid, 8);
  7882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7883. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7884. return;
  7885. }
  7886. returnErrorMsg("找不到订单记录");
  7887. }
  7888. }
  7889. public void upd_erp_masteraftersale()
  7890. {
  7891. if (UrlPostParmsCheck("id"))
  7892. {
  7893. string id = GetPostString("id");
  7894. int st = GetPostInt("afterstate");
  7895. string afmemo = GetPostString("supmemo");
  7896. string image = GetPostString("image");
  7897. string textResult = GetPostString("textResult");
  7898. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7899. if (ceErpTradeResponsible != null)
  7900. {
  7901. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7902. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7903. ceErpTradeResponsible.Update();
  7904. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7905. if (entity != null)
  7906. {
  7907. entity.AfterSaleSupplierState = st;
  7908. entity.AfterSaleSupplierMemo = afmemo;
  7909. if (st == 1)
  7910. {
  7911. }
  7912. else
  7913. {
  7914. CeErpTradeResponsible.dateByTid(entity.ctid);
  7915. //退回到售后
  7916. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7917. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7918. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7919. if (num <= 1)
  7920. {
  7921. entity.AfterSaleState = 1;
  7922. }
  7923. else
  7924. {
  7925. entity.AfterSaleState = 5;
  7926. }
  7927. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7928. if (ceErpTradeAfterSaleExtend != null)
  7929. {
  7930. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7931. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7932. ceErpTradeAfterSaleExtend.Update();
  7933. }
  7934. else
  7935. {
  7936. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7937. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7938. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7939. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7940. ceErpTradeAfterSaleExtend.Create();
  7941. }
  7942. }
  7943. entity.UpdateTime = DateTime.Now;
  7944. entity.Update();
  7945. returnSuccessMsg("操作成功!");
  7946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7947. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7948. return;
  7949. }
  7950. }
  7951. returnErrorMsg("找不到订单记录");
  7952. }
  7953. }
  7954. public void upd_erp_personaftersale()
  7955. {
  7956. if (UrlPostParmsCheck("id"))
  7957. {
  7958. //林小连
  7959. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7960. {
  7961. upd_erp_masteraftersale();
  7962. return;
  7963. }
  7964. string id = GetPostString("id");
  7965. int st = GetPostInt("afterstate");
  7966. string afmemo = GetPostString("supmemo");
  7967. string image = GetPostString("image");
  7968. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7969. if (ceErpTradeResponsible != null)
  7970. {
  7971. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7972. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7973. ceErpTradeResponsible.Update();
  7974. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7975. if (entity != null)
  7976. {
  7977. entity.AfterSaleSupplierMemo = afmemo;
  7978. entity.AfterSaleSupplierState = st;
  7979. if (st == 1)
  7980. {
  7981. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7982. if (isAll)
  7983. {
  7984. entity.AfterSaleState = 4;
  7985. entity.FinishAfterSaleTime = DateTime.Now;
  7986. }
  7987. }
  7988. else
  7989. {
  7990. CeErpTradeResponsible.dateByTid(entity.ctid);
  7991. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7992. if (ceErpTradeAfterSaleExtend != null)
  7993. {
  7994. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7995. ceErpTradeAfterSaleExtend.Update();
  7996. }
  7997. else
  7998. {
  7999. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8000. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8001. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8002. ceErpTradeAfterSaleExtend.Create();
  8003. }
  8004. //退回到主管
  8005. //entity.AfterSaleState = 2;
  8006. }
  8007. if (entity.AfterSaleState == 4)
  8008. {
  8009. ApiVo apiVo = new ApiVo();
  8010. apiVo.orderNumber = entity.ctid;
  8011. apiVo.actionName = "afterOver";
  8012. designHelper.API_WorkCore(apiVo); //afterOver
  8013. }
  8014. entity.UpdateTime = DateTime.Now;
  8015. entity.Update();
  8016. returnSuccessMsg("操作成功!");
  8017. CeErpSukuraData.createInfo(entity.ctid, 8);
  8018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8019. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8020. return;
  8021. }
  8022. }
  8023. returnErrorMsg("找不到订单记录");
  8024. }
  8025. }
  8026. public void set_erp_supplierrefundtag()
  8027. {
  8028. if (UrlPostParmsCheck("ctid"))
  8029. {
  8030. string eid = GetPostString("ctid");
  8031. CeErpTradeCell entity = null;
  8032. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8033. if (entity != null)
  8034. {
  8035. entity.IsSupplierRefund = GetPostInt("tag");
  8036. entity.Update();
  8037. returnSuccessMsg("操作成功!");
  8038. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  8039. return;
  8040. }
  8041. returnErrorMsg("找不到订单记录");
  8042. }
  8043. }
  8044. public void get_erp_refundlist()
  8045. {
  8046. DataStruct dStruct = GetPostStruct();
  8047. List<string> lw = new List<string>();
  8048. string tid = GetPostString("tid");
  8049. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8050. //string rid = GetPostString("refund_id");
  8051. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  8052. string shopname = GetPostString("shopname");
  8053. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8054. string buyernick = GetPostString("buyer_nick");
  8055. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8056. string customer = GetPostString("customer");
  8057. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8058. string design = GetPostString("design");
  8059. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8060. string sellermemo = GetPostString("seller_memo");
  8061. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8062. //string date1 = GetPostString("date1");
  8063. //string date2 = GetPostString("date2");
  8064. //string dateType = GetPostString("dateType");
  8065. //if (dateType.Length > 0)
  8066. //{
  8067. // if (dateType == "1001") dateType = "0";
  8068. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8069. // if (searchDT.Count == 2)
  8070. // {
  8071. // date1 = searchDT[0].ToString();
  8072. // date2 = searchDT[1].ToString();
  8073. // }
  8074. //}
  8075. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8076. //if (dw.Length > 0) lw.Add(dw);
  8077. string redate1 = GetPostString("refunddate1");
  8078. string redate2 = GetPostString("refunddate2");
  8079. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8080. if (dwdate.Length > 0) lw.Add(dwdate);
  8081. string price1 = GetPostString("price1");
  8082. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8083. string price2 = GetPostString("price2");
  8084. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8085. string ispartrefund = GetPostString("ispartrefund");
  8086. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8087. string refundState = GetPostString("refundvstate");
  8088. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8089. int st = GetInt("st");
  8090. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8091. {
  8092. string responsible = GetPostString("responsibleman");
  8093. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8094. lw.Add(string.Format("RefundState>={0}", st));
  8095. string code = CurrentUser.UserPost.Post.Code;
  8096. if (code == "CustomerService")
  8097. {
  8098. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8099. }
  8100. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8101. {
  8102. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8103. }
  8104. else if (code == "Place" || code == "PlaceMr")
  8105. {
  8106. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8107. }
  8108. dStruct.Order = "RefundState asc,created desc";
  8109. }
  8110. else if (st == 10)
  8111. {
  8112. string responsible = GetPostString("responsibleman");
  8113. if (responsible == "空白")
  8114. {
  8115. lw.Add(string.Format("ResponsibleUserName = ''"));
  8116. }
  8117. else if (responsible.Length > 0)
  8118. {
  8119. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8120. }
  8121. lw.Add(string.Format("RefundState>=0"));
  8122. dStruct.Order = "created desc";
  8123. }
  8124. else
  8125. {
  8126. string responsible = GetPostString("responsibleman");
  8127. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8128. lw.Add(string.Format("RefundState={0}", st));
  8129. dStruct.Order = "created desc";
  8130. }
  8131. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8132. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8133. dt.Columns.Add("refund_fees");
  8134. foreach (DataRow dr in dt.Rows)
  8135. {
  8136. String status = dr["status"].ToString();
  8137. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8138. {
  8139. dr["refund_fees"] = dr["refund_fee"];
  8140. }
  8141. else
  8142. {
  8143. dr["refund_fees"] = "0.0";
  8144. }
  8145. }
  8146. writeGridDataTableJson(dStruct.TotalCount, dt);
  8147. }
  8148. public void get_erp_refunddesignlist()
  8149. {
  8150. DataStruct dStruct = GetPostStruct();
  8151. List<string> lw = new List<string>();
  8152. string tid = GetPostString("tid");
  8153. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8154. string shopname = GetPostString("shopname");
  8155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8156. string buyernick = GetPostString("buyer_nick");
  8157. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8158. string customer = GetPostString("customer");
  8159. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8160. string design = GetPostString("design");
  8161. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8162. string sellermemo = GetPostString("seller_memo");
  8163. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8164. string redate1 = GetPostString("refunddate1");
  8165. string redate2 = GetPostString("refunddate2");
  8166. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8167. if (dwdate.Length > 0) lw.Add(dwdate);
  8168. string price1 = GetPostString("price1");
  8169. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8170. string price2 = GetPostString("price2");
  8171. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8172. string ispartrefund = GetPostString("ispartrefund");
  8173. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8174. string designerorg = GetPostString("designerorg");
  8175. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8176. string refundState = GetPostString("refundState");
  8177. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8178. int myOrgid = CurrentUser.UserPost.OrgID;
  8179. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8180. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8181. {
  8182. if (CurrentUser.User.TeamIds.Length > 0)
  8183. {
  8184. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8185. }
  8186. else
  8187. {
  8188. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8189. }
  8190. }
  8191. else if ("SysAdmin".Equals(myOrgCode))
  8192. {
  8193. }
  8194. else
  8195. {
  8196. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8197. {
  8198. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8199. }
  8200. else
  8201. {
  8202. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8203. }
  8204. }
  8205. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8206. dStruct.Order = "created desc";
  8207. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8208. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8209. dt.Columns.Add("refund_fees");
  8210. foreach (DataRow dr in dt.Rows)
  8211. {
  8212. String status = dr["status"].ToString();
  8213. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8214. {
  8215. dr["refund_fees"] = dr["refund_fee"];
  8216. }
  8217. else
  8218. {
  8219. dr["refund_fees"] = "0.0";
  8220. }
  8221. }
  8222. writeGridDataTableJson(dStruct.TotalCount, dt);
  8223. }
  8224. public void handle_erp_refundtag()
  8225. {
  8226. if (UrlPostParmsCheck("refund_id"))
  8227. {
  8228. string eid = GetPostString("refund_id");
  8229. string respMan = GetPostString("ResponsibleName");
  8230. if (respMan.Length <= 0)
  8231. {
  8232. returnErrorMsg("责任人不能为空");
  8233. return;
  8234. }
  8235. CeErpTradeRefund entity = null;
  8236. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8237. if (entity != null)
  8238. {
  8239. entity.ResponsibleUserName = respMan;
  8240. string userid = GetPostString("ResponsibleUserId");
  8241. if (userid.Length > 0)
  8242. {
  8243. entity.ResponsibleUserId = userid;
  8244. }
  8245. entity.Memo = GetPostString("Memo");
  8246. if (respMan.IndexOf("客服") != -1 ||
  8247. respMan.IndexOf("设计师") != -1 ||
  8248. respMan.IndexOf("下单员") != -1)
  8249. {
  8250. entity.RefundState = 2;
  8251. }
  8252. else
  8253. {
  8254. entity.RefundState = 3;
  8255. }
  8256. entity.modified = DateTime.Now;
  8257. entity.Update();
  8258. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8259. returnSuccessMsg("操作成功!");
  8260. return;
  8261. }
  8262. returnErrorMsg("找不到订单记录");
  8263. }
  8264. }
  8265. public void handle_erp_designrefundtag()
  8266. {
  8267. if (UrlPostParmsCheck("refund_id"))
  8268. {
  8269. string eid = GetPostString("refund_id");
  8270. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8271. if (ceErpTradeCellExtend == null)
  8272. {
  8273. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8274. ceErpTradeCellExtend.ctid = eid;
  8275. }
  8276. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8277. if (ceErpTradeCellExtend.ID > 0)
  8278. {
  8279. ceErpTradeCellExtend.Update();
  8280. }
  8281. else
  8282. {
  8283. ceErpTradeCellExtend.Create();
  8284. }
  8285. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8286. returnSuccessMsg("操作成功!");
  8287. return;
  8288. }
  8289. returnErrorMsg("找不到订单记录");
  8290. }
  8291. public void upd_erp_refundverify()
  8292. {
  8293. if (UrlPostParmsCheck("refund_id"))
  8294. {
  8295. string eid = GetPostString("refund_id");
  8296. CeErpTradeRefund entity = null;
  8297. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8298. if (entity != null)
  8299. {
  8300. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8301. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8302. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8303. {
  8304. entity.RefundState = 2;
  8305. }
  8306. else
  8307. {
  8308. entity.RefundState = 3;
  8309. }
  8310. entity.Update();
  8311. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8312. returnSuccessMsg("操作成功!");
  8313. return;
  8314. }
  8315. returnErrorMsg("找不到订单记录");
  8316. }
  8317. }
  8318. public void upd_erp_refundapprove()
  8319. {
  8320. if (UrlPostParmsCheck("refund_id"))
  8321. {
  8322. string eid = GetPostString("refund_id");
  8323. CeErpTradeRefund entity = null;
  8324. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8325. if (entity != null)
  8326. {
  8327. int apr = GetPostInt("approve");
  8328. if (apr == 0)
  8329. {
  8330. entity.RefundState = 1;
  8331. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8332. }
  8333. else if (apr == 1)
  8334. {
  8335. entity.RefundState = 3;
  8336. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8337. }
  8338. entity.modified = DateTime.Now;
  8339. entity.Update();
  8340. returnSuccessMsg("操作成功!");
  8341. return;
  8342. }
  8343. returnErrorMsg("找不到订单记录");
  8344. }
  8345. }
  8346. public void get_erp_billlist()
  8347. {
  8348. DataStruct dStruct = GetPostStruct();
  8349. List<string> lw = new List<string>();
  8350. string title = GetPostString("title");
  8351. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8352. string tid = GetPostString("tid");
  8353. string tids = GetPostString("tids");
  8354. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8355. if (tids.Length > 0)
  8356. {
  8357. tids = "'" + tids + "'";
  8358. tids = tids.Replace(",", "','");
  8359. lw.Add(string.Format("tid in ({0})", tids));
  8360. }
  8361. string shopname = GetPostString("shopname");
  8362. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8363. string buyernick = GetPostString("buyer_nick");
  8364. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8365. string customer = GetPostString("customer");
  8366. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8367. string date1 = GetPostString("date1");
  8368. string date2 = GetPostString("date2");
  8369. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8370. if (dw.Length > 0) lw.Add(dw);
  8371. string price1 = GetPostString("price1");
  8372. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8373. string price2 = GetPostString("price2");
  8374. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8375. string returndate1 = GetPostString("returndate1");
  8376. string returndate2 = GetPostString("returndate2");
  8377. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8378. if (dw1.Length > 0) lw.Add(dw1);
  8379. string billtype = GetPostString("billtype");
  8380. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8381. string billstate = GetPostString("billstate");
  8382. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8383. string usershop = CurrentUser.User.pemShop;
  8384. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8385. dStruct.Order = "createTime desc";
  8386. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8387. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8388. //foreach (DataRow dr in dt.Rows)
  8389. //{
  8390. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8391. //}
  8392. writeGridDataTableJson(dStruct.TotalCount, dt);
  8393. }
  8394. public void modify_erp_billinfo()
  8395. {
  8396. if (UrlPostParmsCheck("ID"))
  8397. {
  8398. string eid = GetPostString("ID");
  8399. CeErpBill bill_entity = null;
  8400. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8401. if (bill_entity != null)
  8402. {
  8403. bill_entity.tid = GetPostString("tid");
  8404. bill_entity.title = GetPostString("title");
  8405. bill_entity.tax = GetPostString("tax");
  8406. bill_entity.bank = GetPostString("bank");
  8407. bill_entity.bankac = GetPostString("bankac");
  8408. bill_entity.address = GetPostString("address");
  8409. bill_entity.phone = GetPostString("phone");
  8410. bill_entity.price = GetPostString("price");
  8411. bill_entity.productId = GetPostInt("ProductName");
  8412. bill_entity.num = GetPostInt("num");
  8413. bill_entity.unit = GetPostString("unit");
  8414. bill_entity.type = GetPostString("type");
  8415. bill_entity.sendType = GetPostString("SendType");
  8416. bill_entity.email = GetPostString("email");
  8417. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8418. bill_entity.shopName = GetPostString("ShopName");
  8419. bill_entity.applymemo = GetPostString("applymemo");
  8420. bill_entity.modifyTime = DateTime.Now;
  8421. bill_entity.createTime = DateTime.Now;
  8422. bill_entity.state = 0;
  8423. bill_entity.Update();
  8424. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8425. returnSuccessMsg("发票修改成功!");
  8426. return;
  8427. }
  8428. returnErrorMsg("找不到对应记录");
  8429. }
  8430. }
  8431. public void set_erp_invoicing()
  8432. {
  8433. if (UrlPostParmsCheck("id"))
  8434. {
  8435. try
  8436. {
  8437. string eid = GetPostString("id");
  8438. CeErpBill bill_entity = null;
  8439. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8440. if (bill_entity != null)
  8441. {
  8442. int ComId = GetPostInt("ComId");
  8443. //string memo = GetPostString("Memo");
  8444. int allInfo = GetPostInt("allinfo");
  8445. string clert = CurrentUser.User.Name;
  8446. //string detailValue = GetPostString("detailvalue");
  8447. string billId = bill_entity.billOrderId;
  8448. string[] billIdList = billId.Split(',');
  8449. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8450. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8451. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8452. {
  8453. billCount += 1;
  8454. }
  8455. if (billId.Length <= 0 || billIdList.Length != billCount)
  8456. {
  8457. bill_entity.billOrderId = "";
  8458. string prebill = "ltb";
  8459. for (int idx = 1; idx <= billCount; idx++)
  8460. {
  8461. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8462. string billoid = prebill + idx + dtstr;
  8463. bill_entity.billOrderId += billoid;
  8464. if (idx < billCount)
  8465. {
  8466. bill_entity.billOrderId += ",";
  8467. }
  8468. }
  8469. }
  8470. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8471. if (bill_entity.state == 5)
  8472. {
  8473. string errMsg = bill_entity.failerror;
  8474. string[] errlist = errMsg.Split('|');
  8475. string[] errTags = new string[errlist.Length];
  8476. for (int itag = 0; itag < errlist.Length; itag++)
  8477. {
  8478. if (errlist[itag].Length <= 0) continue;
  8479. errTags[itag] = errlist[itag].Split('&')[0];
  8480. }
  8481. for (int iii = 0; iii < errTags.Length; iii++)
  8482. {
  8483. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8484. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8485. if (billOrderList.Length >= erroBillOrderTag)
  8486. {
  8487. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8488. if (needModifyBillId.Length <= 19)
  8489. {
  8490. needModifyBillId = needModifyBillId + "1";
  8491. }
  8492. else
  8493. {
  8494. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8495. last = last + 1;
  8496. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8497. }
  8498. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8499. }
  8500. }
  8501. }
  8502. bool isHaveBillSucces = false;
  8503. string totalRes = "";
  8504. bill_entity.failerror = "";
  8505. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8506. {
  8507. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8508. totalRes += res;
  8509. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8510. {
  8511. isHaveBillSucces = true;
  8512. bill_entity.comId = ComId;
  8513. bill_entity.state = 1;
  8514. bill_entity.executeTime = DateTime.Now;
  8515. bill_entity.executeUser = clert;
  8516. }
  8517. else
  8518. {
  8519. bill_entity.state = 5;
  8520. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8521. }
  8522. }
  8523. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8524. bill_entity.Update();
  8525. if (isHaveBillSucces)
  8526. {
  8527. StringBuilder sql = new StringBuilder();
  8528. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8529. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8530. }
  8531. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8532. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8533. {
  8534. returnErrorMsg("开票失败");
  8535. }
  8536. else
  8537. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8538. return;
  8539. }
  8540. returnErrorMsg("找不到对应记录");
  8541. }
  8542. catch (Exception ex)
  8543. {
  8544. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8545. returnErrorMsg("操作失败");
  8546. }
  8547. }
  8548. }
  8549. public void get_erp_invoicing_back()
  8550. {
  8551. if (UrlPostParmsCheck("id"))
  8552. {
  8553. try
  8554. {
  8555. string id = GetPostString("id");
  8556. CeErpBill entiy = CeErpBill.Get(id);
  8557. if (entiy != null)
  8558. {
  8559. if (entiy.state == 0)
  8560. {
  8561. returnErrorMsg("发票还未开具");
  8562. return;
  8563. }
  8564. string[] billOrderList = entiy.billOrderId.Split(',');
  8565. int iTag = 0;
  8566. entiy.fplsh = "";
  8567. entiy.fpdm = "";
  8568. entiy.fphm = "";
  8569. foreach (string billOrderId in billOrderList)
  8570. {
  8571. iTag++;
  8572. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8573. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8574. {
  8575. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8576. try
  8577. {
  8578. Invoicing_get_response_Obj iObj = null;
  8579. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8580. if (iObj != null)
  8581. {
  8582. entiy.state = 2;
  8583. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8584. entiy.fpdm += iObj.list[0].c_fpdm;
  8585. entiy.fphm += iObj.list[0].c_fphm;
  8586. if (iTag < billOrderList.Length)
  8587. {
  8588. entiy.fplsh += ",";
  8589. entiy.fpdm += ",";
  8590. entiy.fphm += ",";
  8591. }
  8592. entiy.Update();
  8593. }
  8594. StringBuilder sql = new StringBuilder();
  8595. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8596. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8597. returnSuccessMsg("开票成功");
  8598. }
  8599. catch (Exception ex)
  8600. {
  8601. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8602. }
  8603. return;
  8604. }
  8605. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8606. {
  8607. var res_obj = new
  8608. {
  8609. data = "开票中"
  8610. };
  8611. string ro_json = JsonConvert.SerializeObject(res_obj);
  8612. returnSuccess(ro_json);
  8613. return;
  8614. }
  8615. else
  8616. {
  8617. int eidx = res.IndexOf("c_resultmsg");
  8618. int lidx = res.IndexOf("c_status");
  8619. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8620. entiy.state = 5;
  8621. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8622. entiy.Update();
  8623. returnErrorMsg("开票失败");
  8624. return;
  8625. }
  8626. }
  8627. }
  8628. }
  8629. catch (Exception ex)
  8630. {
  8631. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8632. }
  8633. return;
  8634. }
  8635. }
  8636. public void get_erp_invoicing()
  8637. {
  8638. if (UrlPostParmsCheck("id"))
  8639. {
  8640. try
  8641. {
  8642. string id = GetPostString("id");
  8643. CeErpBill entiy = CeErpBill.Get(id);
  8644. if (entiy != null)
  8645. {
  8646. if (entiy.state == 0)
  8647. {
  8648. returnErrorMsg("发票还未开具");
  8649. return;
  8650. }
  8651. if (entiy.sendType == "纸质发票")
  8652. {
  8653. if (entiy.img.Length <= 0)
  8654. {
  8655. returnErrorMsg("查无纸质发票");
  8656. return;
  8657. }
  8658. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8659. returnSuccess(returnres);
  8660. return;
  8661. }
  8662. string[] billOrderList = entiy.billOrderId.Split(',');
  8663. int iTag = 0;
  8664. string fpUrl = "";
  8665. entiy.fplsh = "";
  8666. entiy.fpdm = "";
  8667. entiy.fphm = "";
  8668. foreach (string billOrderId in billOrderList)
  8669. {
  8670. iTag++;
  8671. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8672. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8673. {
  8674. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8675. Invoicing_get_response_Obj iObj = null;
  8676. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8677. if (iObj != null)
  8678. {
  8679. //entiy.state = 2;
  8680. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8681. entiy.fpdm += iObj.list[0].c_fpdm;
  8682. entiy.fphm += iObj.list[0].c_fphm;
  8683. if (iTag < billOrderList.Length)
  8684. {
  8685. entiy.fplsh += ",";
  8686. entiy.fpdm += ",";
  8687. entiy.fphm += ",";
  8688. }
  8689. entiy.Update();
  8690. fpUrl += iObj.list[0].c_url + ",";
  8691. }
  8692. //returnSuccess(res);
  8693. StringBuilder sql = new StringBuilder();
  8694. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8695. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8696. }
  8697. else
  8698. {
  8699. int eidx = res.IndexOf("c_resultmsg");
  8700. //int lidx = res.IndexOf("c_status");
  8701. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8702. //开票失败
  8703. entiy.state = 5;
  8704. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8705. entiy.Update();
  8706. returnErrorMsg("开票失败");
  8707. return;
  8708. }
  8709. }
  8710. var returnObj = new
  8711. {
  8712. data = fpUrl
  8713. };
  8714. string ro_json = JsonConvert.SerializeObject(returnObj);
  8715. returnSuccess(ro_json);
  8716. }
  8717. }
  8718. catch (Exception ex)
  8719. {
  8720. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8721. }
  8722. return;
  8723. }
  8724. }
  8725. public void save_erp_billimg()
  8726. {
  8727. if (UrlPostParmsCheck("id"))
  8728. {
  8729. string eid = GetPostString("id");
  8730. CeErpBill bill_entity = null;
  8731. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8732. if (bill_entity != null)
  8733. {
  8734. bill_entity.img = GetPostString("img");
  8735. bill_entity.executeTime = DateTime.Now;
  8736. bill_entity.state = 2;
  8737. bill_entity.Update();
  8738. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8739. returnSuccessMsg("保存成功");
  8740. }
  8741. return;
  8742. }
  8743. }
  8744. public void upd_erp_billreturnback()
  8745. {
  8746. if (UrlPostParmsCheck("id"))
  8747. {
  8748. int eid = GetPostInt("id");
  8749. CeErpBill bill_entity = null;
  8750. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8751. if (bill_entity != null)
  8752. {
  8753. bill_entity.state = 3;
  8754. bill_entity.returnReason = GetPostString("reason");
  8755. bill_entity.Update();
  8756. returnSuccessMsg("驳回成功!");
  8757. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8758. }
  8759. return;
  8760. }
  8761. }
  8762. public void cancel_erp_bill()
  8763. {
  8764. if (UrlPostParmsCheck("id"))
  8765. {
  8766. int eid = GetPostInt("id");
  8767. int detailValue = GetPostInt("detailvalue");
  8768. CeErpBill bill_entity = null;
  8769. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8770. string cres = "";
  8771. string gres = "";
  8772. if (bill_entity != null)
  8773. {
  8774. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8775. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8776. {
  8777. int iTag = 0;
  8778. bill_entity.fplsh = "";
  8779. bill_entity.fpdm = "";
  8780. bill_entity.fphm = "";
  8781. foreach (string billOrderId in billOrderList)
  8782. {
  8783. iTag++;
  8784. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8785. if (gres.IndexOf("success") != -1)
  8786. {
  8787. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8788. Invoicing_get_response_Obj iObj = null;
  8789. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8790. if (iObj != null)
  8791. {
  8792. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8793. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8794. bill_entity.fphm += iObj.list[0].c_fphm;
  8795. if (iTag < billOrderList.Length)
  8796. {
  8797. bill_entity.fplsh += ",";
  8798. bill_entity.fpdm += ",";
  8799. bill_entity.fphm += ",";
  8800. }
  8801. bill_entity.Update();
  8802. }
  8803. }
  8804. else
  8805. {
  8806. returnErrorMsg(gres);
  8807. return;
  8808. }
  8809. }
  8810. }
  8811. if (bill_entity.sendType == "纸质发票")
  8812. {
  8813. //作废
  8814. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8815. //if (DateTime.Now.Month == extime.Month)
  8816. //{
  8817. //cres = taobaoHelper.cancel_invoicing(eid);
  8818. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8819. //{
  8820. bill_entity.state = 4;//已作废
  8821. bill_entity.Update();
  8822. returnSuccessMsg("发票已作废");
  8823. return;
  8824. //}
  8825. //else
  8826. //{
  8827. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8828. // bill_entity.Update();
  8829. // returnErrorMsg(cres);
  8830. // return;
  8831. //}
  8832. //}
  8833. //else
  8834. //{
  8835. // returnErrorMsg("纸质发票只能作废本月的发票");
  8836. // return;
  8837. //}
  8838. }
  8839. //红冲
  8840. int redTag = 0;
  8841. string[] fpdmList = bill_entity.fpdm.Split(',');
  8842. string[] fphmList = bill_entity.fphm.Split(',');
  8843. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8844. {
  8845. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8846. return;
  8847. }
  8848. foreach (string billOrderId in billOrderList)
  8849. {
  8850. redTag++;
  8851. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8852. cres += onecres;
  8853. cres += ",";
  8854. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8855. {
  8856. bill_entity.state = 4;//已作废
  8857. //bill_entity.Update();
  8858. //returnSuccessMsg("发票已红冲");
  8859. }
  8860. else if (onecres.IndexOf("重复冲红") != -1)
  8861. {
  8862. bill_entity.state = 4;//已作废
  8863. //bill_entity.Update();
  8864. //returnSuccessMsg("发票已红冲");
  8865. }
  8866. else
  8867. {
  8868. string errmsg = commonHelper.KeepChinese(onecres);
  8869. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8870. }
  8871. }
  8872. bill_entity.Update();
  8873. if (cres.IndexOf("失败") != -1)
  8874. returnErrorMsg("红冲失败");
  8875. else
  8876. returnSuccessMsg("发票已红冲");
  8877. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8878. return;
  8879. }
  8880. return;
  8881. }
  8882. }
  8883. public void del_erp_billorder()
  8884. {
  8885. if (UrlPostParmsCheck("id"))
  8886. {
  8887. string eid = GetPostString("id");
  8888. CeErpBill.Del(eid);
  8889. CeErpBill bill = CeErpBill.Get(eid);
  8890. if (bill != null)
  8891. {
  8892. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8893. }
  8894. returnSuccessMsg("删除成功");
  8895. }
  8896. }
  8897. public void finish_erp_bill()
  8898. {
  8899. if (UrlPostParmsCheck("ids"))
  8900. {
  8901. string eids = GetPostString("ids");
  8902. string[] list = eids.Split(',');
  8903. foreach (string eid in list)
  8904. {
  8905. CeErpBill bill = CeErpBill.Get(eid);
  8906. if (bill != null)
  8907. {
  8908. bill.state = 2;
  8909. bill.Update();
  8910. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8911. }
  8912. }
  8913. returnSuccessMsg("操作成功");
  8914. }
  8915. }
  8916. public void get_erp_returncash()
  8917. {
  8918. DataStruct dStruct = GetPostStruct();
  8919. List<string> lw = new List<string>();
  8920. string tid = GetPostString("tid");
  8921. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8922. string shopname = GetPostString("shopname");
  8923. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8924. string buyernick = GetPostString("buyer_nick");
  8925. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8926. string customer = GetPostString("customer");
  8927. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8928. string returndate1 = GetPostString("returndate1");
  8929. string returndate2 = GetPostString("returndate2");
  8930. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8931. if (dw.Length > 0) lw.Add(dw);
  8932. string finishDate1 = GetPostString("finishdate1");
  8933. string finishDate2 = GetPostString("finishdate2");
  8934. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8935. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8936. string returntype = GetPostString("returntype");
  8937. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8938. string returnvstate = GetPostString("returnvstate");
  8939. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8940. dStruct.Order = "created desc";
  8941. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8942. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8943. writeGridDataTableJson(dStruct.TotalCount, dt);
  8944. }
  8945. public void get_erp_staygoods()
  8946. {
  8947. DataStruct dStruct = GetPostStruct();
  8948. List<string> lw = new List<string>();
  8949. string tid = GetPostString("tid");
  8950. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8951. string shopname = GetPostString("shopname");
  8952. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8953. string wangwang = GetPostString("wangwang");
  8954. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8955. string customer = GetPostString("customer");
  8956. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8957. string returndate1 = GetPostString("returndate1");
  8958. string returndate2 = GetPostString("returndate2");
  8959. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8960. if (dw.Length > 0) lw.Add(dw);
  8961. string finishDate1 = GetPostString("finishdate1");
  8962. string finishDate2 = GetPostString("finishdate2");
  8963. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8964. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8965. string returnvstate = GetPostString("returnvstate");
  8966. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8967. string persuadetype = GetPostString("persuadetype");
  8968. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8969. string customerOrg = GetPostString("customerOrg");
  8970. if (customerOrg.Length > 0)
  8971. {
  8972. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8973. }
  8974. string designerorg = GetPostString("designerorg");
  8975. if (designerorg.Length > 0)
  8976. {
  8977. lw.Add(string.Format("OrgID = {0}", designerorg));
  8978. }
  8979. dStruct.Order = "creata_time desc";
  8980. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8981. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8982. writeGridDataTableJson(dStruct.TotalCount, dt);
  8983. }
  8984. public void upd_erp_staygoods()
  8985. {
  8986. if (UrlPostParmsCheck("id"))
  8987. {
  8988. int eid = GetPostInt("id");
  8989. CeErpStayGoods entity = null;
  8990. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8991. if (entity != null)
  8992. {
  8993. entity.audit_type = 1;
  8994. entity.audit_time = DateTime.Now;
  8995. entity.audit_u_id = CurrentUser.UserID;
  8996. entity.audit_u_name = CurrentUser.UserName;
  8997. entity.Update();
  8998. returnSuccessMsg("审核成功!");
  8999. return;
  9000. }
  9001. returnErrorMsg("找不到订单记录");
  9002. }
  9003. }
  9004. public void upd_erp_stayGoodsback()
  9005. {
  9006. if (UrlPostParmsCheck("id"))
  9007. {
  9008. int eid = GetPostInt("id");
  9009. CeErpStayGoods entity = null;
  9010. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9011. if (entity != null)
  9012. {
  9013. entity.audit_text = GetPostString("reason");
  9014. entity.audit_type = 2;
  9015. entity.audit_time = DateTime.Now;
  9016. entity.audit_u_id = CurrentUser.UserID;
  9017. entity.audit_u_name = CurrentUser.UserName;
  9018. entity.Update();
  9019. returnSuccessMsg("退回成功!");
  9020. return;
  9021. }
  9022. returnErrorMsg("找不到订单记录");
  9023. }
  9024. }
  9025. public void upd_erp_returncashverify()
  9026. {
  9027. if (UrlPostParmsCheck("ID"))
  9028. {
  9029. int eid = GetPostInt("ID");
  9030. CeErpReturnCash entity = null;
  9031. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9032. if (entity != null)
  9033. {
  9034. entity.cashstate = 1;
  9035. entity.verifytime = DateTime.Now;
  9036. entity.verifyuserid = CurrentUser.UserID;
  9037. entity.Update();
  9038. returnSuccessMsg("审核成功!");
  9039. return;
  9040. }
  9041. returnErrorMsg("找不到订单记录");
  9042. }
  9043. }
  9044. public void upd_all_erp_returncashverify()
  9045. {
  9046. if (UrlPostParmsCheck("ID"))
  9047. {
  9048. String[] list = GetPostString("ID").Split(',');
  9049. CeErpReturnCash entity = null;
  9050. for (int i = 0; i < list.Length; i++)
  9051. {
  9052. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9053. if (entity != null)
  9054. {
  9055. if (entity.cashstate == 1)
  9056. {
  9057. returnErrorMsg("已审核过的订单不需要在审核!");
  9058. return;
  9059. }
  9060. entity.cashstate = 1;
  9061. entity.verifytime = DateTime.Now;
  9062. entity.verifyuserid = CurrentUser.UserID;
  9063. entity.Update();
  9064. }
  9065. }
  9066. returnSuccessMsg("审核成功!");
  9067. return;
  9068. }
  9069. }
  9070. public void upd_erp_returncashback()
  9071. {
  9072. if (UrlPostParmsCheck("ID"))
  9073. {
  9074. int eid = GetPostInt("ID");
  9075. CeErpReturnCash entity = null;
  9076. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9077. if (entity != null)
  9078. {
  9079. entity.backreason = GetPostString("reason");
  9080. entity.cashstate = 2;
  9081. entity.verifytime = DateTime.Now;
  9082. entity.verifyuserid = CurrentUser.UserID;
  9083. entity.Update();
  9084. returnSuccessMsg("退回成功!");
  9085. return;
  9086. }
  9087. returnErrorMsg("找不到订单记录");
  9088. }
  9089. }
  9090. public void upd_erp_returnprice()
  9091. {
  9092. if (UrlPostParmsCheck("ID"))
  9093. {
  9094. int eid = GetPostInt("ID");
  9095. CeErpReturnCash entity = null;
  9096. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9097. if (entity != null)
  9098. {
  9099. if (entity.cashstate == 1)
  9100. {
  9101. returnErrorMsg("审核通过了不能改");
  9102. return;
  9103. }
  9104. entity.returnprice = GetPostDouble("returnprice");
  9105. entity.Update();
  9106. returnSuccessMsg("修改成功!");
  9107. return;
  9108. }
  9109. returnErrorMsg("找不到订单记录");
  9110. }
  9111. }
  9112. public void del_erp_returncash()
  9113. {
  9114. if (UrlPostParmsCheck("ID"))
  9115. {
  9116. int eid = GetPostInt("ID");
  9117. CeErpReturnCash.Del(eid);
  9118. returnSuccessMsg("操作成功");
  9119. return;
  9120. }
  9121. }
  9122. public void test_for_do_sql()
  9123. {
  9124. string sql = GetPostString("sqlstr");
  9125. if (sql.Length > 0)
  9126. {
  9127. try
  9128. {
  9129. DbHelper.DbConn.ExecuteNonQuery(sql);
  9130. var res_obj = new
  9131. {
  9132. data = "成功",
  9133. };
  9134. string ro_json = JsonConvert.SerializeObject(res_obj);
  9135. returnSuccess(ro_json);
  9136. }
  9137. catch (Exception ex)
  9138. {
  9139. var res_obj = new
  9140. {
  9141. data = ex.Message,
  9142. };
  9143. string ro_json = JsonConvert.SerializeObject(res_obj);
  9144. returnSuccess(ro_json);
  9145. }
  9146. }
  9147. }
  9148. public void get_user_info()
  9149. {
  9150. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9151. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9152. }
  9153. public void get_total_data()
  9154. {
  9155. int userId = CurrentUser.UserID;
  9156. string sql = "";
  9157. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9158. {
  9159. 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);
  9160. }
  9161. else
  9162. {
  9163. 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 " +
  9164. "(select ID from CE_ErpUser where ID = {0}) d " +
  9165. "left join " +
  9166. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9167. ") a on d.ID = a.id left join " +
  9168. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9169. ") b on a.id = b.id1 left join" +
  9170. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9171. ") c on a.id = c.id2;", userId);
  9172. }
  9173. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9174. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9175. }
  9176. public void get_date_area_total_data2()
  9177. {
  9178. int userId = CurrentUser.UserID;
  9179. string date_type = GetPostString("timetype");
  9180. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9181. string sql = "";
  9182. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9183. {
  9184. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9185. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9186. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9187. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9188. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9189. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9190. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9191. ") a on e.ID = a.id left join " +
  9192. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9193. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9194. ") b on a.id = b.id1 " +
  9195. "left join " +
  9196. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9197. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9198. ") c on a.id = c.id2 " +
  9199. "left join " +
  9200. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9201. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9202. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9203. }
  9204. else
  9205. {
  9206. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9207. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9208. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9209. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9210. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9211. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9212. ") a on e.ID = a.id left join " +
  9213. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9214. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9215. ") c on a.id = c.id2 " +
  9216. "left join " +
  9217. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9218. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9219. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9220. }
  9221. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9222. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9223. }
  9224. public void get_date_area_total_data()
  9225. {
  9226. int userId = CurrentUser.UserID;
  9227. string date_type = GetPostString("timetype");
  9228. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9229. string date1 = searchDT[0].ToString();
  9230. string date2 = searchDT[1].ToString();
  9231. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9232. {
  9233. SqlParameter[] sqlParameter ={
  9234. new SqlParameter("@userId", SqlDbType.Int,4),
  9235. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9236. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9237. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9238. };
  9239. sqlParameter[0].Value = userId;
  9240. sqlParameter[1].Value = date1;
  9241. sqlParameter[2].Value = date2;
  9242. sqlParameter[3].Direction = ParameterDirection.Output;
  9243. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9244. string res = sqlParameter[3].Value.ToString();
  9245. var res_obj = new
  9246. {
  9247. data = res
  9248. };
  9249. string ro_json = JsonConvert.SerializeObject(res_obj);
  9250. returnSuccess(ro_json);
  9251. }
  9252. else
  9253. {
  9254. SqlParameter[] sqlParameter ={
  9255. new SqlParameter("@userId", SqlDbType.Int,4),
  9256. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9257. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9258. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9259. };
  9260. sqlParameter[0].Value = userId;
  9261. sqlParameter[1].Value = date1;
  9262. sqlParameter[2].Value = date2;
  9263. sqlParameter[3].Direction = ParameterDirection.Output;
  9264. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9265. string res = sqlParameter[3].Value.ToString();
  9266. var res_obj = new
  9267. {
  9268. data = res
  9269. };
  9270. string ro_json = JsonConvert.SerializeObject(res_obj);
  9271. returnSuccess(ro_json);
  9272. }
  9273. //writeGridDataViewJson(dt.Rows.Count, dv);
  9274. }
  9275. public void get_order_list()
  9276. {
  9277. string strFields = GetPostString("paraFields");
  9278. string strOrder = GetPostString("paraOrder");
  9279. string strWhere = GetPostString("paraWhere");
  9280. string strPageSize = GetPostString("paraPageSize");
  9281. DataStruct dStruct = GetPostStruct();
  9282. dStruct.PageSize = int.Parse(strPageSize);
  9283. dStruct.Fileds = strFields;
  9284. dStruct.Order = strOrder;
  9285. dStruct.MainWhere = strWhere;
  9286. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9287. writeGridDataTableJson(dStruct.TotalCount, dt);
  9288. }
  9289. ////获取待开始订单列表
  9290. //public void get_wait_design_order_list()
  9291. //{
  9292. // string date_type = GetPostString("date_type");
  9293. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9294. // DataStruct dStruct = GetPostStruct();
  9295. // dStruct.PageSize = 1000;
  9296. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9297. // List<string> lw = new List<string>();
  9298. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9299. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9300. // dStruct.Order = "WaitDesignTime asc";
  9301. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9302. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9303. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9304. //}
  9305. //获取完成单量排名
  9306. public void get_finish_order_count_ranking()
  9307. {
  9308. /* string date_type = GetPostString("date_type");
  9309. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9310. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9311. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9312. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9313. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9314. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9315. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9316. writeGridDataTableJson(0, new DataTable());
  9317. }
  9318. public void get_finish_order_amount_ranking()
  9319. {
  9320. /*string date_type = GetPostString("date_type");
  9321. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9322. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9323. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9324. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9325. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9326. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9327. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9328. writeGridDataTableJson(0, new DataTable());
  9329. }
  9330. public void get_finish_refund_count_ranking()
  9331. {
  9332. string date_type = GetPostString("date_type");
  9333. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9334. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9335. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9336. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9337. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9338. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9339. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9340. writeGridDataTableJson(dt.Rows.Count, dt);
  9341. }
  9342. public void get_finish_refund_amount_ranking()
  9343. {
  9344. string date_type = GetPostString("date_type");
  9345. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9346. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9347. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9348. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9349. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9350. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9351. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9352. writeGridDataTableJson(dt.Rows.Count, dt);
  9353. }
  9354. public void set_erp_finishorder_director()
  9355. {
  9356. if (UrlPostParmsCheck("ctid"))
  9357. {
  9358. string eid = GetPostString("ctid");
  9359. CeErpTradeCell entity = null;
  9360. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9361. if (entity != null)
  9362. {
  9363. entity.OrderState = 8;
  9364. entity.Update();
  9365. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9366. returnSuccessMsg("操作成功!");
  9367. return;
  9368. }
  9369. returnErrorMsg("找不到记录");
  9370. }
  9371. }
  9372. public void get_erp_placeregistlist()
  9373. {
  9374. DataStruct dStruct = GetPostStruct();
  9375. List<string> lw = new List<string>();
  9376. string outsid = GetPostString("outsid");
  9377. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9378. string memo = GetPostString("memo");
  9379. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9380. string filename = GetPostString("filename");
  9381. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9382. string islate = GetPostString("islate");
  9383. if (islate.Length > 0)
  9384. {
  9385. if (islate == "1")
  9386. lw.Add(string.Format("OutLate>0"));
  9387. else
  9388. lw.Add(string.Format("OutLate=0"));
  9389. }
  9390. string placedate1 = GetPostString("placedate1");
  9391. string placedate2 = GetPostString("placedate2");
  9392. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9393. if (dw.Length > 0) lw.Add(dw);
  9394. string deliveryDate1 = GetPostString("deliverydate1");
  9395. string deliveryDate2 = GetPostString("deliverydate2");
  9396. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9397. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9398. dStruct.Order = "ID desc";
  9399. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9400. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9401. writeGridDataTableJson(dStruct.TotalCount, dt);
  9402. }
  9403. public void ins_erp_placeregist()
  9404. {
  9405. if (UrlPostParmsCheck("id"))
  9406. {
  9407. string eid = GetPostString("id");
  9408. CeErpPlaceRegister entity = null;
  9409. if (eid == "0")//新增
  9410. {
  9411. entity = new CeErpPlaceRegister();
  9412. string xdTime = GetPostString("placeTime");
  9413. if (xdTime.Length > 0)
  9414. {
  9415. entity.PlactTime = Convert.ToDateTime(xdTime);
  9416. }
  9417. string fhTime = GetPostString("deliveryTime");
  9418. if (fhTime.Length > 0)
  9419. {
  9420. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9421. }
  9422. string preTime = GetPostString("preOutTime");
  9423. if (preTime.Length > 0)
  9424. {
  9425. entity.PreOutTime = Convert.ToDateTime(preTime);
  9426. }
  9427. entity.DeliveryCount = GetPostInt("deliveryCount");
  9428. entity.ReceiveCount = GetPostInt("receiveCount");
  9429. entity.OutSid = GetPostString("outSid");
  9430. entity.FileName = GetPostString("fileName");
  9431. entity.Memo = GetPostString("memo");
  9432. entity.AddUserId = CurrentUser.UserID;
  9433. entity.CreateTime = DateTime.Now;
  9434. entity.Img = GetPostString("img");
  9435. entity.Supplier = GetPostInt("supplier");
  9436. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9437. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9438. {
  9439. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9440. DateTime dt2 = (DateTime)entity.PreOutTime;
  9441. TimeSpan span = dt1.Subtract(dt2);
  9442. if (span.Days > 0)
  9443. {
  9444. entity.OutLate = span.Days;
  9445. }
  9446. }
  9447. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9448. entity.Create();
  9449. returnSuccessMsg("添加成功!");
  9450. return;
  9451. }
  9452. else //修改
  9453. {
  9454. entity = CeErpPlaceRegister.Get(eid);
  9455. if (entity != null)
  9456. {
  9457. string xdTime = GetPostString("placeTime");
  9458. if (xdTime.Length > 0)
  9459. {
  9460. entity.PlactTime = Convert.ToDateTime(xdTime);
  9461. }
  9462. string fhTime = GetPostString("deliveryTime");
  9463. if (fhTime.Length > 0)
  9464. {
  9465. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9466. }
  9467. string preTime = GetPostString("preOutTime");
  9468. if (preTime.Length > 0)
  9469. {
  9470. entity.PreOutTime = Convert.ToDateTime(preTime);
  9471. }
  9472. entity.DeliveryCount = GetPostInt("deliveryCount");
  9473. entity.ReceiveCount = GetPostInt("receiveCount");
  9474. if (entity.DeliveryCount == entity.ReceiveCount)
  9475. {
  9476. entity.CurState = "已完成";
  9477. }
  9478. else
  9479. {
  9480. entity.CurState = "未完成";
  9481. }
  9482. entity.OutSid = GetPostString("outSid");
  9483. entity.FileName = GetPostString("fileName");
  9484. entity.Memo = GetPostString("memo");
  9485. entity.Img = GetPostString("img");
  9486. entity.Supplier = GetPostInt("supplier");
  9487. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9488. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9489. {
  9490. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9491. DateTime dt2 = (DateTime)entity.PreOutTime;
  9492. TimeSpan span = dt1.Subtract(dt2);
  9493. if (span.Days > 0)
  9494. {
  9495. entity.OutLate = span.Days;
  9496. }
  9497. }
  9498. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9499. entity.Update();
  9500. returnSuccessMsg("修改成功");
  9501. return;
  9502. }
  9503. returnErrorMsg("找不到对应的记录");
  9504. return;
  9505. }
  9506. }
  9507. returnErrorMsg("缺少必要参数");
  9508. }
  9509. public void del_erp_placeregist()
  9510. {
  9511. string eid = GetPostString("id");
  9512. CeErpPlaceRegister.Del(eid);
  9513. returnSuccessMsg("删除成功!");
  9514. return;
  9515. }
  9516. public void ins_erp_placeregistbyorder()
  9517. {
  9518. string ctid = GetPostString("ctid");
  9519. if (ctid.Length > 0)
  9520. {
  9521. StringBuilder sql = new StringBuilder();
  9522. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9523. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9524. if (dt.Rows.Count > 0)
  9525. {
  9526. foreach (DataRow dr in dt.Rows)
  9527. {
  9528. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9529. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9530. entity.AddUserId = CurrentUser.UserID;
  9531. entity.tid = dr["tid"].ToString();
  9532. entity.Did = Convert.ToString(dr["ctid"]);
  9533. entity.splitTag = dr["SplitTag"].ToString();
  9534. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9535. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9536. if (pre_ctid.Length > 0)
  9537. {
  9538. sellmemo = sellmemo.Replace(pre_ctid, "");
  9539. }
  9540. sellmemo = sellmemo.Replace("[", "");
  9541. sellmemo = sellmemo.Replace("]", "");
  9542. entity.FileName = sellmemo;
  9543. string count = dr["ProductCount"].ToString();
  9544. int usecount = commonHelper.getIntCountFromString(count);
  9545. entity.DeliveryCount = usecount;
  9546. entity.CurState = "未完成";
  9547. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9548. {
  9549. entity.Supplier = 24;//dl手提袋定制
  9550. }
  9551. else
  9552. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9553. entity.CreateTime = DateTime.Now;
  9554. entity.Create();
  9555. }
  9556. returnSuccessMsg("操作成功");
  9557. return;
  9558. }
  9559. returnErrorMsg("没有找到对应订单");
  9560. return;
  9561. }
  9562. returnErrorMsg("缺少订单编号");
  9563. return;
  9564. }
  9565. public void get_erp_persuadelist()
  9566. {
  9567. DataStruct dStruct = GetPostStruct();
  9568. List<string> lw = new List<string>();
  9569. string ctid = GetPostString("ctid");
  9570. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9571. string shopname = GetPostString("shopname");
  9572. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9573. string buyernick = GetPostString("buyer_nick");
  9574. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9575. string customer = GetPostString("customer");
  9576. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9577. string returndate1 = GetPostString("returndate1");
  9578. string returndate2 = GetPostString("returndate2");
  9579. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9580. if (dw.Length > 0) lw.Add(dw);
  9581. string finishDate1 = GetPostString("finishdate1");
  9582. string finishDate2 = GetPostString("finishdate2");
  9583. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9584. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9585. string persuadetype = GetPostString("persuadetype");
  9586. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9587. string returnvstate = GetPostString("returnvstate");
  9588. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9589. dStruct.Order = "created desc";
  9590. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9591. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9592. writeGridDataTableJson(dStruct.TotalCount, dt);
  9593. }
  9594. public void upd_erp_returnpersuadeback()
  9595. {
  9596. if (UrlPostParmsCheck("ID"))
  9597. {
  9598. int eid = GetPostInt("ID");
  9599. CeErpPersuade entity = null;
  9600. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9601. if (entity != null)
  9602. {
  9603. entity.backreason = GetPostString("reason");
  9604. entity.pstate = 2;
  9605. entity.verifytime = DateTime.Now;
  9606. entity.verifyuserid = CurrentUser.UserID;
  9607. entity.Update();
  9608. returnSuccessMsg("退回成功!");
  9609. return;
  9610. }
  9611. returnErrorMsg("找不到订单记录");
  9612. }
  9613. }
  9614. public void upd_erp_returnpersuadeverify()
  9615. {
  9616. if (UrlPostParmsCheck("ID"))
  9617. {
  9618. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9619. {
  9620. returnErrorMsg("暂无权限审核");
  9621. return;
  9622. }
  9623. int eid = GetPostInt("ID");
  9624. CeErpPersuade entity = null;
  9625. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9626. if (entity != null)
  9627. {
  9628. entity.pstate = 1;
  9629. entity.verifytime = DateTime.Now;
  9630. entity.verifyuserid = CurrentUser.UserID;
  9631. entity.Update();
  9632. returnSuccessMsg("审核成功!");
  9633. return;
  9634. }
  9635. returnErrorMsg("找不到订单记录");
  9636. }
  9637. }
  9638. public void del_erp_persuade()
  9639. {
  9640. if (UrlPostParmsCheck("ID"))
  9641. {
  9642. int eid = GetPostInt("ID");
  9643. CeErpPersuade.Del(eid);
  9644. returnSuccessMsg("操作成功");
  9645. return;
  9646. }
  9647. }
  9648. public void get_erp_oldcustoupload()
  9649. {
  9650. DataStruct dStruct = GetPostStruct();
  9651. List<string> lw = new List<string>();
  9652. string buyernick = GetPostString("buyer_nick");
  9653. if (buyernick.Length > 0)
  9654. {
  9655. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9656. }
  9657. else
  9658. return;
  9659. dStruct.Order = "pay_time desc";
  9660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9661. DataTable dt = null;
  9662. dt = WebCache.GetData("view_erptradecell", dStruct);
  9663. writeGridDataTableJson(dStruct.TotalCount, dt);
  9664. }
  9665. public void get_erp_checkorderlist()
  9666. {
  9667. DataStruct dStruct = GetPostStruct();
  9668. List<string> lw = new List<string>();
  9669. string tid = GetPostString("ctid");
  9670. if (tid.Length > 0)
  9671. {
  9672. string select_tid = getTidByCtid(tid);
  9673. lw.Add(string.Format("tid='{0}'", select_tid));
  9674. }
  9675. string shopname = GetPostString("shopname");
  9676. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9677. string buyernick = GetPostString("buyer_nick");
  9678. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9679. string customer = GetPostString("customer");
  9680. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9681. string design = GetPostString("design");
  9682. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9683. string orderState = GetPostString("orderState");
  9684. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9685. string address = GetPostString("address");
  9686. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9687. string sellermemo = GetPostString("seller_memo");
  9688. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9689. string supplier = GetPostString("supplier");
  9690. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9691. {
  9692. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9693. }
  9694. else
  9695. {
  9696. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9697. }
  9698. string date1 = GetPostString("date1");
  9699. string date2 = GetPostString("date2");
  9700. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9701. if (dw.Length > 0) lw.Add(dw);
  9702. string placedate1 = GetPostString("placedate1");
  9703. string placedate2 = GetPostString("placedate2");
  9704. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9705. if (fdw.Length > 0) lw.Add(fdw);
  9706. string price1 = GetPostString("price1");
  9707. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9708. string price2 = GetPostString("price2");
  9709. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9710. string checkst = GetPostString("checkstate");
  9711. if (checkst.Length > 0 && "10".Equals(checkst))
  9712. {
  9713. lw.Add(string.Format("CheckOut>0"));
  9714. }
  9715. else
  9716. {
  9717. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9718. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9719. }
  9720. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9721. {
  9722. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9723. }
  9724. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9725. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9726. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9727. writeGridDataTableJson(dStruct.TotalCount, dt);
  9728. }
  9729. public void ins_erp_startCheck()
  9730. {
  9731. if (UrlPostParmsCheck("ctid"))
  9732. {
  9733. string eid = GetPostString("ctid");
  9734. CeErpTradeCell entity = null;
  9735. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9736. if (entity != null)
  9737. {
  9738. entity.MemoOpt = 4;
  9739. entity.UpdateTime = DateTime.Now;
  9740. entity.Update();
  9741. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9742. CeErpSukuraData.createInfo(entity.ctid, 6);
  9743. returnSuccessMsg("操作成功!");
  9744. return;
  9745. }
  9746. returnErrorMsg("找不到记录");
  9747. }
  9748. }
  9749. public void upd_erp_sendXlw()
  9750. {
  9751. if (UrlPostParmsCheck("ctid"))
  9752. {
  9753. string eid = GetPostString("ctid");
  9754. CeErpTradeCell entity = null;
  9755. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9756. if (entity != null)
  9757. {
  9758. if (entity.IsSendGift == 1)
  9759. {
  9760. returnErrorMsg("请勿重复标记");
  9761. return;
  9762. }
  9763. entity.IsSendGift = 1;
  9764. entity.Update();
  9765. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9766. returnSuccessMsg("操作成功!");
  9767. return;
  9768. }
  9769. returnErrorMsg("找不到记录");
  9770. }
  9771. }
  9772. public void cancel_sendXlw()
  9773. {
  9774. if (UrlPostParmsCheck("ctid"))
  9775. {
  9776. string eid = GetPostString("ctid");
  9777. CeErpTradeCell entity = null;
  9778. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9779. if (entity != null)
  9780. {
  9781. if (entity.IsSendGift == 0)
  9782. {
  9783. returnErrorMsg("未标记小礼物");
  9784. return;
  9785. }
  9786. entity.IsSendGift = 0;
  9787. entity.Update();
  9788. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9789. returnSuccessMsg("操作成功!");
  9790. return;
  9791. }
  9792. returnErrorMsg("找不到记录");
  9793. }
  9794. }
  9795. public void get_erp_designbill()
  9796. {
  9797. DataStruct dStruct = GetPostStruct();
  9798. List<string> lw = new List<string>();
  9799. int isMy = GetInt("my");
  9800. if (isMy == 1)
  9801. {
  9802. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9803. }
  9804. string tid = GetPostString("tid");
  9805. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9806. string userName = GetPostString("design");
  9807. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9808. string price1 = GetPostString("price1");
  9809. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9810. string price2 = GetPostString("price2");
  9811. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9812. string rePrice1 = GetPostString("rePrice1");
  9813. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9814. string rePrice2 = GetPostString("rePrice2");
  9815. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9816. string designerType = GetPostString("designerType");
  9817. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9818. string orderState = GetPostString("orderState");
  9819. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9820. string endTime1 = GetPostString("endTime1");
  9821. string endTime2 = GetPostString("endTime2");
  9822. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9823. if (dw.Length > 0) lw.Add(dw);
  9824. string isDk = GetPostString("isDk");
  9825. if (isDk == "1")
  9826. {
  9827. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9828. }
  9829. else if (isDk == "0")
  9830. {
  9831. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9832. }
  9833. dStruct.Order = "oid, create_time desc";
  9834. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9835. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9836. writeGridDataTableJson(dStruct.TotalCount, dt);
  9837. }
  9838. public void upd_erp_designerbill()
  9839. {
  9840. if (UrlPostParmsCheck("ID"))
  9841. {
  9842. string eid = GetPostString("ID");
  9843. CeErpDesignerBill entity = null;
  9844. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9845. if (entity != null)
  9846. {
  9847. if (GetPostDouble("designerpirce") > 0)
  9848. {
  9849. entity.realPrice = GetPostDouble("designerpirce");
  9850. entity.update_time = DateTime.Now;
  9851. entity.update_u_id = CurrentUser.UserID;
  9852. entity.update_u_name = CurrentUser.UserName;
  9853. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9854. entity.Update();
  9855. returnSuccessMsg("操作成功!");
  9856. return;
  9857. }
  9858. else
  9859. {
  9860. entity.price = GetPostDouble("price");
  9861. entity.update_time = DateTime.Now;
  9862. entity.update_u_id = CurrentUser.UserID;
  9863. entity.update_u_name = CurrentUser.UserName;
  9864. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9865. entity.Update();
  9866. returnSuccessMsg("操作成功!");
  9867. return;
  9868. }
  9869. }
  9870. returnErrorMsg("找不到记录");
  9871. }
  9872. }
  9873. public void audit_erp_designerbill()
  9874. {
  9875. if (UrlPostParmsCheck("ID"))
  9876. {
  9877. string eid = GetPostString("ID");
  9878. CeErpDesignerBill entity = null;
  9879. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9880. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9881. if (entity != null)
  9882. {
  9883. entity.realPrice = GetPostDouble("designerpirce");
  9884. entity.update_time = DateTime.Now;
  9885. entity.update_u_id = CurrentUser.UserID;
  9886. entity.update_u_name = CurrentUser.UserName;
  9887. entity.isAudit = 1;
  9888. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9889. entity.Update();
  9890. if (orderEntity != null)
  9891. {
  9892. orderEntity.IsReadTag = 3;
  9893. orderEntity.Update();
  9894. }
  9895. returnSuccessMsg("操作成功!");
  9896. return;
  9897. }
  9898. returnErrorMsg("找不到记录");
  9899. }
  9900. }
  9901. public void all_audit_erp_designerbill()
  9902. {
  9903. if (UrlPostParmsCheck("idList"))
  9904. {
  9905. string[] list = GetPostString("idList").Split(',');
  9906. CeErpDesignerBill entity = null;
  9907. for (int i = 0; i < list.Length; i++)
  9908. {
  9909. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9910. if (entity == null) return;
  9911. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9912. if (orderEntity == null) return;
  9913. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9914. entity.update_time = DateTime.Now;
  9915. entity.update_u_id = CurrentUser.UserID;
  9916. entity.update_u_name = CurrentUser.UserName;
  9917. entity.isAudit = 1;
  9918. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9919. entity.Update();
  9920. orderEntity.IsReadTag = 3;
  9921. orderEntity.Update();
  9922. }
  9923. returnSuccessMsg("操作成功!");
  9924. return;
  9925. }
  9926. }
  9927. public void get_erp_sameorders()
  9928. {
  9929. if (UrlPostParmsCheck("ctid"))
  9930. {
  9931. string eid = GetPostString("ctid");
  9932. CeErpTradeCell entity = null;
  9933. entity = CeErpTradeCell.GetByCtid(eid);
  9934. if (entity != null)
  9935. {
  9936. StringBuilder sql = new StringBuilder();
  9937. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9938. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9939. var res = new
  9940. {
  9941. data = dt.Rows.Count
  9942. };
  9943. string ro_jsond = JsonConvert.SerializeObject(res);
  9944. returnSuccess(ro_jsond);
  9945. return;
  9946. }
  9947. returnErrorMsg("未找到订单");
  9948. return;
  9949. }
  9950. returnErrorMsg("缺少必要的参数");
  9951. }
  9952. public void get_erp_islasthavesameorder()
  9953. {
  9954. if (UrlPostParmsCheck("ctid"))
  9955. {
  9956. string eid = GetPostString("ctid");
  9957. string[] ctidList = eid.Split(',');
  9958. StringBuilder sql = new StringBuilder();
  9959. string tisCtid = "";
  9960. foreach (string ctid in ctidList)
  9961. {
  9962. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9963. if (entity != null)
  9964. {
  9965. sql = new StringBuilder();
  9966. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9967. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9968. if (dth.Rows.Count > 0)
  9969. {
  9970. tisCtid += entity.ctid;
  9971. tisCtid += ",";
  9972. }
  9973. }
  9974. }
  9975. if (tisCtid.Length > 0)
  9976. {
  9977. var res = new
  9978. {
  9979. data = tisCtid
  9980. };
  9981. string ro_jsond = JsonConvert.SerializeObject(res);
  9982. returnSuccess(ro_jsond);
  9983. }
  9984. else
  9985. {
  9986. var res = new
  9987. {
  9988. data = ""
  9989. };
  9990. string ro_jsond = JsonConvert.SerializeObject(res);
  9991. returnSuccess(ro_jsond);
  9992. }
  9993. return;
  9994. }
  9995. returnErrorMsg("缺少必要的参数");
  9996. }
  9997. public void file_client_down_url()
  9998. {
  9999. if (!UrlPostParmsCheck("userId"))
  10000. {
  10001. returnErrorMsg("缺少必要的参数");
  10002. }
  10003. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  10004. }
  10005. public void checkout_form_data()
  10006. {
  10007. if (!UrlPostParmsCheck("tid"))
  10008. {
  10009. returnErrorMsg("缺少必要的参数");
  10010. }
  10011. string tid = GetPostString("tid");
  10012. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  10013. if (ceErpOrderFormData != null)
  10014. {
  10015. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  10016. returnSuccess(ro_jsond);
  10017. return;
  10018. }
  10019. returnErrorMsg("尚未有文件!");
  10020. }
  10021. public void back_supplier_audit()
  10022. {
  10023. int userId = CurrentUser.UserID;
  10024. StringBuilder sql = new StringBuilder();
  10025. 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);
  10026. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10027. if (dt.Rows.Count > 0)
  10028. {
  10029. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10030. }
  10031. else
  10032. {
  10033. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10034. }
  10035. }
  10036. public void back_supplier_query()
  10037. {
  10038. string eid = GetPostString("ctid");
  10039. if (eid != "")
  10040. {
  10041. StringBuilder sql = new StringBuilder();
  10042. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  10043. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10044. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10045. }
  10046. else
  10047. {
  10048. returnErrorMsg("找不到订单记录");
  10049. return;
  10050. }
  10051. }
  10052. public void verified_to_order()
  10053. {
  10054. int userId = CurrentUser.UserID;
  10055. StringBuilder sql = new StringBuilder();
  10056. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10057. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10058. if (dt.Rows.Count > 0)
  10059. {
  10060. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10061. }
  10062. else
  10063. {
  10064. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10065. }
  10066. }
  10067. public void upd_supplier_audit()
  10068. {
  10069. if (UrlPostParmsCheck("ctid"))
  10070. {
  10071. string eid = GetPostString("ctid");
  10072. string reason = GetPostString("returnreason");
  10073. CeErpTradeCell entity = null;
  10074. CeWithdraw withdraw = null;
  10075. withdraw = CeWithdraw.GetByTid(eid);
  10076. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10077. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10078. {
  10079. if (withdraw != null)
  10080. {
  10081. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10082. {
  10083. returnSuccessMsg("您没有权限操作!");
  10084. return;
  10085. }
  10086. else
  10087. {
  10088. if (reason.Equals("1"))
  10089. {
  10090. if (entity.OrderState == -1)
  10091. {
  10092. if (entity.FinishPlaceTime == null)
  10093. {
  10094. entity.OrderState = 2;
  10095. }
  10096. else
  10097. {
  10098. entity.OrderState = 6;
  10099. }
  10100. }
  10101. entity.Update();
  10102. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10103. if (withdraw != null)
  10104. {
  10105. withdraw.status = int.Parse(reason);
  10106. withdraw.Update();
  10107. }
  10108. returnSuccessMsg("操作成功!");
  10109. return;
  10110. }
  10111. else
  10112. {
  10113. withdraw.status = int.Parse(reason);
  10114. withdraw.acknowledgingtime = DateTime.Now;
  10115. withdraw.Update();
  10116. returnSuccessMsg("查看详细请点击线下订单查询");
  10117. return;
  10118. }
  10119. }
  10120. }
  10121. // 第一个字符是 'N'
  10122. }
  10123. if (eid[0] != 'N')
  10124. {
  10125. }
  10126. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10127. {
  10128. entity.IsVerifyToSupplier = false;
  10129. entity.IsReturn = 1;
  10130. entity.ReturnTime = DateTime.Now;
  10131. entity.ReturnReason = reason;
  10132. if (entity.OrderState == 6)
  10133. {
  10134. entity.OrderState = 5;
  10135. }
  10136. entity.Update();
  10137. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10138. if (withdraw != null)
  10139. {
  10140. withdraw.status = int.Parse(reason);
  10141. withdraw.Update();
  10142. }
  10143. returnSuccessMsg("操作成功!");
  10144. return;
  10145. }
  10146. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10147. {
  10148. ;
  10149. if (withdraw != null)
  10150. {
  10151. withdraw.status = int.Parse(reason);
  10152. withdraw.acknowledgingtime = DateTime.Now;
  10153. withdraw.Update();
  10154. returnSuccessMsg("供应商取消撤回!");
  10155. return;
  10156. }
  10157. }
  10158. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10159. {
  10160. if (entity.OrderState == -1)
  10161. {
  10162. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10163. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10164. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10165. {
  10166. returnErrorMsg("台湾客户需填写身份证!");
  10167. return;
  10168. }
  10169. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10170. {
  10171. returnErrorMsg("偏远地区需要填写物流费!");
  10172. return;
  10173. }
  10174. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10175. {
  10176. returnErrorMsg("订单spu没有确认无法通过审核!");
  10177. return;
  10178. }
  10179. if (entity.FinishPlaceTime == null)
  10180. {
  10181. entity.OrderState = 2;
  10182. }
  10183. else
  10184. {
  10185. entity.OrderState = 3;
  10186. }
  10187. commonHelper.getCytPrice(entity);
  10188. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10189. {
  10190. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10191. }
  10192. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10193. {
  10194. entity.OrderState = 6;
  10195. }
  10196. }
  10197. entity.Update();
  10198. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10199. if (withdraw != null)
  10200. {
  10201. withdraw.status = int.Parse(reason);
  10202. withdraw.Update();
  10203. }
  10204. returnSuccessMsg("操作成功!");
  10205. return;
  10206. }
  10207. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10208. {
  10209. if (withdraw == null)
  10210. {
  10211. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10212. return;
  10213. }
  10214. }
  10215. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10216. {
  10217. if (withdraw != null)
  10218. {
  10219. withdraw.status = int.Parse(reason);
  10220. withdraw.acknowledgingtime = DateTime.Now;
  10221. withdraw.Update();
  10222. returnSuccessMsg("查看详细请点击线下订单查询");
  10223. return;
  10224. }
  10225. }
  10226. return;
  10227. }
  10228. }
  10229. //校验报价
  10230. public void refund_order_tip()
  10231. {
  10232. int userid = CurrentUser.UserID;
  10233. int sectionId = CurrentUser.UserPost.OrgID;
  10234. StringBuilder sql = new StringBuilder();
  10235. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10236. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10237. List<string> ids = new List<string>();
  10238. if (dth.Rows.Count > 0)
  10239. {
  10240. foreach (DataRow dr in dth.Rows)
  10241. {
  10242. ids.Add(dr["ID"].ToString());
  10243. }
  10244. try
  10245. {
  10246. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10247. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10248. }
  10249. catch (Exception ex)
  10250. {
  10251. }
  10252. }
  10253. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10254. }
  10255. public void refund_order_Design()
  10256. {
  10257. int userid = CurrentUser.UserID;
  10258. int sectionId = CurrentUser.UserPost.OrgID;
  10259. StringBuilder sql = new StringBuilder();
  10260. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10261. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10262. List<string> ids = new List<string>();
  10263. if (dth.Rows.Count > 0)
  10264. {
  10265. foreach (DataRow dr in dth.Rows)
  10266. {
  10267. ids.Add(dr["ID"].ToString());
  10268. }
  10269. try
  10270. {
  10271. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10272. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10273. }
  10274. catch (Exception ex)
  10275. {
  10276. }
  10277. }
  10278. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10279. }
  10280. public void change_order_info()
  10281. {
  10282. int userid = CurrentUser.UserID;
  10283. StringBuilder sql = new StringBuilder();
  10284. 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);
  10285. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10286. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10287. }
  10288. public void size_order_tip()
  10289. {
  10290. int userid = CurrentUser.UserID;
  10291. StringBuilder sql = new StringBuilder();
  10292. sql.AppendFormat("select top 1 * from CE_ErpMessageTip c where (c.userId = '{0}' ) and c.isVisit = 0 and c.type in (3,4);", userid);
  10293. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10294. List<string> ids = new List<string>();
  10295. if (dth.Rows.Count > 0)
  10296. {
  10297. foreach (DataRow dr in dth.Rows)
  10298. {
  10299. ids.Add(dr["ID"].ToString());
  10300. }
  10301. try
  10302. {
  10303. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10304. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10305. }
  10306. catch (Exception ex)
  10307. {
  10308. }
  10309. }
  10310. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10311. }
  10312. public void change_win_mome()
  10313. {
  10314. if (UrlPostParmsCheck("id,ctid"))
  10315. {
  10316. string id = GetPostString("id");
  10317. string ctid = GetPostString("ctid");
  10318. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10319. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10320. if (ce == null || ceErpMessageTip == null)
  10321. {
  10322. returnSuccessMsg("未找到对应的订单!");
  10323. return;
  10324. }
  10325. if (ce.OrderState >= 5)
  10326. {
  10327. ceErpMessageTip.isVisit = true;
  10328. ceErpMessageTip.Update();
  10329. returnSuccessMsg("已上传文件无法修改!");
  10330. return;
  10331. }
  10332. int type = GetPostInt("type");
  10333. string content = GetPostString("content");
  10334. if (type == 0)
  10335. {
  10336. content = content.Replace("(", "(");
  10337. content = content.Replace(")", ")");
  10338. string check = MidStrEx(content, "(", ")").Trim();
  10339. if (string.IsNullOrEmpty(check))
  10340. {
  10341. returnSuccessMsg("文件名格式不正确");
  10342. return;
  10343. }
  10344. }
  10345. ce.seller_memo = content;
  10346. ce.Update();
  10347. ceErpMessageTip.isVisit = true;
  10348. ceErpMessageTip.Update();
  10349. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10350. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10351. ApiVo apiVo = new ApiVo();
  10352. apiVo.orderNumber = ce.ctid;
  10353. apiVo.actionName = "demandDesign";
  10354. apiVo.orderRemarks = content;
  10355. apiVo.demandExamine = type + 1;
  10356. designHelper.API_WorkCore(apiVo);//demandDesign
  10357. returnSuccessMsg("修改成功!");
  10358. }
  10359. }
  10360. public static string MidStrEx(string sourse, string startstr, string endstr)
  10361. {
  10362. string result = string.Empty;
  10363. int startindex, endindex;
  10364. try
  10365. {
  10366. startindex = sourse.IndexOf(startstr);
  10367. if (startindex == -1)
  10368. return result;
  10369. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10370. endindex = tmpstr.IndexOf(endstr);
  10371. if (endindex == -1)
  10372. return result;
  10373. result = tmpstr.Remove(endindex);
  10374. }
  10375. catch (Exception ex)
  10376. {
  10377. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10378. }
  10379. return result;
  10380. }
  10381. public void refund_order_list()
  10382. {
  10383. int userid = CurrentUser.UserID;
  10384. int sectionId = CurrentUser.UserPost.OrgID;
  10385. StringBuilder sql = new StringBuilder();
  10386. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10387. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10388. DataStruct dStruct = GetPostStruct();
  10389. DataTable dt = null;
  10390. List<string> ids = new List<string>();
  10391. List<string> tids = new List<string>();
  10392. if (dth.Rows.Count > 0)
  10393. {
  10394. foreach (DataRow dr in dth.Rows)
  10395. {
  10396. tids.Add("'" + dr["tid"].ToString() + "'");
  10397. ids.Add(dr["id"].ToString());
  10398. }
  10399. try
  10400. {
  10401. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10402. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10403. List<string> lw = new List<string>();
  10404. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10405. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10406. dt = WebCache.GetData("view_orderlist", dStruct);
  10407. }
  10408. catch (Exception ex)
  10409. {
  10410. }
  10411. }
  10412. writeGridDataTableJson(dStruct.TotalCount, dt);
  10413. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10414. }
  10415. //新增
  10416. public void order_batch_downloads()
  10417. {
  10418. string ceid = GetPostString("tid");
  10419. String[] tid = ceid.Split(',');
  10420. order_batch_caiyingtong(tid);
  10421. /* (string success, string errors) = UploadFiles(tid);
  10422. returnSuccessMsg(success + errors);*/
  10423. return;
  10424. }
  10425. //报价接口
  10426. public void Get_To_Quote()
  10427. {
  10428. string ceid = GetPostString("ctid");
  10429. if (ceid != null)
  10430. {
  10431. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10432. if (entity != null)
  10433. {
  10434. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10435. {
  10436. return;
  10437. }
  10438. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10439. double price = 0;
  10440. if (cp == null)
  10441. {
  10442. JObject jsonObject12 = new JObject
  10443. {
  10444. { "UserId", "77886" },
  10445. { "Pwd", "lt666888" },
  10446. { "Filename", entity.seller_memo }
  10447. };
  10448. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10449. JObject jsonObjects1 = JObject.Parse(response1);
  10450. string ms1g = (string)jsonObjects1["msg"];
  10451. if (ms1g == "报价成功")
  10452. {
  10453. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10454. string data = (string)jsonObject1["price"];
  10455. 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 + "');";
  10456. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10457. returnSuccessMsg("获取报价成功:" + data);
  10458. price = Convert.ToDouble(data);
  10459. }
  10460. else
  10461. {
  10462. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10463. return;
  10464. }
  10465. }
  10466. String[] beizhu = entity.seller_memo.Split('-');
  10467. String chanp = "";
  10468. if (beizhu.Length > 0)
  10469. {
  10470. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10471. }
  10472. else
  10473. {
  10474. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10475. }
  10476. JObject jsonObject = new JObject
  10477. {
  10478. { "UserId", "77886" },
  10479. { "Pwd", "lt666888" },
  10480. { "Filename", chanp }
  10481. };
  10482. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10483. JObject jsonObjects = JObject.Parse(response);
  10484. string msg = (string)jsonObjects["msg"];
  10485. if (msg == "报价成功")
  10486. {
  10487. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10488. string data = (string)jsonObject1["price"];
  10489. 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 + "');";
  10490. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10491. returnSuccessMsg("获取报价成功:" + data);
  10492. price = Convert.ToDouble(data);
  10493. }
  10494. else
  10495. {
  10496. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10497. return;
  10498. }
  10499. if (price > 0)
  10500. {
  10501. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10502. if (ceErpTradeCellExtend == null)
  10503. {
  10504. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10505. ceErpTradeCellExtend.ctid = entity.ctid;
  10506. ceErpTradeCellExtend.payment_cyt = price;
  10507. ceErpTradeCellExtend.Create();
  10508. }
  10509. else
  10510. {
  10511. ceErpTradeCellExtend.payment_cyt = price;
  10512. ceErpTradeCellExtend.Update();
  10513. }
  10514. }
  10515. return;
  10516. }
  10517. }
  10518. else
  10519. {
  10520. returnErrorMsg("请至少选择一条数据");
  10521. return;
  10522. }
  10523. }
  10524. //新增
  10525. public void order_To_Supplier()
  10526. {
  10527. string ceid = GetPostString("tid");
  10528. String[] tid = ceid.Split(',');
  10529. if (tid.Length > 0)
  10530. {
  10531. try
  10532. {
  10533. for (int i = 0; i < tid.Length; i++)
  10534. {
  10535. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10536. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10537. entity.SupplierId = suid;
  10538. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10539. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10540. entity.Update();
  10541. }
  10542. }
  10543. catch (Exception ex)
  10544. {
  10545. returnErrorMsg("自动匹配供应商失败");
  10546. return;
  10547. }
  10548. }
  10549. else
  10550. {
  10551. returnErrorMsg("请至少选择一条数据");
  10552. return;
  10553. }
  10554. returnSuccessMsg("自动匹配供应商成功");
  10555. return;
  10556. }
  10557. public (string, string) UploadFiles(string[] urls)
  10558. {
  10559. string success = "";
  10560. string errors = "";
  10561. int userid = CurrentUser.UserID;
  10562. foreach (string url in urls)
  10563. {
  10564. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10565. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10566. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10567. {
  10568. JObject jsonObject = new JObject
  10569. {
  10570. { "Userid", "77886" },
  10571. { "pwd", "cyt86435015" },
  10572. { "content", base64FileContent },
  10573. { "ext", Path.GetExtension(fileName) }
  10574. };
  10575. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10576. JObject jsonObjects = JObject.Parse(response);
  10577. string msg = (string)jsonObjects["msg"];
  10578. if (msg.Equals("上传成功"))
  10579. {
  10580. success += url + " 上传成功";
  10581. }
  10582. else
  10583. {
  10584. errors += url + " 上传失败";
  10585. }
  10586. }
  10587. else
  10588. {
  10589. errors += url + " 格式出现问题";
  10590. }
  10591. }
  10592. if (urls.Length == 0)
  10593. {
  10594. return (success, errors);
  10595. }
  10596. return (success, errors);
  10597. }
  10598. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10599. {
  10600. return true; //总是接受
  10601. }
  10602. public static string HttpPost(string url, string param = null)
  10603. {
  10604. HttpWebRequest request;
  10605. //如果是发送HTTPS请求
  10606. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10607. {
  10608. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10609. request = WebRequest.Create(url) as HttpWebRequest;
  10610. request.ProtocolVersion = HttpVersion.Version10;
  10611. }
  10612. else
  10613. {
  10614. request = WebRequest.Create(url) as HttpWebRequest;
  10615. }
  10616. request.Method = "POST";
  10617. request.ContentType = "application/json";
  10618. request.Accept = "*/*";
  10619. request.Timeout = 120000;
  10620. request.AllowAutoRedirect = false;
  10621. StreamWriter requestStream = null;
  10622. WebResponse response = null;
  10623. string responseStr = null;
  10624. try
  10625. {
  10626. requestStream = new StreamWriter(request.GetRequestStream());
  10627. requestStream.Write(param);
  10628. requestStream.Close();
  10629. response = request.GetResponse();
  10630. if (response != null)
  10631. {
  10632. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10633. responseStr = reader.ReadToEnd();
  10634. reader.Close();
  10635. }
  10636. }
  10637. catch (Exception ex)
  10638. {
  10639. return ex.Message;
  10640. }
  10641. finally
  10642. {
  10643. request = null;
  10644. requestStream = null;
  10645. response = null;
  10646. }
  10647. return responseStr;
  10648. }
  10649. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10650. {
  10651. string base64FileContent;
  10652. string fileName;
  10653. using (WebClient webClient = new WebClient())
  10654. {
  10655. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10656. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10657. {
  10658. using (Stream stream = response.GetResponseStream())
  10659. {
  10660. using (MemoryStream memoryStream = new MemoryStream())
  10661. {
  10662. stream.CopyTo(memoryStream);
  10663. byte[] fileBytes = memoryStream.ToArray();
  10664. base64FileContent = Convert.ToBase64String(fileBytes);
  10665. fileName = response.Headers["Content-Disposition"];
  10666. if (!string.IsNullOrEmpty(fileName))
  10667. {
  10668. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10669. if (index >= 0)
  10670. {
  10671. fileName = fileName.Substring(index + 9).Trim('\"');
  10672. }
  10673. }
  10674. else
  10675. {
  10676. fileName = Path.GetFileName(downloadUrl);
  10677. }
  10678. }
  10679. }
  10680. }
  10681. }
  10682. return (fileName, base64FileContent);
  10683. }
  10684. //新增
  10685. public void order_batch_caiyingtong(string[] downloadUrls)
  10686. {
  10687. try
  10688. {
  10689. //遍历文件
  10690. DataStruct dStruct = GetPostStruct();
  10691. DataTable dt = null;
  10692. int userid = CurrentUser.UserID;
  10693. List<string> ids = new List<string>();//失败组
  10694. List<string> tids = new List<string>();
  10695. using (WebClient webClient = new WebClient())
  10696. {
  10697. foreach (var url in downloadUrls)
  10698. {
  10699. try
  10700. {
  10701. tids.Add("'" + url + "'");
  10702. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10703. if (entity != null)
  10704. {
  10705. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10706. if (cp == null)
  10707. {
  10708. JObject jsonObject = new JObject
  10709. {
  10710. { "Userid", "77886" },
  10711. { "pwd", "lt666888" },
  10712. { "Filename",entity.seller_memo }
  10713. };
  10714. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10715. JObject jsonObjects = JObject.Parse(response);
  10716. string msg = (string)jsonObjects["msg"];
  10717. if (msg == "报价成功")
  10718. {
  10719. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10720. DownloadAndConvertToBase64(url1);
  10721. }
  10722. else
  10723. {
  10724. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10725. }
  10726. }
  10727. else
  10728. {
  10729. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10730. JObject jsonObject = new JObject
  10731. {
  10732. { "Userid", "77886" },
  10733. { "pwd", "lt666888" },
  10734. { "Filename",chanp }
  10735. };
  10736. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10737. JObject jsonObjects = JObject.Parse(response);
  10738. string msg = (string)jsonObjects["msg"];
  10739. if (msg == "报价成功")
  10740. {
  10741. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10742. DownloadAndConvertToBase64(url1);
  10743. }
  10744. else
  10745. {
  10746. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10747. }
  10748. }
  10749. }
  10750. // 上传文件到FTP
  10751. }
  10752. catch (Exception ex)
  10753. {
  10754. Console.WriteLine($"An error occurred: {ex.Message}");
  10755. }
  10756. }
  10757. List<string> lw = new List<string>();
  10758. lw.Add(string.Format("( OrderState < 6 )"));
  10759. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10760. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10761. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10762. if (dt.Rows.Count > 0)
  10763. {
  10764. foreach (DataRow dr in dt.Rows)
  10765. {
  10766. ids.Add(dr["ctid"].ToString());
  10767. }
  10768. }
  10769. String ErrorMsgs = "";
  10770. foreach (String id in ids)
  10771. {
  10772. ErrorMsgs += id + ",";
  10773. }
  10774. if (ErrorMsgs.Length > 1)
  10775. {
  10776. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10777. }
  10778. if (ErrorMsgs.Length < 1)
  10779. {
  10780. ErrorMsgs = "上传成功";
  10781. returnSuccessMsg(ErrorMsgs);
  10782. }
  10783. else
  10784. {
  10785. returnErrorMsg("以下订单" + ErrorMsgs);
  10786. }
  10787. }
  10788. // 删除文件夹及其内容
  10789. /* Directory.Delete(localDirectory, true);*/
  10790. }
  10791. catch { }
  10792. }
  10793. public void get_center_data()
  10794. {
  10795. int userId = CurrentUser.UserID;
  10796. string postCode = CurrentUser.UserPost.Post.Code;
  10797. List<string> lw = new List<string>();
  10798. List<string> ww = new List<string>();
  10799. DateTime currentTime = DateTime.Now;
  10800. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10801. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10802. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10803. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10804. string sql = " SELECT ";
  10805. string startTime = "2023-10-01 11:22:31";
  10806. //设计
  10807. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10808. {
  10809. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10810. 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));
  10811. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10812. 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));
  10813. }
  10814. //客服
  10815. else if (postCode == "CustomerService" || postCode == "Director")
  10816. {
  10817. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10818. 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));
  10819. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10820. 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));
  10821. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10822. 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));
  10823. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10824. 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));
  10825. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10826. 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));
  10827. }
  10828. //售后
  10829. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10830. {
  10831. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10832. 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));
  10833. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10834. 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));
  10835. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10836. 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));
  10837. }
  10838. //下单部
  10839. else if (postCode == "Place" || postCode == "PlaceMr")
  10840. {
  10841. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10842. 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));
  10843. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10844. 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));
  10845. }
  10846. //车间
  10847. else if (postCode == "Supplier")
  10848. {
  10849. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10850. 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));
  10851. }
  10852. DataTable dt = new DataTable();
  10853. if (lw.Count > 0)
  10854. {
  10855. sql += string.Join(" , ", lw);
  10856. sql += " FROM ";
  10857. sql += string.Join(" , ", ww);
  10858. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10859. }
  10860. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10861. }
  10862. public void get_center_data_list()
  10863. {
  10864. int userId = CurrentUser.UserID;
  10865. string postCode = CurrentUser.UserPost.Post.Code;
  10866. string shopIds = CurrentUser.User.pemShop;
  10867. DataStruct dStruct = GetPostStruct();
  10868. List<string> lw = new List<string>();
  10869. DateTime currentTime = DateTime.Now;
  10870. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10871. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10872. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10873. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10874. string startTime = "2023-10-01 11:22:31";
  10875. int order_type = GetPostInt("order_type");
  10876. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10877. {
  10878. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10879. if (order_type == 0)
  10880. {
  10881. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10882. }
  10883. else if (order_type == 3)
  10884. {
  10885. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10886. }
  10887. else
  10888. {
  10889. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10890. }
  10891. }
  10892. //客服
  10893. if (postCode == "CustomerService" || postCode == "Director")
  10894. {
  10895. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10896. if (order_type == 0)
  10897. {
  10898. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10899. }
  10900. else if (order_type == 1)
  10901. {
  10902. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10903. }
  10904. else if (order_type == 2)
  10905. {
  10906. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10907. }
  10908. else if (order_type == 3)
  10909. {
  10910. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10911. }
  10912. else if (order_type == 4)
  10913. {
  10914. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10915. }
  10916. else
  10917. {
  10918. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10919. }
  10920. }
  10921. //售后
  10922. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10923. {
  10924. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10925. if (shopIds != "")
  10926. {
  10927. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10928. }
  10929. if (order_type == 2)
  10930. {
  10931. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10932. }
  10933. else if (order_type == 4)
  10934. {
  10935. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10936. }
  10937. else if (order_type == 5)
  10938. {
  10939. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10940. }
  10941. else
  10942. {
  10943. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10944. }
  10945. }
  10946. //下单部
  10947. if (postCode == "Place" || postCode == "PlaceMr")
  10948. {
  10949. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10950. if (shopIds != "")
  10951. {
  10952. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10953. }
  10954. else if (order_type == 1)
  10955. {
  10956. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10957. }
  10958. else if (order_type == 2)
  10959. {
  10960. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10961. }
  10962. else
  10963. {
  10964. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10965. }
  10966. }
  10967. //车间
  10968. if (postCode == "Supplier")
  10969. {
  10970. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10971. if (order_type == 5)
  10972. {
  10973. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10974. }
  10975. else
  10976. {
  10977. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10978. }
  10979. }
  10980. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10981. dStruct.Fileds = "tid,ctid";
  10982. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10983. writeGridDataTableJson(dStruct.TotalCount, dt);
  10984. }
  10985. public void aftersale_audit_master()
  10986. {
  10987. if (UrlPostParmsCheck("ctid"))
  10988. {
  10989. string ctid = GetPostString("ctid");
  10990. if (ctid.Length > 0)
  10991. {
  10992. bool result = aftersale_data_change(ctid);
  10993. if (result)
  10994. {
  10995. returnSuccessMsg("修改成功!");
  10996. return;
  10997. }
  10998. }
  10999. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11000. }
  11001. }
  11002. public void aftersale_documentary_finish()
  11003. {
  11004. if (UrlPostParmsCheck("ctid"))
  11005. {
  11006. string ctid = GetPostString("ctid");
  11007. if (ctid.Length > 0)
  11008. {
  11009. List<string> list = new List<string>();
  11010. string[] ctid_list = ctid.Split(',');
  11011. foreach (var item in ctid_list)
  11012. {
  11013. try
  11014. {
  11015. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(item);
  11016. if (ceErpTradeAfterSaleExtend == null)
  11017. {
  11018. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11019. ceErpTradeAfterSaleExtend.tid = item;
  11020. }
  11021. ceErpTradeAfterSaleExtend.AfterSalSend = 1;
  11022. if (ceErpTradeAfterSaleExtend.ID > 0)
  11023. {
  11024. ceErpTradeAfterSaleExtend.Update();
  11025. }
  11026. else
  11027. {
  11028. ceErpTradeAfterSaleExtend.Create();
  11029. }
  11030. LogHelper.addLog(item, CurrentUser.UserID, "跟单完成", 6, 4);
  11031. }
  11032. catch (Exception ex)
  11033. {
  11034. list.Add(item);
  11035. }
  11036. }
  11037. if (list.Count > 0)
  11038. {
  11039. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11040. return;
  11041. }
  11042. returnSuccessMsg("修改成功!");
  11043. return;
  11044. }
  11045. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11046. }
  11047. }
  11048. public void aftersale_batch_audit_master()
  11049. {
  11050. if (UrlPostParmsCheck("ctids"))
  11051. {
  11052. string ctids = GetPostString("ctids");
  11053. if (ctids.Length > 0)
  11054. {
  11055. List<string> list = new List<string>();
  11056. string[] ctid_list = ctids.Split(',');
  11057. foreach (var item in ctid_list)
  11058. {
  11059. bool result = aftersale_data_change(item);
  11060. if (!result)
  11061. {
  11062. list.Add(item);
  11063. }
  11064. }
  11065. if (list.Count > 0)
  11066. {
  11067. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11068. return;
  11069. }
  11070. returnSuccessMsg("修改成功!");
  11071. return;
  11072. }
  11073. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11074. }
  11075. }
  11076. public bool aftersale_data_change(string ctid)
  11077. {
  11078. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11079. if (ceErpTradeCell != null)
  11080. {
  11081. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  11082. ceErpTradeCell.AfterSaleSupplierState = 0;
  11083. StringBuilder sql = new StringBuilder();
  11084. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  11085. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11086. CeErpTradeResponsible.DelByTid(ctid, 0);
  11087. 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 == "不理赔")
  11088. {
  11089. CeErpTradeResponsible.DelByTid(ctid, -1);
  11090. ceErpTradeCell.AfterSaleSupplierState = 1;
  11091. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11092. ceErpTradeCell.AfterSaleState = 4;
  11093. }
  11094. else
  11095. {
  11096. ceErpTradeCell.AfterSaleState = 3;
  11097. }
  11098. bool needCyt = false;
  11099. if (dt != null)
  11100. {
  11101. if (dt.Rows.Count == 1)
  11102. {
  11103. bool isEnd = false;
  11104. foreach (DataRow dr in dt.Rows)
  11105. {
  11106. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11107. {
  11108. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11109. isEnd = true;
  11110. }
  11111. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  11112. {
  11113. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11114. isEnd = true;
  11115. }
  11116. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11117. {
  11118. needCyt = true;
  11119. }
  11120. }
  11121. if (isEnd)
  11122. {
  11123. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11124. ceErpTradeCell.AfterSaleState = 4;
  11125. ceErpTradeCell.AfterSaleSupplierState = 1;
  11126. }
  11127. }
  11128. else
  11129. {
  11130. bool isAll = true;
  11131. foreach (DataRow dr in dt.Rows)
  11132. {
  11133. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11134. {
  11135. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11136. continue;
  11137. }
  11138. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11139. {
  11140. string path = "";
  11141. int OrgID = 0;
  11142. if (!Convert.IsDBNull(dr["OrgPath"]))
  11143. {
  11144. path = dr["OrgPath"].ToString();
  11145. }
  11146. if (!Convert.IsDBNull(dr["OrgID"]))
  11147. {
  11148. OrgID = Convert.ToInt32(dr["OrgID"]);
  11149. }
  11150. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11151. {
  11152. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11153. continue;
  11154. }
  11155. }
  11156. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11157. {
  11158. needCyt = true;
  11159. }
  11160. isAll = false;
  11161. }
  11162. if (isAll)
  11163. {
  11164. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11165. ceErpTradeCell.AfterSaleState = 4;
  11166. ceErpTradeCell.AfterSaleSupplierState = 1;
  11167. }
  11168. }
  11169. }
  11170. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11171. {
  11172. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11173. }
  11174. if (ceErpTradeCell.AfterSaleState == 4)
  11175. {
  11176. ApiVo apiVo = new ApiVo();
  11177. apiVo.orderNumber = ceErpTradeCell.ctid;
  11178. apiVo.actionName = "afterOver";
  11179. designHelper.API_WorkCore(apiVo); //afterOver
  11180. }
  11181. ceErpTradeCell.Update();
  11182. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11183. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11184. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11185. return true;
  11186. }
  11187. return false;
  11188. }
  11189. public void get_erp_wechatorder()
  11190. {
  11191. DataStruct dStruct = GetPostStruct();
  11192. List<string> lw = new List<string>();
  11193. string tid = GetPostString("tid");
  11194. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11195. string shopname = GetPostString("shopname");
  11196. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11197. string buyernick = GetPostString("buyer_nick");
  11198. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11199. string customer = GetPostString("customer");
  11200. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11201. string returndate1 = GetPostString("returndate1");
  11202. string returndate2 = GetPostString("returndate2");
  11203. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11204. if (dw.Length > 0) lw.Add(dw);
  11205. string finishDate1 = GetPostString("finishdate1");
  11206. string finishDate2 = GetPostString("finishdate2");
  11207. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11208. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11209. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11210. dStruct.Order = "created desc";
  11211. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11212. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11213. writeGridDataTableJson(dStruct.TotalCount, dt);
  11214. }
  11215. public void get_erp_wechatlist_sumprice()
  11216. {
  11217. DataStruct dStruct = GetPostStruct();
  11218. List<string> lw = new List<string>();
  11219. string tid = GetPostString("tid");
  11220. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11221. string shopname = GetPostString("shopname");
  11222. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11223. string buyernick = GetPostString("buyer_nick");
  11224. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11225. string customer = GetPostString("customer");
  11226. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11227. string returndate1 = GetPostString("returndate1");
  11228. string returndate2 = GetPostString("returndate2");
  11229. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11230. if (dw.Length > 0) lw.Add(dw);
  11231. string finishDate1 = GetPostString("finishdate1");
  11232. string finishDate2 = GetPostString("finishdate2");
  11233. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11234. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11235. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11236. string mainWhere = string.Join(" and ", lw.ToArray());
  11237. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11238. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11239. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11240. decimal total = 0;
  11241. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11242. {
  11243. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11244. }
  11245. var res = new
  11246. {
  11247. data = total
  11248. };
  11249. string ro_jsond = JsonConvert.SerializeObject(res);
  11250. returnSuccess(ro_jsond);
  11251. return;
  11252. }
  11253. public void get_erp_qr_waitdeliverylist()
  11254. {
  11255. DataStruct dStruct = GetPostStruct();
  11256. List<string> lw = new List<string>();
  11257. string tid = GetPostString("ctid");
  11258. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11259. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11260. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11261. var res_objz = new
  11262. {
  11263. restype = 1,
  11264. data = dt
  11265. };
  11266. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11267. returnSuccess(ro_jsonz);
  11268. }
  11269. public void get_erp_yield_list()
  11270. {
  11271. DataStruct dStruct = GetPostStruct();
  11272. List<string> lw = new List<string>();
  11273. string tid = GetPostString("ctid");
  11274. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11275. string shopname = GetPostString("shopname");
  11276. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11277. string buyernick = GetPostString("buyer_nick");
  11278. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11279. //if (tid.Length == 0 && buyernick.Length == 0)
  11280. //{
  11281. // lw.Add(string.Format("IsRefund<={0}", 1));
  11282. //}
  11283. string customer = GetPostString("customer");
  11284. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11285. string design = GetPostString("design");
  11286. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11287. string orderState = GetPostString("orderState");
  11288. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11289. string address = GetPostString("address");
  11290. 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));
  11291. string sellermemo = GetPostString("seller_memo");
  11292. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11293. string supplier = GetPostString("supplier");
  11294. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11295. string OrderArea = GetPostString("order_area");
  11296. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11297. string placedate1 = GetPostString("placedate1");
  11298. string placedate2 = GetPostString("placedate2");
  11299. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11300. if (fdw.Length > 0) lw.Add(fdw);
  11301. string price1 = GetPostString("price1");
  11302. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11303. string price2 = GetPostString("price2");
  11304. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11305. string unusualCon = GetPostString("unusualcon");
  11306. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11307. string posTag = CurrentUser.UserPost.Post.Code;
  11308. if (posTag == "Supplier")
  11309. {
  11310. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11311. }
  11312. lw.Add(string.Format("OrderState = 6 "));
  11313. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11314. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11315. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11316. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11317. writeGridDataTableJson(dStruct.TotalCount, dt);
  11318. }
  11319. public void change_erp_sup_state()
  11320. {
  11321. if (UrlPostParmsCheck("ctid"))
  11322. {
  11323. string ctid = GetPostString("ctid");
  11324. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11325. if (ceErpTradeCell != null)
  11326. {
  11327. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11328. if (ceErpTradeCellExtend == null)
  11329. {
  11330. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11331. ceErpTradeCellExtend.ctid = ctid;
  11332. ceErpTradeCellExtend.SupState = 1;
  11333. ceErpTradeCellExtend.Create();
  11334. }
  11335. else
  11336. {
  11337. ceErpTradeCellExtend.SupState = 1;
  11338. ceErpTradeCellExtend.Update();
  11339. }
  11340. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11341. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11342. return;
  11343. }
  11344. returnErrorMsg("找不到订单");
  11345. }
  11346. }
  11347. public void supplier_all_downs()
  11348. {
  11349. if (UrlPostParmsCheck("tids"))
  11350. {
  11351. string tids = GetPostString("tids");
  11352. if (tids != null && tids.Length > 0)
  11353. {
  11354. StringBuilder sql = new StringBuilder();
  11355. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11356. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11357. sql = new StringBuilder();
  11358. 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, "下载设计文件");
  11359. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11360. string[] list = tids.Split(',');
  11361. foreach (string ctid in list)
  11362. {
  11363. CeErpSukuraData.createInfo(ctid, 3);
  11364. }
  11365. designHelper.api_approveDesign(tids); //approveDesign
  11366. returnSuccessMsg("下载成功!");
  11367. return;
  11368. }
  11369. returnErrorMsg("下载订单更新失败");
  11370. }
  11371. }
  11372. public void uploaderFileSuccess()
  11373. {
  11374. if (UrlPostParmsCheck("fileName"))
  11375. {
  11376. string fileName = GetPostString("fileName");
  11377. ApiVo apiVo = new ApiVo();
  11378. apiVo.orderNumber = fileName;
  11379. apiVo.actionName = "finishDesign";
  11380. designHelper.API_WorkCore(apiVo);//finishDesign
  11381. returnSuccessMsg("");
  11382. }
  11383. }
  11384. public void get_sample2_order()
  11385. {
  11386. if (UrlPostParmsCheck("ctid"))
  11387. {
  11388. string ctid = GetPostString("ctid");
  11389. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11390. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11391. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11392. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11393. double total = 0.0;
  11394. double order_price = 0.0;
  11395. if (dt_bu.Rows.Count > 0)
  11396. {
  11397. foreach (DataRow dr in dt_bu.Rows)
  11398. {
  11399. total += Convert.ToDouble(dr["payment"]);
  11400. }
  11401. }
  11402. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11403. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11404. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11405. string tid = ctid.Replace("S_", "");
  11406. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11407. double paymant = 0.0;
  11408. if (entity != null)
  11409. {
  11410. paymant = entity.payment;
  11411. }
  11412. string return_reason = "";
  11413. if (dt_after != null && dt_after.Rows.Count > 0)
  11414. {
  11415. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11416. }
  11417. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11418. }
  11419. }
  11420. public void get_erp_design_status()
  11421. {
  11422. string designName = GetPostString("designName");
  11423. DataStruct dStruct = GetPostStruct();
  11424. if (designName.Length > 0)
  11425. {
  11426. 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";
  11427. sql_user += " and Name like '%" + designName + "%'";
  11428. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11429. List<string> ids_list = new List<string>();
  11430. if (user_table.Rows.Count > 0)
  11431. {
  11432. foreach (DataRow item in user_table.Rows)
  11433. {
  11434. ids_list.Add(item["id"].ToString());
  11435. string ids_s = item["TeamIds"].ToString();
  11436. if (ids_s.Length > 0)
  11437. {
  11438. ids_list.AddRange(ids_s.Split(','));
  11439. }
  11440. }
  11441. }
  11442. HashSet<string> set = new HashSet<string>(ids_list);
  11443. ids_list = set.ToList();
  11444. if (ids_list.Count > 0)
  11445. {
  11446. 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));
  11447. dStruct.MainWhere = sql;
  11448. DataTable dt = null;
  11449. dt = WebCache.GetData("view_ErpUser", dStruct);
  11450. writeGridDataTableJson(dStruct.TotalCount, dt);
  11451. }
  11452. }
  11453. }
  11454. public void change_erp_order_price()
  11455. {
  11456. string ctid = GetPostString("ctid");
  11457. double price = GetPostDouble("price");
  11458. if (ctid.Length > 0)
  11459. {
  11460. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11461. if (ceErpTradeCellExtend == null)
  11462. {
  11463. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11464. ceErpTradeCellExtend.ctid = ctid;
  11465. ceErpTradeCellExtend.payment_cyt = price;
  11466. ceErpTradeCellExtend.Create();
  11467. }
  11468. else
  11469. {
  11470. ceErpTradeCellExtend.payment_cyt = price;
  11471. ceErpTradeCellExtend.Update();
  11472. }
  11473. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11474. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11475. {
  11476. ceErpDataSendOrderInfo.isSync = false;
  11477. ceErpDataSendOrderInfo.Update();
  11478. }
  11479. if (ceErpDataSendOrderInfo == null)
  11480. {
  11481. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11482. ceErpDataSendOrderInfo.isSync = false;
  11483. ceErpDataSendOrderInfo.ctid = ctid;
  11484. ceErpDataSendOrderInfo.Create();
  11485. }
  11486. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11487. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11488. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11489. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11490. {
  11491. dataSendOrderBean dataSendOrderBean = null;
  11492. foreach (DataRow item in dth.Rows)
  11493. {
  11494. try
  11495. {
  11496. dataSendOrderBean = new dataSendOrderBean();
  11497. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11498. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11499. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11500. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11501. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11502. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11503. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11504. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11505. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11506. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11507. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11508. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11509. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11510. if (result != null)
  11511. {
  11512. if ("0".Equals(result.errcode))
  11513. {
  11514. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11515. }
  11516. else
  11517. {
  11518. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11519. }
  11520. }
  11521. }
  11522. catch (Exception ex)
  11523. {
  11524. }
  11525. }
  11526. }
  11527. returnSuccessMsg("修改成功!");
  11528. return;
  11529. }
  11530. returnErrorMsg("找不到订单");
  11531. }
  11532. public void find_he_together()
  11533. {
  11534. string ctid = GetPostString("ctid");
  11535. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11536. List<string> list = new List<string>();
  11537. if (ceErpTradeCell != null)
  11538. {
  11539. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11540. {
  11541. 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);
  11542. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11543. if (table != null && table.Rows.Count > 0)
  11544. {
  11545. foreach (TableRow row in table.Rows)
  11546. {
  11547. }
  11548. }
  11549. }
  11550. }
  11551. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11552. }
  11553. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11554. {
  11555. //chy----19
  11556. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11557. //GD-CYT-----64
  11558. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11559. //ZHX----3
  11560. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11561. //JK----97
  11562. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11563. //ZT----70
  11564. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11565. //GD-CYTUV---126
  11566. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11567. //LHCY-----98
  11568. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11569. //XD-----90
  11570. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11571. //CYCY-----14
  11572. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}},
  11573. //THLZY----122
  11574. {122, new Dictionary<string, string> {{ "烫画", "烫画" }, { "冷转印", "冷转印" }}}
  11575. };
  11576. //其他改名
  11577. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11578. {
  11579. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11580. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11581. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11582. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11583. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11584. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11585. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11586. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" },{ 129,"种子纸"},{ 125,"胶带"},{ 127,"PET透卡"}
  11587. };
  11588. //不统计
  11589. List<int> no_suppliers = new List<int>()
  11590. {
  11591. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11592. };
  11593. //配件单
  11594. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11595. {
  11596. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11597. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11598. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11599. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11600. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11601. {"旗杆",new List<string>(){ "班旗" } },
  11602. {"牙签",new List<string>(){ "不干胶" } }
  11603. };
  11604. public void get_place_order_data()
  11605. {
  11606. string date1 = GetPostString("date1");
  11607. string date2 = GetPostString("date2");
  11608. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11609. DateTime start = DateTime.Parse(starttime);
  11610. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11611. DateTime end = DateTime.Parse(endtime);
  11612. if (date1 != null && date1.Length > 0)
  11613. {
  11614. DateTime dateTime = DateTime.Parse(date1);
  11615. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11616. start = DateTime.Parse(starttime);
  11617. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11618. end = DateTime.Parse(endtime);
  11619. }
  11620. if (date2 != null && date2.Length > 0)
  11621. {
  11622. DateTime dateTime = DateTime.Parse(date2);
  11623. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11624. end = DateTime.Parse(endtime);
  11625. }
  11626. List<int> smSupplier = new List<int>() { 97, 121, 119, 80 };
  11627. string startMonthDate = commonHelper.FirstDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 00:00:00");
  11628. string endMonthDate = commonHelper.LastDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 23:59:59");
  11629. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime,AfterSaleState=0,AfterSaleReason = '',delivery=0 from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierId > 0 ", starttime, endtime);
  11630. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11631. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState,AfterSaleReason,delivery=0 FROM view_ErpTradeCell WHERE ( AfterSalePreTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime IS NOT NULL", startMonthDate, endMonthDate);
  11632. DataTable afterSaleData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11633. data.Merge(afterSaleData);
  11634. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState=0,AfterSaleReason = '',delivery=1 FROM view_ErpTradeCell WHERE orderstate = 6 AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime > '2025-11-01 00:00:31.000' AND IsRefund <= 1 AND status = 'NOT_SHIPPED' AND LEN( ProductName ) > 0 AND SupplierId not in (86,10,105,86)", startMonthDate, endMonthDate);
  11635. DataTable deliveryData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11636. data.Merge(deliveryData);
  11637. //不干胶-----1,卡片-----29
  11638. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11639. foreach (DataRow row in data.Rows)
  11640. {
  11641. int productId = Convert.ToInt32(row["ProductId"]);
  11642. string ProductName = row["ProductName"].ToString();
  11643. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11644. if (no_suppliers.Contains(supplierId))
  11645. {
  11646. continue;
  11647. }
  11648. string seller_memo = row["seller_memo"].ToString();
  11649. bool ispj = false;//是否配件单
  11650. bool isfirst = true;//第一个配
  11651. maps.Keys.ForEach(key =>
  11652. {
  11653. //备注包含配件
  11654. if (seller_memo.Contains(key) && isfirst)
  11655. {
  11656. List<string> list = maps[key];
  11657. ispj = true;
  11658. isfirst = false;
  11659. for (int i = 0; i < list.Count; i++)
  11660. {
  11661. if (seller_memo.Contains(list[i]))
  11662. {
  11663. ispj = false;
  11664. break;
  11665. }
  11666. }
  11667. }
  11668. });
  11669. if (ispj)
  11670. {
  11671. continue;
  11672. }
  11673. seller_memo = seller_memo.Replace("UV", "uv");
  11674. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11675. //吊牌归到卡片
  11676. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11677. seller_memo = seller_memo.Replace("卡套", "卡片");
  11678. seller_memo = seller_memo.Replace("封套", "卡片");
  11679. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11680. seller_memo = seller_memo.Replace("腰封", "卡片");
  11681. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11682. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11683. seller_memo = seller_memo.Replace("横幅", "条幅");
  11684. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11685. string map_key = "";
  11686. string type = "";
  11687. if (supplierMap.ContainsKey(supplierId))
  11688. {
  11689. foreach (var kvp in supplierMap[supplierId])
  11690. {
  11691. if (seller_memo.Contains(kvp.Key))
  11692. {
  11693. map_key = kvp.Value;
  11694. type = kvp.Value;
  11695. break;
  11696. }
  11697. }
  11698. }
  11699. if (map_key == "")
  11700. {
  11701. type = ProductName;
  11702. map_key = ProductName;
  11703. if (smSupplier.Contains(supplierId))
  11704. {
  11705. type = "数码";
  11706. map_key = "数码";
  11707. }
  11708. }
  11709. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11710. {
  11711. map_key = suppliers[supplierId];
  11712. }
  11713. map_key += "_" + row["SupplierName"].ToString();
  11714. Dictionary<string, int> map = null;
  11715. if (other_map.ContainsKey(map_key))
  11716. {
  11717. other_map.TryGetValue(map_key, out map);
  11718. }
  11719. else
  11720. {
  11721. map = new Dictionary<string, int>();
  11722. map.Add("dayDev", 0);//当天出货
  11723. map.Add("dayTotal", 0);//下单总数
  11724. map.Add("payTotal", 0);//500以上
  11725. map.Add("today", 0);//当天出货数量
  11726. map.Add("unusua", 0);//异常数
  11727. map.Add("aftersale", 0);//异常数
  11728. map.Add("deliveryNum", 0);//待发货数
  11729. other_map.Add(map_key, map);
  11730. other_map.TryGetValue(map_key, out map);
  11731. }
  11732. int afterSaleState = Convert.ToInt32(row["AfterSaleState"]);
  11733. int delivery = Convert.ToInt32(row["delivery"]);
  11734. if (afterSaleState == 0 && delivery == 0)
  11735. {
  11736. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11737. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11738. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11739. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11740. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11741. {
  11742. map["dayTotal"]++;
  11743. if (supplierId == 97)
  11744. {
  11745. supplierId = 97;
  11746. }
  11747. }
  11748. if (Convert.ToDecimal(row["payment"]) >= 500)
  11749. {
  11750. map["payTotal"]++;
  11751. }
  11752. bool istoday = false;
  11753. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11754. {
  11755. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11756. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11757. {
  11758. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11759. {
  11760. map["today"]++;
  11761. }
  11762. }
  11763. else
  11764. {
  11765. if (supplierId == 80 || supplierId == 126)
  11766. {
  11767. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11768. {
  11769. map["today"]++;
  11770. }
  11771. }
  11772. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11773. {
  11774. map["today"]++;
  11775. istoday = true;
  11776. }
  11777. }
  11778. }
  11779. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11780. {
  11781. map["unusua"]++;
  11782. }
  11783. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11784. //GD-CYT-----64
  11785. DateTime two = palceTimeStart.AddHours(14);
  11786. DateTime three = palceTimeStart.AddHours(15);
  11787. DateTime four = palceTimeStart.AddHours(16);
  11788. DateTime six = palceTimeStart.AddHours(18);
  11789. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11790. {
  11791. //下午四点前 500-1000
  11792. string count = row["ProductCount"].ToString();
  11793. if (count != null && count.Length > 0)
  11794. {
  11795. int productCount = commonHelper.getPlaceProductCount(count);
  11796. if (productCount >= 500 && productCount <= 1000)
  11797. {
  11798. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11799. {
  11800. map["dayDev"]++;
  11801. }
  11802. }
  11803. }
  11804. }
  11805. //UV
  11806. else if ("uv".Equals(type))
  11807. {
  11808. //ZT----70
  11809. //ZHX----3
  11810. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11811. {
  11812. map["dayDev"]++;
  11813. }
  11814. //JK----97
  11815. //HZX----105
  11816. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11817. {
  11818. map["dayDev"]++;
  11819. }
  11820. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11821. {
  11822. map["dayDev"]++;
  11823. }
  11824. }
  11825. //帆布---52|条幅---27
  11826. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11827. {
  11828. //LHCY-----98
  11829. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11830. {
  11831. map["dayDev"]++;
  11832. }
  11833. }
  11834. //条幅
  11835. else if ("条幅".Equals(type))
  11836. {
  11837. //XD-----90
  11838. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11839. {
  11840. map["dayDev"]++;
  11841. }
  11842. }
  11843. //桌布
  11844. else if ("桌布".Equals(type))
  11845. {
  11846. //XD-----90
  11847. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11848. {
  11849. map["dayDev"]++;
  11850. }
  11851. }
  11852. //DL---10
  11853. //AYTW---119
  11854. //FS-CYT-DY ----80
  11855. //JK----97
  11856. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11857. {
  11858. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11859. {
  11860. map["dayDev"]++;
  11861. }
  11862. }
  11863. // QC---121
  11864. else if (supplierId == 121)
  11865. {
  11866. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11867. {
  11868. map["dayDev"]++;
  11869. }
  11870. }
  11871. }
  11872. else if (delivery == 0)
  11873. {
  11874. if (row["AfterSaleReason"].ToString().Contains("车间责任"))
  11875. {
  11876. map["aftersale"]++;
  11877. }
  11878. }
  11879. else
  11880. {
  11881. map["deliveryNum"]++;
  11882. }
  11883. }
  11884. DataTable dt = new DataTable();
  11885. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11886. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11887. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11888. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11889. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11890. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11891. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11892. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11893. dt.Columns.Add(new DataColumn("aftersale", typeof(string)));
  11894. dt.Columns.Add(new DataColumn("deliveryNum", typeof(string)));
  11895. other_map.Keys.ForEach(key =>
  11896. {
  11897. DataRow dr = dt.NewRow();
  11898. Dictionary<string, int> map = other_map[key];
  11899. string[] key_list = key.Split('_');
  11900. dr[0] = key_list[0];
  11901. dr[1] = key_list[1];
  11902. if (key_list.Length > 2)
  11903. {
  11904. dr[1] += "(" + key_list[2] + ")";
  11905. }
  11906. dr[2] = map["dayTotal"];
  11907. dr[3] = map["payTotal"];
  11908. dr[4] = map["today"];
  11909. dr[5] = map["unusua"];
  11910. dr[6] = map["dayDev"];
  11911. double rate = 0.00;
  11912. if (map["dayDev"] > 0)
  11913. {
  11914. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11915. }
  11916. dr[7] = rate.ToString();
  11917. dr[8] = map["aftersale"];
  11918. dr[9] = map["deliveryNum"];
  11919. dt.Rows.Add(dr);
  11920. });
  11921. DataView dv = new DataView(dt);
  11922. dv.Sort = "SupplierName";
  11923. //dv.Sort = "ProductName desc";
  11924. DataTable dtNew = dv.ToTable();
  11925. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11926. }
  11927. public void get_place_all_order_data()
  11928. {
  11929. string date1 = GetPostString("date1");
  11930. string date2 = GetPostString("date2");
  11931. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11932. DateTime start = DateTime.Parse(starttime);
  11933. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11934. DateTime end = DateTime.Parse(endtime);
  11935. if (date1 != null && date1.Length > 0)
  11936. {
  11937. DateTime dateTime = DateTime.Parse(date1);
  11938. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11939. start = DateTime.Parse(starttime);
  11940. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11941. end = DateTime.Parse(endtime);
  11942. }
  11943. if (date2 != null && date2.Length > 0)
  11944. {
  11945. DateTime dateTime = DateTime.Parse(date2);
  11946. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11947. end = DateTime.Parse(endtime);
  11948. }
  11949. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11950. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,FinishPlaceTime,OrderState,FinishDeliveryTime from view_ErpTradeCell where ( FinishDeliveryTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 and SupplierId > 0 ", starttime, endtime);
  11951. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11952. string timer_sql = string.Format("select * from CE_ErpSupplierProductTime");
  11953. DataTable timer_data = DbHelper.DbConn.ExecuteDataset(timer_sql).Tables[0];
  11954. Dictionary<int, List<CeErpSupplierProductTime>> timer_map = new Dictionary<int, List<CeErpSupplierProductTime>>();
  11955. foreach (DataRow datarow in timer_data.Rows)
  11956. {
  11957. List<CeErpSupplierProductTime> list = null;
  11958. int supplierId = Convert.ToInt32(datarow["SupplierId"]);
  11959. if (timer_map.ContainsKey(supplierId))
  11960. {
  11961. timer_map.TryGetValue(supplierId, out list);
  11962. }
  11963. else
  11964. {
  11965. list = new List<CeErpSupplierProductTime>();
  11966. timer_map.Add(supplierId, list);
  11967. timer_map.TryGetValue(supplierId, out list);
  11968. }
  11969. CeErpSupplierProductTime ceErpSupplierProductTime = new CeErpSupplierProductTime();
  11970. ceErpSupplierProductTime.quantity = Convert.ToInt32(datarow["quantity"]);
  11971. ceErpSupplierProductTime.dayDeadLine = datarow["dayDeadLine"].ToString();
  11972. ceErpSupplierProductTime.deadLine = datarow["deadLine"].ToString();
  11973. ceErpSupplierProductTime.productId = datarow["productId"].ToString();
  11974. ceErpSupplierProductTime.craft = datarow["craft"].ToString();
  11975. ceErpSupplierProductTime.sendDay = Convert.ToInt32(datarow["sendDay"]);
  11976. list.Add(ceErpSupplierProductTime);
  11977. }
  11978. List<int> smSupplier = new List<int>() { 97, 121, 119, 80 };
  11979. foreach (DataRow row in data.Rows)
  11980. {
  11981. //存储数据
  11982. int productId = Convert.ToInt32(row["ProductId"]);
  11983. string ProductName = row["ProductName"].ToString();
  11984. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11985. if (no_suppliers.Contains(supplierId))
  11986. {
  11987. continue;
  11988. }
  11989. string seller_memo = row["seller_memo"].ToString();
  11990. bool ispj = false;//是否配件单
  11991. bool isfirst = true;//第一个配
  11992. maps.Keys.ForEach(key =>
  11993. {
  11994. //备注包含配件
  11995. if (seller_memo.Contains(key) && isfirst)
  11996. {
  11997. List<string> list = maps[key];
  11998. ispj = true;
  11999. isfirst = false;
  12000. for (int i = 0; i < list.Count; i++)
  12001. {
  12002. if (seller_memo.Contains(list[i]))
  12003. {
  12004. ispj = false;
  12005. break;
  12006. }
  12007. }
  12008. }
  12009. });
  12010. if (ispj)
  12011. {
  12012. continue;
  12013. }
  12014. seller_memo = seller_memo.Replace("UV", "uv");
  12015. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  12016. //吊牌归到卡片
  12017. seller_memo = seller_memo.Replace("吊牌", "卡片");
  12018. seller_memo = seller_memo.Replace("卡套", "卡片");
  12019. seller_memo = seller_memo.Replace("封套", "卡片");
  12020. seller_memo = seller_memo.Replace("吸管套", "卡片");
  12021. seller_memo = seller_memo.Replace("腰封", "卡片");
  12022. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  12023. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  12024. seller_memo = seller_memo.Replace("横幅", "条幅");
  12025. seller_memo = seller_memo.Replace("锦旗", "条幅");
  12026. string map_key = "";
  12027. string type = "";
  12028. if (supplierMap.ContainsKey(supplierId))
  12029. {
  12030. foreach (var kvp in supplierMap[supplierId])
  12031. {
  12032. if (seller_memo.Contains(kvp.Key))
  12033. {
  12034. map_key = kvp.Value;
  12035. type = kvp.Value;
  12036. break;
  12037. }
  12038. }
  12039. }
  12040. if (map_key == "")
  12041. {
  12042. type = ProductName;
  12043. map_key = ProductName;
  12044. if (smSupplier.Contains(supplierId))
  12045. {
  12046. type = "数码";
  12047. map_key = "数码";
  12048. }
  12049. }
  12050. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  12051. {
  12052. map_key = suppliers[supplierId];
  12053. }
  12054. map_key += "_" + row["SupplierName"].ToString();
  12055. Dictionary<string, int> map = null;
  12056. if (other_map.ContainsKey(map_key))
  12057. {
  12058. other_map.TryGetValue(map_key, out map);
  12059. }
  12060. else
  12061. {
  12062. map = new Dictionary<string, int>();
  12063. map.Add("all", 0);//全部
  12064. map.Add("unusua", 0);//异常数
  12065. map.Add("normal", 0);//正常数
  12066. map.Add("noMatch", 0);//未匹配
  12067. other_map.Add(map_key, map);
  12068. other_map.TryGetValue(map_key, out map);
  12069. }
  12070. //处理是否超时
  12071. string finishPlaceTime = row["FinishPlaceTime"].ToString();
  12072. string sellmer_mome = row["seller_memo"].ToString();
  12073. string txtCount = row["ProductCount"].ToString();
  12074. string FinishDeliveryTime = row["FinishDeliveryTime"].ToString();
  12075. map["all"]++;
  12076. if (string.IsNullOrEmpty(finishPlaceTime))
  12077. {
  12078. map["noMatch"]++;
  12079. continue;
  12080. }
  12081. if (string.IsNullOrEmpty(FinishDeliveryTime))
  12082. {
  12083. map["noMatch"]++;
  12084. continue;
  12085. }
  12086. if (!timer_map.ContainsKey(supplierId))
  12087. {
  12088. map["noMatch"]++;
  12089. continue;
  12090. }
  12091. List<CeErpSupplierProductTime> lists = timer_map[supplierId];
  12092. if (lists.Count > 0)
  12093. {
  12094. bool isComplate = false;
  12095. string[] productIds = null;
  12096. foreach (CeErpSupplierProductTime ceErpSupplierProductTime in lists)
  12097. {
  12098. string[] crafts = { };
  12099. if (string.IsNullOrEmpty(ceErpSupplierProductTime.productId))
  12100. {
  12101. continue;
  12102. }
  12103. if (ceErpSupplierProductTime.quantity > 0)
  12104. {
  12105. int quantity = commonHelper.handleProductCount(txtCount, true);
  12106. //订单数量大于写入的数量则跳过
  12107. if (quantity > ceErpSupplierProductTime.quantity)
  12108. {
  12109. continue;
  12110. }
  12111. }
  12112. productIds = ceErpSupplierProductTime.productId.Split(',');
  12113. if (productIds.Contains(productId.ToString()))
  12114. {
  12115. string textCraft = ceErpSupplierProductTime.craft;
  12116. textCraft = textCraft.Replace(",", ",");//统一格式
  12117. if (!string.IsNullOrEmpty(textCraft))
  12118. {
  12119. crafts = textCraft.Split(',');
  12120. }
  12121. if (crafts.Length > 0)
  12122. {
  12123. bool isinCraft = false;
  12124. for (int i = 0; i < crafts.Length; i++)
  12125. {
  12126. if (sellmer_mome.IndexOf(crafts[i]) >= 0)
  12127. {
  12128. isinCraft = true;
  12129. break;
  12130. }
  12131. }
  12132. //有写工艺并且备注中没匹配中则跳过
  12133. if (!isinCraft)
  12134. {
  12135. continue;
  12136. }
  12137. }
  12138. DateTime deadLine = DateTime.Parse(ceErpSupplierProductTime.deadLine);
  12139. DateTime dayDeadLine = DateTime.Parse(ceErpSupplierProductTime.dayDeadLine);
  12140. int sendDay = ceErpSupplierProductTime.sendDay;
  12141. //订单发货时间
  12142. DateTime placeTime = DateTime.Parse(finishPlaceTime);
  12143. DateTime sendtime = DateTime.Now;//预计发货时间
  12144. DateTime dateTime = DateTime.Parse(FinishDeliveryTime);//实际发货时间
  12145. //下单时间小于当日发货时间则不用判断
  12146. //当日发货必须发货
  12147. if (dayDeadLine.Hour > 0 && dayDeadLine.Hour > placeTime.Hour)
  12148. {
  12149. sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59"));
  12150. }
  12151. else if (deadLine.Hour > 0 && deadLine.Hour > placeTime.Hour)
  12152. {
  12153. //在截稿时间之前下单的可以减去一天时间
  12154. sendDay = Math.Max(1, sendDay - 1);
  12155. sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 00:00:00")).AddDays(sendDay);
  12156. }
  12157. else
  12158. {
  12159. sendDay = Math.Max(1, sendDay - 1);
  12160. sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59")).AddDays(sendDay);
  12161. }
  12162. isComplate = true;
  12163. //判断有没有到发货日期大于0还没到发货时间
  12164. if (DateTime.Compare(sendtime.Date, dateTime.Date) < 0)
  12165. {
  12166. //匹配到就不要继续匹配了
  12167. map["unusua"]++;
  12168. break;
  12169. }
  12170. else
  12171. {
  12172. map["normal"]++;
  12173. break;
  12174. }
  12175. }
  12176. }
  12177. if (!isComplate)
  12178. {
  12179. map["noMatch"]++;
  12180. continue;
  12181. }
  12182. }
  12183. else
  12184. {
  12185. map["noMatch"]++;
  12186. }
  12187. }
  12188. DataTable dt = new DataTable();
  12189. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  12190. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  12191. dt.Columns.Add(new DataColumn("all", typeof(string)));
  12192. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  12193. dt.Columns.Add(new DataColumn("normal", typeof(string)));
  12194. dt.Columns.Add(new DataColumn("noMatch", typeof(string)));
  12195. dt.Columns.Add(new DataColumn("shipmentRate", typeof(string)));
  12196. other_map.Keys.ForEach(key =>
  12197. {
  12198. DataRow dr = dt.NewRow();
  12199. Dictionary<string, int> map = other_map[key];
  12200. string[] key_list = key.Split('_');
  12201. dr[0] = key_list[0];
  12202. dr[1] = key_list[1];
  12203. if (key_list.Length > 2)
  12204. {
  12205. dr[1] += "(" + key_list[2] + ")";
  12206. }
  12207. dr[2] = map["all"];
  12208. dr[3] = map["unusua"];
  12209. dr[4] = map["normal"];
  12210. dr[5] = map["noMatch"];
  12211. double rate = 0.00;
  12212. if (map["all"] > 0)
  12213. {
  12214. rate = Math.Round(((Convert.ToDouble(map["normal"]) + Convert.ToDouble(map["noMatch"])) / Convert.ToDouble(map["all"])), 2) * 100;
  12215. }
  12216. dr[6] = rate.ToString();
  12217. dt.Rows.Add(dr);
  12218. });
  12219. DataView dv = new DataView(dt);
  12220. dv.Sort = "SupplierName";
  12221. //dv.Sort = "ProductName desc";
  12222. DataTable dtNew = dv.ToTable();
  12223. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  12224. }
  12225. public void check_order_desing_info()
  12226. {
  12227. string ctid = GetPostString("ctid");
  12228. if (!string.IsNullOrEmpty(ctid))
  12229. {
  12230. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12231. if (ceErpTradeCell != null)
  12232. {
  12233. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  12234. returnSuccess(JsonConvert.SerializeObject(new { response }));
  12235. return;
  12236. }
  12237. returnErrorMsg("找不到订单");
  12238. return;
  12239. }
  12240. returnErrorMsg("找不到订单");
  12241. }
  12242. public void get_timeout_detail()
  12243. {
  12244. string poscode = CurrentUser.UserPost.Post.Code;
  12245. DataStruct dStruct = GetPostStruct();
  12246. List<string> lw = new List<string>();
  12247. string id = GetPostString("id");
  12248. string pay_date1 = GetPostString("pay_date1");
  12249. string pay_date2 = GetPostString("pay_date2");
  12250. int type = GetPostInt("type");
  12251. if (type == 0)
  12252. {
  12253. if (pay_date1.Length > 0)
  12254. {
  12255. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  12256. }
  12257. if (pay_date2.Length > 0)
  12258. {
  12259. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  12260. }
  12261. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  12262. }
  12263. if (type == 1)
  12264. {
  12265. if (pay_date1.Length > 0)
  12266. {
  12267. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  12268. }
  12269. if (pay_date2.Length > 0)
  12270. {
  12271. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  12272. }
  12273. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  12274. }
  12275. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12276. DataTable dt = null;
  12277. dt = WebCache.GetData("view_orderlist", dStruct);
  12278. writeGridDataTableJson(dStruct.TotalCount, dt);
  12279. }
  12280. public void saveUrgentChargePrice()
  12281. {
  12282. string ctid = GetPostString("ctid");
  12283. if (!string.IsNullOrEmpty(ctid))
  12284. {
  12285. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12286. if (ceErpTradeCell != null)
  12287. {
  12288. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  12289. if (prices <= 100)
  12290. {
  12291. returnErrorMsg("此订单金额不足100元,无法加急。");
  12292. return;
  12293. }
  12294. double price = GetPostDouble("price");
  12295. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  12296. if (ceErpTradeCellExtend == null)
  12297. {
  12298. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12299. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  12300. }
  12301. ceErpTradeCellExtend.urgentCharge = price;
  12302. if (ceErpTradeCellExtend.ID > 0)
  12303. {
  12304. ceErpTradeCellExtend.Update();
  12305. }
  12306. else
  12307. {
  12308. ceErpTradeCellExtend.Save();
  12309. }
  12310. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  12311. returnSuccessMsg("修改成功!");
  12312. return;
  12313. }
  12314. returnErrorMsg("找不到订单");
  12315. return;
  12316. }
  12317. returnErrorMsg("找不到订单");
  12318. }
  12319. public void finish_erp_order()
  12320. {
  12321. string ctid = GetPostString("ctid");
  12322. if (!string.IsNullOrEmpty(ctid))
  12323. {
  12324. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  12325. {
  12326. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12327. if (ceErpTradeCell != null)
  12328. {
  12329. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  12330. ceErpTradeCell.Update();
  12331. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  12332. returnSuccessMsg("修改成功!");
  12333. return;
  12334. }
  12335. }
  12336. }
  12337. returnErrorMsg("找不到订单");
  12338. }
  12339. public void get_trade_order_list()
  12340. {
  12341. string tid = GetPostString("tid");
  12342. if (!string.IsNullOrEmpty(tid))
  12343. {
  12344. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  12345. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12346. writeGridDataTableJson(data.Rows.Count, data);
  12347. return;
  12348. }
  12349. returnErrorMsg("找不到订单");
  12350. }
  12351. public void save_cell_spu()
  12352. {
  12353. string ctid = GetPostString("ctid");
  12354. string spu_id = GetPostString("spu_id");
  12355. if (!string.IsNullOrEmpty(ctid))
  12356. {
  12357. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12358. if (ceErpTradeCellExtend == null)
  12359. {
  12360. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12361. ceErpTradeCellExtend.ctid = ctid;
  12362. }
  12363. ceErpTradeCellExtend.spu_id = spu_id;
  12364. if (!string.IsNullOrEmpty(spu_id))
  12365. {
  12366. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12367. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  12368. }
  12369. if (ceErpTradeCellExtend.ID == 0)
  12370. {
  12371. ceErpTradeCellExtend.Create();
  12372. }
  12373. else
  12374. {
  12375. ceErpTradeCellExtend.Update();
  12376. }
  12377. returnSuccessMsg("修改成功!");
  12378. return;
  12379. }
  12380. returnErrorMsg("找不到订单");
  12381. }
  12382. public void change_express_info()
  12383. {
  12384. string ctid = GetPostString("ctid");
  12385. string transNo = GetPostString("transNo");
  12386. string transCom = GetPostString("transCom");
  12387. if (!string.IsNullOrEmpty(ctid))
  12388. {
  12389. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12390. if (ceErpTradeCellExtend == null)
  12391. {
  12392. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12393. ceErpTradeCellExtend.ctid = ctid;
  12394. }
  12395. ceErpTradeCellExtend.modExpressNo = transNo;
  12396. ceErpTradeCellExtend.modExpressCom = transCom;
  12397. ceErpTradeCellExtend.readMod = 2;
  12398. if (ceErpTradeCellExtend.ID == 0)
  12399. {
  12400. ceErpTradeCellExtend.Create();
  12401. }
  12402. else
  12403. {
  12404. ceErpTradeCellExtend.Update();
  12405. }
  12406. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  12407. returnSuccessMsg("修改成功!");
  12408. return;
  12409. }
  12410. returnErrorMsg("找不到订单");
  12411. }
  12412. public void get_change_express_list()
  12413. {
  12414. DataStruct dStruct = GetPostStruct();
  12415. List<string> lw = new List<string>();
  12416. int st = 2;
  12417. string tid = GetPostString("ctid");
  12418. if (tid.Length > 0)
  12419. {
  12420. string select_tid = getTidByCtid(tid);
  12421. lw.Add(string.Format("tid='{0}'", select_tid));
  12422. }
  12423. string shopname = GetPostString("shopname");
  12424. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12425. string buyernick = GetPostString("buyer_nick");
  12426. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12427. string sellermemo = GetPostString("seller_memo");
  12428. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12429. string supplier = GetPostString("supplier");
  12430. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12431. string customer = GetPostString("customer");
  12432. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12433. string design = GetPostString("design");
  12434. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12435. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12436. string poscode = CurrentUser.UserPost.Post.Code;
  12437. if (poscode != "SysAdmin")
  12438. {
  12439. string shopid = CurrentUser.User.pemShop;
  12440. lw.Add(string.Format("shopId in ({0})", shopid));
  12441. }
  12442. lw.Add("readMod = 2");
  12443. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12444. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  12445. writeGridDataTableJson(dStruct.TotalCount, dt);
  12446. }
  12447. public void deal_express_complete()
  12448. {
  12449. string ctid = GetPostString("ctid");
  12450. if (!string.IsNullOrEmpty(ctid))
  12451. {
  12452. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12453. if (ceErpTradeCellExtend == null)
  12454. {
  12455. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12456. ceErpTradeCellExtend.ctid = ctid;
  12457. }
  12458. ceErpTradeCellExtend.readMod = 1;
  12459. if (ceErpTradeCellExtend.ID == 0)
  12460. {
  12461. ceErpTradeCellExtend.Create();
  12462. }
  12463. else
  12464. {
  12465. ceErpTradeCellExtend.Update();
  12466. }
  12467. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12468. returnSuccessMsg("修改成功!");
  12469. return;
  12470. }
  12471. returnErrorMsg("找不到订单");
  12472. }
  12473. public void aftersale_return_visit()
  12474. {
  12475. string ctid = GetPostString("ctid");
  12476. if (!string.IsNullOrEmpty(ctid))
  12477. {
  12478. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12479. if (ceErpTradeCellExtend == null)
  12480. {
  12481. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12482. ceErpTradeCellExtend.ctid = ctid;
  12483. }
  12484. ceErpTradeCellExtend.returnVisit = 1;
  12485. if (ceErpTradeCellExtend.ID == 0)
  12486. {
  12487. ceErpTradeCellExtend.Create();
  12488. }
  12489. else
  12490. {
  12491. ceErpTradeCellExtend.Update();
  12492. }
  12493. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12494. if (ceErpTradeAfterSaleExtend != null)
  12495. {
  12496. ceErpTradeAfterSaleExtend.TextResult = "";
  12497. ceErpTradeAfterSaleExtend.Update();
  12498. }
  12499. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12500. returnSuccessMsg("修改成功!");
  12501. return;
  12502. }
  12503. returnErrorMsg("找不到订单");
  12504. }
  12505. public void orderPlaceInfo()
  12506. {
  12507. string ctids = GetPostString("ctids");
  12508. string[] list = ctids.Split(',');
  12509. foreach (string ctid in list)
  12510. {
  12511. CeErpSukuraData.createInfo(ctid, 3);
  12512. }
  12513. StringBuilder sql = new StringBuilder();
  12514. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12515. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12516. designHelper.api_approveDesign(ctids); //approveDesign
  12517. returnSuccessMsg("");
  12518. }
  12519. public void get_issue_list()
  12520. {
  12521. DataStruct dStruct = GetPostStruct();
  12522. List<string> lw = new List<string>();
  12523. int st = 2;
  12524. string tid = GetPostString("ctid");
  12525. if (tid.Length > 0)
  12526. {
  12527. string select_tid = getTidByCtid(tid);
  12528. lw.Add(string.Format("tid='{0}'", select_tid));
  12529. }
  12530. string shopname = GetPostString("shopname");
  12531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12532. string buyernick = GetPostString("buyer_nick");
  12533. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12534. string sellermemo = GetPostString("seller_memo");
  12535. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12536. string supplier = GetPostString("supplier");
  12537. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12538. string customer = GetPostString("customer");
  12539. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12540. string design = GetPostString("design");
  12541. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12542. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12543. string poscode = CurrentUser.UserPost.Post.Code;
  12544. if (poscode != "SysAdmin")
  12545. {
  12546. string shopid = CurrentUser.User.pemShop;
  12547. lw.Add(string.Format("shopId in ({0})", shopid));
  12548. }
  12549. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12550. {
  12551. lw.Add("IssueState = 1");
  12552. }
  12553. else
  12554. {
  12555. string iisstate = GetPostString("iisstate");
  12556. if ("1".Equals(iisstate))
  12557. {
  12558. lw.Add("IssueState =1");
  12559. }
  12560. else if ("2".Equals(iisstate))
  12561. {
  12562. lw.Add("IssueState = 2");
  12563. }
  12564. else
  12565. {
  12566. lw.Add("IssueState > 0");
  12567. }
  12568. }
  12569. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12570. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12571. writeGridDataTableJson(dStruct.TotalCount, dt);
  12572. }
  12573. public void saveIssueContent()
  12574. {
  12575. string ctid = GetPostString("ctid");
  12576. if (!string.IsNullOrEmpty(ctid))
  12577. {
  12578. string content = GetPostString("content");
  12579. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12580. if (ceErpTradeAfterSaleExtend == null)
  12581. {
  12582. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12583. ceErpTradeAfterSaleExtend.tid = ctid;
  12584. }
  12585. ceErpTradeAfterSaleExtend.IssueContent = content;
  12586. ceErpTradeAfterSaleExtend.IssueState = 1;
  12587. if (ceErpTradeAfterSaleExtend.ID > 0)
  12588. {
  12589. ceErpTradeAfterSaleExtend.Update();
  12590. }
  12591. else
  12592. {
  12593. ceErpTradeAfterSaleExtend.Create();
  12594. }
  12595. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12596. returnSuccessMsg("添加成功!");
  12597. return;
  12598. }
  12599. returnErrorMsg("找不到订单");
  12600. }
  12601. public void dealIssueContent()
  12602. {
  12603. string ctid = GetPostString("ctid");
  12604. if (!string.IsNullOrEmpty(ctid))
  12605. {
  12606. string content = GetPostString("content");
  12607. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12608. if (ceErpTradeAfterSaleExtend != null)
  12609. {
  12610. ceErpTradeAfterSaleExtend.IssueState = 2;
  12611. ceErpTradeAfterSaleExtend.Update();
  12612. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12613. returnSuccessMsg("修改完成!");
  12614. return;
  12615. }
  12616. }
  12617. returnErrorMsg("找不到订单");
  12618. }
  12619. public void set_tid_attachments()
  12620. {
  12621. string tid = GetPostString("tid");
  12622. string atta = GetPostString("atta");
  12623. if (!string.IsNullOrEmpty(tid))
  12624. {
  12625. if (string.IsNullOrEmpty(atta))
  12626. {
  12627. returnErrorMsg("文件地址为空");
  12628. return;
  12629. }
  12630. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12631. if (ceErpTradeCell != null)
  12632. {
  12633. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12634. if (ceErpTrade == null)
  12635. {
  12636. returnErrorMsg("找不到订单");
  12637. return;
  12638. }
  12639. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12640. bool isSend = false;
  12641. if (dt != null && dt.Rows.Count > 0)
  12642. {
  12643. foreach (DataRow row in dt.Rows)
  12644. {
  12645. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12646. {
  12647. isSend = true;
  12648. }
  12649. }
  12650. if (isSend)
  12651. {
  12652. returnErrorMsg("已发货无法修改");
  12653. return;
  12654. }
  12655. ceErpTrade.Attachments = atta;
  12656. ceErpTrade.Update();
  12657. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12658. returnSuccessMsg("上传成功!");
  12659. return;
  12660. }
  12661. }
  12662. }
  12663. returnErrorMsg("找不到订单");
  12664. }
  12665. public void get_tid_attachments()
  12666. {
  12667. string tid = GetPostString("tid");
  12668. if (!string.IsNullOrEmpty(tid))
  12669. {
  12670. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12671. if (ceErpTradeCell != null)
  12672. {
  12673. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12674. if (ceErpTrade == null)
  12675. {
  12676. returnErrorMsg("找不到订单");
  12677. return;
  12678. }
  12679. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12680. return;
  12681. }
  12682. }
  12683. returnErrorMsg("找不到订单");
  12684. }
  12685. public void check_erp_sameorders()
  12686. {
  12687. if (UrlPostParmsCheck("ctid"))
  12688. {
  12689. string eid = GetPostString("ctid");
  12690. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12691. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12692. if (entity != null && ceErpTrade != null)
  12693. {
  12694. if (entity.OrderState > 6)
  12695. {
  12696. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12697. return;
  12698. }
  12699. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12700. List<string> ids = new List<string>();
  12701. if (dt != null && dt.Rows.Count > 1)
  12702. {
  12703. bool needhe = true;
  12704. foreach (DataRow dr in dt.Rows)
  12705. {
  12706. ids.Add("'" + dr["ctid"] + "'");
  12707. /* //备注有合包
  12708. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12709. {
  12710. needhe = true;
  12711. }
  12712. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12713. {
  12714. needhe = true;
  12715. }
  12716. //顺丰快递
  12717. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12718. {
  12719. needhe = true;
  12720. }*/
  12721. }
  12722. if (!needhe)
  12723. {
  12724. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12725. return;
  12726. }
  12727. StringBuilder sql = new StringBuilder();
  12728. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12729. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12730. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12731. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12732. foreach (DataRow dr in dt.Rows)
  12733. {
  12734. dr["dstate"] = 0;
  12735. dr["dnumber"] = 0;
  12736. foreach (DataRow row in dt1.Rows)
  12737. {
  12738. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12739. {
  12740. dr["dstate"] = 2;
  12741. dr["default"] = 1;
  12742. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12743. }
  12744. }
  12745. if (eid.Equals(dr["ctid"].ToString()))
  12746. {
  12747. dr["dstate"] = 1;
  12748. dr["default"] = 1;
  12749. }
  12750. }
  12751. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12752. return;
  12753. }
  12754. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12755. return;
  12756. }
  12757. returnErrorMsg("未找到订单");
  12758. return;
  12759. }
  12760. returnErrorMsg("缺少必要的参数");
  12761. }
  12762. public void get_mark_number()
  12763. {
  12764. string eid = GetPostString("ctid");
  12765. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12766. if (entity != null)
  12767. {
  12768. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12769. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12770. int current = 1;
  12771. if (ceErpDeliverMark == null)
  12772. {
  12773. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12774. List<string> ids = new List<string>();
  12775. if (dt != null && dt.Rows.Count > 1)
  12776. {
  12777. foreach (DataRow dr in dt.Rows)
  12778. {
  12779. ids.Add("'" + dr["ctid"] + "'");
  12780. }
  12781. //查询已有的编号
  12782. StringBuilder sql = new StringBuilder();
  12783. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12784. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12785. if (dt1 == null || dt1.Rows.Count == 0)
  12786. {
  12787. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12788. List<int> list_number = new List<int>();
  12789. foreach (DataRow row in numbers.Rows)
  12790. {
  12791. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12792. }
  12793. //查询空余编号
  12794. for (int i = 0; i < list_number.Count + 2; i++)
  12795. {
  12796. if (!list_number.Contains(current))
  12797. {
  12798. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12799. //防止查询过程中有新数据生成
  12800. if (ceErpDeliverMark1 == null)
  12801. {
  12802. break;
  12803. }
  12804. }
  12805. current++;
  12806. }
  12807. }
  12808. else
  12809. {
  12810. foreach (DataRow row in dt1.Rows)
  12811. {
  12812. current = Convert.ToInt32(row["markNumber"]);
  12813. }
  12814. }
  12815. ceErpDeliverMark = new CeErpDeliverMark();
  12816. ceErpDeliverMark.ctid = eid;
  12817. ceErpDeliverMark.createtime = DateTime.Now;
  12818. if (ceErpTrade != null)
  12819. {
  12820. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12821. }
  12822. ceErpDeliverMark.markNumber = current;
  12823. ceErpDeliverMark.Create();
  12824. }
  12825. }
  12826. else
  12827. {
  12828. current = ceErpDeliverMark.markNumber;
  12829. }
  12830. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12831. return;
  12832. }
  12833. }
  12834. public void aftersaleCytSend()
  12835. {
  12836. string ctid = GetPostString("ctid");
  12837. if (!string.IsNullOrEmpty(ctid))
  12838. {
  12839. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12840. if (ceErpTradeCell != null)
  12841. {
  12842. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12843. }
  12844. returnSuccessMsg("推送成功");
  12845. return;
  12846. }
  12847. returnErrorMsg("缺少必要的参数");
  12848. }
  12849. public void packOrderInfo()
  12850. {
  12851. string ctids = GetPostString("ctids");
  12852. if (!string.IsNullOrEmpty(ctids))
  12853. {
  12854. string[] ctid_list = ctids.Split(',');
  12855. if (ctid_list.Length > 20)
  12856. {
  12857. returnErrorMsg("单次下载次数不能超过20个");
  12858. return;
  12859. }
  12860. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12861. StringBuilder sql = new StringBuilder();
  12862. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12863. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12864. int supplierId = 0;
  12865. StringBuilder insterSql = new StringBuilder();
  12866. for (int i = 0; i < dt.Rows.Count; i++)
  12867. {
  12868. DataRow row = dt.Rows[i];
  12869. if (i == 0)
  12870. {
  12871. supplierId = Convert.ToInt32(row["SupplierId"]);
  12872. }
  12873. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12874. {
  12875. returnErrorMsg("同车间的订单才能一起打包");
  12876. return;
  12877. }
  12878. int orderState = Convert.ToInt32(row["OrderState"]);
  12879. if (orderState != 5)
  12880. {
  12881. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12882. return;
  12883. }
  12884. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12885. }
  12886. CeErpPackData ceErpPackData = new CeErpPackData();
  12887. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12888. ceErpPackData.supplierId = supplierId;
  12889. ceErpPackData.createtime = DateTime.Now;
  12890. ceErpPackData.createBy = CurrentUser.UserID;
  12891. ceErpPackData.createName = CurrentUser.UserName;
  12892. ceErpPackData.Create();
  12893. if (ceErpPackData.ID > 0)
  12894. {
  12895. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12896. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12897. }
  12898. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12899. returnSuccessMsg("打包成功");
  12900. return;
  12901. }
  12902. returnErrorMsg("缺少必要的参数");
  12903. }
  12904. public void rePackOrderInfo()
  12905. {
  12906. string id = GetPostString("id");
  12907. if (!string.IsNullOrEmpty(id))
  12908. {
  12909. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12910. if (ceErpPackData == null)
  12911. {
  12912. returnSuccessMsg("查无数据");
  12913. return;
  12914. }
  12915. ceErpPackData.upStatus = 0;
  12916. ceErpPackData.message = "";
  12917. ceErpPackData.Update();
  12918. returnSuccessMsg("打包成功");
  12919. return;
  12920. }
  12921. returnErrorMsg("缺少必要的参数");
  12922. }
  12923. public void backPackOrderInfo()
  12924. {
  12925. string id = GetPostString("id");
  12926. if (!string.IsNullOrEmpty(id))
  12927. {
  12928. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12929. if (ceErpPackData == null)
  12930. {
  12931. returnSuccessMsg("查无数据");
  12932. return;
  12933. }
  12934. ceErpPackData.upStatus = 4;
  12935. ceErpPackData.Update();
  12936. List<string> list = new List<string>();
  12937. StringBuilder sql = new StringBuilder();
  12938. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12939. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12940. for (int i = 0; i < dt.Rows.Count; i++)
  12941. {
  12942. DataRow row = dt.Rows[i];
  12943. list.Add("'" + row["ctid"].ToString() + "'");
  12944. }
  12945. string textCtids = string.Join(",", list);
  12946. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12947. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12948. returnSuccessMsg("退回成功");
  12949. return;
  12950. }
  12951. returnErrorMsg("缺少必要的参数");
  12952. }
  12953. public void addPackDownNum()
  12954. {
  12955. string id = GetPostString("id");
  12956. if (!string.IsNullOrEmpty(id))
  12957. {
  12958. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12959. returnSuccessMsg("下载成功");
  12960. return;
  12961. }
  12962. returnErrorMsg("缺少必要的参数");
  12963. }
  12964. public void get_pack_list()
  12965. {
  12966. DataStruct dStruct = GetPostStruct();
  12967. List<string> lw = new List<string>();
  12968. string supplier = GetPostString("supplier");
  12969. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12970. string posTag = CurrentUser.UserPost.Post.Code;
  12971. if (posTag == "Supplier")
  12972. {
  12973. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12974. }
  12975. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12976. dStruct.Order = "createtime desc";
  12977. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12978. writeGridDataTableJson(dStruct.TotalCount, dt);
  12979. }
  12980. public void get_pack_order_list()
  12981. {
  12982. string packId = GetPostString("packId");
  12983. if (string.IsNullOrEmpty(packId))
  12984. {
  12985. returnErrorMsg("缺少必要的参数");
  12986. return;
  12987. }
  12988. StringBuilder sql = new StringBuilder();
  12989. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12990. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12991. if (dt == null || dt.Rows.Count == 0)
  12992. {
  12993. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12994. return;
  12995. }
  12996. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12997. return;
  12998. }
  12999. public void get_supplier_product_time_list()
  13000. {
  13001. DataStruct dStruct = GetPostStruct();
  13002. List<string> lw = new List<string>();
  13003. string txtKey = GetPostString("txtKey");
  13004. if (txtKey.Length > 0)
  13005. {
  13006. lw.Add(string.Format("(supplierName = '{0}' or productName like '%{0}%')", txtKey));
  13007. }
  13008. string posTag = CurrentUser.UserPost.Post.Code;
  13009. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  13010. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  13011. writeGridDataTableJson(dStruct.TotalCount, dt);
  13012. }
  13013. public void saveSupplierProductTime()
  13014. {
  13015. string productId = GetPostString("productId");
  13016. if (string.IsNullOrEmpty(productId))
  13017. {
  13018. returnErrorMsg("缺少必要的参数");
  13019. return;
  13020. }
  13021. string productName = GetPostString("productName");
  13022. int supplierId = GetPostInt("supplierId");
  13023. if (supplierId == 0)
  13024. {
  13025. returnErrorMsg("缺少必要的参数");
  13026. return;
  13027. }
  13028. int quantity = GetPostInt("quantity");
  13029. int sendDay = GetPostInt("sendTime");
  13030. string supplierName = GetPostString("supplierName");
  13031. string craft = GetPostString("craft");
  13032. string deadLine = GetPostString("deadLine");
  13033. string dayDeadLine = GetPostString("dayDeadLine");
  13034. try
  13035. {
  13036. int eid = GetPostInt("eid");
  13037. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  13038. if (ceErpSupplierProductTime == null)
  13039. {
  13040. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  13041. }
  13042. ceErpSupplierProductTime.productId = productId;
  13043. ceErpSupplierProductTime.productName = productName;
  13044. ceErpSupplierProductTime.supplierId = supplierId;
  13045. ceErpSupplierProductTime.supplierName = supplierName;
  13046. ceErpSupplierProductTime.craft = craft;
  13047. ceErpSupplierProductTime.sendDay = sendDay;
  13048. ceErpSupplierProductTime.quantity = quantity;
  13049. if (!string.IsNullOrEmpty(deadLine))
  13050. {
  13051. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  13052. }
  13053. if (!string.IsNullOrEmpty(dayDeadLine))
  13054. {
  13055. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  13056. }
  13057. if (ceErpSupplierProductTime.ID == 0)
  13058. {
  13059. ceErpSupplierProductTime.Save();
  13060. }
  13061. else
  13062. {
  13063. ceErpSupplierProductTime.Update();
  13064. }
  13065. }
  13066. catch (Exception e)
  13067. {
  13068. }
  13069. returnSuccessMsg("保存成功");
  13070. return;
  13071. }
  13072. public void delSupplierProductTime()
  13073. {
  13074. int eid = GetPostInt("eid");
  13075. if (eid > 0)
  13076. {
  13077. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  13078. if (ceErpSupplierProductTime == null)
  13079. {
  13080. returnErrorMsg("查无数据");
  13081. return;
  13082. }
  13083. ceErpSupplierProductTime.Delete();
  13084. returnSuccessMsg("保存成功");
  13085. return;
  13086. }
  13087. returnErrorMsg("缺少必要的参数");
  13088. }
  13089. public void getExpressInfo()
  13090. {
  13091. string ctid = GetPostString("ctid");
  13092. if (!string.IsNullOrEmpty(ctid))
  13093. {
  13094. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13095. if (ceErpTradeCell != null)
  13096. {
  13097. string outSid = ceErpTradeCell.OutSid;
  13098. if (outSid.Length > 0)
  13099. {
  13100. string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  13101. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13102. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  13103. return;
  13104. }
  13105. }
  13106. returnErrorMsg("查无记录");
  13107. return;
  13108. }
  13109. returnErrorMsg("缺少必要的参数");
  13110. }
  13111. public void getExpressPostData()
  13112. {
  13113. string express = GetPostString("express");
  13114. if (!string.IsNullOrEmpty(express))
  13115. {
  13116. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  13117. if (ceErpExpressInfo != null)
  13118. {
  13119. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  13120. return;
  13121. }
  13122. }
  13123. returnErrorMsg("缺少必要的参数");
  13124. }
  13125. public void checkSupplierOrder()
  13126. {
  13127. string ctids = GetPostString("ctids");
  13128. if (ctids != null)
  13129. {
  13130. List<string> list = new List<string>();
  13131. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  13132. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13133. for (int i = 0; i < dt.Rows.Count; i++)
  13134. {
  13135. DataRow row = dt.Rows[i];
  13136. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  13137. {
  13138. continue;
  13139. }
  13140. list.Add(row["seller_memo"].ToString());
  13141. }
  13142. if (list.Count > 0)
  13143. {
  13144. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  13145. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  13146. return;
  13147. }
  13148. }
  13149. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  13150. return;
  13151. }
  13152. public void addPersonId()
  13153. {
  13154. string tid = GetPostString("tid");
  13155. string personId = GetPostString("personId");
  13156. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  13157. if (ceErpTrade != null)
  13158. {
  13159. ceErpTrade.receiver_zip = personId;
  13160. ceErpTrade.Update();
  13161. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  13162. returnSuccessMsg("保存成功");
  13163. return;
  13164. }
  13165. returnErrorMsg("缺少必要的参数");
  13166. }
  13167. public void addDeliveryPaymant()
  13168. {
  13169. string tid = GetPostString("tid");
  13170. string paymant = GetPostString("paymant");
  13171. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  13172. if (ceErpTrade != null)
  13173. {
  13174. if (!string.IsNullOrEmpty(paymant))
  13175. {
  13176. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  13177. }
  13178. ceErpTrade.Update();
  13179. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  13180. returnSuccessMsg("保存成功");
  13181. return;
  13182. }
  13183. returnErrorMsg("缺少必要的参数");
  13184. }
  13185. public void saveCellFile()
  13186. {
  13187. string tid = GetPostString("tid");
  13188. string ctid = GetPostString("ctid");
  13189. string urls = GetPostString("urls");
  13190. string type = GetPostString("type");
  13191. string del = GetPostString("del");
  13192. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  13193. {
  13194. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  13195. {
  13196. ctid = tid;
  13197. }
  13198. if ("1".Equals(del))
  13199. {
  13200. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  13201. }
  13202. string[] list = urls.Split(',');
  13203. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  13204. {
  13205. foreach (string item in list)
  13206. {
  13207. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  13208. ceErpTradeCellFile.Create();
  13209. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  13210. }
  13211. }
  13212. returnSuccessMsg("保存成功");
  13213. return;
  13214. }
  13215. returnErrorMsg("缺少必要的参数");
  13216. }
  13217. public void getCellFile()
  13218. {
  13219. string tid = GetPostString("tid");
  13220. string ctid = GetPostString("ctid");
  13221. string type = GetPostString("type");
  13222. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  13223. {
  13224. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  13225. {
  13226. ctid = tid;
  13227. }
  13228. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  13229. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13230. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  13231. return;
  13232. }
  13233. returnErrorMsg("缺少必要的参数");
  13234. }
  13235. public void delCellFile()
  13236. {
  13237. string id = GetPostString("id");
  13238. if (string.IsNullOrEmpty(id))
  13239. {
  13240. returnErrorMsg("缺少必要的参数");
  13241. return;
  13242. }
  13243. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  13244. CeErpTradeCellFile.delByID(id);
  13245. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  13246. returnSuccessMsg("保存成功");
  13247. }
  13248. public void getInvoiceOrder()
  13249. {
  13250. string tid = GetPostString("tid");
  13251. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  13252. List<string> tids = new List<string>();
  13253. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  13254. {
  13255. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WHERE buyer_id = '{0}' AND seller_nick = '{1}' order by pay_time desc;", ceErpTrade.buyer_id, ceErpTrade.seller_nick);
  13256. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13257. foreach (DataRow dr in dt.Rows)
  13258. {
  13259. tids.Add("'" + dr["tid"].ToString() + "'");
  13260. }
  13261. }
  13262. else
  13263. {
  13264. tids.Add("'" + ceErpTrade.tid + "'");
  13265. }
  13266. DataTable cell_dt = new DataTable();
  13267. if (tids.Count > 0)
  13268. {
  13269. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  13270. }
  13271. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  13272. return;
  13273. }
  13274. public void getOrderLogInfo()
  13275. {
  13276. string ctid = GetPostString("ctid");
  13277. if (!string.IsNullOrEmpty(ctid))
  13278. {
  13279. StringBuilder sql = new StringBuilder();
  13280. sql.AppendFormat("select * from view_erptradelog where tid='{0}' order by id;", ctid);
  13281. DataSet ds = DbHelper.DbConn.ExecuteDataset(sql.ToString());
  13282. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(ds.Tables[0])) + "}");
  13283. return;
  13284. }
  13285. returnErrorMsg("缺少必要的参数");
  13286. }
  13287. public void setCellTeampId()
  13288. {
  13289. string ctid = GetPostString("ctid");
  13290. string tempId = GetPostString("tempId");
  13291. if (!string.IsNullOrEmpty(ctid))
  13292. {
  13293. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  13294. if (ceErpTradeCellExtend == null)
  13295. {
  13296. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  13297. ceErpTradeCellExtend.ctid = ctid;
  13298. }
  13299. ceErpTradeCellExtend.tempId = tempId;
  13300. if (ceErpTradeCellExtend.ID > 0)
  13301. {
  13302. ceErpTradeCellExtend.Update();
  13303. }
  13304. else
  13305. {
  13306. ceErpTradeCellExtend.Create();
  13307. }
  13308. designHelper.API_sendTempInfo(ctid, tempId);
  13309. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "修改模板id" + tempId, 6);
  13310. returnSuccessMsg("保存成功");
  13311. return;
  13312. }
  13313. returnErrorMsg("缺少必要的参数");
  13314. }
  13315. public void saveJointorder()
  13316. {
  13317. string ctid = GetPostString("ctid");
  13318. if (!string.IsNullOrEmpty(ctid))
  13319. {
  13320. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  13321. if (ceErpTradeCellExtend == null)
  13322. {
  13323. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  13324. ceErpTradeCellExtend.ctid = ctid;
  13325. }
  13326. if (ceErpTradeCellExtend.IsJoint == 1)
  13327. {
  13328. ceErpTradeCellExtend.IsJoint = 0;
  13329. }
  13330. else
  13331. {
  13332. ceErpTradeCellExtend.IsJoint = 1;
  13333. }
  13334. if (ceErpTradeCellExtend.ID > 0)
  13335. {
  13336. ceErpTradeCellExtend.Update();
  13337. }
  13338. else
  13339. {
  13340. ceErpTradeCellExtend.Create();
  13341. }
  13342. returnSuccessMsg("保存成功");
  13343. return;
  13344. }
  13345. returnErrorMsg("缺少必要的参数");
  13346. }
  13347. public void applyOrderBack()
  13348. {
  13349. string ctid = GetPostString("ctid");
  13350. string reason = GetPostString("reason");
  13351. if (!string.IsNullOrEmpty(ctid))
  13352. {
  13353. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13354. if (ceErpTradeCell == null)
  13355. {
  13356. returnErrorMsg("找不到订单");
  13357. return;
  13358. }
  13359. if (ceErpTradeCell.OrderState != 5 && ceErpTradeCell.OrderState != 6)
  13360. {
  13361. returnErrorMsg("待下单已下单才能申请");
  13362. return;
  13363. }
  13364. //下单后24小时后无法申请
  13365. if (ceErpTradeCell.OrderState == 6 && ceErpTradeCell.FinishPlaceTime != null)
  13366. {
  13367. DateTime now = DateTime.Now;
  13368. if (!string.IsNullOrEmpty(ceErpTradeCell.FinishPlaceTime.ToString()) && DateTime.Compare(DateTime.Parse(ceErpTradeCell.FinishPlaceTime.ToString()), now.AddHours(-24)) < 0)
  13369. {
  13370. returnErrorMsg("下单后24小时后无法申请");
  13371. return;
  13372. }
  13373. }
  13374. string sql = string.Format("select Con,UserId from CE_ErpTradeLog where tid = '{0}'", ceErpTradeCell.ctid);
  13375. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13376. if (dataTable != null && dataTable.Rows.Count > 0)
  13377. {
  13378. foreach (DataRow row in dataTable.Rows)
  13379. {
  13380. if (row["Con"].ToString().Contains("拒绝打回"))
  13381. {
  13382. returnErrorMsg("被拒绝过无法继续申请");
  13383. return;
  13384. }
  13385. }
  13386. }
  13387. ceErpTradeCell.IsReturn = 4;
  13388. ceErpTradeCell.Update();
  13389. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请打回:" + reason, ceErpTradeCell.OrderState);
  13390. returnSuccessMsg("保存成功");
  13391. return;
  13392. }
  13393. returnErrorMsg("缺少必要的参数");
  13394. }
  13395. public void cancelApplyOrderBack()
  13396. {
  13397. string ctid = GetPostString("ctid");
  13398. if (!string.IsNullOrEmpty(ctid))
  13399. {
  13400. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13401. if (ceErpTradeCell == null)
  13402. {
  13403. returnErrorMsg("找不到订单");
  13404. return;
  13405. }
  13406. if (ceErpTradeCell.IsReturn != 4)
  13407. {
  13408. returnErrorMsg("订单未在申请阶段");
  13409. return;
  13410. }
  13411. ceErpTradeCell.IsReturn = 0;
  13412. ceErpTradeCell.Update();
  13413. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "取消申请打回", ceErpTradeCell.OrderState);
  13414. returnSuccessMsg("保存成功");
  13415. return;
  13416. }
  13417. returnErrorMsg("缺少必要的参数");
  13418. }
  13419. public void get_erp_applybackorderlist()
  13420. {
  13421. DataStruct dStruct = GetPostStruct();
  13422. List<string> lw = new List<string>();
  13423. string tid = GetPostString("ctid");
  13424. if (tid.Length > 0)
  13425. {
  13426. string select_tid = getTidByCtid(tid);
  13427. lw.Add(string.Format("tid='{0}'", select_tid));
  13428. }
  13429. string shopname = GetPostString("shopname");
  13430. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  13431. string buyernick = GetPostString("buyer_nick");
  13432. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  13433. string customer = GetPostString("customer");
  13434. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  13435. string design = GetPostString("design");
  13436. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  13437. string orderState = GetPostString("orderState");
  13438. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  13439. string supplier = GetPostString("supplier");
  13440. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  13441. string sellermemo = GetPostString("seller_memo");
  13442. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  13443. string otherMemo = GetPostString("otherMemo");
  13444. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  13445. string address = GetPostString("address");
  13446. 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));
  13447. string date1 = GetPostString("date1");
  13448. string date2 = GetPostString("date2");
  13449. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  13450. if (dw.Length > 0) lw.Add(dw);
  13451. string price1 = GetPostString("price1");
  13452. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  13453. string price2 = GetPostString("price2");
  13454. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  13455. if (CurrentUser.UserPost.Post.Code == "Supplier")
  13456. {
  13457. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  13458. lw.Add(string.Format("OrderState = 6"));
  13459. }
  13460. else if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  13461. {
  13462. lw.Add("OrderState in (5,6) ");
  13463. }
  13464. lw.Add(string.Format("IsReturn = 4"));
  13465. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  13466. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  13467. string pagesize = GetPostString("pagesize");
  13468. if (pagesize != null)
  13469. {
  13470. dStruct.PageSize = 200;
  13471. }
  13472. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  13473. writeGridDataTableJson(dStruct.TotalCount, dt);
  13474. }
  13475. public void refuseBackOrder()
  13476. {
  13477. string ctid = GetPostString("ctid");
  13478. if (!string.IsNullOrEmpty(ctid))
  13479. {
  13480. string reason = GetPostString("returnreason");
  13481. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13482. if (ceErpTradeCell == null)
  13483. {
  13484. returnErrorMsg("找不到订单");
  13485. return;
  13486. }
  13487. string sql = string.Format("select Con,UserId from CE_ErpTradeLog where tid = '{0}' order by ID desc", ceErpTradeCell.ctid);
  13488. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13489. int userId = 0;
  13490. if (dataTable != null && dataTable.Rows.Count > 0)
  13491. {
  13492. foreach (DataRow row in dataTable.Rows)
  13493. {
  13494. if (row["Con"].ToString().Contains("申请打回:"))
  13495. {
  13496. userId = Convert.ToInt32(row["UserId"]);
  13497. }
  13498. }
  13499. }
  13500. if (userId > 0)
  13501. {
  13502. CeErpMessageTip ct = new CeErpMessageTip();
  13503. ct.tid = ceErpTradeCell.ctid;
  13504. ct.sectionId = 0;
  13505. ct.userId = userId;
  13506. ct.type = 4;
  13507. ct.isVisit = false;
  13508. ct.content = ceErpTradeCell.ctid + ",申请打回被拒绝:" + reason;
  13509. ct.Create();
  13510. }
  13511. ceErpTradeCell.IsReturn = 0;
  13512. ceErpTradeCell.Update();
  13513. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "拒绝打回:" + reason, ceErpTradeCell.OrderState);
  13514. returnSuccessMsg("保存成功");
  13515. return;
  13516. }
  13517. returnErrorMsg("缺少必要的参数");
  13518. }
  13519. public void passApplyBack()
  13520. {
  13521. if (UrlPostParmsCheck("ctid"))
  13522. {
  13523. string eid = GetPostString("ctid");
  13524. CeErpTradeCell entity = null;
  13525. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  13526. string userpost = CurrentUser.UserPost.Post.Code;
  13527. if (entity != null)
  13528. {
  13529. string message = "操作成功!";
  13530. string isDown = "";
  13531. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  13532. {
  13533. message = "订单有被点击下载。请注意沟通是否已下载完!";
  13534. isDown = "被点击下载";
  13535. }
  13536. bool isPlace = false;
  13537. if (entity.OrderState > 6)
  13538. {
  13539. returnErrorMsg("已发货无法打回!");
  13540. return;
  13541. }
  13542. if (entity.OrderState == 6)
  13543. {
  13544. isPlace = true;
  13545. }
  13546. bool isNeedUpdateCell2 = false;
  13547. if (entity.OrderState >= 6)
  13548. {
  13549. isNeedUpdateCell2 = true;
  13550. }
  13551. int returnTag = 2;
  13552. if (userpost == "Supplier")
  13553. {
  13554. returnTag = 1;
  13555. }
  13556. int toType = GetPostInt("totype");
  13557. string fromType = "3";
  13558. if (entity.OrderState < 5)
  13559. {
  13560. fromType = "3";
  13561. }
  13562. else
  13563. {
  13564. fromType = "4";
  13565. }
  13566. if (entity.IsXianHuo == 0)
  13567. {
  13568. if (returnTag == 2)
  13569. {
  13570. if (toType == 1)
  13571. {
  13572. entity.OrderState = 0;
  13573. entity.ReturnUserType = 1;
  13574. string clearman = GetPostString("clearman");
  13575. if (!string.IsNullOrEmpty(clearman))
  13576. {
  13577. entity.DesignUserId = 0;
  13578. }
  13579. }
  13580. else
  13581. {
  13582. entity.OrderState = 3;
  13583. entity.ReturnUserType = 2;
  13584. }
  13585. entity.IsReadTag = 1;
  13586. }
  13587. else if (returnTag == 1)
  13588. {
  13589. entity.OrderState = 5;
  13590. }
  13591. entity.IsVerifyToSupplier = false;
  13592. }
  13593. if (entity.IsXianHuo == 1)
  13594. {
  13595. entity.OrderState = 5;
  13596. }
  13597. entity.IsVerifyToSupplier = false;
  13598. entity.IsHaveNewOrder = 0;
  13599. entity.UnusualTag = 0;
  13600. entity.UnusualTime = null;
  13601. entity.UnusualCon = "";
  13602. entity.IsReturn = returnTag;
  13603. entity.ReturnTime = DateTime.Now;
  13604. entity.UpdateTime = DateTime.Now;
  13605. entity.ReturnReason = GetPostString("returnreason");
  13606. entity.Update();
  13607. if (entity.OrderState == 3)
  13608. {
  13609. ApiVo apiVo = new ApiVo();
  13610. apiVo.orderNumber = entity.ctid;
  13611. apiVo.actionName = "rebutDesign";
  13612. apiVo.orderRemarks = entity.ReturnReason;
  13613. designHelper.API_WorkCore(apiVo);//rebutDesign
  13614. }
  13615. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason + isDown, entity.OrderState);
  13616. if (isPlace)
  13617. {
  13618. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  13619. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  13620. if (dth != null && dth.Rows.Count > 0)
  13621. {
  13622. dataSendOrderBean dataSendOrderBean = null;
  13623. foreach (DataRow item in dth.Rows)
  13624. {
  13625. try
  13626. {
  13627. dataSendOrderBean = new dataSendOrderBean();
  13628. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  13629. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  13630. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  13631. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  13632. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  13633. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  13634. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  13635. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  13636. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  13637. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  13638. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  13639. dataSendOrderBean.Radio1723534706288 = "打回";
  13640. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  13641. if (result != null)
  13642. {
  13643. if ("0".Equals(result.errcode))
  13644. {
  13645. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  13646. }
  13647. else
  13648. {
  13649. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  13650. }
  13651. }
  13652. }
  13653. catch (Exception ex)
  13654. {
  13655. }
  13656. }
  13657. }
  13658. }
  13659. returnSuccessMsg(message);
  13660. return;
  13661. }
  13662. returnErrorMsg("找不到订单记录");
  13663. }
  13664. }
  13665. public void getApplyBackCount()
  13666. {
  13667. string sql = string.Format("SELECT top 1 ctid FROM [dbo].[CE_ErpTradeCell]");
  13668. List<string> lw = new List<string>();
  13669. lw.Add("IsReturn = 4");
  13670. if (CurrentUser.UserPost.Post.Code == "Supplier")
  13671. {
  13672. lw.Add("OrderState = 6");
  13673. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  13674. }
  13675. else if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  13676. {
  13677. lw.Add("OrderState = 5");
  13678. }
  13679. else
  13680. {
  13681. ReturnSuccess("{" + string.Format("\"data\":{0}", "0") + "}");
  13682. return;
  13683. }
  13684. sql += " where " + string.Join(" and ", lw.ToArray());
  13685. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13686. List<string> list = new List<string>();
  13687. if (dataTable != null && dataTable.Rows.Count > 0)
  13688. {
  13689. foreach (DataRow row in dataTable.Rows)
  13690. {
  13691. list.Add(row["ctid"].ToString());
  13692. }
  13693. }
  13694. ReturnSuccess("{" + string.Format("\"data\":{0}", "\"" + string.Join(",", list) + "\"") + "}");
  13695. return;
  13696. }
  13697. }
  13698. }