sync.order.cs 657 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058
  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. namespace SiteCore.Handler
  54. {
  55. public partial class sync
  56. {
  57. public void get_erp_orderlist()
  58. {
  59. string poscode = CurrentUser.UserPost.Post.Code;
  60. DataStruct dStruct = GetPostStruct();
  61. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\领淘文件名命名规范.xls");
  63. //apiHelper.Api_SyncOrderByTime("598825");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  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\":1756945416000,\"deliveryType\":\"OFFLINE\",\"discountFee\":20.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1757118213000,\"lines\":[{\"latestDeliveryTime\":1757118213000,\"mark2\":[\"DELIVERED\"],\"num\":1,\"outerId\":\"JSBHUVZYT\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/490100363/O1CN01pEaojF1EYIjYhp76h_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4718408366815008220\",\"refSkuId\":\"5139754537453\",\"refSpuId\":\"641811002682\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"【撕膜留字 | 易撕无残留】\",\"status\":\"SHIPPED\",\"title\":\"水晶标贴UV转印贴logo定制透明标识贴纸设计金属商标烫金标签定做\",\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"YT7568465598389\",\"mark2\":[],\"modifyTime\":1756946987000,\"openBuyerId\":\"AAEVRHraABkUZRPgSx3gFRIR\",\"openBuyerNick\":\"a**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1756945412000,\"payTime\":1756945413000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{\"logisticNo\":\"YT7568465598389\",\"logisticName\":\"圆通速递\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"苏州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴江区\",\"receiverId\":\"871dbaa880a955e031c5061436d7a5c1$\",\"receiverState\":\"江苏省\",\"receiverTown\":\"江陵街道\",\"refOid\":\"4718408366815008220\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-不干胶-uv转印贴小尺寸字母银色黑色-aa_小f-龙井-5,寄样-不干胶-金属标字母银色黑色-aa_小f-龙井-5\",\"serviceFee\":0.0,\"shippingTime\":1756946983000,\"status\":\"SHIPPED\",\"sysTags\":[],\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0,\"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 = 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 = 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) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  217. string addwechat = GetPostString("addwechat");
  218. if (addwechat.Length > 0)
  219. {
  220. int addWt = Convert.ToInt32(addwechat);
  221. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  222. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  223. }
  224. string customer = GetPostString("customer");
  225. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  226. string design = GetPostString("design");
  227. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  228. string orderState = GetPostString("orderState");
  229. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  230. string address = GetPostString("address");
  231. 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));
  232. string sellermemo = GetPostString("seller_memo");
  233. if (sellermemo.Length > 0)
  234. {
  235. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  236. }
  237. string backReason = GetPostString("backReason");
  238. if (backReason.Length > 0)
  239. {
  240. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  241. }
  242. string apdate1 = GetPostString("apdate1");
  243. string apdate2 = GetPostString("apdate2");
  244. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  245. if (dwap.Length > 0) lw.Add(dwap);
  246. string price1 = GetPostString("price1");
  247. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  248. string price2 = GetPostString("price2");
  249. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  250. string isoldcustomer = GetPostString("isoldcus");
  251. string spudata = GetPostString("spudata");
  252. if ("0".Equals(spudata))
  253. {
  254. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  255. }
  256. if ("1".Equals(spudata))
  257. {
  258. lw.Add(string.Format("spu_id <> ''"));
  259. }
  260. string finishdate1 = GetPostString("finishdate1");
  261. string finishdate2 = GetPostString("finishdate2");
  262. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  263. bool isFinish = false;
  264. if (finishdate.Length > 0)
  265. {
  266. lw.Add(finishdate);
  267. isFinish = true;
  268. paramsCount++;
  269. }
  270. if (isoldcustomer.Length > 0)
  271. {
  272. if ("2".Equals(isoldcustomer))
  273. {
  274. lw.Add(string.Format("VipCustomer=1"));
  275. }
  276. else
  277. {
  278. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  279. }
  280. }
  281. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  282. if (ex_psize > 0)
  283. {
  284. int UserID = CurrentUser.UserID;
  285. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  286. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  287. {
  288. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  289. }
  290. dStruct.Order = "pay_time desc";
  291. }
  292. string isNew = GetPostString("isNew");
  293. if (isNew == "true")
  294. {
  295. lw.Add(string.Format("IsNew = {0}", 1));
  296. }
  297. string overtime = GetPostString("overtime");
  298. if (overtime == "1")
  299. {
  300. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  301. }
  302. String usePost = CurrentUser.UserPost.Post.Code;
  303. if (usePost.Equals("Operation") == true)
  304. {
  305. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  306. }
  307. else
  308. {
  309. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  310. }
  311. //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";
  312. if (dStruct.PageSize == 100000)
  313. {
  314. dStruct.Order = "";
  315. }
  316. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  317. DataTable dt = null;
  318. string tablename = "view_orderlist";
  319. if (isFinish)
  320. {
  321. tablename = "view_orderlist_end";
  322. }
  323. dt = WebCache.GetData(tablename, dStruct);
  324. if (dt != null && dt.Rows.Count > 0)
  325. {
  326. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  327. foreach (DataRow dr in dt.Rows)
  328. {
  329. try
  330. {
  331. if (dr["refund_fees"] != null)
  332. {
  333. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  334. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  335. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  336. if (payment == refund_fees)
  337. {
  338. dr["refund_fees"] = Math.Round(refund_fees, 2);
  339. }
  340. else if (refund_fees == total_fee)
  341. {
  342. dr["refund_fees"] = payment;
  343. }
  344. else
  345. {
  346. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  347. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  348. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  349. }
  350. }
  351. // 对象操作
  352. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  353. ceErpTradeCell.ctid = dr["ctid"].ToString();
  354. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  355. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  356. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  357. if (dStruct.PageSize != 100000)
  358. {
  359. if (dr["DispatchSort"].ToString() == "2")
  360. {
  361. dr["gongchuang"] = 200;
  362. }
  363. else if ("外协".Equals(dr["ToType"].ToString()))
  364. {
  365. dr["gongchuang"] = 200;
  366. }
  367. else if ("内部".Equals(dr["ToType"].ToString()))
  368. {
  369. dr["gongchuang"] = -1;
  370. }
  371. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  372. {
  373. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  374. dr["gongchuang"] = response.code;
  375. }
  376. }
  377. }
  378. catch (NullReferenceException ex)
  379. {
  380. // 处理空引用异常
  381. dr["refund_fees"] = "0.00";
  382. }
  383. }
  384. }
  385. writeGridDataTableJson(dStruct.TotalCount, dt);
  386. }
  387. public void get_erp_orderlist_sumprice()
  388. {
  389. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  390. return;
  391. List<string> lw = new List<string>();
  392. string tid = GetPostString("ctid");
  393. string date1 = GetPostString("date1");
  394. string date2 = GetPostString("date2");
  395. if (tid.Length > 0 || date1.Length > 0)
  396. {
  397. lw.Add(string.Format("ctid like '%{0}%'", tid));
  398. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  399. if (dw.Length > 0) lw.Add(dw);
  400. }
  401. else
  402. {
  403. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  404. }
  405. string shopname = GetPostString("shopname");
  406. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  407. string buyernick = GetPostString("buyer_nick");
  408. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  409. string customer = GetPostString("customer");
  410. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  411. string design = GetPostString("design");
  412. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  413. string orderState = GetPostString("orderState");
  414. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  415. string address = GetPostString("address");
  416. 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));
  417. string sellermemo = GetPostString("seller_memo");
  418. if (sellermemo.Length > 0)
  419. {
  420. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  421. }
  422. string apdate1 = GetPostString("apdate1");
  423. string apdate2 = GetPostString("apdate2");
  424. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  425. if (dwap.Length > 0) lw.Add(dwap);
  426. string price1 = GetPostString("price1");
  427. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  428. string price2 = GetPostString("price2");
  429. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  430. string isoldcustomer = GetPostString("isoldcus");
  431. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  432. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  433. if (PKey != "admin")
  434. {
  435. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  436. lw.Add(string.Format("shopId in ({0})", usershop));
  437. }
  438. //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";
  439. string mainWhere = string.Join(" and ", lw.ToArray());
  440. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  441. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  442. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  443. decimal total = 0;
  444. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  445. {
  446. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  447. }
  448. var res = new
  449. {
  450. data = total
  451. };
  452. string ro_jsond = JsonConvert.SerializeObject(res);
  453. returnSuccess(ro_jsond);
  454. return;
  455. }
  456. public void get_erp_CustomerServiceGather()
  457. {
  458. string userWhere = "", orderWhere = "";
  459. List<string> lw = new List<string>();
  460. string customer = GetPostString("customer");
  461. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  462. string shopname = GetPostString("shopname");
  463. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  464. string date1 = GetPostString("date1");
  465. string date2 = GetPostString("date2");
  466. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  467. if (dw.Length > 0) lw.Add(dw);
  468. orderWhere = string.Join(" and ", lw.ToArray());
  469. 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 " +
  470. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  471. "left join " +
  472. "( " +
  473. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  474. ") as b on a.ID = b.CustomerUserId " +
  475. "left join " +
  476. "( " +
  477. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  478. ") as d on a.ID = d.CustomerUserId " +
  479. "left join " +
  480. "( " +
  481. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  482. ") as e on a.ID = e.CustomerUserId " +
  483. "left join " +
  484. "( " +
  485. " select CustomerUserId, RefundCount, RefundSum from " +
  486. " ( " +
  487. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  488. " from CE_ErpTradeRefund a " +
  489. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  490. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  491. " group by CustomerUserId " +
  492. " ) as a " +
  493. ") as f on a.ID = f.CustomerUserId " +
  494. "where a.PostCode = 'CustomerService'",
  495. userWhere, orderWhere);
  496. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  497. writeGridDataTableJson(dt.Rows.Count, dt);
  498. //writeGridDataTableJson(dt.Rows.Count, dt);
  499. }
  500. //设计汇总
  501. public void get_erp_DesignerGather()
  502. {
  503. string userWhere = "", orderWhere = "";
  504. List<string> lw = new List<string>();
  505. string Designer = GetPostString("designer");
  506. int org = GetPostInt("org");
  507. if (Designer.Length > 0)
  508. {
  509. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  510. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  511. }
  512. else if (org > 0)
  513. {
  514. userWhere = string.Format(" where OrgID ={0}", org);
  515. }
  516. string shopname = GetPostString("shopname");
  517. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  518. string state = GetPostString("state");
  519. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  520. string OrderArea = GetPostString("order_area");
  521. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  522. string date1 = GetPostString("date1");
  523. string date2 = GetPostString("date2");
  524. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  525. if (dw.Length > 0) lw.Add(dw);
  526. string UpDate1 = GetPostString("UpDate1");
  527. string UpDate2 = GetPostString("UpDate2");
  528. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  529. if (dw.Length > 0) lw.Add(dw);
  530. orderWhere = string.Join(" and ", lw.ToArray());
  531. 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 (" +
  532. "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 " +
  533. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  534. "left join " +
  535. "( " +
  536. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  537. ") as b on a.ID = b.DesignUserId " +
  538. "left join " +
  539. "( " +
  540. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  541. ") as d on a.ID = d.DesignUserId " +
  542. "left join " +
  543. "( " +
  544. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  545. ") as e on a.ID = e.DesignUserId " +
  546. "left join " +
  547. "( " +
  548. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  549. ") as g on a.ID = g.DesignUserId " +
  550. "left join " +
  551. "( " +
  552. " select CustomerUserId, RefundCount, RefundSum from " +
  553. " ( " +
  554. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  555. " from CE_ErpTradeRefund a " +
  556. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  557. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  558. " group by CustomerUserId " +
  559. " ) as a " +
  560. ") as f on a.ID = f.CustomerUserId " +
  561. "where a.PostCode = 'Designer') as z",
  562. userWhere, orderWhere);
  563. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  564. writeGridDataTableJson(dt.Rows.Count, dt);
  565. }
  566. //删除tradecell的订单
  567. public void del_erp_cellorder()
  568. {
  569. if (UrlPostParmsCheck("ctid"))
  570. {
  571. string eid = GetPostString("ctid");
  572. CeErpTradeCell.DelByCtid(eid);
  573. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  574. returnSuccessMsg("删除成功");
  575. }
  576. }
  577. public void clear_erp_refundstate()
  578. {
  579. if (UrlPostParmsCheck("ids"))
  580. {
  581. string eids = GetPostString("ids");
  582. string[] ctidList = eids.Split(',');
  583. foreach (string ctid in ctidList)
  584. {
  585. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  586. if (entity != null)
  587. {
  588. entity.IsRefund = 0;
  589. entity.Update();
  590. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  591. }
  592. else
  593. continue;
  594. }
  595. returnSuccessMsg("操作成功");
  596. return;
  597. }
  598. returnErrorMsg("缺少必要参数");
  599. }
  600. public void set_erp_urgency()
  601. {
  602. if (UrlPostParmsCheck("ctid"))
  603. {
  604. string eid = GetPostString("ctid");
  605. CeErpTradeCell entity = null;
  606. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  607. if (entity != null)
  608. {
  609. double prices = commonHelper.calculationPrice(entity);
  610. if (prices <= 100)
  611. {
  612. returnErrorMsg("此订单金额不足100元,无法加急。");
  613. return;
  614. }
  615. string utime = GetPostString("urgencytime");
  616. if (utime.Length > 0)
  617. {
  618. entity.UrgencyTime = Convert.ToDateTime(utime);
  619. }
  620. else
  621. {
  622. returnErrorMsg("请选择加急时间");
  623. return;
  624. }
  625. if (entity.OrderState <= 4)
  626. {
  627. //entity.seller_memo = entity.seller_memo + "-加急";
  628. string smemo = entity.seller_memo;
  629. int kindex = smemo.IndexOf(")");
  630. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  631. if (lastoneStr != "-")
  632. {
  633. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  634. }
  635. string prememo = smemo.Substring(0, kindex + 2);
  636. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  637. int lastkindex = lastmemo.IndexOf("(");
  638. DateTime urgtime = Convert.ToDateTime(utime);
  639. string newlastmemo = "";
  640. if (lastkindex == 0)
  641. {
  642. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  643. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  644. }
  645. else
  646. {
  647. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  648. }
  649. entity.seller_memo = prememo + newlastmemo;
  650. }
  651. entity.IsUrgency = true;
  652. entity.UpdateTime = DateTime.Now;
  653. entity.Update();
  654. ApiVo apiVo = new ApiVo();
  655. apiVo.orderNumber = entity.ctid;
  656. apiVo.actionName = "changeDesign";
  657. apiVo.orderRemarks = entity.seller_memo;
  658. apiVo.remarkSign = 3;
  659. designHelper.API_WorkCore(apiVo); //changeDesign
  660. CeErpSukuraData.createInfo(entity.ctid, 7);
  661. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  662. returnSuccessMsg("设置成功!");
  663. return;
  664. }
  665. returnErrorMsg("找不到记录");
  666. }
  667. }
  668. public void set_erp_reset()
  669. {
  670. if (UrlPostParmsCheck("ctid"))
  671. {
  672. string eid = GetPostString("ctid");
  673. CeErpTradeCell entity = null;
  674. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  675. if (entity != null)
  676. {
  677. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  678. {
  679. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  680. {
  681. returnErrorMsg("财务要求已下单已发货无法重置");
  682. return;
  683. }
  684. }
  685. entity.IsUrgency = false;
  686. entity.seller_memo = "";
  687. entity.OtherMemo = "";
  688. entity.OrderState = 0;
  689. entity.IsReturn = 0;
  690. //entity.IsRefund = 0;
  691. entity.MemoOpt = 0;
  692. entity.AfterSaleState = 0;
  693. entity.AfterSaleResponsible = "";
  694. entity.AfterSaleUserId = 0;
  695. entity.IsNeedBill = 0;
  696. entity.CustomerUserId = 0;
  697. entity.DesignUserId = 0;
  698. entity.SupplierId = 0;
  699. entity.PlaceUserId = 0;
  700. entity.ptid = "";
  701. entity.IsSample = 0;
  702. entity.IsXianHuo = 0;
  703. entity.isDianziOrder = 0;
  704. entity.DispatchSort = 0;
  705. entity.IsVerifyToSupplier = false;
  706. entity.FinishPlaceTime = null;
  707. entity.Update();
  708. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  709. if (trade != null)
  710. {
  711. trade.seller_memo = "";
  712. trade.Update();
  713. }
  714. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  715. returnSuccessMsg("重置成功!");
  716. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  717. if (desginBill != null)
  718. {
  719. desginBill.isDel = 1;
  720. desginBill.Update();
  721. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  722. }
  723. ApiVo apiVo = new ApiVo();
  724. apiVo.orderNumber = entity.ctid;
  725. apiVo.actionName = "resetDesign";
  726. designHelper.API_WorkCore(apiVo);//resetDesign
  727. return;
  728. }
  729. returnErrorMsg("找不到记录");
  730. }
  731. }
  732. public void save_erp_sellermemo()
  733. {
  734. if (UrlPostParmsCheck("ctid"))
  735. {
  736. string ctid = GetPostString("ctid");
  737. CeErpTradeCell entity = null;
  738. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  739. if (entity != null)
  740. {
  741. string memo = GetPostString("seller_memo");
  742. string qn_memo = GetPostString("qn_memo");
  743. memo = memo.Replace(" ", "");
  744. if (memo.Contains("补差"))
  745. {
  746. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  747. return;
  748. }
  749. List<string> bitList = new List<string>
  750. {
  751. "\\","/",":","*","?", "\"","<" ,">","|"
  752. };
  753. bool isIn = false;
  754. foreach (string bit in bitList)
  755. {
  756. if (memo.Contains(bit))
  757. {
  758. isIn = true;
  759. }
  760. }
  761. if (isIn)
  762. {
  763. returnErrorMsg("不能使用 一些符合作为文件名");
  764. return;
  765. }
  766. if (entity.seller_memo != memo)
  767. {
  768. if (entity.IsSample == 2)
  769. {
  770. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  771. return;
  772. }
  773. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  774. {
  775. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  776. {
  777. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  778. return;
  779. }
  780. /*if (CurrentUser.UserPost.Post.Code != "Place")
  781. {
  782. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  783. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  784. {
  785. returnErrorMsg("售前系统订单无法再此修改!");
  786. return;
  787. }
  788. }*/
  789. }
  790. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  791. }
  792. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  793. {
  794. if (entity.OrderState >= 5)
  795. {
  796. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  797. return;
  798. }
  799. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  800. if (string.IsNullOrEmpty(delMemo))
  801. {
  802. returnErrorMsg("备注不规范,无法识别");
  803. return;
  804. }
  805. memo = delMemo;
  806. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  807. }
  808. commonHelper.getCytPrice(entity);
  809. int memoopt = GetPostInt("MemoOpt");
  810. Boolean ismemoopt = false;
  811. if (memoopt > 0)
  812. {
  813. string stropt = "";
  814. if (memoopt == 1)
  815. {
  816. stropt = "“改稿”";
  817. ismemoopt = true;
  818. }
  819. else if (memoopt == 2)
  820. {
  821. stropt = "“定稿”";
  822. }
  823. else if (memoopt == 3)
  824. {
  825. stropt = "“查货”";
  826. CeErpSukuraData.createInfo(entity.ctid, 6);
  827. }
  828. entity.MemoOpt = Convert.ToInt32(memoopt);
  829. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  830. }
  831. if (entity.OrderState < 5)
  832. {
  833. memo = memo.Replace("(", "(");
  834. memo = memo.Replace(")", ")");
  835. }
  836. /* if (entity.OrderState < 3)
  837. {
  838. entity.DispatchSort = 0;
  839. }*/
  840. entity.seller_memo = memo;
  841. entity.UpdateTime = DateTime.Now;
  842. entity.Update();
  843. ApiVo apiVo = new ApiVo();
  844. apiVo.orderNumber = entity.ctid;
  845. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  846. apiVo.orderRemarks = memo;
  847. apiVo.remarkSign = memoopt;
  848. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  849. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  850. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  851. {
  852. dataHelper.api_orderBack(entity.ctid, "0", "");
  853. }
  854. if (entity.seller_memo.Contains("改稿"))
  855. {
  856. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  857. }
  858. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  859. returnSuccessMsg("保存成功!");
  860. return;
  861. }
  862. returnErrorMsg("找不到记录");
  863. }
  864. }
  865. public void ins_erp_checkorder()
  866. {
  867. if (UrlPostParmsCheck("ctid"))
  868. {
  869. string ctid = GetPostString("ctid");
  870. CeErpTradeCell entity = null;
  871. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  872. if (entity != null)
  873. {
  874. if (entity.OrderState < 6)
  875. {
  876. returnErrorMsg("下单完成后才可查货");
  877. return;
  878. }
  879. /*if (entity.OrderState > 6)
  880. {
  881. returnErrorMsg("订单已发货");
  882. return;
  883. }*/
  884. if (entity.FinishPlaceTime != null)
  885. {
  886. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  887. {
  888. returnErrorMsg("下单时间不足,无法查货");
  889. return;
  890. }
  891. }
  892. entity.MemoOpt = 3;
  893. entity.CheckOrderTime = DateTime.Now;
  894. entity.UpdateTime = DateTime.Now;
  895. entity.Update();
  896. CeErpSukuraData.createInfo(entity.ctid, 6);
  897. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  898. returnSuccessMsg("操作成功!");
  899. return;
  900. }
  901. returnErrorMsg("找不到记录");
  902. }
  903. }
  904. public void save_erp_othermemo()
  905. {
  906. if (UrlPostParmsCheck("ctid"))
  907. {
  908. string ctid = GetPostString("ctid");
  909. CeErpTradeCell entity = null;
  910. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  911. if (entity != null)
  912. {
  913. entity.OtherMemo = GetPostString("otherMemo");
  914. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  915. {
  916. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  917. StringBuilder sql = new StringBuilder();
  918. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  919. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  920. if (dt != null && dt.Rows.Count > 0)
  921. {
  922. foreach (DataRow dr in dt.Rows)
  923. {
  924. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  925. {
  926. //品类一直
  927. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  928. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  929. if (ceErpSampleCustomer == null)
  930. {
  931. ceErpSampleCustomer = new CeErpSampleCustomer();
  932. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  933. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  934. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  935. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  936. ceErpSampleCustomer.shopId = entity.ShopId;
  937. }
  938. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  939. ceErpSampleCustomer.lastTid = entity.tid;
  940. if (ceErpSampleCustomer.ID > 0)
  941. {
  942. ceErpSampleCustomer.Update();
  943. }
  944. else
  945. {
  946. ceErpSampleCustomer.Create();
  947. }
  948. }
  949. }
  950. }
  951. }
  952. //if (entity.IsOldCustomer == 1)
  953. //{
  954. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  955. //{
  956. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  957. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  958. //}
  959. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  960. //{
  961. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  962. // {
  963. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  964. // {
  965. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  966. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  967. // }
  968. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  969. // {
  970. // entity.OrderState = 2;
  971. // entity.DesignUserId = 0;
  972. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  973. // }
  974. // else
  975. // {
  976. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  977. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  978. // }
  979. // }
  980. //}
  981. //}
  982. entity.UpdateTime = DateTime.Now;
  983. entity.Update();
  984. returnSuccessMsg("保存成功!");
  985. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  986. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  987. if (entity.OtherMemo.Contains("改稿"))
  988. {
  989. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  990. }
  991. return;
  992. }
  993. returnErrorMsg("找不到记录");
  994. }
  995. }
  996. public void save_erp_customermemo()
  997. {
  998. if (UrlPostParmsCheck("ctid"))
  999. {
  1000. string ctid = GetPostString("ctid");
  1001. CeErpTradeCell entity = null;
  1002. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1003. if (entity != null)
  1004. {
  1005. entity.UpdateTime = DateTime.Now;
  1006. entity.CustomerMemo = GetPostString("CustomerMemo");
  1007. entity.Update();
  1008. ApiVo apiVo = new ApiVo();
  1009. apiVo.orderNumber = entity.ctid;
  1010. apiVo.actionName = "followRemarks";
  1011. apiVo.orderRemarks = entity.CustomerMemo;
  1012. designHelper.API_WorkCore(apiVo);//followRemarks
  1013. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1014. returnSuccessMsg("保存成功!");
  1015. return;
  1016. }
  1017. returnErrorMsg("找不到记录");
  1018. }
  1019. }
  1020. public void upd_erp_addmemotag()
  1021. {
  1022. if (UrlPostParmsCheck("ctid"))
  1023. {
  1024. ;
  1025. string eid = GetPostString("ctid");
  1026. string sfTagstr = GetPostString("memotag");
  1027. CeErpTradeCell entity = null;
  1028. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1029. if (entity != null)
  1030. {
  1031. ApiVo apiVo = new ApiVo();
  1032. if (entity.OrderState == 0)
  1033. {
  1034. returnErrorMsg("请先领单");
  1035. return;
  1036. }
  1037. //撤销顺丰
  1038. if (sfTagstr == "撤销顺丰")
  1039. {
  1040. entity.IsSF = 0;
  1041. string reMsg = "";
  1042. string oldmemo = entity.seller_memo;
  1043. if (entity.OrderState < 5)
  1044. {
  1045. oldmemo = oldmemo.Replace("顺丰到付", "");
  1046. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1047. entity.seller_memo = oldmemo;
  1048. }
  1049. else
  1050. {
  1051. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1052. {
  1053. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1054. }
  1055. }
  1056. entity.Update();
  1057. apiVo.orderNumber = entity.ctid;
  1058. apiVo.actionName = "orderRemarks";
  1059. apiVo.orderRemarks = entity.seller_memo;
  1060. apiVo.isSf = entity.IsSF.ToString();
  1061. designHelper.API_WorkCore(apiVo);//orderRemarks
  1062. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1063. returnSuccessMsg("撤销成功!" + reMsg);
  1064. return;
  1065. }
  1066. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1067. {
  1068. //string oldmemo = entity.seller_memo;
  1069. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1070. string sfStr = GetPostString("memotag");
  1071. string smemo = entity.seller_memo;
  1072. int kindex = smemo.IndexOf(")");
  1073. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1074. if (lastoneStr != "-")
  1075. {
  1076. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1077. }
  1078. string prememo = smemo.Substring(0, kindex + 2);
  1079. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1080. int lastkindex = lastmemo.IndexOf("(");
  1081. string newlastmemo = "";
  1082. if (lastkindex == 0)
  1083. {
  1084. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1085. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1086. }
  1087. else
  1088. {
  1089. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1090. }
  1091. entity.seller_memo = prememo + newlastmemo;
  1092. }
  1093. string sfTagMSg = "";
  1094. if (sfTagstr == "顺丰寄付")
  1095. {
  1096. entity.IsSF = 1;
  1097. sfTagMSg = "顺丰寄付";
  1098. }
  1099. else if (sfTagstr == "顺丰到付")
  1100. {
  1101. entity.IsSF = 2;
  1102. sfTagMSg = "顺丰到付";
  1103. }
  1104. entity.Update();
  1105. apiVo = new ApiVo();
  1106. apiVo.orderNumber = entity.ctid;
  1107. apiVo.actionName = "orderRemarks";
  1108. apiVo.orderRemarks = entity.seller_memo;
  1109. apiVo.isSf = entity.IsSF.ToString();
  1110. designHelper.API_WorkCore(apiVo);//orderRemarks
  1111. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1112. returnSuccessMsg("标记成功!");
  1113. return;
  1114. }
  1115. returnErrorMsg("找不到记录");
  1116. }
  1117. }
  1118. public void upd_erp_ordertag()
  1119. {
  1120. if (UrlPostParmsCheck("ctid"))
  1121. {
  1122. string eid = GetPostString("ctid");
  1123. CeErpTradeCell entity = null;
  1124. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1125. if (entity != null)
  1126. {
  1127. int tag = GetPostInt("wechattag");
  1128. //if(tag==4 && entity.IsSample == 2)
  1129. //{
  1130. // returnErrorMsg("补差价单不能标记微信单");
  1131. // return;
  1132. //}
  1133. entity.wechatTag = tag;
  1134. entity.Update();
  1135. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1136. if (tag == 1)
  1137. {
  1138. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1139. if (cash == null)
  1140. {
  1141. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1142. cash = new CeErpReturnCash();
  1143. cash.tid = entity.tid;
  1144. cash.seller_nick = main.seller_nick;
  1145. cash.payment = trade.payment;
  1146. cash.buyer_nick = main.buyer_nick;
  1147. cash.cashstate = 0;
  1148. cash.rtype = "微信返现";
  1149. cash.returnprice = 0;
  1150. cash.created = DateTime.Now;
  1151. cash.con = "订单标记微信单";
  1152. cash.img = "";
  1153. cash.applyuserid = CurrentUser.UserID;
  1154. cash.Create();
  1155. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1156. }
  1157. else
  1158. {
  1159. cash.cashstate = 0;
  1160. cash.Update();
  1161. }
  1162. CeErpSukuraData.createInfo(entity.ctid, 9);
  1163. }
  1164. else if (tag == 2)
  1165. {
  1166. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1167. if (cash == null)
  1168. {
  1169. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1170. cash = new CeErpReturnCash();
  1171. cash.tid = entity.tid;
  1172. cash.seller_nick = main.seller_nick;
  1173. cash.payment = trade.payment;
  1174. cash.buyer_nick = main.buyer_nick;
  1175. cash.cashstate = 0;
  1176. cash.rtype = "推购返现";
  1177. cash.returnprice = 5;
  1178. cash.created = DateTime.Now;
  1179. cash.con = "订单标记推购单";
  1180. cash.img = "";
  1181. cash.applyuserid = CurrentUser.UserID;
  1182. cash.Create();
  1183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1184. }
  1185. else
  1186. {
  1187. cash.cashstate = 0;
  1188. cash.Update();
  1189. }
  1190. CeErpSukuraData.createInfo(entity.ctid, 9);
  1191. }
  1192. else if (tag == 3)
  1193. {
  1194. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1195. if (pers == null)
  1196. {
  1197. pers = new CeErpPersuade();
  1198. pers.ctid = entity.ctid;
  1199. pers.pstate = 0;
  1200. pers.created = DateTime.Now;
  1201. pers.applyuserid = CurrentUser.UserID;
  1202. pers.Create();
  1203. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1204. }
  1205. else
  1206. {
  1207. pers.pstate = 0;
  1208. pers.Update();
  1209. }
  1210. }
  1211. else if (tag == 4 || tag == 5)
  1212. {
  1213. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1214. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1215. if (pers == null)
  1216. {
  1217. pers = CeErpStayGoods.GetByTid(entity.tid);
  1218. }
  1219. if (pers == null)
  1220. {
  1221. pers = new CeErpStayGoods();
  1222. pers.t_id = entity.tid;
  1223. pers.ctid = entity.ctid;
  1224. pers.status = "待审核";
  1225. pers.audit_type = 0;
  1226. if (tag == 4)
  1227. {
  1228. pers.stay_type = "微信推购";
  1229. }
  1230. else
  1231. {
  1232. pers.stay_type = "旺旺推购";
  1233. }
  1234. if (entity.IsXianHuo == 0)
  1235. {
  1236. pers.product_id = entity.ProductId;
  1237. }
  1238. pers.wangwang = main.buyer_nick;
  1239. pers.shop_name = main.seller_nick;
  1240. pers.creata_time = DateTime.Now;
  1241. pers.create_u_id = CurrentUser.UserID;
  1242. pers.create_u_name = CurrentUser.UserName;
  1243. pers.Create();
  1244. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1245. }
  1246. else
  1247. {
  1248. pers.ctid = entity.ctid;
  1249. pers.audit_type = 0;
  1250. pers.Update();
  1251. }
  1252. CeErpSukuraData.createInfo(entity.ctid, 10);
  1253. }
  1254. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1255. returnSuccessMsg("标记成功!");
  1256. return;
  1257. }
  1258. returnErrorMsg("找不到记录");
  1259. }
  1260. }
  1261. public void upd_erp_ordertag_cancel()
  1262. {
  1263. if (UrlPostParmsCheck("ctid"))
  1264. {
  1265. string eid = GetPostString("ctid");
  1266. CeErpTradeCell entity = null;
  1267. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1268. if (entity != null)
  1269. {
  1270. entity.wechatTag = 0;
  1271. entity.Update();
  1272. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1273. if (pers != null)
  1274. {
  1275. pers.status = "取消推购";
  1276. pers.audit_type = 3;
  1277. pers.Update();
  1278. }
  1279. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1280. returnSuccessMsg("标记成功!");
  1281. return;
  1282. }
  1283. returnErrorMsg("找不到记录");
  1284. }
  1285. }
  1286. public void upd_erp_addweichattag()
  1287. {
  1288. if (UrlPostParmsCheck("ctid"))
  1289. {
  1290. ;
  1291. string eid = GetPostString("ctid");
  1292. CeErpTradeCell entity = null;
  1293. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1294. if (entity != null)
  1295. {
  1296. if (entity.IsAddWechat > 0)
  1297. {
  1298. returnErrorMsg("此单已经标记过了");
  1299. return;
  1300. }
  1301. 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);
  1302. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1303. if (dt.Rows.Count > 0)
  1304. {
  1305. entity.IsAddWechat = 2;
  1306. }
  1307. else
  1308. {
  1309. entity.IsAddWechat = 1;
  1310. }
  1311. entity.Update();
  1312. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1313. returnSuccessMsg("标记成功!");
  1314. return;
  1315. }
  1316. returnErrorMsg("找不到记录");
  1317. }
  1318. }
  1319. public void upd_erp_getmyorder()
  1320. {
  1321. if (UrlPostParmsCheck("ctid"))
  1322. {
  1323. string eid = GetPostString("ctid");
  1324. CeErpTradeCell entity = null;
  1325. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1326. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1327. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1328. {
  1329. returnErrorMsg("台湾客户需填写身份证号!");
  1330. return;
  1331. }
  1332. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1333. {
  1334. returnErrorMsg("偏远地区需要填写物流费!");
  1335. return;
  1336. }
  1337. if (entity != null)
  1338. {
  1339. if (entity.ctid.IndexOf("C") != -1)
  1340. {
  1341. StringBuilder sql = new StringBuilder();
  1342. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1343. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1344. if (dt.Rows.Count > 0)
  1345. {
  1346. decimal total = 0;
  1347. foreach (DataRow dr in dt.Rows)
  1348. {
  1349. total += Convert.ToDecimal(dr["payment"]);
  1350. }
  1351. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1352. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1353. {
  1354. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1355. return;
  1356. }
  1357. }
  1358. }
  1359. if (entity.OrderState == -1)
  1360. {
  1361. returnErrorMsg("待审核订单无法领取!");
  1362. return;
  1363. }
  1364. entity.CustomerUserId = CurrentUser.UserID;
  1365. if (entity.OrderState < 2)
  1366. {
  1367. entity.OrderState = 2;
  1368. if (entity.ShopId != 0)
  1369. {
  1370. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1371. }
  1372. }
  1373. entity.UpdateTime = DateTime.Now;
  1374. entity.Update();
  1375. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1376. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1377. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1378. {
  1379. dataHelper.api_orderBack(entity.ctid, "0", "");
  1380. }
  1381. returnSuccessMsg("领单成功!");
  1382. return;
  1383. }
  1384. returnErrorMsg("找不到记录");
  1385. }
  1386. }
  1387. public void getmyorder_from_init()
  1388. {
  1389. if (UrlPostParmsCheck("ctid"))
  1390. {
  1391. string eid = GetPostString("ctid");
  1392. CeErpTradeCell entity = null;
  1393. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1394. if (entity != null)
  1395. {
  1396. string sellerMemo = GetPostString("sellerMemo");
  1397. if (sellerMemo.Length > 0)
  1398. {
  1399. entity.seller_memo = sellerMemo;
  1400. }
  1401. string oterhMemo = GetPostString("otherMemo");
  1402. if (oterhMemo.Length > 0)
  1403. {
  1404. entity.OtherMemo = oterhMemo;
  1405. }
  1406. int urg = GetPostInt("urgency");
  1407. entity.IsUrgency = (urg == 1 ? true : false);
  1408. int wechat = GetPostInt("wechat");
  1409. int command = GetPostInt("command");
  1410. if (wechat == 1)
  1411. {
  1412. entity.wechatTag = 1;
  1413. }
  1414. if (command == 1)
  1415. {
  1416. entity.wechatTag = 2;
  1417. }
  1418. string pPro = GetPostString("pprofession");
  1419. if (pPro.Length > 0)
  1420. {
  1421. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1422. string spro = GetPostString("profession");
  1423. if (spro.Length > 0)
  1424. {
  1425. entity.ProfessionId = Convert.ToInt32(spro);
  1426. }
  1427. }
  1428. string proId = GetPostString("productId");
  1429. if (proId.Length > 0)
  1430. {
  1431. entity.ProductId = Convert.ToInt32(proId);
  1432. }
  1433. entity.Material = GetPostString("material");
  1434. entity.Craft = GetPostString("craft");
  1435. entity.CustomerUserId = CurrentUser.UserID;
  1436. if (entity.OrderState < 2)
  1437. {
  1438. entity.OrderState = 2;
  1439. if (entity.ShopId != 0)
  1440. {
  1441. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1442. }
  1443. }
  1444. entity.Update();
  1445. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1446. returnSuccessMsg("领单成功!");
  1447. return;
  1448. }
  1449. returnErrorMsg("找不到记录");
  1450. }
  1451. }
  1452. public void upd_erp_setrelationorder()
  1453. {
  1454. if (UrlPostParmsCheck("ctid"))
  1455. {
  1456. ;
  1457. string eid = GetPostString("ctid");
  1458. string ftid = GetPostString("ftid");
  1459. CeErpTradeCell entity = null;
  1460. CeErpTradeCell fentity = null;
  1461. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1462. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1463. if (fentity == null)
  1464. {
  1465. returnErrorMsg("找不到关联的主订单");
  1466. return;
  1467. }
  1468. if (entity != null)
  1469. {
  1470. if (entity.OrderState >= 5)
  1471. {
  1472. returnErrorMsg("本单已经设计完成无法关联");
  1473. return;
  1474. }
  1475. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1476. {
  1477. returnErrorMsg("线下单续审核后才能关联!");
  1478. return;
  1479. }
  1480. entity.ptid = ftid;
  1481. entity.OrderState = fentity.OrderState;
  1482. //entity.status = fentity.status;
  1483. entity.CustomerUserId = fentity.CustomerUserId;
  1484. entity.DesignUserId = fentity.DesignUserId;
  1485. entity.seller_memo = "补差价单:" + ftid;
  1486. entity.IsSample = 2;
  1487. entity.Update();
  1488. ApiVo apiVo = new ApiVo();
  1489. apiVo.orderNumber = ftid;
  1490. apiVo.payment = entity.payment;
  1491. apiVo.actionName = "repairDesign";
  1492. designHelper.API_WorkCore(apiVo);//repairDesign
  1493. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1494. returnSuccessMsg("关联成功!");
  1495. return;
  1496. }
  1497. else
  1498. returnErrorMsg("找不到记录");
  1499. }
  1500. }
  1501. public void download_erp_neworder()
  1502. {
  1503. string seller = GetPostString("seller_nick");
  1504. string tid = GetPostString("tid");
  1505. if (seller.Length <= 0 || tid.Length <= 0)
  1506. {
  1507. returnErrorMsg("数据错误");
  1508. }
  1509. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1510. //{
  1511. // returnErrorMsg("找不到店铺Sessionkey");
  1512. //}
  1513. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1514. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1515. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1516. if (res.IndexOf("refOid") == -1)
  1517. {
  1518. returnErrorMsg("下载订单数据失败");
  1519. return;
  1520. }
  1521. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1522. returnSuccessMsg("下载完成");
  1523. //tmcHelper.createNewOrder(res);
  1524. //CeErpTrade entr = null;
  1525. //entr = CeErpTrade.Get(tid);
  1526. //if (entr != null)
  1527. //{
  1528. // returnSuccess("下载成功");
  1529. // //下载成功之后,Cell表生成对应的订单;
  1530. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1531. //}
  1532. //else
  1533. //{
  1534. // returnErrorMsg("下载失败或者创建订单失败");
  1535. //}
  1536. }
  1537. public void set_erp_atersale()
  1538. {
  1539. if (UrlPostParmsCheck("ctid"))
  1540. {
  1541. string eid = GetPostString("ctid");
  1542. string reason = GetPostString("AfterSaleReason");
  1543. CeErpTradeCell entity = null;
  1544. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1545. if (entity != null)
  1546. {
  1547. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1548. {
  1549. returnErrorMsg("此订单已经在售后");
  1550. return;
  1551. }*/
  1552. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1553. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1554. entity.AfterSaleTime = DateTime.Now;
  1555. entity.HandleTime = null;
  1556. entity.Update();
  1557. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1558. returnSuccessMsg("转售后成功!");
  1559. return;
  1560. }
  1561. returnErrorMsg("找不到记录");
  1562. }
  1563. }
  1564. public void set_erp_withdraw()
  1565. {
  1566. if (UrlPostParmsCheck("ctid"))
  1567. {
  1568. try
  1569. {
  1570. string eid = GetPostString("ctid");//商品id
  1571. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1572. CeWithdraw ceWithdrawSelect = null;
  1573. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1574. if (ceWithdrawSelect != null)
  1575. {
  1576. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1577. {
  1578. ceWithdrawSelect.status = -1;
  1579. ceWithdrawSelect.Update();
  1580. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1581. returnSuccessMsg("重新发起审核成功");
  1582. return;
  1583. }
  1584. else
  1585. {
  1586. returnSuccessMsg("请勿重复申请!");
  1587. return;
  1588. }
  1589. }
  1590. else
  1591. {
  1592. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1593. if (string.IsNullOrEmpty(CustomerUserId))
  1594. {
  1595. CustomerUserId = "-1";
  1596. }
  1597. int Userid = CurrentUser.UserID;//用户id
  1598. CeWithdraw ceWithdraw = new CeWithdraw();
  1599. ceWithdraw.tid = eid;
  1600. ceWithdraw.userid = Userid;
  1601. ceWithdraw.providerid = CustomerUserId;
  1602. ceWithdraw.status = 3;
  1603. ceWithdraw.creationtime = DateTime.Now;
  1604. ceWithdraw.Create();
  1605. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1606. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1607. return;
  1608. }
  1609. }
  1610. catch
  1611. {
  1612. returnErrorMsg("申请撤回订单失败");
  1613. return;
  1614. }
  1615. }
  1616. }
  1617. public void ins_erp_billinfo()
  1618. {
  1619. if (UrlPostParmsCheck("ctid"))
  1620. {
  1621. string eid = GetPostString("ctid");
  1622. CeErpTradeCell entity = null;
  1623. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1624. if (entity != null)
  1625. {
  1626. CeErpBill bill = CeErpBill.GetByTid(eid);
  1627. bool isHave = false;
  1628. if (bill != null)
  1629. {
  1630. isHave = true;
  1631. if (bill.state != 4)
  1632. {
  1633. returnErrorMsg("此单已经申请过发票了");
  1634. return;
  1635. }
  1636. }
  1637. if (entity.IsNeedBill == 0)
  1638. {
  1639. entity.IsNeedBill = 1;
  1640. }
  1641. entity.Update();
  1642. string errjson = "";
  1643. try
  1644. {
  1645. CeErpBill bill_entity = new CeErpBill();
  1646. bill_entity.tid = entity.tid;
  1647. bill_entity.title = GetPostString("title");
  1648. string taxstr = GetPostString("tax");
  1649. taxstr = taxstr.Replace(" ", "");
  1650. bill_entity.tax = taxstr;
  1651. bill_entity.bank = GetPostString("bank");
  1652. string bankacstr = GetPostString("bankac");
  1653. bankacstr = bankacstr.Replace(" ", "");
  1654. bill_entity.bankac = bankacstr;
  1655. bill_entity.address = GetPostString("address");
  1656. bill_entity.phone = GetPostString("phone");
  1657. bill_entity.price = GetPostString("price");
  1658. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1659. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1660. {
  1661. billCount += 1;
  1662. }
  1663. string prebill = "ltb";
  1664. for (int idx = 1; idx <= billCount; idx++)
  1665. {
  1666. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1667. string billoid = prebill + idx + dtstr;
  1668. bill_entity.billOrderId += billoid;
  1669. if (idx < billCount)
  1670. {
  1671. bill_entity.billOrderId += ",";
  1672. }
  1673. }
  1674. bill_entity.productId = GetPostInt("ProductName");
  1675. bill_entity.num = GetPostInt("num");
  1676. bill_entity.unit = GetPostString("unit");
  1677. bill_entity.type = GetPostString("type");
  1678. bill_entity.sendType = GetPostString("SendType");
  1679. bill_entity.email = GetPostString("email");
  1680. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1681. bill_entity.shopName = GetPostString("ShopName");
  1682. bill_entity.applymemo = GetPostString("applyMemo");
  1683. bill_entity.createTime = DateTime.Now;
  1684. bill_entity.state = 0;
  1685. bill_entity.userId = CurrentUser.UserID;
  1686. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1687. bill_entity.Create();
  1688. }
  1689. catch (Exception ex)
  1690. {
  1691. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1692. returnErrorMsg("创建发票出错!");
  1693. return;
  1694. }
  1695. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1696. returnSuccessMsg("发票申请成功!");
  1697. return;
  1698. }
  1699. returnErrorMsg("找不到记录");
  1700. }
  1701. }
  1702. public void ins_erp_neworder()
  1703. {
  1704. if (UrlPostParmsCheck("receiver_name"))
  1705. {
  1706. CeErpTrade entity = new CeErpTrade();
  1707. string plat_form = GetPostString("platform");
  1708. string preStr = "N_";
  1709. if (plat_form == "拼多多")
  1710. {
  1711. preStr = "P_";
  1712. }
  1713. else if (plat_form == "阿里巴巴")
  1714. {
  1715. preStr = "A_";
  1716. }
  1717. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1718. entity.seller_nick = GetPostString("seller_nick");
  1719. entity.buyer_nick = GetPostString("buyer_nick");
  1720. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1721. entity.total_fee = entity.payment;
  1722. entity.pay_time = DateTime.Now;
  1723. entity.status = "NOT_SHIPPED";
  1724. entity.receiver_name = GetPostString("receiver_name");
  1725. entity.receiver_mobile = GetPostString("receiver_mobile");
  1726. entity.receiver_state = GetPostString("receiver_state");
  1727. entity.receiver_city = GetPostString("receiver_city");
  1728. entity.receiver_district = GetPostString("receiver_district");
  1729. entity.receiver_address = GetPostString("receiver_address");
  1730. if (entity.receiver_state == "" || entity.receiver_city == "")
  1731. {
  1732. returnErrorMsg("收件地址不能为空");
  1733. return;
  1734. }
  1735. int shopId = 0;
  1736. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1737. if (nShop != null)
  1738. {
  1739. shopId = nShop.ID;
  1740. }
  1741. if (shopId != 34 && entity.payment == 0)
  1742. {
  1743. returnErrorMsg("公司自用的单金额才能为0");
  1744. return;
  1745. }
  1746. entity.Create();
  1747. CeErpTradeCell entitycell = new CeErpTradeCell();
  1748. entitycell.ctid = entity.tid;
  1749. entitycell.tid = entity.tid;
  1750. entitycell.ShopId = shopId;
  1751. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1752. entitycell.OrderState = 0;
  1753. entitycell.pay_time = entity.pay_time;
  1754. entitycell.IsOffLineOrder = 1;
  1755. entitycell.Create();
  1756. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1757. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1758. return;
  1759. }
  1760. }
  1761. public void ins_erp_neworder2()
  1762. {
  1763. if (UrlPostParmsCheck("receiver_name"))
  1764. {
  1765. //string plat_form = GetPostString("platform");
  1766. string preStr = "X_";
  1767. string memo = GetPostString("memo");
  1768. string productId = GetPostString("productId");
  1769. string primg = GetPostString("proofimg");
  1770. string sellerNick = GetPostString("seller_nick");
  1771. string addFrom = GetPostString("addfrom");
  1772. if (addFrom == "1")
  1773. {
  1774. preStr = "N_";
  1775. }
  1776. int shopId = 0;
  1777. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1778. if (nShop != null)
  1779. {
  1780. shopId = nShop.ID;
  1781. }
  1782. else
  1783. {
  1784. returnErrorMsg("找不到对应店铺");
  1785. return;
  1786. }
  1787. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1788. {
  1789. returnErrorMsg("必须上传付款凭证");
  1790. return;
  1791. }
  1792. CeErpTrade entity = new CeErpTrade();
  1793. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1794. entity.seller_nick = sellerNick;
  1795. entity.buyer_nick = GetPostString("buyer_nick");
  1796. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1797. entity.total_fee = entity.payment;
  1798. entity.pay_time = DateTime.Now;
  1799. entity.status = "NOT_SHIPPED";
  1800. entity.receiver_name = GetPostString("receiver_name");
  1801. entity.receiver_mobile = GetPostString("receiver_mobile");
  1802. entity.receiver_state = GetPostString("receiver_state");
  1803. entity.receiver_city = GetPostString("receiver_city");
  1804. entity.receiver_district = GetPostString("receiver_district");
  1805. entity.receiver_address = GetPostString("receiver_address");
  1806. entity.seller_memo = memo;
  1807. entity.orderFrom = 20;
  1808. entity.orderType = 15;
  1809. if (entity.receiver_state == "" || entity.receiver_city == "")
  1810. {
  1811. returnErrorMsg("收件地址不能为空");
  1812. return;
  1813. }
  1814. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1815. {
  1816. returnErrorMsg("公司自用的单金额才能为0");
  1817. return;
  1818. }
  1819. entity.Create();
  1820. string toWhere = GetPostString("towhere");
  1821. CeErpTradeCell entitycell = new CeErpTradeCell();
  1822. entitycell.ctid = entity.tid;
  1823. //唯一标识
  1824. entitycell.OrderSn = entity.tid;
  1825. string orderSn = dataHelper.getSaleOrderSn();
  1826. if (orderSn != "")
  1827. {
  1828. entitycell.OrderSn = orderSn;
  1829. }
  1830. entitycell.tid = entity.tid;
  1831. //if (preStr == "X_")
  1832. //{
  1833. entitycell.IsOffLineOrder = 1;
  1834. //}
  1835. entitycell.CustomerUserId = CurrentUser.UserID;
  1836. entitycell.PayProofImg = primg;
  1837. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1838. entitycell.ProductId = Convert.ToInt32(productId);
  1839. entitycell.ShopId = shopId;
  1840. entitycell.UpdateTime = DateTime.Now;
  1841. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1842. if (entitycell.ProductId > 0)
  1843. {
  1844. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1845. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1846. {
  1847. entitycell.NewProduct = 1;
  1848. }
  1849. }
  1850. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1851. {
  1852. entitycell.IsXianHuo = 1;
  1853. }
  1854. entitycell.pay_time = entity.pay_time;
  1855. if (toWhere == "1")
  1856. {
  1857. entitycell.OrderState = 2;
  1858. }
  1859. else
  1860. {
  1861. entitycell.OrderState = 6;
  1862. entitycell.FinishPlaceTime = entitycell.pay_time;
  1863. }
  1864. if (shopId == 94)
  1865. {
  1866. entitycell.OrderState = 4;
  1867. entitycell.WaitDesignTime = entitycell.pay_time;
  1868. entitycell.StartDesignTime = entitycell.pay_time;
  1869. entitycell.DesignUserId = 218;
  1870. }
  1871. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1872. {
  1873. entitycell.OrderState = -1;//修改12-5
  1874. CeWithdraw ceWithdraw = new CeWithdraw();
  1875. ceWithdraw.tid = entity.tid;
  1876. ceWithdraw.providerid = "-1";
  1877. ceWithdraw.status = -1;
  1878. ceWithdraw.creationtime = DateTime.Now;
  1879. ceWithdraw.userid = 4634;
  1880. ceWithdraw.Create();
  1881. }
  1882. entitycell.Create();
  1883. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1884. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1885. {
  1886. addPlaceRegist(entitycell, CurrentUser.UserID);
  1887. }
  1888. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1889. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1890. return;
  1891. }
  1892. }
  1893. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1894. {
  1895. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1896. entity.PlactTime = tradecell.pay_time;
  1897. entity.AddUserId = userid;
  1898. entity.FileName = tradecell.seller_memo;
  1899. entity.Supplier = 24;
  1900. entity.CreateTime = DateTime.Now;
  1901. entity.Did = tradecell.ctid;
  1902. entity.tid = tradecell.tid;
  1903. entity.splitTag = tradecell.SplitTag;
  1904. entity.CurState = "未完成";
  1905. entity.Create();
  1906. }
  1907. public void get_erp_offlinelist()
  1908. {
  1909. DataStruct dStruct = GetPostStruct();
  1910. List<string> lw = new List<string>();
  1911. string tid = GetPostString("ctid");
  1912. string date1 = GetPostString("date1");
  1913. string date2 = GetPostString("date2");
  1914. if (tid.Length > 0 || date1.Length > 0)
  1915. {
  1916. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1917. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1918. if (dw.Length > 0) lw.Add(dw);
  1919. }
  1920. else
  1921. {
  1922. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1923. }
  1924. string shopname = GetPostString("shopname");
  1925. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1926. string buyernick = GetPostString("buyer_nick");
  1927. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1928. string customer = GetPostString("customer");
  1929. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1930. string design = GetPostString("design");
  1931. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1932. string orderState = GetPostString("orderState");
  1933. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1934. string address = GetPostString("address");
  1935. 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));
  1936. string sellermemo = GetPostString("seller_memo");
  1937. if (sellermemo.Length > 0)
  1938. {
  1939. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1940. }
  1941. string price1 = GetPostString("price1");
  1942. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1943. string price2 = GetPostString("price2");
  1944. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1945. //if (PKey != "admin")
  1946. //{
  1947. // string usershop = CurrentUser.User.pemShop;
  1948. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1949. //}
  1950. //if (ex_psize > 0)
  1951. //{
  1952. dStruct.Order = "pay_time desc";
  1953. //}
  1954. //else
  1955. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1956. lw.Add(string.Format("IsOffLineOrder=1"));
  1957. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1958. DataTable dt = null;
  1959. dt = WebCache.GetData("view_erptradecell", dStruct);
  1960. writeGridDataTableJson(dStruct.TotalCount, dt);
  1961. }
  1962. public void get_erp_returncashrecord()
  1963. {
  1964. DataStruct dStruct = GetPostStruct();
  1965. List<string> lw = new List<string>();
  1966. string tid = GetPostString("ctid");
  1967. if (tid.Length > 0)
  1968. {
  1969. lw.Add(string.Format("tid like '%{0}%'", tid));
  1970. dStruct.Order = "id desc";
  1971. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1972. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1973. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1974. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1975. return;
  1976. }
  1977. returnErrorMsg("id数据错误!");
  1978. }
  1979. public void ins_erp_returncashrecord()
  1980. {
  1981. if (UrlPostParmsCheck("tid"))
  1982. {
  1983. string tid = GetPostString("tid");
  1984. string retype = GetPostString("type");
  1985. StringBuilder sql = new StringBuilder();
  1986. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1987. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1988. if (dt.Rows.Count > 0)
  1989. {
  1990. returnErrorMsg("相同返现类型记录已存在");
  1991. return;
  1992. }
  1993. CeErpReturnCash entity = new CeErpReturnCash();
  1994. entity.tid = tid;
  1995. entity.seller_nick = GetPostString("seller_nick");
  1996. string pment = GetPostString("payment");
  1997. if (pment.Length > 0)
  1998. {
  1999. entity.payment = Convert.ToDouble(pment);
  2000. }
  2001. entity.buyer_nick = GetPostString("buyer_nick");
  2002. entity.cashstate = 0;
  2003. entity.rtype = retype;
  2004. string rPrice = GetPostString("returnprice");
  2005. if (rPrice.Length > 0)
  2006. {
  2007. entity.returnprice = Convert.ToDouble(rPrice);
  2008. }
  2009. entity.created = DateTime.Now;
  2010. entity.con = GetPostString("con");
  2011. entity.img = GetPostString("img");
  2012. entity.applyuserid = CurrentUser.UserID;
  2013. entity.Create();
  2014. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2015. returnSuccessMsg("操作成功!");
  2016. return;
  2017. }
  2018. }
  2019. public void set_erp_predelivery()
  2020. {
  2021. if (UrlPostParmsCheck("ctid"))
  2022. {
  2023. string eid = GetPostString("ctid");
  2024. CeErpTradeCell entity = null;
  2025. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2026. if (entity != null)
  2027. {
  2028. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2029. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2030. //{
  2031. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2032. // return;
  2033. //}
  2034. entity.IsPreDelivery = 1;
  2035. entity.Update();
  2036. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2037. returnSuccessMsg("预发货成功!");
  2038. return;
  2039. //string shop = GetPostString("seller_nick");
  2040. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2041. //string comName = GetPostString("comName");
  2042. //string comCode = GetPostString("comCode");
  2043. //string outSid = GetPostString("outSid");//运单号
  2044. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2045. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2046. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2047. //string apires = "";
  2048. //if (deliveryType == "虚拟发货")
  2049. //{
  2050. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2051. //}
  2052. //else
  2053. //{
  2054. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2055. //}
  2056. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2057. ////{
  2058. //if (apires.IndexOf("发货成功") != -1)
  2059. //{
  2060. // if (deliveryType != "虚拟发货")
  2061. // {
  2062. // //还要插入快递信息到 快递信息表
  2063. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2064. // exinfo.tid = eid;
  2065. // exinfo.out_sid = outSid;
  2066. // exinfo.company_code = comCode;
  2067. // exinfo.company_name = comName;
  2068. // exinfo.delivery_memo = deliveryMemo;
  2069. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2070. // exinfo.deliveryType = deliveryType;
  2071. // exinfo.Create();
  2072. // }
  2073. // returnSuccessMsg("发货成功!");
  2074. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2075. //}
  2076. //else
  2077. //{
  2078. // returnErrorMsg("淘宝发货失败!!");
  2079. //}
  2080. //return;
  2081. }
  2082. returnErrorMsg("找不到订单记录");
  2083. }
  2084. }
  2085. public void get_erp_unusuallist()
  2086. {
  2087. DataStruct dStruct = GetPostStruct();
  2088. List<string> lw = new List<string>();
  2089. string tid = GetPostString("ctid");
  2090. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2091. string shopname = GetPostString("shopname");
  2092. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2093. string buyernick = GetPostString("buyer_nick");
  2094. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2095. string ResponsibleMan = GetPostString("responsible");
  2096. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2097. string date1 = GetPostString("date1");
  2098. string date2 = GetPostString("date2");
  2099. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2100. if (dw.Length > 0) lw.Add(dw);
  2101. string price1 = GetPostString("price1");
  2102. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2103. string price2 = GetPostString("price2");
  2104. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2105. string orderState = GetPostString("orderState");
  2106. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2107. string sellermemo = GetPostString("seller_memo");
  2108. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2109. lw.Add(string.Format("UnusualTag > 0"));
  2110. lw.Add(string.Format("IsRefund<={0}", 1));
  2111. dStruct.Order = "pay_time desc";
  2112. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2113. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2114. writeGridDataTableJson(dStruct.TotalCount, dt);
  2115. }
  2116. public void set_erp_unusualtonomal()
  2117. {
  2118. if (UrlPostParmsCheck("ctid"))
  2119. {
  2120. string eid = GetPostString("ctid");
  2121. CeErpTradeCell entity = null;
  2122. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2123. if (entity != null)
  2124. {
  2125. entity.UnusualTag = -1;
  2126. entity.Update();
  2127. returnSuccessMsg("忽略成功!");
  2128. return;
  2129. }
  2130. returnErrorMsg("找不到记录");
  2131. }
  2132. }
  2133. public void ins_erp_unusualreason()
  2134. {
  2135. if (UrlPostParmsCheck("ctid"))
  2136. {
  2137. string eid = GetPostString("ctid");
  2138. CeErpTradeCell entity = null;
  2139. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2140. if (entity != null)
  2141. {
  2142. entity.MemoOpt = 4;
  2143. entity.UnusualCon = GetPostString("con");
  2144. entity.Update();
  2145. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2146. if (trade != null)
  2147. {
  2148. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2149. }
  2150. //查货是否超时
  2151. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2152. if (ceErpTradeCellExtend == null)
  2153. {
  2154. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2155. ceErpTradeCellExtend.ctid = entity.ctid;
  2156. }
  2157. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2158. {
  2159. ceErpTradeCellExtend.CheckOut += 1;
  2160. }
  2161. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2162. if (ceErpTradeCellExtend.ID > 0)
  2163. {
  2164. ceErpTradeCellExtend.Update();
  2165. }
  2166. else
  2167. {
  2168. ceErpTradeCellExtend.Create();
  2169. }
  2170. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2171. returnSuccessMsg("操作成功!");
  2172. return;
  2173. }
  2174. returnErrorMsg("找不到记录");
  2175. }
  2176. }
  2177. public void upd_erp_sampleorder()
  2178. {
  2179. if (UrlPostParmsCheck("ctid"))
  2180. {
  2181. string eid = GetPostString("ctid");
  2182. string[] eArr = eid.Split(',');
  2183. if (eArr.Length > 1)
  2184. {
  2185. List<string> eLst = new List<string>();
  2186. for (int i = 0; i < eArr.Length; i++)
  2187. {
  2188. eLst.Add("'" + eArr[i] + "'");
  2189. }
  2190. eid = string.Join(",", eLst.ToArray());
  2191. }
  2192. else
  2193. {
  2194. eid = "'" + eid + "'";
  2195. }
  2196. StringBuilder sql = new StringBuilder();
  2197. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2198. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2199. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2200. if (dt.Rows.Count > 0)
  2201. {
  2202. string errmsg = "";
  2203. foreach (DataRow dr in dt.Rows)
  2204. {
  2205. StringBuilder sqlsb = new StringBuilder();
  2206. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2207. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2208. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2209. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2210. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2211. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2212. {
  2213. continue;
  2214. }
  2215. else
  2216. {
  2217. string emsg = commonHelper.KeepChinese(apires);
  2218. errmsg += emsg;
  2219. }*/
  2220. }
  2221. if (errmsg.Length > 0)
  2222. {
  2223. returnErrorMsg(errmsg);
  2224. return;
  2225. }
  2226. returnSuccessMsg("操作成功");
  2227. return;
  2228. }
  2229. returnErrorMsg("找不到记录");
  2230. }
  2231. }
  2232. public void upd_erp_transcustomer()
  2233. {
  2234. if (UrlPostParmsCheck("ctid"))
  2235. {
  2236. string eid = GetPostString("ctid");
  2237. int userid = GetPostInt("CustomerUserId");
  2238. CeErpTradeCell entity = null;
  2239. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2240. if (entity != null)
  2241. {
  2242. //string[] mlist = entity.seller_memo.Split('-');
  2243. //string sql = "select * from view_erpuser where id=" + userid;
  2244. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2245. //if (dt != null && dt.Rows.Count > 0)
  2246. //{
  2247. // string nmemo = "";
  2248. // for(int i = 0; i < mlist.Length - 1; i++)
  2249. // {
  2250. // nmemo += mlist[i];
  2251. // nmemo += "-";
  2252. // }
  2253. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2254. // entity.seller_memo = nmemo;
  2255. //}
  2256. entity.CustomerUserId = userid;
  2257. entity.Update();
  2258. returnSuccessMsg("操作成功!");
  2259. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2260. return;
  2261. }
  2262. returnErrorMsg("找不到记录");
  2263. }
  2264. }
  2265. public void upd_erp_transdesigner()
  2266. {
  2267. if (UrlPostParmsCheck("ctid"))
  2268. {
  2269. string eids = GetPostString("ctid");
  2270. string[] ctidList = eids.Split(',');
  2271. int userid = GetPostInt("DesignUserId");
  2272. foreach (string ctid in ctidList)
  2273. {
  2274. CeErpTradeCell entity = null;
  2275. CeErpDesignerBill entitys = null;
  2276. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2277. entitys = CeErpDesignerBill.GetByTid(ctid);
  2278. if (entity != null)
  2279. {
  2280. if (entity.OrderState > 4)
  2281. {
  2282. continue;
  2283. }
  2284. //存在退款不能流转
  2285. if (entity.IsRefund > 0)
  2286. {
  2287. continue;
  2288. }
  2289. entity.DesignUserId = userid;
  2290. entity.WaitDesignTime = DateTime.Now;
  2291. entity.Update();
  2292. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2293. }
  2294. }
  2295. returnSuccessMsg("操作成功!");
  2296. }
  2297. }
  2298. public void upd_erp_distributedesigner()
  2299. {
  2300. if (UrlPostParmsCheck("ctid"))
  2301. {
  2302. string eid = GetPostString("ctid");
  2303. int userid = GetPostInt("DesignUserId");
  2304. string[] idlist = eid.Split(',');
  2305. if (idlist.Length <= 0)
  2306. {
  2307. returnErrorMsg("订单不能为空");
  2308. return;
  2309. }
  2310. foreach (string ctid in idlist)
  2311. {
  2312. CeErpTradeCell entity = null;
  2313. CeErpDesignerBill entitys = null;
  2314. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2315. else continue;
  2316. if (entity != null)
  2317. {
  2318. if (userid == 2125 || userid == 3542)
  2319. { }
  2320. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2321. {
  2322. returnErrorMsg("金额错误的订单无法指派");
  2323. return;
  2324. }
  2325. if (entity.OrderState >= 5)
  2326. {
  2327. returnErrorMsg("已经设计完成无法指派");
  2328. return;
  2329. }
  2330. if (entity.OrderState == -1)
  2331. {
  2332. returnErrorMsg("审核中的订单无法指派");
  2333. return;
  2334. }
  2335. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2336. {
  2337. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2338. return;
  2339. }
  2340. //157赖橙帆 159林晨 73 静之颖
  2341. 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)
  2342. {
  2343. returnErrorMsg("指派设计共创无法再次指派!");
  2344. return;
  2345. }
  2346. entity.OrderState = 3;
  2347. if (entity.SupplierId == 0)
  2348. {
  2349. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2350. entity.SupplierId = suid;
  2351. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2352. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2353. }
  2354. if (userid == 2125 && entity.seller_memo != "")
  2355. {
  2356. apiDesign.API_GetPrintData_CreateOrder(entity);
  2357. }
  2358. if (userid == 3542 && entity.seller_memo != "")
  2359. {
  2360. string userPost = CurrentUser.UserPost.Post.Code;
  2361. if (CurrentUser.UserID == 73)
  2362. {
  2363. userPost = "SysAdmin";
  2364. }
  2365. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2366. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2367. if (response.msg != "设计共创:成功")
  2368. {
  2369. returnErrorMsg(response.msg);
  2370. return;
  2371. }
  2372. entity.DispatchSort = 2;
  2373. }
  2374. else
  2375. {
  2376. if (entity.DispatchSort == 2)
  2377. {
  2378. ApiVo apiVo = new ApiVo();
  2379. apiVo.actionName = "closeDesign";
  2380. apiVo.orderNumber = entity.ctid;
  2381. designHelper.API_WorkCore(apiVo);//closeDesign
  2382. }
  2383. entity.DispatchSort = 0;
  2384. }
  2385. entity.DesignUserId = userid;
  2386. entity.WaitDesignTime = DateTime.Now;
  2387. entity.UpdateTime = DateTime.Now;
  2388. entity.Update();
  2389. string name = commonHelper.getUserNameById(userid);
  2390. commonHelper.UpdateRelationOrder(entity.ctid);
  2391. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2392. }
  2393. }
  2394. returnSuccessMsg("操作成功!");
  2395. return;
  2396. }
  2397. }
  2398. public string getTidByCtid(string ctid)
  2399. {
  2400. string tid = "";
  2401. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2402. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2403. if (dataTable != null && dataTable.Rows.Count > 0)
  2404. {
  2405. tid = dataTable.Rows[0]["tid"].ToString();
  2406. }
  2407. return tid;
  2408. }
  2409. public List<string> getTidByCtidMore(string ctid)
  2410. {
  2411. 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);
  2412. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2413. List<string> list = new List<string>();
  2414. if (dataTable != null && dataTable.Rows.Count > 0)
  2415. {
  2416. foreach (DataRow item in dataTable.Rows)
  2417. {
  2418. list.Add("'" + item["tid"].ToString() + "'");
  2419. }
  2420. }
  2421. return list;
  2422. }
  2423. public List<string> getTidByCtidLike(string ctid)
  2424. {
  2425. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2426. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2427. List<string> list = new List<string>();
  2428. if (dataTable != null && dataTable.Rows.Count > 0)
  2429. {
  2430. foreach (DataRow item in dataTable.Rows)
  2431. {
  2432. list.Add("'" + item["tid"].ToString() + "'");
  2433. }
  2434. }
  2435. return list;
  2436. }
  2437. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2438. {
  2439. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2440. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2441. List<string> list = new List<string>();
  2442. if (dataTable != null && dataTable.Rows.Count > 0)
  2443. {
  2444. foreach (DataRow item in dataTable.Rows)
  2445. {
  2446. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2447. {
  2448. continue;
  2449. }
  2450. list.Add("'" + item["receiverId"].ToString() + "'");
  2451. }
  2452. }
  2453. return list;
  2454. }
  2455. public void get_erp_myorderlist()
  2456. {
  2457. DataStruct dStruct = GetPostStruct();
  2458. List<string> lw = new List<string>();
  2459. string tid = GetPostString("ctid");
  2460. if (tid.Length > 0)
  2461. {
  2462. string select_tid = getTidByCtid(tid);
  2463. lw.Add(string.Format("tid='{0}'", select_tid));
  2464. }
  2465. else
  2466. {
  2467. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2468. }
  2469. //12-1 修改
  2470. string urgent = GetPostString("urgent");
  2471. string back = GetPostString("back");
  2472. string offlineSearch = GetPostString("offlineSearch");
  2473. if (!string.IsNullOrWhiteSpace(urgent))
  2474. {
  2475. if (urgent.Equals("true"))
  2476. {
  2477. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2478. }
  2479. }
  2480. if (!string.IsNullOrWhiteSpace(back))
  2481. {
  2482. if (back.Equals("true"))
  2483. {
  2484. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2485. }
  2486. }
  2487. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2488. {
  2489. if (offlineSearch.Equals("true"))
  2490. {
  2491. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2492. }
  2493. }
  2494. //end
  2495. string shopname = GetPostString("shopname");
  2496. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2497. string buyernick = GetPostString("buyer_nick");
  2498. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2499. string design = GetPostString("design");
  2500. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2501. string orderState = GetPostString("orderState");
  2502. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2503. string sellermemo = GetPostString("seller_memo");
  2504. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2505. string date1 = GetPostString("date1");
  2506. string date2 = GetPostString("date2");
  2507. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2508. if (dw.Length > 0) lw.Add(dw);
  2509. string price1 = GetPostString("price1");
  2510. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2511. string price2 = GetPostString("price2");
  2512. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2513. string urgency = GetPostString("urgency");
  2514. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2515. string after = GetPostString("after");
  2516. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2517. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2518. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2519. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2520. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2521. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2522. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2523. if (dt != null && dt.Rows.Count > 0)
  2524. {
  2525. foreach (DataRow dr in dt.Rows)
  2526. {
  2527. try
  2528. {
  2529. // 对象操作
  2530. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2531. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2532. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2533. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2534. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2535. if (dStruct.PageSize != 100000)
  2536. {
  2537. if (dr["DispatchSort"].ToString() == "2")
  2538. {
  2539. dr["gongchuang"] = 200;
  2540. }
  2541. else if ("外协".Equals(dr["ToType"].ToString()))
  2542. {
  2543. dr["gongchuang"] = 200;
  2544. }
  2545. else if ("内部".Equals(dr["ToType"].ToString()))
  2546. {
  2547. dr["gongchuang"] = -1;
  2548. }
  2549. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2550. {
  2551. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2552. dr["gongchuang"] = response.code;
  2553. }
  2554. }
  2555. }
  2556. catch (NullReferenceException ex)
  2557. {
  2558. }
  2559. }
  2560. }
  2561. writeGridDataTableJson(dStruct.TotalCount, dt);
  2562. }
  2563. public void get_erp_myreturnorderlist()
  2564. {
  2565. DataStruct dStruct = GetPostStruct();
  2566. List<string> lw = new List<string>();
  2567. string tid = GetPostString("ctid");
  2568. if (tid.Length > 0)
  2569. {
  2570. string select_tid = getTidByCtid(tid);
  2571. lw.Add(string.Format("tid='{0}'", select_tid));
  2572. }
  2573. else
  2574. {
  2575. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2576. }
  2577. string shopname = GetPostString("shopname");
  2578. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2579. string buyernick = GetPostString("buyer_nick");
  2580. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2581. string design = GetPostString("design");
  2582. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2583. string orderState = GetPostString("orderState");
  2584. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2585. string sellermemo = GetPostString("seller_memo");
  2586. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2587. string date1 = GetPostString("date1");
  2588. string date2 = GetPostString("date2");
  2589. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2590. if (dw.Length > 0) lw.Add(dw);
  2591. string price1 = GetPostString("price1");
  2592. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2593. string price2 = GetPostString("price2");
  2594. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2595. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2596. {
  2597. lw.Add(string.Format("CusOrgID = 94"));
  2598. }
  2599. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2600. {
  2601. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2602. }
  2603. else
  2604. {
  2605. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2606. }
  2607. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2608. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2609. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2610. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2611. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2612. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2613. if (dt != null && dt.Rows.Count > 0)
  2614. {
  2615. foreach (DataRow dr in dt.Rows)
  2616. {
  2617. try
  2618. {
  2619. // 对象操作
  2620. if (dStruct.PageSize != 100000)
  2621. {
  2622. if (dr["DispatchSort"].ToString() == "2")
  2623. {
  2624. dr["gongchuang"] = 200;
  2625. }
  2626. else if ("外协".Equals(dr["ToType"].ToString()))
  2627. {
  2628. dr["gongchuang"] = 200;
  2629. }
  2630. else if ("内部".Equals(dr["ToType"].ToString()))
  2631. {
  2632. dr["gongchuang"] = -1;
  2633. }
  2634. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2635. {
  2636. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2637. dr["gongchuang"] = response.code;
  2638. }
  2639. }
  2640. }
  2641. catch (NullReferenceException ex)
  2642. {
  2643. // 处理空引用异常
  2644. }
  2645. }
  2646. }
  2647. writeGridDataTableJson(dStruct.TotalCount, dt);
  2648. }
  2649. public void get_erp_myorderlist_pregather()
  2650. {
  2651. string date1 = GetPostString("date1");
  2652. string date2 = GetPostString("date2");
  2653. int userId = CurrentUser.UserID; //客服id
  2654. string orderWhere = "";
  2655. List<string> lw = new List<string>();
  2656. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2657. if (dw.Length > 0) lw.Add(dw);
  2658. lw.Add(string.Format("CustomerUserId={0}", userId));
  2659. lw.Add(string.Format("OrderState<9"));
  2660. orderWhere = string.Join(" and ", lw.ToArray());
  2661. string orderWhere2 = "";
  2662. List<string> lw2 = new List<string>();
  2663. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2664. if (dw2.Length > 0) lw2.Add(dw2);
  2665. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2666. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2667. string sql = string.Format("select *" +
  2668. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2669. "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 " +
  2670. "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 " +
  2671. "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");
  2672. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2673. //writeGridDataTableJson(dt.Rows.Count, dt);
  2674. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2675. }
  2676. public void upd_erp_publishorder()
  2677. {
  2678. if (UrlPostParmsCheck("ctid"))
  2679. {
  2680. string eid = GetPostString("ctid");
  2681. CeErpTradeCell entity = null;
  2682. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2683. if (entity != null)
  2684. {
  2685. entity.OrderState = 0; //发布后,变为待抢单
  2686. entity.Update();
  2687. commonHelper.UpdateRelationOrder(entity.ctid);
  2688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2689. returnSuccessMsg("发布成功!");
  2690. return;
  2691. }
  2692. returnErrorMsg("找不到记录");
  2693. }
  2694. }
  2695. public void get_erp_my_tiporder()
  2696. {
  2697. StringBuilder sql = new StringBuilder();
  2698. int userId = 0;
  2699. if (CurrentUser != null) userId = CurrentUser.UserID;
  2700. string posCode = CurrentUser.UserPost.Post.Code;
  2701. string isTipedAfterSaleVerify = GetPostString("af");
  2702. DataTable dt = new DataTable();
  2703. if (posCode != "Supplier")
  2704. {
  2705. if (posCode == "CustomerService" || posCode == "Director")
  2706. {
  2707. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2708. }
  2709. else if (posCode == "Place" || posCode == "PlaceMr")
  2710. {
  2711. }
  2712. else
  2713. {
  2714. string teamIds = CurrentUser.User.TeamIds;
  2715. if (teamIds == "")
  2716. {
  2717. teamIds = "0";
  2718. }
  2719. 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);
  2720. }
  2721. if (sql.Length > 0)
  2722. {
  2723. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2724. }
  2725. }
  2726. if (dt.Rows.Count <= 0)
  2727. {
  2728. string key = "aftersale_order_" + userId;
  2729. if (RedisHelper.HasKey(key))
  2730. {
  2731. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2732. dt.Columns.Add("ctid", typeof(string));
  2733. dt.Columns.Add("IsReadTag", typeof(int));
  2734. foreach (var i in list)
  2735. {
  2736. DataRow data = dt.NewRow();
  2737. data["ctid"] = i;
  2738. data["IsReadTag"] = 4;
  2739. dt.Rows.Add(data);
  2740. }
  2741. RedisHelper.StringDelete(key);
  2742. }
  2743. }
  2744. if (dt.Rows.Count <= 0)
  2745. {
  2746. sql = new StringBuilder();
  2747. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2748. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2749. }
  2750. if (posCode == "Supplier")
  2751. {
  2752. string ids = CurrentUser.User.pemVend;
  2753. if (ids != null && ids.Length > 0)
  2754. {
  2755. string[] ids_list = ids.Split(',');
  2756. foreach (var item in ids_list)
  2757. {
  2758. string key = "return_order_" + item;
  2759. if (RedisHelper.HasKey(key))
  2760. {
  2761. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2762. dt.Columns.Add("ctid", typeof(string));
  2763. dt.Columns.Add("IsReadTag", typeof(int));
  2764. foreach (var i in list)
  2765. {
  2766. DataRow data = dt.NewRow();
  2767. data["ctid"] = i;
  2768. data["IsReadTag"] = 1;
  2769. dt.Rows.Add(data);
  2770. }
  2771. RedisHelper.StringDelete(key);
  2772. }
  2773. }
  2774. }
  2775. if (dt.Rows.Count <= 0)
  2776. {
  2777. sql = new StringBuilder();
  2778. 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);
  2779. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2780. }
  2781. }
  2782. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2783. }
  2784. public void reset_erp_tiporder()
  2785. {
  2786. string ids = GetPostString("ids");
  2787. string[] ctidList = ids.Split(',');
  2788. foreach (string ctid in ctidList)
  2789. {
  2790. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2791. if (enty != null)
  2792. {
  2793. enty.IsReadTag = 0;
  2794. enty.Update();
  2795. }
  2796. }
  2797. returnSuccessMsg("成功!");
  2798. return;
  2799. }
  2800. public void get_erp_designlist()
  2801. {
  2802. DataStruct dStruct = GetPostStruct();
  2803. List<string> lw = new List<string>();
  2804. string tid = GetPostString("ctid");
  2805. if (tid.Length > 0)
  2806. {
  2807. string select_tid = getTidByCtid(tid);
  2808. lw.Add(string.Format("tid='{0}'", select_tid));
  2809. }
  2810. string shopname = GetPostString("shopname");
  2811. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2812. string buyernick = GetPostString("buyer_nick");
  2813. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2814. string customer = GetPostString("customer");
  2815. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2816. string design = GetPostString("design");
  2817. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2818. string orderState = GetPostString("orderState");
  2819. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2820. lw.Add(string.Format("OrderState<6"));
  2821. string address = GetPostString("address");
  2822. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2823. string sellermemo = GetPostString("seller_memo");
  2824. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2825. string date1 = GetPostString("date1");
  2826. string date2 = GetPostString("date2");
  2827. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2828. if (dw.Length > 0) lw.Add(dw);
  2829. string apdate1 = GetPostString("apdate1");
  2830. string apdate2 = GetPostString("apdate2");
  2831. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2832. if (dwap.Length > 0) lw.Add(dwap);
  2833. string price1 = GetPostString("price1");
  2834. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2835. string price2 = GetPostString("price2");
  2836. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2837. string designTime = GetPostString("designtime");
  2838. if (designTime.Length > 0)
  2839. {
  2840. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2841. }
  2842. string usershop = CurrentUser.User.pemShop;
  2843. if (usershop.Length > 0)
  2844. {
  2845. lw.Add(string.Format("shopId in ({0})", usershop));
  2846. }
  2847. int myOrgid = CurrentUser.UserPost.OrgID;
  2848. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2849. if (myOrgCode.IndexOf("Designer") != -1)
  2850. {
  2851. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2852. {
  2853. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2854. }
  2855. else
  2856. {
  2857. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2858. }
  2859. }
  2860. else
  2861. {
  2862. string orgId = GetPostString("designerhd");
  2863. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2864. }
  2865. if (tid.Length > 0 || buyernick.Length > 0)
  2866. {
  2867. lw.Add(string.Format("OrderState >= 3"));
  2868. }
  2869. else
  2870. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2871. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2872. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2873. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2874. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2875. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2876. if (dt != null && dt.Rows.Count > 0)
  2877. {
  2878. foreach (DataRow dr in dt.Rows)
  2879. {
  2880. try
  2881. {
  2882. // 对象操作
  2883. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2884. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2885. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2886. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2887. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2888. if (dStruct.PageSize != 100000)
  2889. {
  2890. if (dr["DispatchSort"].ToString() == "2")
  2891. {
  2892. dr["gongchuang"] = 200;
  2893. }
  2894. else if ("外协".Equals(dr["ToType"].ToString()))
  2895. {
  2896. dr["gongchuang"] = 200;
  2897. }
  2898. else if ("内部".Equals(dr["ToType"].ToString()))
  2899. {
  2900. dr["gongchuang"] = -1;
  2901. }
  2902. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2903. {
  2904. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2905. dr["gongchuang"] = response.code;
  2906. }
  2907. }
  2908. }
  2909. catch (NullReferenceException ex)
  2910. {
  2911. }
  2912. }
  2913. }
  2914. writeGridDataTableJson(dStruct.TotalCount, dt);
  2915. }
  2916. public void get_erp_mydesignlist()
  2917. {
  2918. DataStruct dStruct = GetPostStruct();
  2919. List<string> lw = new List<string>();
  2920. string tid = GetPostString("ctid");
  2921. if (tid.Length > 0)
  2922. {
  2923. string select_tid = getTidByCtid(tid);
  2924. lw.Add(string.Format("tid='{0}'", select_tid));
  2925. }
  2926. string shopname = GetPostString("shopname");
  2927. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2928. string buyernick = GetPostString("buyer_nick");
  2929. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2930. string customer = GetPostString("customer");
  2931. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2932. string orderState = GetPostString("orderState");
  2933. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2934. //lw.Add(string.Format("OrderState<6"));
  2935. string date1 = GetPostString("date1");
  2936. string date2 = GetPostString("date2");
  2937. string dw = GetDateWhere("pay_time", date1, date2);
  2938. if (dw.Length > 0) lw.Add(dw);
  2939. string apdate1 = GetPostString("apdate1");
  2940. string apdate2 = GetPostString("apdate2");
  2941. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2942. if (dwap.Length > 0) lw.Add(dwap);
  2943. string price1 = GetPostString("price1");
  2944. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2945. string price2 = GetPostString("price2");
  2946. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2947. string olddownload = GetPostString("olddown");
  2948. if (olddownload == "1")
  2949. {
  2950. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2951. }
  2952. else if (olddownload == "2")
  2953. {
  2954. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2955. }
  2956. string sellermemo = GetPostString("seller_memo");
  2957. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2958. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2959. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2960. {
  2961. if (CurrentUser.User.TeamIds.Length > 0)
  2962. {
  2963. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2964. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2965. else
  2966. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2967. }
  2968. else
  2969. {
  2970. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2971. }
  2972. }
  2973. if (tid.Length <= 0)
  2974. {
  2975. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2976. }
  2977. lw.Add(string.Format("IsReturn!=3"));
  2978. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2979. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2980. string teamids = CurrentUser.User.TeamIds.ToString();
  2981. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2982. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2983. if (dt != null && dt.Rows.Count > 0)
  2984. {
  2985. foreach (DataRow dr in dt.Rows)
  2986. {
  2987. try
  2988. {
  2989. // 对象操作
  2990. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2991. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2992. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2993. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2994. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2995. if (dStruct.PageSize != 100000)
  2996. {
  2997. if (dr["DispatchSort"].ToString() == "2")
  2998. {
  2999. dr["gongchuang"] = 200;
  3000. }
  3001. else if ("外协".Equals(dr["ToType"].ToString()))
  3002. {
  3003. dr["gongchuang"] = 200;
  3004. }
  3005. else if ("内部".Equals(dr["ToType"].ToString()))
  3006. {
  3007. dr["gongchuang"] = -1;
  3008. }
  3009. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3010. {
  3011. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3012. dr["gongchuang"] = response.code;
  3013. }
  3014. }
  3015. }
  3016. catch (NullReferenceException ex)
  3017. {
  3018. }
  3019. }
  3020. }
  3021. writeGridDataTableJson(dStruct.TotalCount, dt);
  3022. }
  3023. public void set_erp_startdesign()
  3024. {
  3025. if (UrlPostParmsCheck("ctid"))
  3026. {
  3027. string eid = GetPostString("ctid");
  3028. CeErpTradeCell entity = null;
  3029. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3030. if (entity != null)
  3031. {
  3032. if (entity.OrderState != 3)
  3033. {
  3034. returnErrorMsg("请刷新,订单已经设计了");
  3035. return;
  3036. }
  3037. entity.StartDesignTime = DateTime.Now;
  3038. entity.OrderState = 4;
  3039. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3040. {
  3041. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3042. entity.SupplierId = suid;
  3043. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3044. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3045. }
  3046. entity.UpdateTime = DateTime.Now;
  3047. //entity.MakeSupplier = suname;
  3048. entity.Update();
  3049. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3050. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3051. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3052. commonHelper.getCytPrice(entity);
  3053. returnSuccessMsg("操作成功!");
  3054. return;
  3055. }
  3056. returnErrorMsg("找不到记录");
  3057. }
  3058. }
  3059. public void ins_erp_designselfmemo()
  3060. {
  3061. if (UrlPostParmsCheck("ctid"))
  3062. {
  3063. string eid = GetPostString("ctid");
  3064. string con = GetPostString("con");
  3065. CeErpTradeCell entity = null;
  3066. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3067. if (entity != null)
  3068. {
  3069. entity.DesignSelfMemo = con;
  3070. entity.Update();
  3071. returnSuccessMsg("操作成功!");
  3072. return;
  3073. }
  3074. returnErrorMsg("找不到记录");
  3075. }
  3076. }
  3077. public void ins_erp_designprice()
  3078. {
  3079. if (UrlPostParmsCheck("ctid"))
  3080. {
  3081. string eid = GetPostString("ctid");
  3082. int uid = CurrentUser.UserID;
  3083. string userName = CurrentUser.UserName;
  3084. CeErpTradeCell entity = null;
  3085. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3086. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3087. if (entitys == null)
  3088. {
  3089. entitys = new CeErpDesignerBill();
  3090. }
  3091. if (entity != null)
  3092. {
  3093. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3094. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3095. entity.StartDesignTime = DateTime.Now;
  3096. entity.OrderState = 4;
  3097. string suname = "";
  3098. if (entity.SupplierId == 0)
  3099. {
  3100. int sid = commonHelper.autoDistributeToSupplier(entity);
  3101. entity.SupplierId = sid;
  3102. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3103. }
  3104. entity.Update();
  3105. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3106. if (ceErpUserPost != null)
  3107. {
  3108. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3109. if (ceErpPost != null)
  3110. {
  3111. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3112. {
  3113. entitys.tid = entity.ctid;
  3114. entitys.oid = entity.tid;
  3115. entitys.uid = uid;
  3116. entitys.userName = userName;
  3117. entitys.designerType = 1;
  3118. entitys.designerTypeText = "内部设计师";
  3119. entitys.price = Convert.ToDouble(GetPostString("price"));
  3120. entitys.designNum = GetPostInt("designNum");
  3121. entitys.modifyNum = GetPostInt("modifyNum");
  3122. entitys.designSize = GetPostString("designSize");
  3123. entitys.modifySize = GetPostString("modifySize");
  3124. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3125. {
  3126. entitys.create_time = DateTime.Now;
  3127. entitys.create_u_id = uid;
  3128. entitys.create_u_name = userName;
  3129. entitys.Save();
  3130. }
  3131. else
  3132. {
  3133. entitys.update_time = DateTime.Now;
  3134. entitys.update_u_id = uid;
  3135. entitys.update_u_name = userName;
  3136. entitys.Update();
  3137. }
  3138. }
  3139. }
  3140. }
  3141. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3142. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3143. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3144. if (suname != "")
  3145. {
  3146. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3147. }
  3148. commonHelper.getCytPrice(entity);
  3149. returnSuccessMsg("操作成功!");
  3150. return;
  3151. }
  3152. returnErrorMsg("找不到记录");
  3153. }
  3154. }
  3155. public void upload_erp_filecomplete()
  3156. {
  3157. if (UrlPostParmsCheck("ctid"))
  3158. {
  3159. string eid = GetPostString("ctid");
  3160. CeErpTradeCell entity = null;
  3161. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3162. if (entity != null)
  3163. {
  3164. entity.OrderState = 5; //设计完成
  3165. entity.Update();
  3166. returnSuccessMsg(eid + "上传成功,设计完成!");
  3167. return;
  3168. }
  3169. returnErrorMsg("找不到订单记录");
  3170. }
  3171. }
  3172. public void get_erp_designovertimelist()
  3173. {
  3174. DataStruct dStruct = GetPostStruct();
  3175. List<string> lw = new List<string>();
  3176. string tid = GetPostString("ctid");
  3177. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3178. string shopname = GetPostString("shopname");
  3179. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3180. string buyernick = GetPostString("buyer_nick");
  3181. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3182. string ResponsibleMan = GetPostString("responsible");
  3183. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3184. string date1 = GetPostString("date1");
  3185. string date2 = GetPostString("date2");
  3186. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3187. if (dw.Length > 0) lw.Add(dw);
  3188. string price1 = GetPostString("price1");
  3189. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3190. string price2 = GetPostString("price2");
  3191. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3192. string orderState = GetPostString("orderState");
  3193. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3194. string sellermemo = GetPostString("seller_memo");
  3195. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3196. lw.Add(string.Format("UnusualTag=3"));
  3197. lw.Add(string.Format("IsRefund<={0}", 1));
  3198. dStruct.Order = "WaitDesignTime desc";
  3199. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3200. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3201. writeGridDataTableJson(dStruct.TotalCount, dt);
  3202. }
  3203. //设计管理 获取抢单大厅列表
  3204. public void get_erp_grabinglist()
  3205. {
  3206. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3207. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3208. bool oldOrder = false;
  3209. if (org != null)
  3210. {
  3211. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3212. }
  3213. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3214. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3215. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3216. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3217. //先处理订单数据
  3218. if (dt.Rows.Count > 0)
  3219. {
  3220. Dictionary<string, int> design = null;
  3221. int count = 0;
  3222. foreach (DataRow row in dt.Rows)
  3223. {
  3224. if (map.ContainsKey(row["ShopId"].ToString()))
  3225. {
  3226. map.TryGetValue(row["ShopId"].ToString(), out design);
  3227. }
  3228. else
  3229. {
  3230. design = new Dictionary<string, int>();
  3231. }
  3232. if (design.ContainsKey(row["ProductId"].ToString()))
  3233. {
  3234. design.TryGetValue(row["ProductId"].ToString(), out count);
  3235. }
  3236. count++;
  3237. design[row["ProductId"].ToString()] = count;
  3238. map[row["ShopId"].ToString()] = design;
  3239. }
  3240. }
  3241. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3242. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3243. //把店铺排序和技能排序分类
  3244. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3245. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3246. if (design_dt.Rows.Count > 0)
  3247. {
  3248. Dictionary<string, string> design = null;
  3249. List<string> shopIds = null;
  3250. foreach (DataRow row in design_dt.Rows)
  3251. {
  3252. if ("0".Equals(row["designId"].ToString()))
  3253. {
  3254. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3255. {
  3256. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3257. }
  3258. else
  3259. {
  3260. shopIds = new List<string>();
  3261. }
  3262. shopIds.Add(row["shopId"].ToString());
  3263. shop_orders[row["orders"].ToString()] = shopIds;
  3264. }
  3265. else
  3266. {
  3267. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3268. {
  3269. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3270. }
  3271. else
  3272. {
  3273. design = new Dictionary<string, string>();
  3274. }
  3275. design[row["orders"].ToString()] = row["designId"].ToString();
  3276. design_orders[row["shopId"].ToString()] = design;
  3277. }
  3278. }
  3279. //处理成key value后根据key排序
  3280. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3281. foreach (List<string> val in shop_orders.Values)
  3282. {
  3283. if (val != null)
  3284. {
  3285. foreach (string key in val)
  3286. {
  3287. if (design_orders.ContainsKey(key.ToString()))
  3288. {
  3289. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3290. }
  3291. }
  3292. }
  3293. }
  3294. }
  3295. //校验哪个优先级有订单
  3296. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3297. foreach (string key in shop_orders.Keys)
  3298. {
  3299. List<string> ids = null;
  3300. shop_orders.TryGetValue(key, out ids);
  3301. //id为shopid
  3302. foreach (string id in ids)
  3303. {
  3304. Dictionary<string, int> list = null;
  3305. Dictionary<string, string> desing = null;
  3306. map.TryGetValue(id, out list);
  3307. design_orders.TryGetValue(id, out desing);
  3308. if (list != null && desing != null)
  3309. {
  3310. foreach (var item in desing)
  3311. {
  3312. int count = 0;
  3313. if (list.ContainsKey(item.Value))
  3314. {
  3315. list.TryGetValue(item.Value, out count);
  3316. if (count > 0)
  3317. {
  3318. designIds[id] = item.Value;
  3319. break;
  3320. }
  3321. }
  3322. }
  3323. }
  3324. }
  3325. if (designIds.Count > 0)
  3326. {
  3327. break;
  3328. }
  3329. }
  3330. DataTable table = new DataTable();
  3331. table.Columns.Add("tid", typeof(string));
  3332. table.Columns.Add("ctid", typeof(string));
  3333. table.Columns.Add("seller_nick", typeof(string));
  3334. table.Columns.Add("productName", typeof(string));
  3335. table.Columns.Add("pay_time", typeof(string));
  3336. table.Columns.Add("seller_memo", typeof(string));
  3337. if (designIds.Count > 0)
  3338. {
  3339. string shopId = "";
  3340. string productId = "";
  3341. foreach (var designInfo in designIds)
  3342. {
  3343. shopId = designInfo.Key;
  3344. productId = designInfo.Value;
  3345. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3346. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3347. if (dt.Rows.Count > 0)
  3348. {
  3349. foreach (DataRow row in dt.Rows)
  3350. {
  3351. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3352. {
  3353. DataRow data = table.NewRow();
  3354. data["ctid"] = row["ctid"].ToString();
  3355. data["tid"] = row["tid"].ToString();
  3356. data["seller_nick"] = ceErpShop.ShopName;
  3357. data["pay_time"] = row["pay_time"].ToString();
  3358. data["seller_memo"] = row["seller_memo"].ToString();
  3359. data["productName"] = ceErpProduct.PType;
  3360. table.Rows.Add(data);
  3361. }
  3362. }
  3363. }
  3364. }
  3365. }
  3366. writeGridDataTableJson(table.Rows.Count, table);
  3367. }
  3368. private object rushLockObject = new object();
  3369. public void set_erp_grabingorder()
  3370. {
  3371. if (UrlPostParmsCheck("ctid"))
  3372. {
  3373. int total = CurrentUser.User.Person.Total;
  3374. int userId = CurrentUser.User.ID;
  3375. int noFinish = CurrentUser.User.Person.NoFinish;
  3376. int finalization = CurrentUser.User.Person.Finalization;
  3377. string eids = GetPostString("ctid");
  3378. string key = "RushKey_" + userId;
  3379. int count = 0;
  3380. if (erpRedis.RedisHelper.KeyExists(key))
  3381. {
  3382. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3383. if (redisCount != null)
  3384. {
  3385. count = Convert.ToInt32(redisCount);
  3386. }
  3387. }
  3388. if (count >= total)
  3389. {
  3390. returnErrorMsg("半小时内已经抢" + total + "单");
  3391. return;
  3392. }
  3393. string[] ctidlist = eids.Split(',');
  3394. if (count + ctidlist.Length > total)
  3395. {
  3396. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3397. return;
  3398. }
  3399. int itag = 0;
  3400. lock (rushLockObject)
  3401. {
  3402. if (ctidlist.Length > 0)
  3403. {
  3404. string[] dtList = new string[ctidlist.Length];
  3405. for (int i = 0; i < ctidlist.Length; i++)
  3406. {
  3407. dtList[i] = "'" + ctidlist[i] + "'";
  3408. }
  3409. 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"));
  3410. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3411. if (dt_user.Rows.Count > 0)
  3412. {
  3413. int doing = 0;//未定稿
  3414. int finish = 0;//已完成
  3415. foreach (DataRow dr in dt_user.Rows)
  3416. {
  3417. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3418. {
  3419. doing++;
  3420. }
  3421. else
  3422. {
  3423. finish++;
  3424. }
  3425. }
  3426. if (doing >= noFinish)
  3427. {
  3428. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3429. return;
  3430. }
  3431. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3432. {
  3433. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3434. return;
  3435. }
  3436. }
  3437. //校验选择单子状态
  3438. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3439. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3440. if (dt.Rows.Count > 0)
  3441. {
  3442. List<string> list = new List<string>();
  3443. foreach (DataRow dr in dt.Rows)
  3444. {
  3445. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3446. {
  3447. list.Add(dr["ctid"].ToString());
  3448. }
  3449. }
  3450. if (list.Count > 0)
  3451. {
  3452. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3453. return;
  3454. }
  3455. }
  3456. foreach (string ctid in ctidlist)
  3457. {
  3458. CeErpTradeCell entity = null;
  3459. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3460. if (entity != null)
  3461. {
  3462. entity.OrderState = 3;
  3463. entity.DesignUserId = CurrentUser.UserID;
  3464. entity.WaitDesignTime = DateTime.Now;
  3465. entity.StartDesignTime = DateTime.Now;
  3466. entity.Update();
  3467. commonHelper.UpdateRelationOrder(entity.ctid);
  3468. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3469. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3470. itag++;
  3471. }
  3472. }
  3473. }
  3474. }
  3475. count += ctidlist.Length;
  3476. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3477. if (itag == 0)
  3478. returnErrorMsg("没有找到相关订单");
  3479. else
  3480. returnSuccessMsg("抢单成功!");
  3481. return;
  3482. }
  3483. }
  3484. public void get_erp_waitorderlist()
  3485. {
  3486. DataStruct dStruct = GetPostStruct();
  3487. List<string> lw = new List<string>();
  3488. string tid = GetPostString("ctid");
  3489. if (tid.Length > 0)
  3490. {
  3491. string select_tid = getTidByCtid(tid);
  3492. lw.Add(string.Format("tid='{0}'", select_tid));
  3493. }
  3494. string shopname = GetPostString("shopname");
  3495. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3496. string buyernick = GetPostString("buyer_nick");
  3497. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3498. string customer = GetPostString("customer");
  3499. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3500. string design = GetPostString("design");
  3501. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3502. string orderState = GetPostString("orderState");
  3503. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3504. string supplier = GetPostString("supplier");
  3505. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3506. string sellermemo = GetPostString("seller_memo");
  3507. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3508. string otherMemo = GetPostString("otherMemo");
  3509. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3510. string address = GetPostString("address");
  3511. 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));
  3512. string date1 = GetPostString("date1");
  3513. string date2 = GetPostString("date2");
  3514. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3515. if (dw.Length > 0) lw.Add(dw);
  3516. string price1 = GetPostString("price1");
  3517. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3518. string price2 = GetPostString("price2");
  3519. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3520. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3521. lw.Add(string.Format("IsSample != 2 "));
  3522. lw.Add(string.Format("OrderState = 5 "));
  3523. lw.Add(string.Format("IsRefund<={0}", 1));
  3524. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3525. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3526. string pagesize = GetPostString("pagesize");
  3527. if (pagesize != null)
  3528. {
  3529. dStruct.PageSize = 200;
  3530. }
  3531. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3532. List<string> tids = new List<string>();
  3533. if (dt != null)
  3534. {
  3535. dt.Columns.Add("compenPrice", typeof(double));
  3536. foreach (DataRow dr in dt.Rows)
  3537. {
  3538. if (Convert.IsDBNull(dr["compenPrice"]))
  3539. {
  3540. dr["compenPrice"] = 0;
  3541. }
  3542. tids.Add("'" + dr["tid"].ToString() + "'");
  3543. 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();
  3544. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3545. {
  3546. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3547. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3548. entity.SupplierId = suid;
  3549. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3550. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3551. entity.Update();
  3552. }
  3553. }
  3554. }
  3555. if (tids.Count > 0)
  3556. {
  3557. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3558. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3559. if (dt_price != null && dt_price.Rows.Count > 0)
  3560. {
  3561. foreach (DataRow dr in dt_price.Rows)
  3562. {
  3563. foreach (DataRow row in dt.Rows)
  3564. {
  3565. if (row["tid"].Equals(dr["ptid"]))
  3566. {
  3567. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3568. break;
  3569. }
  3570. }
  3571. }
  3572. }
  3573. }
  3574. writeGridDataTableJson(dStruct.TotalCount, dt);
  3575. }
  3576. public void get_erp_supplierwaitorderlist()
  3577. {
  3578. DataStruct dStruct = GetPostStruct();
  3579. List<string> lw = new List<string>();
  3580. string tid = GetPostString("ctid");
  3581. if (tid.Length > 0)
  3582. {
  3583. string select_tid = getTidByCtid(tid);
  3584. lw.Add(string.Format("tid='{0}'", select_tid));
  3585. }
  3586. string shopname = GetPostString("shopname");
  3587. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3588. string sellermemo = GetPostString("seller_memo");
  3589. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3590. string date1 = GetPostString("date1");
  3591. string date2 = GetPostString("date2");
  3592. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3593. if (dw.Length > 0) lw.Add(dw);
  3594. lw.Add(string.Format("OrderState = 5 "));
  3595. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3596. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3597. {
  3598. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3599. }
  3600. string supplier = GetPostString("supplier");
  3601. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3602. {
  3603. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3604. }
  3605. lw.Add(string.Format("IsRefund<={0}", 1));
  3606. dStruct.Order = "FinishDesignTime desc";
  3607. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3608. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3609. if (dt != null)
  3610. {
  3611. foreach (DataRow dr in dt.Rows)
  3612. {
  3613. 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();
  3614. }
  3615. }
  3616. writeGridDataTableJson(dStruct.TotalCount, dt);
  3617. }
  3618. public void upd_erp_verifytosupplier()
  3619. {
  3620. if (UrlPostParmsCheck("ctid"))
  3621. {
  3622. string eids = GetPostString("ctid");
  3623. CeErpTradeCell entity = null;
  3624. string[] eidsList = eids.Split(',');
  3625. if (eidsList.Length <= 0)
  3626. {
  3627. returnErrorMsg("订单号不能空");
  3628. return;
  3629. }
  3630. List<string> tLst = new List<string>();
  3631. foreach (string ctidstr in eidsList)
  3632. {
  3633. tLst.Add("'" + ctidstr + "'");
  3634. CeErpDataSendOrderInfo.createObject(ctidstr);
  3635. }
  3636. string needtids = string.Join(",", tLst.ToArray());
  3637. StringBuilder sql = new StringBuilder();
  3638. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3639. 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);
  3640. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3641. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3642. returnSuccessMsg("操作成功!");
  3643. return;
  3644. /**foreach (string ctidstr in eidsList)
  3645. {
  3646. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3647. if (entity != null)
  3648. {
  3649. if (entity.SupplierId == 0)
  3650. {
  3651. continue;
  3652. }
  3653. entity.IsVerifyToSupplier = true;
  3654. if (entity.IsReturn == 1) //1是供应商打回
  3655. {
  3656. entity.IsReturn = 0;
  3657. }
  3658. entity.FinishPlaceTime = DateTime.Now;
  3659. entity.PlaceUserId = CurrentUser.UserID;
  3660. entity.Update();
  3661. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3662. }
  3663. }
  3664. returnSuccessMsg("操作成功!");
  3665. return;**/
  3666. }
  3667. }
  3668. public void upd_erp_supplierback()
  3669. {
  3670. if (UrlPostParmsCheck("ctid"))
  3671. {
  3672. string eid = GetPostString("ctid");
  3673. string reason = GetPostString("returnreason");
  3674. CeErpTradeCell entity = null;
  3675. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3676. if (entity != null)
  3677. {
  3678. string message = "操作成功!";
  3679. string isDown = "";
  3680. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3681. {
  3682. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3683. isDown = "被点击下载";
  3684. }
  3685. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3686. {
  3687. string key = "return_order_" + entity.SupplierId;
  3688. List<string> list = new List<string>();
  3689. if (RedisHelper.HasKey(key))
  3690. {
  3691. object data = RedisHelper.StringGet(key);
  3692. list = Convert.ToString(data).Split(',').ToList();
  3693. }
  3694. list.Add(eid);
  3695. RedisHelper.StringSet(key, string.Join(",", list));
  3696. }
  3697. entity.IsVerifyToSupplier = false;
  3698. entity.IsReturn = 1;
  3699. entity.IsHaveNewOrder = 0;
  3700. entity.ReturnTime = DateTime.Now;
  3701. entity.ReturnReason = reason;
  3702. if (entity.OrderState == 6)
  3703. {
  3704. entity.OrderState = 5;
  3705. }
  3706. entity.Update();
  3707. CeErpSukuraData.createInfo(entity.ctid, 5);
  3708. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3709. returnSuccessMsg(message);
  3710. return;
  3711. }
  3712. returnErrorMsg("找不到订单记录");
  3713. }
  3714. }
  3715. public void upd_erp_toaftersaleorder()
  3716. {
  3717. if (UrlPostParmsCheck("ctid"))
  3718. {
  3719. string eid = GetPostString("ctid");
  3720. string reason = GetPostString("returnreason");
  3721. CeErpTradeCell entity = null;
  3722. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3723. if (entity != null)
  3724. {
  3725. if (entity.isAfterSaleOrder != 1)
  3726. {
  3727. returnErrorMsg("带S的售后单才能打回给售后");
  3728. return;
  3729. }
  3730. if (entity.OrderState >= 5)
  3731. {
  3732. returnErrorMsg("已经设计完成了不能打回给售后");
  3733. return;
  3734. }
  3735. entity.OrderState = 0;
  3736. entity.IsReturn = 3;
  3737. entity.ReturnTime = DateTime.Now;
  3738. entity.UpdateTime = DateTime.Now;
  3739. entity.ReturnReason = reason;
  3740. entity.Update();
  3741. CeErpSukuraData.createInfo(entity.ctid, 5);
  3742. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3743. returnSuccessMsg("操作成功!");
  3744. return;
  3745. }
  3746. returnErrorMsg("找不到订单记录");
  3747. }
  3748. }
  3749. public void upd_erp_aftersaletodesign()
  3750. {
  3751. if (UrlPostParmsCheck("ctid"))
  3752. {
  3753. string eid = GetPostString("ctid");
  3754. CeErpTradeCell entity = null;
  3755. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3756. if (entity != null)
  3757. {
  3758. entity.OrderState = 3;
  3759. entity.IsReturn = 0;
  3760. entity.UpdateTime = DateTime.Now;
  3761. entity.Update();
  3762. CeErpSukuraData.createInfo(entity.ctid, 5);
  3763. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3764. returnSuccessMsg("操作成功!");
  3765. return;
  3766. }
  3767. returnErrorMsg("找不到订单记录");
  3768. }
  3769. }
  3770. public void assign_erp_supplier()
  3771. {
  3772. if (UrlPostParmsCheck("ctid"))
  3773. {
  3774. string eids = GetPostString("ctid");
  3775. int sid = GetPostInt("SupplierName");
  3776. string fromTag = GetPostString("tag");
  3777. string[] eidList = eids.Split(',');
  3778. if (eidList.Length <= 0)
  3779. {
  3780. returnErrorMsg("指派不能为空");
  3781. return;
  3782. }
  3783. string errMsg = "";
  3784. string suname = commonHelper.getSupplierNameById(sid);
  3785. foreach (string ctid in eidList)
  3786. {
  3787. CeErpTradeCell entity = null;
  3788. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3789. if (entity != null)
  3790. {
  3791. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3792. {
  3793. errMsg += (ctid + "指派失败!!!");
  3794. continue;
  3795. }
  3796. entity.SupplierId = sid;
  3797. entity.Update();
  3798. commonHelper.UpdateRelationOrder(entity.ctid);
  3799. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3800. if (entity.OrderState >= 6)
  3801. {
  3802. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3803. //{
  3804. // string msl = entity.MakeSupplier;
  3805. // string[] mslist = msl.Split(',');
  3806. // 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);
  3807. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3808. //}
  3809. //else
  3810. //{
  3811. StringBuilder sql = new StringBuilder();
  3812. 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);
  3813. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3814. //}
  3815. }
  3816. }
  3817. else
  3818. {
  3819. continue;
  3820. }
  3821. }
  3822. if (errMsg.Length > 0)
  3823. {
  3824. returnErrorMsg(errMsg);
  3825. return;
  3826. }
  3827. returnSuccessMsg("操作成功!");
  3828. return;
  3829. }
  3830. }
  3831. public void assign_erp_makesupplier()
  3832. {
  3833. if (UrlPostParmsCheck("ctid"))
  3834. {
  3835. string eids = GetPostString("ctid");
  3836. string sname = GetPostString("SupplierName");
  3837. string[] eidList = eids.Split(',');
  3838. if (eidList.Length <= 0)
  3839. {
  3840. returnErrorMsg("指派不能为空");
  3841. return;
  3842. }
  3843. List<string> tLst = new List<string>();
  3844. foreach (string ctid in eidList)
  3845. {
  3846. CeErpTradeCell entity = null;
  3847. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3848. if (entity != null)
  3849. {
  3850. entity.MakeSupplier = sname;
  3851. entity.Update();
  3852. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3853. tLst.Add("'" + ctid + "'");
  3854. }
  3855. else
  3856. {
  3857. continue;
  3858. }
  3859. }
  3860. string ctids = string.Join(",", tLst.ToArray());
  3861. StringBuilder sql2 = new StringBuilder();
  3862. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3863. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3864. returnSuccessMsg("操作成功!");
  3865. return;
  3866. }
  3867. }
  3868. public void ins_erp_returnreason()
  3869. {
  3870. if (UrlPostParmsCheck("ctid"))
  3871. {
  3872. string eid = GetPostString("ctid");
  3873. CeErpTradeCell entity = null;
  3874. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3875. string userpost = CurrentUser.UserPost.Post.Code;
  3876. if (entity != null)
  3877. {
  3878. bool isPlace = false;
  3879. if (entity.OrderState > 6)
  3880. {
  3881. returnErrorMsg("已发货无法打回!");
  3882. return;
  3883. }
  3884. if (entity.OrderState == 6)
  3885. {
  3886. isPlace = true;
  3887. }
  3888. bool isNeedUpdateCell2 = false;
  3889. if (entity.OrderState >= 6)
  3890. {
  3891. isNeedUpdateCell2 = true;
  3892. }
  3893. int returnTag = 2;
  3894. if (userpost == "Supplier")
  3895. {
  3896. returnTag = 1;
  3897. }
  3898. int toType = GetPostInt("totype");
  3899. string fromType = "3";
  3900. if (entity.OrderState < 5)
  3901. {
  3902. fromType = "3";
  3903. }
  3904. else
  3905. {
  3906. fromType = "4";
  3907. }
  3908. if (entity.IsXianHuo == 0)
  3909. {
  3910. if (returnTag == 2)
  3911. {
  3912. if (toType == 1)
  3913. {
  3914. entity.OrderState = 0;
  3915. entity.ReturnUserType = 1;
  3916. string clearman = GetPostString("clearman");
  3917. if (!string.IsNullOrEmpty(clearman))
  3918. {
  3919. entity.DesignUserId = 0;
  3920. }
  3921. }
  3922. else
  3923. {
  3924. entity.OrderState = 3;
  3925. entity.ReturnUserType = 2;
  3926. }
  3927. entity.IsReadTag = 1;
  3928. }
  3929. else if (returnTag == 1)
  3930. {
  3931. entity.OrderState = 5;
  3932. }
  3933. entity.IsVerifyToSupplier = false;
  3934. }
  3935. if (entity.IsXianHuo == 1)
  3936. {
  3937. entity.OrderState = 5;
  3938. }
  3939. entity.UnusualTag = 0;
  3940. entity.UnusualTime = null;
  3941. entity.UnusualCon = "";
  3942. entity.IsReturn = returnTag;
  3943. entity.ReturnTime = DateTime.Now;
  3944. entity.UpdateTime = DateTime.Now;
  3945. entity.ReturnReason = GetPostString("returnreason");
  3946. entity.Update();
  3947. if (entity.OrderState == 3)
  3948. {
  3949. ApiVo apiVo = new ApiVo();
  3950. apiVo.orderNumber = entity.ctid;
  3951. apiVo.actionName = "rebutDesign";
  3952. apiVo.orderRemarks = entity.ReturnReason;
  3953. designHelper.API_WorkCore(apiVo);//rebutDesign
  3954. }
  3955. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3956. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3957. {
  3958. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3959. }
  3960. CeErpSukuraData.createInfo(entity.ctid, 5);
  3961. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3962. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3963. if (isPlace)
  3964. {
  3965. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3966. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3967. if (dth != null && dth.Rows.Count > 0)
  3968. {
  3969. dataSendOrderBean dataSendOrderBean = null;
  3970. foreach (DataRow item in dth.Rows)
  3971. {
  3972. try
  3973. {
  3974. dataSendOrderBean = new dataSendOrderBean();
  3975. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3976. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3977. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3978. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3979. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3980. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3981. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3982. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3983. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3984. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3985. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3986. dataSendOrderBean.Radio1723534706288 = "打回";
  3987. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3988. if (result != null)
  3989. {
  3990. if ("0".Equals(result.errcode))
  3991. {
  3992. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3993. }
  3994. else
  3995. {
  3996. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3997. }
  3998. }
  3999. }
  4000. catch (Exception ex)
  4001. {
  4002. }
  4003. }
  4004. }
  4005. }
  4006. if (isNeedUpdateCell2)
  4007. {
  4008. if (entity.MakeSupplier.IndexOf(",") != -1)
  4009. {
  4010. StringBuilder sql2 = new StringBuilder();
  4011. 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);
  4012. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4013. }
  4014. else
  4015. {
  4016. StringBuilder sql2 = new StringBuilder();
  4017. 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);
  4018. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4019. }
  4020. }
  4021. returnSuccessMsg("操作成功!");
  4022. return;
  4023. }
  4024. returnErrorMsg("找不到订单记录");
  4025. }
  4026. }
  4027. public void cyt_erp_returnreason()
  4028. {
  4029. if (UrlPostParmsCheck("ctid"))
  4030. {
  4031. string eid = GetPostString("ctid");
  4032. CeErpTradeCell entity = null;
  4033. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4034. string userpost = CurrentUser.UserPost.Post.Code;
  4035. if (entity != null)
  4036. {
  4037. if (entity.OrderState > 6)
  4038. {
  4039. returnErrorMsg("已发货无法打回!");
  4040. return;
  4041. }
  4042. JObject jsonObject = new JObject
  4043. {
  4044. { "Userid", "77886" },
  4045. { "Pwd", "lt666888" },
  4046. { "LTOrderId",eid }
  4047. };
  4048. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4049. JObject jsonObjects = JObject.Parse(response);
  4050. string msg = (string)jsonObjects["msg"];
  4051. if (msg != "取消成功")
  4052. {
  4053. returnErrorMsg(msg);
  4054. return;
  4055. }
  4056. bool isNeedUpdateCell2 = false;
  4057. if (entity.OrderState >= 6)
  4058. {
  4059. isNeedUpdateCell2 = true;
  4060. }
  4061. int returnTag = 2;
  4062. if (userpost == "Supplier")
  4063. {
  4064. returnTag = 1;
  4065. }
  4066. if (entity.IsXianHuo == 0)
  4067. {
  4068. if (returnTag == 2)
  4069. {
  4070. int toType = GetPostInt("totype");
  4071. if (toType == 1)
  4072. {
  4073. entity.OrderState = 0;
  4074. entity.ReturnUserType = 1;
  4075. }
  4076. else
  4077. {
  4078. entity.OrderState = 4;
  4079. entity.ReturnUserType = 2;
  4080. }
  4081. entity.IsReadTag = 1;
  4082. }
  4083. else if (returnTag == 1)
  4084. {
  4085. entity.OrderState = 5;
  4086. }
  4087. entity.IsVerifyToSupplier = false;
  4088. }
  4089. entity.UnusualTag = 0;
  4090. entity.UnusualTime = null;
  4091. entity.UnusualCon = "";
  4092. entity.IsReturn = returnTag;
  4093. entity.ReturnTime = DateTime.Now;
  4094. entity.ReturnReason = GetPostString("returnreason");
  4095. entity.Update();
  4096. if (entity.OrderState == 4)
  4097. {
  4098. ApiVo apiVo = new ApiVo();
  4099. apiVo.orderNumber = entity.ctid;
  4100. apiVo.actionName = "rebutDesign";
  4101. apiVo.orderRemarks = entity.ReturnReason;
  4102. designHelper.API_WorkCore(apiVo);//rebutDesign
  4103. }
  4104. CeErpSukuraData.createInfo(entity.ctid, 5);
  4105. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4106. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4107. if (isNeedUpdateCell2)
  4108. {
  4109. if (entity.MakeSupplier.IndexOf(",") != -1)
  4110. {
  4111. StringBuilder sql2 = new StringBuilder();
  4112. 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);
  4113. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4114. }
  4115. else
  4116. {
  4117. StringBuilder sql2 = new StringBuilder();
  4118. 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);
  4119. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4120. }
  4121. }
  4122. returnSuccessMsg("操作成功!");
  4123. return;
  4124. }
  4125. returnErrorMsg("找不到订单记录");
  4126. }
  4127. }
  4128. public void upd_erp_xianhuoreturntag()
  4129. {
  4130. if (UrlPostParmsCheck("ctid"))
  4131. {
  4132. string eids = GetPostString("ctid");
  4133. string[] ctids = eids.Split(',');
  4134. foreach (string ctid in ctids)
  4135. {
  4136. CeErpTradeCell entity = null;
  4137. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4138. if (entity != null)
  4139. {
  4140. entity.IsReturn = 0;
  4141. entity.Update();
  4142. CeErpSukuraData.createInfo(entity.ctid, 5);
  4143. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4144. }
  4145. }
  4146. returnSuccessMsg("操作成功!");
  4147. return;
  4148. }
  4149. }
  4150. public void get_erp_waitdeliverylist()
  4151. {
  4152. DataStruct dStruct = GetPostStruct();
  4153. List<string> lw = new List<string>();
  4154. string tid = GetPostString("ctid");
  4155. if (tid.Length > 0)
  4156. {
  4157. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4158. if (tid.Length > 5)
  4159. {
  4160. List<string> tids = getTidByCtidLike(tid);
  4161. if (tids.Count > 0 && tids.Count < 10)
  4162. {
  4163. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4164. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4165. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4166. {
  4167. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4168. }*/
  4169. }
  4170. }
  4171. lw.Add(tid_sql);
  4172. }
  4173. string shopname = GetPostString("shopname");
  4174. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4175. string buyernick = GetPostString("buyer_nick");
  4176. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4177. //if (tid.Length == 0 && buyernick.Length == 0)
  4178. //{
  4179. // lw.Add(string.Format("IsRefund<={0}", 1));
  4180. //}
  4181. string customer = GetPostString("customer");
  4182. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4183. string design = GetPostString("design");
  4184. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4185. string orderState = GetPostString("orderState");
  4186. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4187. string address = GetPostString("address");
  4188. 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));
  4189. string sellermemo = GetPostString("seller_memo");
  4190. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4191. string supplier = GetPostString("supplier");
  4192. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4193. string OrderArea = GetPostString("order_area");
  4194. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4195. string placedate1 = GetPostString("placedate1");
  4196. string placedate2 = GetPostString("placedate2");
  4197. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4198. if (fdw.Length > 0) lw.Add(fdw);
  4199. string price1 = GetPostString("price1");
  4200. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4201. string price2 = GetPostString("price2");
  4202. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4203. string unusualCon = GetPostString("unusualcon");
  4204. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4205. string otherMemo = GetPostString("otherMemo");
  4206. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4207. string posTag = CurrentUser.UserPost.Post.Code;
  4208. if (posTag == "Supplier")
  4209. {
  4210. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4211. }
  4212. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4213. lw.Add(string.Format("type != 'PDD' "));
  4214. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4215. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4216. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4217. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4218. writeGridDataTableJson(dStruct.TotalCount, dt);
  4219. }
  4220. public void get_erp_changedeliverylist()
  4221. {
  4222. DataStruct dStruct = GetPostStruct();
  4223. List<string> lw = new List<string>();
  4224. string tid = GetPostString("ctid");
  4225. if (tid.Length > 0)
  4226. {
  4227. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4228. if (tid.Length > 5)
  4229. {
  4230. List<string> tids = getTidByCtidLike(tid);
  4231. if (tids.Count > 0 && tids.Count < 10)
  4232. {
  4233. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4234. }
  4235. }
  4236. lw.Add(tid_sql);
  4237. }
  4238. string shopname = GetPostString("shopname");
  4239. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4240. string buyernick = GetPostString("buyer_nick");
  4241. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4242. //if (tid.Length == 0 && buyernick.Length == 0)
  4243. //{
  4244. // lw.Add(string.Format("IsRefund<={0}", 1));
  4245. //}
  4246. string customer = GetPostString("customer");
  4247. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4248. string design = GetPostString("design");
  4249. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4250. string orderState = GetPostString("orderState");
  4251. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4252. string address = GetPostString("address");
  4253. 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));
  4254. string sellermemo = GetPostString("seller_memo");
  4255. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4256. string supplier = GetPostString("supplier");
  4257. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4258. string OrderArea = GetPostString("order_area");
  4259. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4260. string placedate1 = GetPostString("placedate1");
  4261. string placedate2 = GetPostString("placedate2");
  4262. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4263. if (fdw.Length > 0) lw.Add(fdw);
  4264. string price1 = GetPostString("price1");
  4265. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4266. string price2 = GetPostString("price2");
  4267. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4268. string unusualCon = GetPostString("unusualcon");
  4269. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4270. string otherMemo = GetPostString("otherMemo");
  4271. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4272. string posTag = CurrentUser.UserPost.Post.Code;
  4273. if (posTag == "Supplier")
  4274. {
  4275. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4276. }
  4277. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4278. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4279. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4280. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4281. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4282. /*if (tid.Length > 0)
  4283. {
  4284. List<string> tids = new List<string>();
  4285. if (dt != null && dt.Rows.Count > 0)
  4286. {
  4287. foreach (DataRow item in dt.Rows)
  4288. {
  4289. tids.Add("'" + item["tid"] + "'");
  4290. }
  4291. }
  4292. if (tids.Count > 0)
  4293. {
  4294. lw.RemoveAt(0);
  4295. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4296. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4297. dt = WebCache.GetData("view_erptradecell", dStruct);
  4298. }
  4299. }*/
  4300. writeGridDataTableJson(dStruct.TotalCount, dt);
  4301. }
  4302. public void get_erp_pddderiving()
  4303. {
  4304. DataStruct dStruct = GetPostStruct();
  4305. List<string> lw = new List<string>();
  4306. string tid = GetPostString("ctid");
  4307. if (tid.Length > 0)
  4308. {
  4309. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4310. if (tid.Length > 5)
  4311. {
  4312. List<string> tids = getTidByCtidLike(tid);
  4313. if (tids.Count > 0 && tids.Count < 10)
  4314. {
  4315. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4316. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4317. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4318. {
  4319. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4320. }*/
  4321. }
  4322. }
  4323. lw.Add(tid_sql);
  4324. }
  4325. string shopname = GetPostString("shopname");
  4326. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4327. string buyernick = GetPostString("buyer_nick");
  4328. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4329. //if (tid.Length == 0 && buyernick.Length == 0)
  4330. //{
  4331. // lw.Add(string.Format("IsRefund<={0}", 1));
  4332. //}
  4333. string customer = GetPostString("customer");
  4334. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4335. string design = GetPostString("design");
  4336. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4337. string orderState = GetPostString("orderState");
  4338. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4339. string address = GetPostString("address");
  4340. 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));
  4341. string sellermemo = GetPostString("seller_memo");
  4342. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4343. string supplier = GetPostString("supplier");
  4344. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4345. string OrderArea = GetPostString("order_area");
  4346. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4347. string placedate1 = GetPostString("placedate1");
  4348. string placedate2 = GetPostString("placedate2");
  4349. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4350. if (fdw.Length > 0) lw.Add(fdw);
  4351. string price1 = GetPostString("price1");
  4352. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4353. string price2 = GetPostString("price2");
  4354. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4355. string unusualCon = GetPostString("unusualcon");
  4356. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4357. string posTag = CurrentUser.UserPost.Post.Code;
  4358. if (posTag == "Supplier")
  4359. {
  4360. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4361. }
  4362. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4363. lw.Add(string.Format("type = 'PDD' "));
  4364. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4365. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4366. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4367. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4368. /*if (tid.Length > 0)
  4369. {
  4370. List<string> tids = new List<string>();
  4371. if (dt != null && dt.Rows.Count > 0)
  4372. {
  4373. foreach (DataRow item in dt.Rows)
  4374. {
  4375. tids.Add("'" + item["tid"] + "'");
  4376. }
  4377. }
  4378. if (tids.Count > 0)
  4379. {
  4380. lw.RemoveAt(0);
  4381. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4382. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4383. dt = WebCache.GetData("view_erptradecell", dStruct);
  4384. }
  4385. }*/
  4386. writeGridDataTableJson(dStruct.TotalCount, dt);
  4387. }
  4388. public void get_erp_jdderiving()
  4389. {
  4390. DataStruct dStruct = GetPostStruct();
  4391. List<string> lw = new List<string>();
  4392. string tid = GetPostString("ctid");
  4393. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4394. string shopname = GetPostString("shopname");
  4395. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4396. string buyernick = GetPostString("buyer_nick");
  4397. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4398. //if (tid.Length == 0 && buyernick.Length == 0)
  4399. //{
  4400. // lw.Add(string.Format("IsRefund<={0}", 1));
  4401. //}
  4402. string customer = GetPostString("customer");
  4403. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4404. string design = GetPostString("design");
  4405. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4406. string orderState = GetPostString("orderState");
  4407. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4408. string address = GetPostString("address");
  4409. 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));
  4410. string sellermemo = GetPostString("seller_memo");
  4411. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4412. string supplier = GetPostString("supplier");
  4413. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4414. string OrderArea = GetPostString("order_area");
  4415. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4416. string placedate1 = GetPostString("placedate1");
  4417. string placedate2 = GetPostString("placedate2");
  4418. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4419. if (fdw.Length > 0) lw.Add(fdw);
  4420. string price1 = GetPostString("price1");
  4421. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4422. string price2 = GetPostString("price2");
  4423. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4424. string unusualCon = GetPostString("unusualcon");
  4425. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4426. string posTag = CurrentUser.UserPost.Post.Code;
  4427. if (posTag == "Supplier")
  4428. {
  4429. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4430. }
  4431. lw.Add(string.Format("OrderState = 6 "));
  4432. lw.Add(string.Format("type = 'JD' "));
  4433. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4434. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4435. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4436. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4437. writeGridDataTableJson(dStruct.TotalCount, dt);
  4438. }
  4439. public void get_erp_demoorderlist()
  4440. {
  4441. DataStruct dStruct = GetPostStruct();
  4442. List<string> lw = new List<string>();
  4443. string tid = GetPostString("ctid");
  4444. if (tid.Length > 0)
  4445. {
  4446. string select_tid = getTidByCtid(tid);
  4447. lw.Add(string.Format("tid='{0}'", select_tid));
  4448. }
  4449. string shopname = GetPostString("shopname");
  4450. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4451. string buyernick = GetPostString("buyer_nick");
  4452. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  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("address 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 date1 = GetPostString("date1");
  4468. string date2 = GetPostString("date2");
  4469. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4470. if (dw.Length > 0) lw.Add(dw);
  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 posTag = CurrentUser.UserPost.Post.Code;
  4476. if (posTag == "Supplier")
  4477. {
  4478. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4479. }
  4480. //lw.Add(string.Format("OrderState = 6 "));
  4481. lw.Add(string.Format("IsSample={0}", 3));
  4482. lw.Add(string.Format("IsRefund<={0}", 1));
  4483. dStruct.Order = "pay_time desc";
  4484. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4485. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4486. writeGridDataTableJson(dStruct.TotalCount, dt);
  4487. }
  4488. public void save_erp_checkmemo()
  4489. {
  4490. if (UrlPostParmsCheck("ctid"))
  4491. {
  4492. string ctid = GetPostString("ctid");
  4493. CeErpTradeCell entity = null;
  4494. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4495. if (entity != null)
  4496. {
  4497. entity.CheckMemo = GetPostString("CheckMemo");
  4498. entity.Update();
  4499. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4500. if (trade != null)
  4501. {
  4502. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4503. }
  4504. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4505. returnSuccessMsg("保存成功!");
  4506. return;
  4507. }
  4508. returnErrorMsg("找不到记录");
  4509. }
  4510. }
  4511. public void get_erp_returnlist()
  4512. {
  4513. DataStruct dStruct = GetPostStruct();
  4514. List<string> lw = new List<string>();
  4515. string tid = GetPostString("ctid");
  4516. if (tid.Length > 0)
  4517. {
  4518. string select_tid = getTidByCtid(tid);
  4519. lw.Add(string.Format("tid='{0}'", select_tid));
  4520. }
  4521. string shopname = GetPostString("shopname");
  4522. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4523. string buyernick = GetPostString("buyer_nick");
  4524. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4525. string customer = GetPostString("customer");
  4526. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4527. string design = GetPostString("design");
  4528. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4529. string orderState = GetPostString("orderState");
  4530. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4531. string address = GetPostString("address");
  4532. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4533. string sellermemo = GetPostString("seller_memo");
  4534. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4535. string supplier = GetPostString("supplier");
  4536. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4537. string date1 = GetPostString("date1");
  4538. string date2 = GetPostString("date2");
  4539. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4540. if (dw.Length > 0) lw.Add(dw);
  4541. string bdate1 = GetPostString("backdate1");
  4542. string bdate2 = GetPostString("backdate2");
  4543. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4544. if (dw_back.Length > 0) lw.Add(dw_back);
  4545. string price1 = GetPostString("price1");
  4546. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4547. string price2 = GetPostString("price2");
  4548. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4549. lw.Add(string.Format("IsReturn>0"));
  4550. lw.Add(string.Format("IsXianHuo=0"));
  4551. lw.Add(string.Format("IsReturn!=3"));
  4552. string backtype = GetPostString("backtype");
  4553. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4554. dStruct.Order = "FinishDesignTime desc";
  4555. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4556. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4557. writeGridDataTableJson(dStruct.TotalCount, dt);
  4558. }
  4559. public void get_erp_today_sumreturn()
  4560. {
  4561. DataStruct dStruct = GetPostStruct();
  4562. List<string> lw = new List<string>();
  4563. string bdate1 = GetPostString("returnTimeS");
  4564. string bdate2 = GetPostString("returnTimeE");
  4565. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4566. if (dw_back.Length > 0) lw.Add(dw_back);
  4567. lw.Add(string.Format("IsReturn=0"));
  4568. lw.Add(string.Format("IsXianHuo=0"));
  4569. string mainWhere = string.Join(" and ", lw.ToArray());
  4570. string sql = "";
  4571. if (dw_back.Length > 0)
  4572. {
  4573. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4574. }
  4575. else
  4576. {
  4577. 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 + "'";
  4578. }
  4579. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4580. decimal total = 0, today_finish = 0;
  4581. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4582. {
  4583. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4584. }
  4585. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4586. {
  4587. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4588. }
  4589. var res = new
  4590. {
  4591. data = total,
  4592. data1 = today_finish,
  4593. };
  4594. string ro_jsond = JsonConvert.SerializeObject(res);
  4595. returnSuccess(ro_jsond);
  4596. return;
  4597. }
  4598. public void get_erp_allreturnlist()
  4599. {
  4600. DataStruct dStruct = GetPostStruct();
  4601. List<string> lw = new List<string>();
  4602. string tid = GetPostString("ctid");
  4603. if (tid.Length > 0)
  4604. {
  4605. string select_tid = getTidByCtid(tid);
  4606. lw.Add(string.Format("tid='{0}'", select_tid));
  4607. }
  4608. string shopname = GetPostString("shopname");
  4609. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4610. string buyernick = GetPostString("buyer_nick");
  4611. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4612. string customer = GetPostString("customer");
  4613. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4614. string design = GetPostString("design");
  4615. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4616. string orderState = GetPostString("orderState");
  4617. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4618. string address = GetPostString("address");
  4619. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4620. string sellermemo = GetPostString("seller_memo");
  4621. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4622. string supplier = GetPostString("supplier");
  4623. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4624. string date1 = GetPostString("date1");
  4625. string date2 = GetPostString("date2");
  4626. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4627. if (dw.Length > 0) lw.Add(dw);
  4628. string bdate1 = GetPostString("backdate1");
  4629. string bdate2 = GetPostString("backdate2");
  4630. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4631. if (dw_back.Length > 0) lw.Add(dw_back);
  4632. string price1 = GetPostString("price1");
  4633. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4634. string price2 = GetPostString("price2");
  4635. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4636. string backreason = GetPostString("backreason");
  4637. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4638. lw.Add(string.Format("IsXianHuo=0"));
  4639. lw.Add(string.Format("ReturnTime != ''"));
  4640. string backtype = GetPostString("backtype");
  4641. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4642. dStruct.Order = "FinishDesignTime desc";
  4643. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4644. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4645. writeGridDataTableJson(dStruct.TotalCount, dt);
  4646. }
  4647. public void get_erp_aftersalereturnlist()
  4648. {
  4649. DataStruct dStruct = GetPostStruct();
  4650. List<string> lw = new List<string>();
  4651. string tid = GetPostString("ctid");
  4652. if (tid.Length > 0)
  4653. {
  4654. string select_tid = getTidByCtid(tid);
  4655. lw.Add(string.Format("tid='{0}'", select_tid));
  4656. }
  4657. string shopname = GetPostString("shopname");
  4658. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4659. string buyernick = GetPostString("buyer_nick");
  4660. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4661. string customer = GetPostString("customer");
  4662. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4663. string design = GetPostString("design");
  4664. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4665. string orderState = GetPostString("orderState");
  4666. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4667. string address = GetPostString("address");
  4668. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4669. string sellermemo = GetPostString("seller_memo");
  4670. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4671. string supplier = GetPostString("supplier");
  4672. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4673. string date1 = GetPostString("date1");
  4674. string date2 = GetPostString("date2");
  4675. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4676. if (dw.Length > 0) lw.Add(dw);
  4677. string bdate1 = GetPostString("backdate1");
  4678. string bdate2 = GetPostString("backdate2");
  4679. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4680. if (dw_back.Length > 0) lw.Add(dw_back);
  4681. string price1 = GetPostString("price1");
  4682. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4683. string price2 = GetPostString("price2");
  4684. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4685. lw.Add(string.Format("IsReturn=3"));
  4686. string backtype = GetPostString("backtype");
  4687. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4688. string backreason = GetPostString("backreason");
  4689. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4690. dStruct.Order = "ReturnTime desc";
  4691. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4692. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4693. writeGridDataTableJson(dStruct.TotalCount, dt);
  4694. }
  4695. public void get_erp_xianhuoreturnlist()
  4696. {
  4697. DataStruct dStruct = GetPostStruct();
  4698. List<string> lw = new List<string>();
  4699. string tid = GetPostString("ctid");
  4700. if (tid.Length > 0)
  4701. {
  4702. string select_tid = getTidByCtid(tid);
  4703. lw.Add(string.Format("tid='{0}'", select_tid));
  4704. }
  4705. string shopname = GetPostString("shopname");
  4706. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4707. string buyernick = GetPostString("buyer_nick");
  4708. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4709. string customer = GetPostString("customer");
  4710. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4711. string design = GetPostString("design");
  4712. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4713. string orderState = GetPostString("orderState");
  4714. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4715. string address = GetPostString("address");
  4716. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4717. string sellermemo = GetPostString("seller_memo");
  4718. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4719. string supplier = GetPostString("supplier");
  4720. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4721. string OrderArea = GetPostString("order_area");
  4722. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4723. string date1 = GetPostString("date1");
  4724. string date2 = GetPostString("date2");
  4725. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4726. if (dw.Length > 0) lw.Add(dw);
  4727. string price1 = GetPostString("price1");
  4728. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4729. string price2 = GetPostString("price2");
  4730. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4731. string posTag = CurrentUser.UserPost.Post.Code;
  4732. if (posTag == "Supplier")
  4733. {
  4734. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4735. }
  4736. lw.Add(string.Format("OrderState=6 "));
  4737. lw.Add(string.Format("IsXianHuo=1 "));
  4738. lw.Add(string.Format("IsReturn>0 "));
  4739. lw.Add(string.Format("IsReturn!=3"));
  4740. lw.Add(string.Format("IsRefund<={0}", 1));
  4741. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4742. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4743. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4744. writeGridDataTableJson(dStruct.TotalCount, dt);
  4745. }
  4746. public void set_erp_orderdelivery()
  4747. {
  4748. if (UrlPostParmsCheck("ctid"))
  4749. {
  4750. string eid = GetPostString("ctid");
  4751. CeErpTradeCell entity = null;
  4752. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4753. if (entity != null)
  4754. {
  4755. if (entity.OrderState >= 7)
  4756. {
  4757. returnErrorMsg("此单已发货,无需重复发货");
  4758. return;
  4759. }
  4760. if (entity.OrderState != 6)
  4761. {
  4762. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4763. return;
  4764. }
  4765. string shop = GetPostString("seller_nick");
  4766. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4767. string comName = GetPostString("comName");
  4768. string comCode = GetPostString("comCode");
  4769. string outSid = GetPostString("outSid");
  4770. string deliveryType = GetPostString("deliveryType");
  4771. string deliveryMemo = GetPostString("deliveryMemo");
  4772. outSid = outSid.Trim();
  4773. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4774. if (mainEn == null)
  4775. {
  4776. returnErrorMsg("找不到原始订单记录");
  4777. return;
  4778. }
  4779. bool isInitOrderDeliv = false;
  4780. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4781. {
  4782. isInitOrderDeliv = true;
  4783. }
  4784. string apires = "";
  4785. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4786. 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)
  4787. {
  4788. apires = "发货成功true";
  4789. }
  4790. else
  4791. {
  4792. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4793. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4794. }
  4795. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4796. {
  4797. entity.OrderState = 7;//发货后订单已发货
  4798. entity.OutSid = outSid;
  4799. entity.MemoOpt = 0;
  4800. entity.UpdateTime = DateTime.Now;
  4801. entity.FinishDeliveryTime = DateTime.Now;
  4802. entity.Update();
  4803. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4804. commonHelper.UpdateRelationOrder(entity.ctid);
  4805. //还要插入快递信息到 快递信息表
  4806. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4807. exinfo.tid = eid;
  4808. exinfo.out_sid = outSid;
  4809. exinfo.company_code = comCode;
  4810. exinfo.company_name = comName;
  4811. exinfo.delivery_memo = deliveryMemo;
  4812. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4813. exinfo.deliveryType = deliveryType;
  4814. exinfo.Create();
  4815. returnSuccessMsg("发货操作成功!");
  4816. commonHelper.UpdateRelationOrder(entity.ctid);
  4817. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4818. CeErpSukuraData.createInfo(entity.ctid, 4);
  4819. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4820. {
  4821. commonHelper.sendCytExpress(exinfo);
  4822. }
  4823. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4824. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4825. }
  4826. else
  4827. {
  4828. string errmsg = commonHelper.KeepChinese(apires);
  4829. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4830. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4831. }
  4832. return;
  4833. }
  4834. returnErrorMsg("找不到订单记录");
  4835. }
  4836. }
  4837. public void set_erp_multidelivery()
  4838. {
  4839. string eids = GetPostString("tids");
  4840. string[] eidList = eids.Split(',');
  4841. if (eidList.Length <= 0)
  4842. {
  4843. returnErrorMsg("发货不能为空");
  4844. return;
  4845. }
  4846. foreach (string ctid in eidList)
  4847. {
  4848. if (ctid.Length <= 0) continue;
  4849. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4850. if (expInfo != null)
  4851. {
  4852. StringBuilder sql = new StringBuilder();
  4853. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4854. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4855. if (dt.Rows.Count > 0)
  4856. {
  4857. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4858. {
  4859. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4860. expInfo.state = "异常";
  4861. expInfo.isMultiDelivery = 1;
  4862. expInfo.Update();
  4863. continue;
  4864. }
  4865. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4866. {
  4867. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4868. expInfo.state = "异常";
  4869. expInfo.Update();
  4870. continue;
  4871. }
  4872. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4873. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4874. bool isInitOrderDeliv = false;
  4875. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4876. {
  4877. isInitOrderDeliv = true;
  4878. expInfo.isMultiDelivery = 1;
  4879. }
  4880. if (ctid.IndexOf("N") != -1)
  4881. {
  4882. StringBuilder sqlbucha = new StringBuilder();
  4883. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4884. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4885. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4886. commonHelper.UpdateRelationOrder(ctid);
  4887. expInfo.delivery_memo = "发货成功";
  4888. expInfo.state = "发货成功";
  4889. expInfo.isMultiDelivery = 1;
  4890. expInfo.Update();
  4891. }
  4892. else
  4893. {
  4894. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4895. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4896. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4897. {
  4898. expInfo.delivery_memo = "发货成功";
  4899. expInfo.state = "发货成功";
  4900. expInfo.isMultiDelivery = 1;
  4901. expInfo.Update();
  4902. commonHelper.UpdateRelationOrder(ctid);
  4903. CeErpSukuraData.createInfo(ctid, 4);
  4904. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4905. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4906. }
  4907. else
  4908. {
  4909. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4910. expInfo.state = "异常";
  4911. expInfo.Update();
  4912. }
  4913. }
  4914. }
  4915. }
  4916. }
  4917. returnSuccessMsg("操作完成");
  4918. }
  4919. public void reset_erp_memoopt()
  4920. {
  4921. if (UrlPostParmsCheck("ctid"))
  4922. {
  4923. string eid = GetPostString("ctid");
  4924. CeErpTradeCell entity = null;
  4925. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4926. if (entity != null)
  4927. {
  4928. string stropt = "";
  4929. if (entity.MemoOpt == 1)
  4930. {
  4931. stropt = "“改稿”";
  4932. }
  4933. else if (entity.MemoOpt == 2)
  4934. {
  4935. stropt = "“定稿”";
  4936. }
  4937. else if (entity.MemoOpt == 3)
  4938. {
  4939. stropt = "“完成查货”";
  4940. CeErpSukuraData.createInfo(entity.ctid, 6);
  4941. }
  4942. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4943. entity.UpdateTime = DateTime.Now;
  4944. entity.MemoOpt = 0;
  4945. entity.Update();
  4946. returnSuccessMsg("操作成功!");
  4947. return;
  4948. }
  4949. returnErrorMsg("找不到记录");
  4950. }
  4951. }
  4952. public void get_erp_deliveryunusual()
  4953. {
  4954. DataStruct dStruct = GetPostStruct();
  4955. List<string> lw = new List<string>();
  4956. string tid = GetPostString("ctid");
  4957. if (tid.Length > 0)
  4958. {
  4959. string select_tid = getTidByCtid(tid);
  4960. lw.Add(string.Format("tid='{0}'", select_tid));
  4961. }
  4962. string shopname = GetPostString("shopname");
  4963. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4964. string buyernick = GetPostString("buyer_nick");
  4965. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4966. string customer = GetPostString("customer");
  4967. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4968. string design = GetPostString("design");
  4969. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4970. string sellermemo = GetPostString("seller_memo");
  4971. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4972. string supplier = GetPostString("supplier");
  4973. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4974. string date1 = GetPostString("date1");
  4975. string date2 = GetPostString("date2");
  4976. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4977. if (dw.Length > 0) lw.Add(dw);
  4978. string placedate1 = GetPostString("placedate1");
  4979. string placedate2 = GetPostString("placedate2");
  4980. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4981. if (dw_place.Length > 0) lw.Add(dw_place);
  4982. string price1 = GetPostString("price1");
  4983. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4984. string price2 = GetPostString("price2");
  4985. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4986. string unusualCon = GetPostString("unusualcon");
  4987. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4988. string posTag = CurrentUser.UserPost.Post.Code;
  4989. if (posTag == "Supplier")
  4990. {
  4991. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4992. }
  4993. lw.Add(string.Format("OrderState = 6"));
  4994. lw.Add(string.Format("UnusualTag = 5"));
  4995. lw.Add(string.Format("IsRefund<={0}", 1));
  4996. dStruct.Order = "FinishPlaceTime desc";
  4997. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4998. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4999. writeGridDataTableJson(dStruct.TotalCount, dt);
  5000. }
  5001. public void get_erp_deliveryedlist()
  5002. {
  5003. DataStruct dStruct = GetPostStruct();
  5004. List<string> lw = new List<string>();
  5005. string tid = GetPostString("ctid");
  5006. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5007. string shopname = GetPostString("shopname");
  5008. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5009. string buyernick = GetPostString("buyer_nick");
  5010. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5011. string customer = GetPostString("customer");
  5012. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5013. string design = GetPostString("design");
  5014. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5015. string sellermemo = GetPostString("seller_memo");
  5016. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5017. string logistics = GetPostString("logistics");
  5018. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5019. string date1 = GetPostString("date1");
  5020. string date2 = GetPostString("date2");
  5021. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5022. //if (dw.Length > 0) lw.Add(dw);
  5023. string placedate1 = GetPostString("placedate1");
  5024. string placedate2 = GetPostString("placedate2");
  5025. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5026. if (fdw.Length > 0) lw.Add(fdw);
  5027. string devdate1 = GetPostString("deliverydate1");
  5028. string devdate2 = GetPostString("deliverydate2");
  5029. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5030. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5031. string price1 = GetPostString("price1");
  5032. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5033. string price2 = GetPostString("price2");
  5034. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5035. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5036. {
  5037. if (tid.Length > 0)
  5038. {
  5039. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5040. if (tid.Length > 5)
  5041. {
  5042. List<string> tids = getTidByCtidLike(tid);
  5043. if (tids.Count > 0 && tids.Count < 10)
  5044. {
  5045. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5046. }
  5047. }
  5048. lw.Add(tid_sql);
  5049. }
  5050. if (buyernick.Length > 0)
  5051. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5052. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5053. if (dw.Length > 0) lw.Add(dw);
  5054. }
  5055. else
  5056. {
  5057. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5058. }
  5059. string posTag = CurrentUser.UserPost.Post.Code;
  5060. if (posTag == "Supplier")
  5061. {
  5062. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5063. }
  5064. else
  5065. {
  5066. string supplier = GetPostString("supplier");
  5067. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5068. }
  5069. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5070. lw.Add(string.Format("type != 'PDD' "));
  5071. lw.Add(string.Format("IsRefund!={0}", 2));
  5072. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5073. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5074. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5075. /*if (tid.Length > 0)
  5076. {
  5077. List<string> tids = new List<string>();
  5078. if (dt != null && dt.Rows.Count > 0)
  5079. {
  5080. foreach (DataRow item in dt.Rows)
  5081. {
  5082. tids.Add("'" + item["tid"] + "'");
  5083. }
  5084. }
  5085. if (tids.Count > 0)
  5086. {
  5087. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5088. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5089. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5090. dt = WebCache.GetData("view_erptradecell", dStruct);
  5091. }
  5092. }*/
  5093. if (dt != null)
  5094. {
  5095. foreach (DataRow dr in dt.Rows)
  5096. {
  5097. 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();
  5098. }
  5099. }
  5100. writeGridDataTableJson(dStruct.TotalCount, dt);
  5101. }
  5102. public void get_erp_pdddeliveryed()
  5103. {
  5104. DataStruct dStruct = GetPostStruct();
  5105. List<string> lw = new List<string>();
  5106. string tid = GetPostString("ctid");
  5107. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5108. string shopname = GetPostString("shopname");
  5109. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5110. string buyernick = GetPostString("buyer_nick");
  5111. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5112. string customer = GetPostString("customer");
  5113. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5114. string design = GetPostString("design");
  5115. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5116. string sellermemo = GetPostString("seller_memo");
  5117. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5118. string logistics = GetPostString("logistics");
  5119. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5120. string date1 = GetPostString("date1");
  5121. string date2 = GetPostString("date2");
  5122. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5123. //if (dw.Length > 0) lw.Add(dw);
  5124. string placedate1 = GetPostString("placedate1");
  5125. string placedate2 = GetPostString("placedate2");
  5126. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5127. if (fdw.Length > 0) lw.Add(fdw);
  5128. string devdate1 = GetPostString("deliverydate1");
  5129. string devdate2 = GetPostString("deliverydate2");
  5130. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5131. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5132. string price1 = GetPostString("price1");
  5133. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5134. string price2 = GetPostString("price2");
  5135. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5136. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5137. {
  5138. if (tid.Length > 0)
  5139. {
  5140. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5141. if (tid.Length > 5)
  5142. {
  5143. List<string> tids = getTidByCtidLike(tid);
  5144. if (tids.Count > 0 && tids.Count < 10)
  5145. {
  5146. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5147. }
  5148. }
  5149. lw.Add(tid_sql);
  5150. }
  5151. if (buyernick.Length > 0)
  5152. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5153. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5154. if (dw.Length > 0) lw.Add(dw);
  5155. }
  5156. else
  5157. {
  5158. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5159. }
  5160. string posTag = CurrentUser.UserPost.Post.Code;
  5161. if (posTag == "Supplier")
  5162. {
  5163. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5164. }
  5165. else
  5166. {
  5167. string supplier = GetPostString("supplier");
  5168. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5169. }
  5170. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5171. lw.Add(string.Format("type = 'PDD' "));
  5172. lw.Add(string.Format("IsRefund!={0}", 2));
  5173. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5174. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5175. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5176. /* if (tid.Length > 0)
  5177. {
  5178. List<string> tids = new List<string>();
  5179. if (dt != null && dt.Rows.Count > 0)
  5180. {
  5181. foreach (DataRow item in dt.Rows)
  5182. {
  5183. tids.Add("'" + item["tid"] + "'");
  5184. }
  5185. }
  5186. if (tids.Count > 0)
  5187. {
  5188. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5189. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5190. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5191. dt = WebCache.GetData("view_erptradecell", dStruct);
  5192. }
  5193. }*/
  5194. foreach (DataRow dr in dt.Rows)
  5195. {
  5196. 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();
  5197. }
  5198. writeGridDataTableJson(dStruct.TotalCount, dt);
  5199. }
  5200. public void get_erp_jddeliveryed()
  5201. {
  5202. DataStruct dStruct = GetPostStruct();
  5203. List<string> lw = new List<string>();
  5204. string tid = GetPostString("ctid");
  5205. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5206. string shopname = GetPostString("shopname");
  5207. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5208. string buyernick = GetPostString("buyer_nick");
  5209. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5210. string customer = GetPostString("customer");
  5211. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5212. string design = GetPostString("design");
  5213. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5214. string sellermemo = GetPostString("seller_memo");
  5215. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5216. string date1 = GetPostString("date1");
  5217. string date2 = GetPostString("date2");
  5218. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5219. //if (dw.Length > 0) lw.Add(dw);
  5220. string placedate1 = GetPostString("placedate1");
  5221. string placedate2 = GetPostString("placedate2");
  5222. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5223. if (fdw.Length > 0) lw.Add(fdw);
  5224. string devdate1 = GetPostString("deliverydate1");
  5225. string devdate2 = GetPostString("deliverydate2");
  5226. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5227. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5228. string price1 = GetPostString("price1");
  5229. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5230. string price2 = GetPostString("price2");
  5231. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5232. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5233. {
  5234. if (tid.Length > 0)
  5235. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5236. if (buyernick.Length > 0)
  5237. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5238. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5239. if (dw.Length > 0) lw.Add(dw);
  5240. }
  5241. else
  5242. {
  5243. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5244. }
  5245. string posTag = CurrentUser.UserPost.Post.Code;
  5246. if (posTag == "Supplier")
  5247. {
  5248. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5249. }
  5250. else
  5251. {
  5252. string supplier = GetPostString("supplier");
  5253. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5254. }
  5255. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5256. lw.Add(string.Format("type = 'JD' "));
  5257. lw.Add(string.Format("IsRefund!={0}", 2));
  5258. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5259. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5260. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5261. foreach (DataRow dr in dt.Rows)
  5262. {
  5263. 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();
  5264. }
  5265. writeGridDataTableJson(dStruct.TotalCount, dt);
  5266. }
  5267. public void get_erp_allplacelist()
  5268. {
  5269. DataStruct dStruct = GetPostStruct();
  5270. List<string> lw = new List<string>();
  5271. string tid = GetPostString("ctid");
  5272. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5273. string shopname = GetPostString("shopname");
  5274. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5275. string buyernick = GetPostString("buyer_nick");
  5276. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5277. string customer = GetPostString("customer");
  5278. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5279. string design = GetPostString("design");
  5280. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5281. string sellermemo = GetPostString("seller_memo");
  5282. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5283. string supplier = GetPostString("supplier");
  5284. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5285. string date1 = GetPostString("date1");
  5286. string date2 = GetPostString("date2");
  5287. string pldate1 = GetPostString("placedate1");
  5288. string pldate2 = GetPostString("placedate2");
  5289. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5290. //if (dw.Length > 0) lw.Add(dw);
  5291. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5292. {
  5293. if (tid.Length > 0)
  5294. {
  5295. string select_tid = getTidByCtid(tid);
  5296. lw.Add(string.Format("tid='{0}'", select_tid));
  5297. }
  5298. if (buyernick.Length > 0)
  5299. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5300. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5301. if (dw.Length > 0) lw.Add(dw);
  5302. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5303. if (dw_place.Length > 0) lw.Add(dw_place);
  5304. }
  5305. else
  5306. {
  5307. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5308. {
  5309. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5310. }
  5311. }
  5312. string price1 = GetPostString("price1");
  5313. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5314. string price2 = GetPostString("price2");
  5315. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5316. string posTag = CurrentUser.UserPost.Post.Code;
  5317. if (posTag == "Supplier")
  5318. {
  5319. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5320. }
  5321. lw.Add(string.Format("OrderState >= 6"));
  5322. lw.Add(string.Format("IsSample != 2 "));
  5323. //lw.Add(string.Format("isDianziOrder = 0 "));
  5324. lw.Add(string.Format("SupplierId > 0 "));
  5325. //lw.Add(string.Format("IsRefund<={0}", 1));
  5326. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5327. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5328. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5329. foreach (DataRow dr in dt.Rows)
  5330. {
  5331. 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();
  5332. }
  5333. writeGridDataTableJson(dStruct.TotalCount, dt);
  5334. }
  5335. public void get_erp_financeallplacelist()
  5336. {
  5337. DataStruct dStruct = GetPostStruct();
  5338. List<string> lw = new List<string>();
  5339. string tid = GetPostString("ctid");
  5340. string shopname = GetPostString("shopname");
  5341. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5342. string buyernick = GetPostString("buyer_nick");
  5343. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5344. string customer = GetPostString("customer");
  5345. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5346. string design = GetPostString("design");
  5347. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5348. string sellermemo = GetPostString("seller_memo");
  5349. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5350. string supplier = GetPostString("supplier");
  5351. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5352. string date1 = GetPostString("date1");
  5353. string date2 = GetPostString("date2");
  5354. string pldate1 = GetPostString("placedate1");
  5355. string pldate2 = GetPostString("placedate2");
  5356. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5357. {
  5358. if (tid.Length > 0)
  5359. {
  5360. string select_tid = getTidByCtid(tid);
  5361. lw.Add(string.Format("tid='{0}'", select_tid));
  5362. }
  5363. if (buyernick.Length > 0)
  5364. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5365. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5366. if (dw.Length > 0) lw.Add(dw);
  5367. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5368. if (dw_place.Length > 0) lw.Add(dw_place);
  5369. }
  5370. else
  5371. {
  5372. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5373. {
  5374. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5375. }
  5376. }
  5377. string price1 = GetPostString("price1");
  5378. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5379. string price2 = GetPostString("price2");
  5380. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5381. string posTag = CurrentUser.UserPost.Post.Code;
  5382. if (posTag == "Supplier")
  5383. {
  5384. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5385. }
  5386. //lw.Add(string.Format("OrderState >= 6"));
  5387. lw.Add(string.Format("IsSample != 2 "));
  5388. lw.Add(string.Format("isDianziOrder = 0 "));
  5389. //lw.Add(string.Format("IsRefund<={0}", 1));
  5390. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5391. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5392. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5393. foreach (DataRow dr in dt.Rows)
  5394. {
  5395. 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();
  5396. }
  5397. writeGridDataTableJson(dStruct.TotalCount, dt);
  5398. }
  5399. public void get_erp_expresslist()
  5400. {
  5401. int listtype = GetInt("ltype");
  5402. DataStruct dStruct = GetPostStruct();
  5403. List<string> lw = new List<string>();
  5404. string tid = GetPostString("tid");
  5405. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5406. string outsid = GetPostString("out_sid");
  5407. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5408. string importer = GetPostString("ImportUserName");
  5409. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5410. string file = GetPostString("import_file");
  5411. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5412. string printman = GetPostString("printman");
  5413. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5414. string date1 = GetPostString("date1");
  5415. string date2 = GetPostString("date2");
  5416. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5417. if (dw.Length > 0) lw.Add(dw);
  5418. string fdate1 = GetPostString("finishdate1");
  5419. string fdate2 = GetPostString("finishdate2");
  5420. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5421. if (fdw.Length > 0) lw.Add(fdw);
  5422. string supplierId = GetPostString("supplierId");
  5423. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5424. if (listtype == 1)
  5425. {
  5426. lw.Add(string.Format("importUserId !=0"));
  5427. }
  5428. string posTag = CurrentUser.UserPost.Post.Code;
  5429. if (posTag == "Supplier")
  5430. {
  5431. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5432. }
  5433. if (dStruct.PageSize != 100000)
  5434. {
  5435. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5436. }
  5437. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5438. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5439. writeGridDataTableJson(dStruct.TotalCount, dt);
  5440. }
  5441. public void set_erp_buchaorderdelivery()
  5442. {
  5443. if (UrlPostParmsCheck("ctid"))
  5444. {
  5445. string eid = GetPostString("ctid");
  5446. CeErpTradeCell entity = null;
  5447. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5448. if (entity != null)
  5449. {
  5450. if (entity.IsSample != 2)
  5451. {
  5452. returnErrorMsg("补差价单才能标记为已发货");
  5453. return;
  5454. }
  5455. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5456. entity.OrderState = 7;
  5457. entity.Update();
  5458. returnSuccessMsg("操作成功!");
  5459. return;
  5460. }
  5461. returnErrorMsg("找不到记录");
  5462. }
  5463. }
  5464. public void get_stdtemplates()
  5465. {
  5466. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5467. //string res = taobaoHelper.test();
  5468. string res = apiHelper.API_PrintTemplate();
  5469. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5470. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5471. {
  5472. int sidx = res.IndexOf("error_code");
  5473. int eidx = res.IndexOf("success");
  5474. string msg = res.Substring(sidx, eidx - sidx);
  5475. returnErrorMsg(msg);
  5476. return;
  5477. }
  5478. if (res.Length <= 0)
  5479. {
  5480. returnErrorMsg("模板数据为空!");
  5481. return;
  5482. }
  5483. ReturnSuccess(res);
  5484. }
  5485. public void cancel_print_order()
  5486. {
  5487. if (UrlPostParmsCheck("ctid"))
  5488. {
  5489. string ctid = GetPostString("ctid");
  5490. CeErpTradeCell entity = null;
  5491. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5492. if (entity != null)
  5493. {
  5494. string res = "";
  5495. string code = entity.LastBillWaybillCode;
  5496. if (code == "")
  5497. {
  5498. code = entity.OutSid;
  5499. }
  5500. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5501. XLog.SaveLog(0, "取消面单" + res);
  5502. }
  5503. }
  5504. }
  5505. public void set_erp_printwaybill()
  5506. {
  5507. if (UrlPostParmsCheck("ctid"))
  5508. {
  5509. string ctid = GetPostString("ctid");
  5510. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5511. string cpName = GetPostString("cpname");
  5512. string isTogether = GetPostString("together");
  5513. string printType = GetPostString("printType");
  5514. //var res_obj = new
  5515. //{
  5516. // restype = 1,
  5517. // 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\"}"
  5518. //};
  5519. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5520. //ReturnSuccess(ro_json);
  5521. //return;
  5522. bool isUseLastWayBillCode = false;
  5523. CeErpTradeCell entity = null;
  5524. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5525. if (entity != null)
  5526. {
  5527. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5528. {
  5529. isUseLastWayBillCode = true;
  5530. }
  5531. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5532. {
  5533. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5534. return;
  5535. }
  5536. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5537. {
  5538. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5539. return;
  5540. }
  5541. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5542. {
  5543. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5544. return;
  5545. }
  5546. }
  5547. string res = "";
  5548. Api_waybill_code_response_Obj fullObj = null;
  5549. string pData_str = "";
  5550. string curUseWayBillCode = "";
  5551. if (isUseLastWayBillCode == false)
  5552. {
  5553. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5554. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5555. if (res.IndexOf("failure") != -1)
  5556. {
  5557. //int idx = res.IndexOf("sub_message");
  5558. //int idx2 = res.IndexOf("flag");
  5559. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5560. string errMsgNeed = commonHelper.KeepChinese(res);
  5561. var res_objd = new
  5562. {
  5563. restype = 0,
  5564. data = "获取面单失败" + errMsgNeed
  5565. };
  5566. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5567. returnSuccess(ro_jsond);
  5568. if (res.IndexOf("停发") != -1)
  5569. {
  5570. entity.UnusualCon = "物流停发";
  5571. entity.Update();
  5572. }
  5573. //returnErrorMsg("获取面单失败,"+emsg);
  5574. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5575. return;
  5576. }
  5577. else if (res.IndexOf("errorMsg") != -1)
  5578. {
  5579. //int idx = res.IndexOf("errorMsg");
  5580. //int idx2 = res.IndexOf("}]}");
  5581. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5582. string errMsgNeed = commonHelper.KeepChinese(res);
  5583. var res_objf = new
  5584. {
  5585. restype = 0,
  5586. data = "获取面单失败2" + errMsgNeed
  5587. };
  5588. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5589. if (res.IndexOf("停发") != -1)
  5590. {
  5591. entity.UnusualCon = "物流停发";
  5592. entity.Update();
  5593. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5594. if (trade != null)
  5595. {
  5596. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5597. }
  5598. }
  5599. returnSuccess(ro_jsonf);
  5600. //returnErrorMsg("获取面单失败," + emsg);
  5601. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5602. return;
  5603. }
  5604. try
  5605. {
  5606. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5607. //res = res.Replace(" ", "");
  5608. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5609. }
  5610. catch (Exception ex)
  5611. {
  5612. XLog.SaveLog(0, "生成fullObj" + res);
  5613. var res_objf = new
  5614. {
  5615. restype = 0,
  5616. data = "生成fullObj发生错误" + ex.Message
  5617. };
  5618. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5619. returnSuccess(ro_jsonf);
  5620. return;
  5621. }
  5622. if (fullObj.response.data.content.Count > 0)
  5623. {
  5624. ContentItem codeObj = fullObj.response.data.content[0];
  5625. if (cpCode.IndexOf("SFFQ-") != -1)
  5626. {
  5627. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5628. }
  5629. else
  5630. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5631. curUseWayBillCode = codeObj.waybillCode;
  5632. }
  5633. else
  5634. {
  5635. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5636. var res_objf = new
  5637. {
  5638. restype = 0,
  5639. data = "生成fullObj找不到快递单号waybillCode"
  5640. };
  5641. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5642. returnSuccess(ro_jsonf);
  5643. return;
  5644. }
  5645. }
  5646. else
  5647. {
  5648. //使用上次打印的快递单号
  5649. if (cpCode == "SFFQ-LY")
  5650. {
  5651. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5652. }
  5653. else
  5654. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5655. curUseWayBillCode = entity.LastBillWaybillCode;
  5656. }
  5657. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5658. {
  5659. var res_obje = new
  5660. {
  5661. restype = 0,
  5662. data = "获取加密打印数据失败"
  5663. };
  5664. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5665. returnSuccess(ro_jsone);
  5666. entity.LastBillCpCode = cpCode;
  5667. entity.LastBillWaybillCode = curUseWayBillCode;
  5668. entity.Update();
  5669. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5670. //returnErrorMsg("获取加密打印数据失败");
  5671. return;
  5672. }
  5673. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5674. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5675. string btnType = "";
  5676. string errorMsg = "";
  5677. if (entity != null)
  5678. {
  5679. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5680. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5681. //cpcode是 YTO-CAINIAO
  5682. //string comCode = cpCode.Split('-')[0].ToString();
  5683. string apires = "";
  5684. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5685. //isTogether=2是新的合包弹窗
  5686. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5687. {
  5688. if (ctid.IndexOf("N") != -1)
  5689. {
  5690. apires = "发货成功";
  5691. }
  5692. else
  5693. {
  5694. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5695. }
  5696. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5697. //打单后发货
  5698. StringBuilder sql = new StringBuilder();
  5699. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5700. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5701. {
  5702. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5703. }
  5704. else
  5705. {
  5706. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5707. }
  5708. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5709. foreach (DataRow row in dt.Rows)
  5710. {
  5711. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5712. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5713. {
  5714. try
  5715. {
  5716. btnType = "待发货";
  5717. entity.OutSid = curUseWayBillCode;
  5718. entity.OrderState = 7;
  5719. entity.IsUrgency = false;
  5720. entity.LastBillCpCode = "";
  5721. entity.LastBillWaybillCode = "";
  5722. entity.FinishDeliveryTime = DateTime.Now;
  5723. entity.IsReturn = 0;
  5724. entity.MemoOpt = 0;
  5725. entity.UpdateTime = DateTime.Now;
  5726. entity.Update();
  5727. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5728. //还要插入快递信息到 快递信息表
  5729. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5730. exinfo.tid = entity.ctid;
  5731. exinfo.out_sid = curUseWayBillCode;
  5732. exinfo.company_code = cpCode;
  5733. exinfo.company_name = cpName;
  5734. exinfo.supplierUserName = supplierName;
  5735. exinfo.deliveryType = "发货成功";
  5736. exinfo.print_time = DateTime.Now;
  5737. exinfo.printUser = CurrentUser.UserName;
  5738. exinfo.postData = pData_str;
  5739. exinfo.Create();
  5740. commonHelper.UpdateRelationOrder(entity.ctid);
  5741. CeErpSukuraData.createInfo(ctid, 4);
  5742. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5743. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5744. {
  5745. commonHelper.sendCytExpress(exinfo);
  5746. }
  5747. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5748. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5749. }
  5750. catch (Exception ex)
  5751. {
  5752. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5753. }
  5754. }
  5755. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5756. {
  5757. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5758. if (entity.OrderState == 6)
  5759. {
  5760. entity.OrderState = 7;
  5761. }
  5762. entity.UpdateTime = DateTime.Now;
  5763. entity.FinishDeliveryTime = DateTime.Now;
  5764. btnType = "已发货";
  5765. entity.Update();
  5766. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5767. exinfo.tid = entity.ctid;
  5768. exinfo.out_sid = curUseWayBillCode;
  5769. exinfo.company_code = cpCode;
  5770. exinfo.company_name = cpName;
  5771. exinfo.supplierUserName = supplierName;
  5772. exinfo.deliveryType = "发货成功";
  5773. exinfo.print_time = DateTime.Now;
  5774. exinfo.printUser = CurrentUser.UserName;
  5775. exinfo.postData = pData_str;
  5776. exinfo.Create();
  5777. commonHelper.UpdateRelationOrder(entity.ctid);
  5778. CeErpSukuraData.createInfo(entity.ctid, 4);
  5779. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5780. {
  5781. commonHelper.sendCytExpress(exinfo);
  5782. }
  5783. //不处理
  5784. }
  5785. else
  5786. {
  5787. entity.UpdateTime = DateTime.Now;
  5788. entity.LastBillCpCode = cpCode;
  5789. entity.LastBillWaybillCode = curUseWayBillCode;
  5790. entity.Update();
  5791. string errmsg = commonHelper.KeepChinese(apires);
  5792. var res_objz = new
  5793. {
  5794. restype = 0,
  5795. data = "打单后发货失败"
  5796. };
  5797. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5798. returnSuccess(ro_jsonz);
  5799. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5800. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5801. return;
  5802. }
  5803. }
  5804. }
  5805. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5806. {
  5807. string ctids = GetPostString("ctids");
  5808. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5809. List<string> list = new List<string>();
  5810. List<string> send_list = new List<string>();
  5811. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5812. CeErpTrade ceErpTrade = new CeErpTrade();
  5813. //可合包的合并一起发货
  5814. if (dt == null && string.IsNullOrEmpty(ctids))
  5815. {
  5816. var res_objz = new
  5817. {
  5818. restype = 0,
  5819. data = "打单后发货失败"
  5820. };
  5821. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5822. returnSuccess(ro_jsonz);
  5823. return;
  5824. }
  5825. if (!string.IsNullOrEmpty(ctids))
  5826. {
  5827. StringBuilder sql = new StringBuilder();
  5828. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5829. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5830. }
  5831. foreach (DataRow row in dt.Rows)
  5832. {
  5833. list.Add("'" + row["ctid"] + "'");
  5834. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5835. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5836. if (ctid.IndexOf("N") != -1)
  5837. {
  5838. apires = "发货成功";
  5839. }
  5840. else
  5841. {
  5842. if (!send_list.Contains(ceErpTrade.tid))
  5843. {
  5844. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5845. }
  5846. else
  5847. {
  5848. apires = "发货成功";
  5849. }
  5850. }
  5851. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5852. {
  5853. send_list.Add(ceErpTrade.tid);
  5854. try
  5855. {
  5856. btnType = "待发货";
  5857. ceErpTradeCell.OutSid = curUseWayBillCode;
  5858. ceErpTradeCell.OrderState = 7;
  5859. ceErpTradeCell.IsUrgency = false;
  5860. ceErpTradeCell.LastBillCpCode = "";
  5861. ceErpTradeCell.LastBillWaybillCode = "";
  5862. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5863. ceErpTradeCell.IsReturn = 0;
  5864. ceErpTradeCell.MemoOpt = 0;
  5865. ceErpTradeCell.UpdateTime = DateTime.Now;
  5866. ceErpTradeCell.Update();
  5867. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5868. //还要插入快递信息到 快递信息表
  5869. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5870. exinfo.tid = ceErpTradeCell.ctid;
  5871. exinfo.out_sid = curUseWayBillCode;
  5872. exinfo.company_code = cpCode;
  5873. exinfo.company_name = cpName;
  5874. exinfo.supplierUserName = supplierName;
  5875. exinfo.deliveryType = "发货成功";
  5876. exinfo.print_time = DateTime.Now;
  5877. exinfo.printUser = CurrentUser.UserName;
  5878. exinfo.postData = pData_str;
  5879. exinfo.Create();
  5880. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5881. CeErpSukuraData.createInfo(ctid, 4);
  5882. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5883. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5884. {
  5885. commonHelper.sendCytExpress(exinfo);
  5886. }
  5887. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5888. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5889. }
  5890. catch (Exception ex)
  5891. {
  5892. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5893. }
  5894. }
  5895. else
  5896. {
  5897. ceErpTradeCell.UpdateTime = DateTime.Now;
  5898. ceErpTradeCell.LastBillCpCode = cpCode;
  5899. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5900. ceErpTradeCell.Update();
  5901. string errmsg = commonHelper.KeepChinese(apires);
  5902. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5903. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5904. }
  5905. }
  5906. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5907. }
  5908. }
  5909. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5910. var res_obj = new
  5911. {
  5912. restype = 1,
  5913. data = pData_str,
  5914. errorMsg
  5915. };
  5916. string ro_json = JsonConvert.SerializeObject(res_obj);
  5917. ReturnSuccess(ro_json);
  5918. return;
  5919. }
  5920. }
  5921. private string GetUTF8String(byte[] vs)
  5922. {
  5923. throw new NotImplementedException();
  5924. }
  5925. public void set_erp_printwaybill_cn()
  5926. {
  5927. if (UrlPostParmsCheck("ctid"))
  5928. {
  5929. string ctid = GetPostString("ctid");
  5930. string cpCode = GetPostString("cpcode");
  5931. string cpName = GetPostString("cpname");
  5932. string tempUrl = GetPostString("tempurl");
  5933. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5934. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5935. //string res = taobaoHelper.test();
  5936. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5937. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5938. {
  5939. int sidx = res.IndexOf("errorMsg");
  5940. int eidx = res.IndexOf("}");
  5941. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5942. var res_objzxx = new
  5943. {
  5944. restype = 0,
  5945. data = msg
  5946. };
  5947. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5948. returnSuccess(ro_jsonzxx);
  5949. //returnErrorMsg(msg);
  5950. return;
  5951. }
  5952. int idx = res.IndexOf("waybillCode");
  5953. int idx2 = res.IndexOf("printData");
  5954. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5955. string eid = GetPostString("ctid");
  5956. CeErpTradeCell entity = null;
  5957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5958. if (entity != null)
  5959. {
  5960. string osid = entity.OutSid;
  5961. entity.OutSid = osid + "," + outsid;
  5962. entity.FinishDeliveryTime = DateTime.Now;
  5963. entity.OrderState = 7;
  5964. entity.UpdateTime = DateTime.Now;
  5965. entity.IsReturn = 0;
  5966. entity.Update();
  5967. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5968. exinfo.tid = entity.ctid;
  5969. exinfo.out_sid = outsid;
  5970. exinfo.company_code = cpCode;
  5971. exinfo.company_name = cpName;
  5972. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5973. exinfo.deliveryType = "发货成功";
  5974. exinfo.print_time = DateTime.Now;
  5975. exinfo.printUser = CurrentUser.UserName;
  5976. exinfo.Create();
  5977. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5978. {
  5979. commonHelper.sendCytExpress(exinfo);
  5980. }
  5981. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5982. }
  5983. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5984. var res_objz = new
  5985. {
  5986. restype = 1,
  5987. data = res
  5988. };
  5989. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5990. returnSuccess(ro_jsonz);
  5991. //ReturnSuccess(res);
  5992. }
  5993. }
  5994. ////打单,打印面单 获取面单号
  5995. //public void set_erp_printwaybill()
  5996. //{
  5997. // if (UrlPostParmsCheck("ctid"))
  5998. // {
  5999. // string ctid = GetPostString("ctid");
  6000. // string cpCode = GetPostString("cpcode");
  6001. // string tempUrl = GetPostString("tempurl");
  6002. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6003. // //string res = taobaoHelper.test();
  6004. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6005. // if (res.IndexOf("error_response") != -1)
  6006. // {
  6007. // int sidx = res.IndexOf("sub_msg");
  6008. // int eidx = res.IndexOf("request_id");
  6009. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6010. // returnErrorMsg(msg);
  6011. // return;
  6012. // }
  6013. // int idx = res.IndexOf("waybill_code");
  6014. // int idx2 = res.IndexOf("}]}");
  6015. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6016. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6017. // ReturnSuccess(res);
  6018. // }
  6019. //}
  6020. public void cancel_erp_aftersale()
  6021. {
  6022. if (UrlPostParmsCheck("ctid"))
  6023. {
  6024. string eid = GetPostString("ctid");
  6025. CeErpTradeCell entity = null;
  6026. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6027. if (entity != null)
  6028. {
  6029. //有过处理的售后,取消也不能删除 售 字,保留
  6030. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6031. {
  6032. entity.AfterSaleState = 4;
  6033. }
  6034. else
  6035. entity.AfterSaleState = 0;
  6036. entity.UpdateTime = DateTime.Now;
  6037. entity.Update();
  6038. returnSuccessMsg("操作成功!");
  6039. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6040. return;
  6041. }
  6042. returnErrorMsg("找不到订单记录");
  6043. }
  6044. }
  6045. public void get_erp_aftersalelist()
  6046. {
  6047. DataStruct dStruct = GetPostStruct();
  6048. List<string> lw = new List<string>();
  6049. int st = GetInt("st");
  6050. string tid = GetPostString("ctid");
  6051. if (st == 3)
  6052. {
  6053. if (tid.Length > 0)
  6054. {
  6055. string select_tid = getTidByCtid(tid);
  6056. lw.Add(string.Format("tid='{0}'", select_tid));
  6057. }
  6058. }
  6059. else
  6060. {
  6061. if (tid.Length > 0)
  6062. {
  6063. string select_tid = getTidByCtid(tid);
  6064. lw.Add(string.Format("tid='{0}'", select_tid));
  6065. }
  6066. }
  6067. string shopname = GetPostString("shopname");
  6068. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6069. string buyernick = GetPostString("buyer_nick");
  6070. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6071. string sellermemo = GetPostString("seller_memo");
  6072. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6073. string orderState = GetPostString("orderState");
  6074. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6075. string afterState = GetPostString("afterstate");
  6076. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6077. string date1 = GetPostString("date1");
  6078. string date2 = GetPostString("date2");
  6079. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6080. if (dw.Length > 0) lw.Add(dw);
  6081. string price1 = GetPostString("price1");
  6082. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6083. string price2 = GetPostString("price2");
  6084. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6085. //lw.Add(string.Format("IsRefund!={0}", 1));
  6086. string reason = GetPostString("reason");
  6087. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6088. string method = GetPostString("method");
  6089. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6090. string handler = GetPostString("handler");
  6091. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6092. string handledate1 = GetPostString("handledate1");
  6093. string handledate2 = GetPostString("handledate2");
  6094. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6095. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6096. string finish1 = GetPostString("finishdate1");
  6097. string finish2 = GetPostString("finishdate2");
  6098. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6099. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6100. string afterdate1 = GetPostString("afterdate1");
  6101. string afterdate2 = GetPostString("afterdate2");
  6102. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6103. if (afterDate.Length > 0) lw.Add(afterDate);
  6104. string supplier = GetPostString("supplier");
  6105. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6106. string responsible = GetPostString("responsibleman");
  6107. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6108. string customer = GetPostString("customer");
  6109. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6110. string design = GetPostString("design");
  6111. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6112. string afterMemoType = GetPostString("aftermemotype");
  6113. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6114. string posCode = CurrentUser.UserPost.Post.Code;
  6115. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6116. //{
  6117. // string vstate = GetPostString("vstate");
  6118. // if (vstate.Length > 0)
  6119. // {
  6120. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6121. // }
  6122. // if (posCode == "Supplier")
  6123. // {
  6124. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6125. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6126. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6127. // }
  6128. // else
  6129. // {
  6130. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6131. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6132. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6133. // {
  6134. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6135. // }
  6136. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6137. // {
  6138. // int orgid = CurrentUser.UserPost.OrgID;
  6139. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6140. // }
  6141. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6142. // {
  6143. // string shopid = CurrentUser.User.pemShop;
  6144. // lw.Add(string.Format("shopId in ({0})", shopid));
  6145. // }
  6146. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6147. // //{
  6148. // // int org_id = CurrentUser.UserPost.OrgID;
  6149. // // lw.Add(string.Format("OrgID={0}", org_id));
  6150. // //}
  6151. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6152. // }
  6153. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6154. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6155. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6156. //}
  6157. if (st == 5)
  6158. {
  6159. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6160. {
  6161. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6162. {
  6163. string shopid = CurrentUser.User.pemShop;
  6164. lw.Add(string.Format("shopId in ({0})", shopid));
  6165. }
  6166. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6167. {
  6168. int mrOrgid = CurrentUser.UserPost.OrgID;
  6169. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6170. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6171. }
  6172. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6173. //{
  6174. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6175. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6176. //}
  6177. else
  6178. {
  6179. string userIdStr = "";
  6180. if (posCode == "CustomerService")
  6181. {
  6182. userIdStr = CurrentUser.UserID + "_k";
  6183. }
  6184. else if (posCode == "Designer" || posCode == "wxDesigner")
  6185. {
  6186. userIdStr = CurrentUser.UserID + "_s";
  6187. }
  6188. else if (posCode == "Place")
  6189. {
  6190. userIdStr = CurrentUser.UserID + "_x";
  6191. }
  6192. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6193. }
  6194. }
  6195. string placedate1 = GetPostString("placedate1");
  6196. string placedate2 = GetPostString("placedate2");
  6197. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6198. if (dwplace.Length > 0) lw.Add(dwplace);
  6199. string supState = GetPostString("supState");
  6200. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6201. string searchType = GetPostString("searchType");
  6202. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6203. {
  6204. lw.Add(string.Format("BackNum>1"));
  6205. }
  6206. lw.Add(string.Format("AfterSaleState>0"));
  6207. if (ex_psize > 0)
  6208. {
  6209. if (CurrentUser.UserPost.Post.Code == "Finance")
  6210. dStruct.Order = "pay_time desc";
  6211. else
  6212. dStruct.Order = "HandleTime desc";
  6213. }
  6214. else
  6215. dStruct.Order = "HandleTime desc";
  6216. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6217. DataTable dt = WebCache.GetData("view_test", dStruct);
  6218. writeGridDataTableJson(dStruct.TotalCount, dt);
  6219. }
  6220. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6221. //{
  6222. // lw.Add(string.Format("AfterSaleState=4"));
  6223. // string code = CurrentUser.UserPost.Post.Code;
  6224. // if (code == "CustomerService")
  6225. // {
  6226. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6227. // }
  6228. // else if (code == "Designer" || code == "DesignerMr")
  6229. // {
  6230. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6231. // }
  6232. // else if (code == "Place" || code == "PlaceMr")
  6233. // {
  6234. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6235. // }
  6236. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6237. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6238. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6239. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6240. //}
  6241. //else //处理中的售后,待处理和处理中合并
  6242. //{
  6243. // if (afterState.Length <= 0)
  6244. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6245. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6246. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6247. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6248. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6249. //}
  6250. }
  6251. public void get_erp_disagreeftersalelist()
  6252. {
  6253. DataStruct dStruct = GetPostStruct();
  6254. List<string> lw = new List<string>();
  6255. int st = 2;
  6256. string tid = GetPostString("ctid");
  6257. if (tid.Length > 0)
  6258. {
  6259. string select_tid = getTidByCtid(tid);
  6260. lw.Add(string.Format("tid='{0}'", select_tid));
  6261. }
  6262. string shopname = GetPostString("shopname");
  6263. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6264. string buyernick = GetPostString("buyer_nick");
  6265. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6266. string sellermemo = GetPostString("seller_memo");
  6267. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6268. string orderState = GetPostString("orderState");
  6269. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6270. string afterState = GetPostString("afterstate");
  6271. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6272. string date1 = GetPostString("date1");
  6273. string date2 = GetPostString("date2");
  6274. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6275. if (dw.Length > 0) lw.Add(dw);
  6276. string price1 = GetPostString("price1");
  6277. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6278. string price2 = GetPostString("price2");
  6279. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6280. //lw.Add(string.Format("IsRefund!={0}", 1));
  6281. string reason = GetPostString("reason");
  6282. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6283. string method = GetPostString("method");
  6284. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6285. string handler = GetPostString("handler");
  6286. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6287. string handledate1 = GetPostString("handledate1");
  6288. string handledate2 = GetPostString("handledate2");
  6289. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6290. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6291. string afterdate1 = GetPostString("afterdate1");
  6292. string afterdate2 = GetPostString("afterdate2");
  6293. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6294. if (afterDate.Length > 0) lw.Add(afterDate);
  6295. string backdate1 = GetPostString("backdate1");
  6296. string backdate2 = GetPostString("backdate2");
  6297. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6298. if (backDate.Length > 0) lw.Add(backDate);
  6299. string supplier = GetPostString("supplier");
  6300. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6301. string responsible = GetPostString("responsibleman");
  6302. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6303. string customer = GetPostString("customer");
  6304. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6305. string design = GetPostString("design");
  6306. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6307. string afterSaleMemo = GetPostString("afterSaleMemo");
  6308. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6309. string afterMemoType = GetPostString("aftermemotype");
  6310. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6311. string aftersakereason = GetPostString("aftersakereason");
  6312. if (aftersakereason.Length > 0)
  6313. {
  6314. if (aftersakereason == "1")
  6315. {
  6316. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6317. }
  6318. if (aftersakereason == "2")
  6319. {
  6320. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6321. }
  6322. }
  6323. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6324. string poscode = CurrentUser.UserPost.Post.Code;
  6325. if (poscode != "SysAdmin")
  6326. {
  6327. string shopid = CurrentUser.User.pemShop;
  6328. lw.Add(string.Format("shopId in ({0})", shopid));
  6329. }
  6330. string searchType = GetPostString("searchType");
  6331. if (searchType == "wait")
  6332. {
  6333. lw.Add(string.Format("HandleTime is null"));
  6334. }
  6335. if (searchType == "handling")
  6336. {
  6337. lw.Add(string.Format("HandleTime is not null "));
  6338. }
  6339. if (searchType == "back" || searchType == "puBack")
  6340. {
  6341. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6342. }
  6343. if (searchType == "reBack")
  6344. {
  6345. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6346. }
  6347. if (searchType == "moreBack")
  6348. {
  6349. lw.Add(string.Format("backNum > 1"));
  6350. }
  6351. lw.Add(string.Format("(AfterSaleState=5)"));
  6352. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6353. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6354. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6355. writeGridDataTableJson(dStruct.TotalCount, dt);
  6356. }
  6357. public void get_erp_handlingaftersalelist()
  6358. {
  6359. DataStruct dStruct = GetPostStruct();
  6360. List<string> lw = new List<string>();
  6361. int st = 2;
  6362. string tid = GetPostString("ctid");
  6363. if (tid.Length > 0)
  6364. {
  6365. string select_tid = getTidByCtid(tid);
  6366. lw.Add(string.Format("tid='{0}'", select_tid));
  6367. }
  6368. string shopname = GetPostString("shopname");
  6369. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6370. string buyernick = GetPostString("buyer_nick");
  6371. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6372. string sellermemo = GetPostString("seller_memo");
  6373. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6374. string orderState = GetPostString("orderState");
  6375. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6376. string afterState = GetPostString("afterstate");
  6377. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6378. string date1 = GetPostString("date1");
  6379. string date2 = GetPostString("date2");
  6380. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6381. if (dw.Length > 0) lw.Add(dw);
  6382. string price1 = GetPostString("price1");
  6383. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6384. string price2 = GetPostString("price2");
  6385. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6386. //lw.Add(string.Format("IsRefund!={0}", 1));
  6387. string reason = GetPostString("reason");
  6388. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6389. string method = GetPostString("method");
  6390. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6391. string handler = GetPostString("handler");
  6392. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6393. string handledate1 = GetPostString("handledate1");
  6394. string handledate2 = GetPostString("handledate2");
  6395. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6396. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6397. string afterdate1 = GetPostString("afterdate1");
  6398. string afterdate2 = GetPostString("afterdate2");
  6399. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6400. if (afterDate.Length > 0) lw.Add(afterDate);
  6401. string supplier = GetPostString("supplier");
  6402. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6403. string responsible = GetPostString("responsibleman");
  6404. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6405. string customer = GetPostString("customer");
  6406. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6407. string design = GetPostString("design");
  6408. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6409. string afterSaleMemo = GetPostString("afterSaleMemo");
  6410. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6411. string afterMemoType = GetPostString("aftermemotype");
  6412. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6413. string afterresult = GetPostString("afterresult");
  6414. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6415. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6416. string poscode = CurrentUser.UserPost.Post.Code;
  6417. if (poscode != "SysAdmin")
  6418. {
  6419. string shopid = CurrentUser.User.pemShop;
  6420. lw.Add(string.Format("shopId in ({0})", shopid));
  6421. }
  6422. string searchType = GetPostString("searchType");
  6423. if (searchType == "wait")
  6424. {
  6425. lw.Add(string.Format("HandleTime is null"));
  6426. }
  6427. if (searchType == "documentary")
  6428. {
  6429. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6430. }
  6431. if (searchType == "handling")
  6432. {
  6433. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6434. }
  6435. if (searchType == "back" || searchType == "puBack")
  6436. {
  6437. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6438. }
  6439. if (searchType == "reBack")
  6440. {
  6441. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6442. }
  6443. if (afterState.Length <= 0)
  6444. {
  6445. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6446. }
  6447. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6448. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6449. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6450. writeGridDataTableJson(dStruct.TotalCount, dt);
  6451. }
  6452. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6453. //public void get_erp_back_handlingaftersalelist()
  6454. //{
  6455. // DataStruct dStruct = GetPostStruct();
  6456. // List<string> lw = new List<string>();
  6457. // string tid = GetPostString("ctid");
  6458. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6459. // string shopname = GetPostString("shopname");
  6460. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6461. // string buyernick = GetPostString("buyer_nick");
  6462. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6463. // string sellermemo = GetPostString("seller_memo");
  6464. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6465. // string orderState = GetPostString("orderState");
  6466. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6467. // string afterState = GetPostString("afterstate");
  6468. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6469. // string date1 = GetPostString("date1");
  6470. // string date2 = GetPostString("date2");
  6471. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6472. // if (dw.Length > 0) lw.Add(dw);
  6473. // string price1 = GetPostString("price1");
  6474. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6475. // string price2 = GetPostString("price2");
  6476. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6477. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6478. // string reason = GetPostString("reason");
  6479. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6480. // string method = GetPostString("method");
  6481. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6482. // string handler = GetPostString("handler");
  6483. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6484. // string handledate1 = GetPostString("handledate1");
  6485. // string handledate2 = GetPostString("handledate2");
  6486. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6487. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6488. // string afterdate1 = GetPostString("afterdate1");
  6489. // string afterdate2 = GetPostString("afterdate2");
  6490. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6491. // if (afterDate.Length > 0) lw.Add(afterDate);
  6492. // string supplier = GetPostString("supplier");
  6493. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6494. // string responsible = GetPostString("responsibleman");
  6495. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6496. // string customer = GetPostString("customer");
  6497. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6498. // string design = GetPostString("design");
  6499. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6500. // string afterMemoType = GetPostString("aftermemotype");
  6501. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6502. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6503. // if (afterState.Length <= 0)
  6504. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6505. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6506. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6507. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6508. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6509. //}
  6510. public void get_erp_aftersaleverifylist()
  6511. {
  6512. DataStruct dStruct = GetPostStruct();
  6513. List<string> lw = new List<string>();
  6514. string tid = GetPostString("ctid");
  6515. if (tid.Length > 0)
  6516. {
  6517. string select_tid = getTidByCtid(tid);
  6518. lw.Add(string.Format("otid='{0}'", select_tid));
  6519. }
  6520. string shopname = GetPostString("shopname");
  6521. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6522. string buyernick = GetPostString("buyer_nick");
  6523. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6524. string sellermemo = GetPostString("seller_memo");
  6525. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6526. string orderState = GetPostString("orderState");
  6527. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6528. //lw.Add(string.Format("IsRefund!={0}", 1));
  6529. string reason = GetPostString("reason");
  6530. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6531. string method = GetPostString("method");
  6532. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6533. string handler = GetPostString("handler");
  6534. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6535. string handledate1 = GetPostString("handledate1");
  6536. string handledate2 = GetPostString("handledate2");
  6537. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6538. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6539. string finish1 = GetPostString("finishdate1");
  6540. string finish2 = GetPostString("finishdate2");
  6541. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6542. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6543. string supplier = GetPostString("supplier");
  6544. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6545. string responsible = GetPostString("responsibleman");
  6546. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6547. string posCode = CurrentUser.UserPost.Post.Code;
  6548. string vstate = GetPostString("vstate");
  6549. if (vstate.Length > 0)
  6550. {
  6551. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6552. }
  6553. if (posCode == "Supplier")
  6554. {
  6555. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6556. lw.Add(string.Format("VerifyState = 0"));
  6557. lw.Add("type = 1");
  6558. lw.Add(string.Format("AfterSaleState={0}", 3));
  6559. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6560. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6562. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6563. writeGridDataTableJson(dStruct.TotalCount, dt);
  6564. }
  6565. else if (posCode == "logistics")
  6566. {
  6567. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6568. lw.Add(string.Format("VerifyState = 0"));
  6569. lw.Add("type = 2");
  6570. lw.Add(string.Format("AfterSaleState={0}", 3));
  6571. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6572. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6573. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6574. writeGridDataTableJson(dStruct.TotalCount, dt);
  6575. }
  6576. else
  6577. {
  6578. lw.Add(string.Format("(AfterSaleState = 3)"));
  6579. lw.Add("type = 0");
  6580. string reasonState = GetPostString("reasonState");
  6581. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6582. {
  6583. if (reasonState == "2")
  6584. {
  6585. lw.Add("VerifyState = 3");
  6586. }
  6587. else if (reasonState == "1")
  6588. {
  6589. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6590. }
  6591. else
  6592. {
  6593. lw.Add("VerifyState in (0,3)");
  6594. }
  6595. //不加条件,可以看全部
  6596. }
  6597. 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")
  6598. {
  6599. int orgid = CurrentUser.UserPost.OrgID;
  6600. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6601. if (string.IsNullOrEmpty(manageOrgId))
  6602. {
  6603. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6604. }
  6605. else
  6606. {
  6607. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6608. }
  6609. if (reasonState == "1")
  6610. {
  6611. lw.Add("VerifyState = 3");
  6612. }
  6613. else if (reasonState == "2")
  6614. {
  6615. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6616. }
  6617. else
  6618. {
  6619. }
  6620. }
  6621. else
  6622. {
  6623. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6624. }
  6625. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6626. //{
  6627. // int org_id = CurrentUser.UserPost.OrgID;
  6628. // lw.Add(string.Format("OrgID={0}", org_id));
  6629. //}
  6630. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6631. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6632. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6633. writeGridDataTableJson(dStruct.TotalCount, dt);
  6634. }
  6635. }
  6636. public void get_erp_finishaftersalelist()
  6637. {
  6638. DataStruct dStruct = GetPostStruct();
  6639. List<string> lw = new List<string>();
  6640. int st = 4;
  6641. string tid = GetPostString("ctid");
  6642. if (tid.Length > 0)
  6643. {
  6644. string select_tid = getTidByCtid(tid);
  6645. lw.Add(string.Format("otid='{0}'", select_tid));
  6646. }
  6647. string shopname = GetPostString("shopname");
  6648. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6649. //lw.Add(string.Format("IsRefund!={0}", 1));
  6650. string reason = GetPostString("reason");
  6651. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6652. string method = GetPostString("method");
  6653. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6654. string buyernick = GetPostString("buyer_nick");
  6655. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6656. string handler = GetPostString("handler");
  6657. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6658. string handledate1 = GetPostString("handledate1");
  6659. string handledate2 = GetPostString("handledate2");
  6660. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6661. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6662. string finish1 = GetPostString("finishdate1");
  6663. string finish2 = GetPostString("finishdate2");
  6664. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6665. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6666. string supplier = GetPostString("supplier");
  6667. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6668. string responsible = GetPostString("responsibleman");
  6669. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6670. string vstate = GetPostString("vstate");
  6671. if (vstate.Length > 0)
  6672. {
  6673. if ("3".Equals(vstate))
  6674. {
  6675. lw.Add(string.Format("IsTem=1"));
  6676. }
  6677. else
  6678. {
  6679. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6680. }
  6681. }
  6682. lw.Add(string.Format("AfterSaleState=4"));
  6683. string code = CurrentUser.UserPost.Post.Code;
  6684. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6685. {
  6686. //不加条件,可以看全部
  6687. }
  6688. else if (code == "Supplier")
  6689. {
  6690. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6691. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6692. lw.Add("type = 1");
  6693. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6694. }
  6695. else if (code == "logistics")
  6696. {
  6697. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6698. lw.Add("type = 2");
  6699. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6700. }
  6701. 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")
  6702. {
  6703. lw.Add("type = 0");
  6704. int orgid = CurrentUser.UserPost.OrgID;
  6705. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6706. if (string.IsNullOrEmpty(manageOrgIds))
  6707. {
  6708. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6709. }
  6710. else
  6711. {
  6712. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6713. }
  6714. }
  6715. else
  6716. {
  6717. lw.Add("type = 0");
  6718. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6719. }
  6720. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6721. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6722. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6723. writeGridDataTableJson(dStruct.TotalCount, dt);
  6724. }
  6725. public void handle_erp_aftersale()
  6726. {
  6727. if (UrlPostParmsCheck("ctid"))
  6728. {
  6729. string eid = GetPostString("ctid");
  6730. string responStr = GetPostString("AfterSaleResponsible");
  6731. if (responStr.Length <= 0)
  6732. {
  6733. returnErrorMsg("售后责任人不能为空");
  6734. return;
  6735. }
  6736. bool isDesign = false;
  6737. double designFree = 0.00;
  6738. int responsibleId = 0;
  6739. CeErpTradeCell entity = null;
  6740. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6741. if (entity != null)
  6742. {
  6743. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6744. string afterMethod = GetPostString("AfterSaleMethod");
  6745. if (isNeedNewOrder == 1)
  6746. {
  6747. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6748. bool ishav = true;
  6749. if (newentity == null)
  6750. {
  6751. newentity = entity.Clone() as CeErpTradeCell;
  6752. ishav = false;
  6753. newentity.ctid = "S_" + entity.ctid;
  6754. newentity.OrderState = 0;
  6755. //唯一标识
  6756. newentity.OrderSn = newentity.ctid;
  6757. string orderSn = dataHelper.getSaleOrderSn();
  6758. if (orderSn != "")
  6759. {
  6760. newentity.OrderSn = orderSn;
  6761. }
  6762. }
  6763. newentity.UpdateTime = DateTime.Now;
  6764. newentity.AfterSaleState = 0;
  6765. newentity.AfterSaleMethod = afterMethod;
  6766. if (!ishav)
  6767. {
  6768. string memo_str = newentity.seller_memo;
  6769. memo_str = memo_str.Replace("(", "(");
  6770. memo_str = memo_str.Replace(")", ")");
  6771. int sIndex = memo_str.IndexOf("(");
  6772. int eIndex = memo_str.IndexOf(")");
  6773. if (sIndex == -1 || eIndex == -1)
  6774. {
  6775. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6776. return;
  6777. }
  6778. string first = memo_str.Substring(0, sIndex + 1);
  6779. string memoCtid = newentity.OrderSn;
  6780. //if (memoCtid.IndexOf("C") != -1)
  6781. //{
  6782. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6783. //if (CIdx.IndexOf("+") != -1)
  6784. //{
  6785. //CIdx = "C" + CIdx.Split('+')[1];
  6786. //}
  6787. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6788. //}
  6789. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6790. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6791. string newMemo = first + memoCtid + last;
  6792. newentity.seller_memo = newMemo;
  6793. newentity.FinishPlaceTime = null;
  6794. newentity.UnusualTag = 0;
  6795. newentity.UnusualCon = "";
  6796. newentity.UnusualTime = null;
  6797. newentity.AfterSaleMemo = "";
  6798. newentity.AfterSaleMethod = afterMethod;
  6799. newentity.AfterSalePreTime = null;
  6800. newentity.AfterSaleReason = "";
  6801. newentity.AfterSaleResponsible = "";
  6802. newentity.AfterSaleState = 0;
  6803. newentity.AfterSaleTime = null;
  6804. newentity.AfterSaleUserId = 0;
  6805. newentity.AfterSaleSupplierState = 0;
  6806. newentity.LastBillWaybillCode = "";
  6807. newentity.LastBillCpCode = "";
  6808. newentity.FinishAfterSaleTime = null;
  6809. newentity.HandleTime = null;
  6810. newentity.IsSF = 0;
  6811. newentity.IsOldCustomer = 0;
  6812. newentity.UrgencyTime = null;
  6813. newentity.ResponsibleUserId = "";
  6814. newentity.IsVerifyToSupplier = false;
  6815. newentity.payment = 0;
  6816. newentity.CheckMemo = "";
  6817. newentity.OutSid = "";
  6818. newentity.CheckOrderTime = null;
  6819. newentity.MemoOpt = 0;
  6820. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6821. }
  6822. newentity.isAfterSaleOrder = 1;
  6823. newentity.IsRefund = 0;
  6824. string receiveMobile = GetPostString("receiver_mobile");
  6825. if (receiveMobile.Length > 0)
  6826. {
  6827. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6828. if (trade != null)
  6829. {
  6830. trade.receiver_name = GetPostString("receiver_name");
  6831. trade.receiver_mobile = receiveMobile;
  6832. trade.receiver_state = GetPostString("receiver_state");
  6833. trade.receiver_city = GetPostString("receiver_city");
  6834. trade.receiver_district = GetPostString("receiver_district");
  6835. trade.receiver_address = GetPostString("receiver_address");
  6836. newentity.IsOffLineOrder = 1;
  6837. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6838. }
  6839. }
  6840. string st = GetPostString("ToState");
  6841. if (st.Length > 0)
  6842. {
  6843. if (newentity.OrderState <= 3)
  6844. {
  6845. newentity.WaitDesignTime = DateTime.Now;
  6846. newentity.StartDesignTime = null;
  6847. newentity.FinishDesignTime = null;
  6848. newentity.OrderState = 3;
  6849. if (st == "下单员")
  6850. {
  6851. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6852. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6853. {
  6854. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6855. }
  6856. }
  6857. else
  6858. {
  6859. newentity.WaitDesignTime = DateTime.Now;
  6860. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6861. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6862. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6863. {
  6864. DataRow user = dt1.Rows[0];
  6865. //找主管
  6866. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6867. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6868. if (dt != null && dt.Rows.Count > 0)
  6869. {
  6870. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6871. newentity.DesignUserId = designMr;
  6872. string key = "aftersale_order_" + designMr;
  6873. if (RedisHelper.HasKey(key))
  6874. {
  6875. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6876. list.Add(newentity.ctid);
  6877. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6878. }
  6879. }
  6880. //账号正常
  6881. if (user["State"].ToString() == "0")
  6882. {
  6883. newentity.DesignUserId = entity.DesignUserId;
  6884. string key = "aftersale_order_" + entity.DesignUserId;
  6885. if (RedisHelper.HasKey(key))
  6886. {
  6887. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6888. list.Add(newentity.ctid);
  6889. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6890. }
  6891. }
  6892. }
  6893. }
  6894. }
  6895. if (entity.IsXianHuo == 1)
  6896. {
  6897. newentity.OrderState = 6;
  6898. entity.FinishPlaceTime = DateTime.Now;
  6899. }
  6900. }
  6901. if (ishav)
  6902. {
  6903. newentity.Update();
  6904. }
  6905. else
  6906. {
  6907. newentity.Create();
  6908. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6909. newCellExtend.ctid = newentity.ctid;
  6910. newCellExtend.orderFrom = 20;
  6911. newCellExtend.orderType = 30;
  6912. if (st == "下单员")
  6913. {
  6914. }
  6915. else
  6916. {
  6917. newCellExtend.ReprintTime = DateTime.Now;
  6918. }
  6919. newCellExtend.Create();
  6920. }
  6921. if (st != "下单员")
  6922. {
  6923. if (entity.DispatchSort == 2)
  6924. {
  6925. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6926. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6927. }
  6928. }
  6929. }
  6930. //处理售后扩展
  6931. string resIdStr = GetPostString("ResponsibleUserId");
  6932. string refundFees = GetPostString("refundFrees");
  6933. int IsComplain = GetPostInt("isComplain");
  6934. int IsBad = GetPostInt("isBad");
  6935. string IsOriginal = GetPostString("isOriginal");
  6936. double diffResultPrice = GetPostDouble("diffResultPrice");
  6937. string textResult = GetPostString("textResult");
  6938. string supplierResponsible = GetPostString("supplierResponsible");
  6939. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6940. if (ceErpTradeAfterSaleExtend == null)
  6941. {
  6942. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6943. ceErpTradeAfterSaleExtend.tid = eid;
  6944. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6945. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6946. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6947. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6948. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6949. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6950. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6951. ceErpTradeAfterSaleExtend.Create();
  6952. }
  6953. else
  6954. {
  6955. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6956. {
  6957. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6958. }
  6959. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6960. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6961. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6962. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6963. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6964. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6965. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6966. ceErpTradeAfterSaleExtend.Update();
  6967. }
  6968. int gysid = GetPostInt("ResponsibleSupId");
  6969. if (entity.AfterSaleUserId == 0)
  6970. {
  6971. entity.AfterSaleUserId = CurrentUser.UserID;
  6972. }
  6973. entity.ResponsibleUserId = resIdStr;
  6974. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6975. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6976. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6977. {
  6978. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6979. int backNum = 0;
  6980. if (number != null)
  6981. {
  6982. backNum = number.BackNum;
  6983. }
  6984. char[] separator = { ',' };
  6985. string[] sArray = resIdStr.Split(separator);
  6986. string[] refundFreeList = { };
  6987. if (refundFees.Length > 0)
  6988. {
  6989. refundFreeList = refundFees.Split(separator);
  6990. }
  6991. int index = -1;
  6992. List<int> responsibleIds = new List<int>();
  6993. foreach (string i in sArray)
  6994. {
  6995. index++;
  6996. if (i.Length <= 0) continue;
  6997. char[] separator2 = { '_' };
  6998. string idstr = i.Split(separator2)[0];
  6999. string idtype = i.Split(separator2)[1];
  7000. double refudFree = 0;
  7001. if (refundFreeList.Length > 0)
  7002. {
  7003. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7004. }
  7005. if (idtype == "s")
  7006. {
  7007. isDesign = true;
  7008. designFree = refudFree;
  7009. }
  7010. int userId = Convert.ToInt32(idstr);
  7011. int type = 0;
  7012. if (idtype == "g")
  7013. {
  7014. type = 1;
  7015. }
  7016. if (idtype == "w")
  7017. {
  7018. type = 2;
  7019. }
  7020. if (idtype == "t")
  7021. {
  7022. type = 3;
  7023. }
  7024. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7025. if (ceErpTradeResponsible == null)
  7026. {
  7027. ceErpTradeResponsible = new CeErpTradeResponsible();
  7028. ceErpTradeResponsible.tid = eid;
  7029. ceErpTradeResponsible.UserId = userId;
  7030. ceErpTradeResponsible.createdTime = DateTime.Now;
  7031. ceErpTradeResponsible.type = type;
  7032. if (type == 1)
  7033. {
  7034. ceErpTradeResponsible.IsSup = 1;
  7035. }
  7036. if (type == 2)
  7037. {
  7038. ceErpTradeResponsible.IsFlow = 1;
  7039. }
  7040. }
  7041. int state = 0;
  7042. //已认可的不需要再次认可
  7043. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7044. {
  7045. state = 1;
  7046. }
  7047. ceErpTradeResponsible.RefundFee = refudFree;
  7048. ceErpTradeResponsible.VerifyState = state;
  7049. if (userId == 2125 || idtype == "w")
  7050. {
  7051. ceErpTradeResponsible.VerifyState = 1;
  7052. }
  7053. if (idtype == "w" && userId == 101)
  7054. {
  7055. ceErpTradeResponsible.VerifyState = state;
  7056. }
  7057. if (ceErpTradeResponsible.ID > 0)
  7058. {
  7059. ceErpTradeResponsible.Update();
  7060. }
  7061. else
  7062. {
  7063. ceErpTradeResponsible.Create();
  7064. }
  7065. if (isDesign)
  7066. {
  7067. responsibleId = ceErpTradeResponsible.ID;
  7068. }
  7069. responsibleIds.Add(ceErpTradeResponsible.ID);
  7070. }
  7071. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7072. CeErpTradeResponsible.NumByTid(backNum, eid);
  7073. }
  7074. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7075. if (ceErpTradeCellExtend != null)
  7076. {
  7077. ceErpTradeCellExtend.returnVisit = 0;
  7078. ceErpTradeCellExtend.Update();
  7079. }
  7080. if (entity.HandleTime != null)
  7081. {
  7082. if (entity.AfterSaleState == 1)
  7083. {
  7084. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7085. }
  7086. else
  7087. {
  7088. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7089. }
  7090. }
  7091. else
  7092. {
  7093. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7094. entity.HandleTime = DateTime.Now;
  7095. }
  7096. bool isCompale = false;
  7097. if (entity.AfterSaleState == 5)
  7098. {
  7099. isCompale = true;
  7100. entity.AfterSaleState = 3;
  7101. }
  7102. entity.AfterSaleSupplierState = 0;
  7103. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7104. {
  7105. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7106. }
  7107. string sImgs = GetPostString("img");
  7108. entity.AfterSaleSupplierImg = sImgs;
  7109. entity.supRefundType = GetPostString("supRefundType");
  7110. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7111. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7112. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7113. entity.AfterSaleMemoType = GetPostString("MemoType");
  7114. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7115. {
  7116. //entity.AfterSaleSupplierState = 2;
  7117. }
  7118. string df = GetPostString("DeductFee");
  7119. if (df == "")
  7120. {
  7121. df = "0";
  7122. }
  7123. string rf = GetPostString("RefundFee");
  7124. if (rf == "")
  7125. {
  7126. rf = "0";
  7127. }
  7128. string pm = GetPostString("AfterSalePayment");
  7129. if (pm == "")
  7130. {
  7131. pm = "0";
  7132. }
  7133. entity.AfterSalePayment = Convert.ToDouble(pm);
  7134. entity.DeductFee = Convert.ToDouble(df);
  7135. entity.RefundFee = Convert.ToDouble(rf);
  7136. entity.UpdateTime = DateTime.Now;
  7137. entity.Update();
  7138. string toState = GetPostString("ToState");
  7139. string original = GetPostString("isOriginal");
  7140. ApiVo apiVo = new ApiVo();
  7141. apiVo.orderNumber = entity.ctid;
  7142. apiVo.actionName = "afterDesign";
  7143. apiVo.orderRemarks = entity.AfterSaleMethod;
  7144. apiVo.reasonRemarks = entity.AfterSaleReason;
  7145. apiVo.isDesign = isDesign;
  7146. apiVo.designFree = designFree;
  7147. apiVo.responsibleId = responsibleId;
  7148. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7149. if (toState == "设计师")
  7150. {
  7151. apiVo.isOriginal = Convert.ToBoolean(original);
  7152. }
  7153. designHelper.API_WorkCore(apiVo);//afterDesign
  7154. CeErpMethod methodSql = new CeErpMethod();
  7155. methodSql.con = entity.AfterSaleMethod;
  7156. methodSql.addTime = DateTime.Now;
  7157. methodSql.Create();
  7158. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7159. CeErpMethod.ExecuteNonQuery(delsql);
  7160. if (isCompale)
  7161. {
  7162. aftersale_data_change(entity.ctid);
  7163. }
  7164. returnSuccessMsg("操作成功!");
  7165. return;
  7166. }
  7167. returnErrorMsg("找不到订单记录");
  7168. }
  7169. }
  7170. public void ins_erp_toresponsible()
  7171. {
  7172. if (UrlPostParmsCheck("ctid"))
  7173. {
  7174. string eid = GetPostString("ctid");
  7175. CeErpTradeCell entity = null;
  7176. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7177. if (entity != null)
  7178. {
  7179. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7180. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7181. {
  7182. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7183. return;
  7184. }
  7185. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7186. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7187. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7188. if (entity.AfterSalePreTime == null)
  7189. {
  7190. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7191. {
  7192. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7193. }
  7194. }
  7195. entity.AfterSalePreTime = DateTime.Now;
  7196. //预完成给售后主管审核客户问题直接完成
  7197. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7198. {
  7199. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7200. {
  7201. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7202. }
  7203. }
  7204. ceErpTradeAfterSaleExtend.Update();
  7205. entity.AfterSaleState = 2;
  7206. entity.UpdateTime = DateTime.Now;
  7207. entity.Update();
  7208. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7209. aftersale_data_change(entity.ctid);
  7210. returnSuccessMsg("操作成功!");
  7211. return;
  7212. }
  7213. returnErrorMsg("找不到订单记录");
  7214. }
  7215. }
  7216. public void cancel_erp_aftersaleanddelnew()
  7217. {
  7218. if (UrlPostParmsCheck("ctid"))
  7219. {
  7220. string eid = GetPostString("ctid");
  7221. CeErpTradeCell entity = null;
  7222. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7223. if (entity != null)
  7224. {
  7225. entity.AfterSaleState = 0;
  7226. entity.AfterSaleReason = "";
  7227. entity.AfterSaleMethod = "";
  7228. entity.AfterSaleMemo = "";
  7229. entity.AfterSaleResponsible = "";
  7230. entity.ResponsibleUserId = "";
  7231. entity.DeductFee = 0;
  7232. entity.RefundFee = 0;
  7233. entity.IsArbitrate = 0;
  7234. CeErpTradeResponsible.DelByTid(eid, -1);
  7235. entity.Update();
  7236. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7237. if (after != null)
  7238. {
  7239. if (after.OrderState < 5)
  7240. CeErpTradeCell.DelByCtid("S_" + eid);
  7241. }
  7242. returnSuccessMsg("操作成功!");
  7243. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7244. return;
  7245. }
  7246. returnErrorMsg("找不到订单记录");
  7247. }
  7248. }
  7249. public void get_erp_aftersale_pregather()
  7250. {
  7251. List<string> lw = new List<string>();
  7252. int st = GetInt("st");
  7253. string tid = GetPostString("ctid");
  7254. if (tid.Length > 0)
  7255. {
  7256. string select_tid = getTidByCtid(tid);
  7257. lw.Add(string.Format("tid='{0}'", select_tid));
  7258. }
  7259. string shopname = GetPostString("shopname");
  7260. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7261. string buyernick = GetPostString("buyer_nick");
  7262. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7263. string sellermemo = GetPostString("seller_memo");
  7264. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7265. string orderState = GetPostString("orderState");
  7266. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7267. string reason = GetPostString("reason");
  7268. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7269. string method = GetPostString("method");
  7270. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7271. string handler = GetPostString("handler");
  7272. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7273. string handledate1 = GetPostString("handledate1");
  7274. string handledate2 = GetPostString("handledate2");
  7275. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7276. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7277. string supplier = GetPostString("supplier");
  7278. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7279. string responsible = GetPostString("responsibleman");
  7280. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7281. string customer = GetPostString("customer");
  7282. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7283. string design = GetPostString("design");
  7284. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7285. string afterMemoType = GetPostString("aftermemotype");
  7286. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7287. string afterSaleMemo = GetPostString("afterSaleMemo");
  7288. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7289. string afterresult = GetPostString("afterresult");
  7290. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7291. string poscode = CurrentUser.UserPost.Post.Code;
  7292. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7293. {
  7294. string shopid = CurrentUser.User.pemShop;
  7295. lw.Add(string.Format("shopId in ({0})", shopid));
  7296. }
  7297. var mainwhere = string.Join(" and ", lw.ToArray());
  7298. string ro_json = "";
  7299. string type = GetPostString("gather_type");
  7300. int number = 0;
  7301. if (poscode == "AfterSale")
  7302. {
  7303. //处理中
  7304. if (type == "Handling")
  7305. {
  7306. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7307. DataTable dt = null;
  7308. try
  7309. {
  7310. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7311. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7312. }
  7313. catch (Exception e)
  7314. {
  7315. dt = new DataTable();
  7316. }
  7317. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7318. return;
  7319. }
  7320. if (type == "Wait")
  7321. {
  7322. //待处理
  7323. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7324. DataTable dt1 = null;
  7325. try
  7326. {
  7327. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7328. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7329. }
  7330. catch (Exception e)
  7331. {
  7332. dt1 = new DataTable();
  7333. }
  7334. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7335. return;
  7336. }
  7337. if (type == "back")
  7338. {
  7339. //打回
  7340. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7341. DataTable dt2 = null;
  7342. try
  7343. {
  7344. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7345. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7346. }
  7347. catch (Exception e)
  7348. {
  7349. dt2 = new DataTable();
  7350. }
  7351. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7352. return;
  7353. }
  7354. if (type == "preCompletion")
  7355. {
  7356. //预完成
  7357. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7358. DataTable dt3 = null;
  7359. try
  7360. {
  7361. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7362. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7363. }
  7364. catch (Exception e)
  7365. {
  7366. dt3 = new DataTable();
  7367. }
  7368. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7369. return;
  7370. }
  7371. if (type == "documentary")
  7372. {
  7373. //跟单中
  7374. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('重印-转设计师','重印-转下单员') " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7375. DataTable dt4 = null;
  7376. try
  7377. {
  7378. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7379. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7380. }
  7381. catch (Exception e)
  7382. {
  7383. dt4 = new DataTable();
  7384. }
  7385. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7386. return;
  7387. }
  7388. if (type == "reBack")
  7389. {
  7390. //被打回
  7391. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7392. DataTable dt1 = null;
  7393. try
  7394. {
  7395. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7396. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7397. }
  7398. catch (Exception e)
  7399. {
  7400. dt1 = new DataTable();
  7401. }
  7402. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7403. return;
  7404. }
  7405. }
  7406. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7407. {
  7408. if (type == "puBack")
  7409. {
  7410. //退回
  7411. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7412. DataTable dt = null;
  7413. try
  7414. {
  7415. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7416. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7417. }
  7418. catch (Exception e)
  7419. {
  7420. dt = new DataTable();
  7421. }
  7422. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7423. return;
  7424. }
  7425. if (type == "reBack")
  7426. {
  7427. //打回
  7428. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7429. DataTable dt1 = null;
  7430. try
  7431. {
  7432. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7433. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7434. }
  7435. catch (Exception e)
  7436. {
  7437. dt1 = new DataTable();
  7438. }
  7439. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7440. return;
  7441. }
  7442. if (type == "examEd")
  7443. {
  7444. //已审核
  7445. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7446. DataTable dt2 = null;
  7447. try
  7448. {
  7449. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7450. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7451. }
  7452. catch (Exception e)
  7453. {
  7454. dt2 = new DataTable();
  7455. }
  7456. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7457. return;
  7458. }
  7459. if (type == "waitExam")
  7460. {
  7461. //待审核
  7462. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7463. DataTable dt3 = null;
  7464. try
  7465. {
  7466. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7467. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7468. }
  7469. catch (Exception e)
  7470. {
  7471. dt3 = new DataTable();
  7472. }
  7473. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7474. return;
  7475. }
  7476. if (type == "Handling")
  7477. {
  7478. //处理中
  7479. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7480. DataTable dt4 = null;
  7481. try
  7482. {
  7483. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7484. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7485. }
  7486. catch (Exception e)
  7487. {
  7488. dt4 = new DataTable();
  7489. }
  7490. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7491. return;
  7492. }
  7493. if (type == "Wait")
  7494. {
  7495. //待处理
  7496. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7497. DataTable dt5 = null;
  7498. try
  7499. {
  7500. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7501. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7502. }
  7503. catch (Exception e)
  7504. {
  7505. dt5 = new DataTable();
  7506. }
  7507. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7508. return;
  7509. }
  7510. if (type == "documentary")
  7511. {
  7512. //跟单中
  7513. string sql6 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7514. DataTable dt6 = null;
  7515. try
  7516. {
  7517. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7518. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7519. }
  7520. catch (Exception e)
  7521. {
  7522. dt6 = new DataTable();
  7523. }
  7524. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7525. return;
  7526. }
  7527. }
  7528. returnSuccess(ro_json);
  7529. }
  7530. public void end_erp_aftersale()
  7531. {
  7532. if (UrlPostParmsCheck("ctid"))
  7533. {
  7534. string eid = GetPostString("ctid");
  7535. CeErpTradeCell entity = null;
  7536. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7537. if (entity != null)
  7538. {
  7539. string stype = GetPostString("stype");
  7540. string typeStr = stype;
  7541. entity.AfterSaleState = 4;
  7542. entity.FinishAfterSaleTime = DateTime.Now;
  7543. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7544. entity.Update();
  7545. ApiVo apiVo = new ApiVo();
  7546. apiVo.orderNumber = entity.ctid;
  7547. apiVo.actionName = "afterOver";
  7548. designHelper.API_WorkCore(apiVo); //afterOver
  7549. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7550. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7551. CeErpSukuraData.createInfo(entity.ctid, 8);
  7552. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7553. returnSuccessMsg("操作成功!");
  7554. return;
  7555. }
  7556. returnErrorMsg("找不到订单记录");
  7557. }
  7558. }
  7559. public void ins_erp_finishaftersale()
  7560. {
  7561. if (UrlPostParmsCheck("id"))
  7562. {
  7563. string eid = GetPostString("id");
  7564. CeErpTradeResponsible entity = null;
  7565. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7566. if (entity != null)
  7567. {
  7568. entity.VerifyState = 1;
  7569. entity.VerifyTime = DateTime.Now;
  7570. entity.Update();
  7571. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7572. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7573. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7574. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7575. if (dt.Rows.Count <= 0)
  7576. {
  7577. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7578. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7579. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7580. CeErpSukuraData.createInfo(entity.tid, 8);
  7581. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7582. {
  7583. CeErpDesignerBill.Del(entity.tid);
  7584. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7585. }
  7586. }
  7587. returnSuccessMsg("操作成功!");
  7588. return;
  7589. }
  7590. returnErrorMsg("找不到订单记录");
  7591. }
  7592. }
  7593. public void upd_erp_arbitrateaftersale()
  7594. {
  7595. if (UrlPostParmsCheck("id"))
  7596. {
  7597. string eid = GetPostString("id");
  7598. CeErpTradeResponsible entity = null;
  7599. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7600. if (entity != null)
  7601. {
  7602. entity.IsArbitrate = 1;
  7603. entity.ArbitradeMemo = GetPostString("reason");
  7604. entity.VerifyState = 2;
  7605. entity.Update();
  7606. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7607. if (tradecell != null)
  7608. {
  7609. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7610. tradecell.IsArbitrate = 1;
  7611. tradecell.Update();
  7612. }
  7613. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7614. returnSuccessMsg("操作成功!");
  7615. return;
  7616. }
  7617. returnErrorMsg("找不到订单记录");
  7618. }
  7619. }
  7620. public void upd_erp_backaftersale()
  7621. {
  7622. if (UrlPostParmsCheck("tid"))
  7623. {
  7624. string eid = GetPostString("tid");
  7625. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7626. int backNum = 0;
  7627. if (number != null)
  7628. {
  7629. backNum = number.BackNum;
  7630. }
  7631. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7632. CeErpTradeCell entity = null;
  7633. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7634. if (entity != null)
  7635. {
  7636. entity.AfterSaleBackReason = GetPostString("backreason");
  7637. entity.AfterSaleState = 1;
  7638. entity.AfterSaleSupplierState = 0;
  7639. entity.UpdateTime = DateTime.Now;
  7640. entity.Update();
  7641. returnSuccessMsg("操作成功!");
  7642. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7643. return;
  7644. }
  7645. returnErrorMsg("找不到订单记录");
  7646. }
  7647. }
  7648. public void get_erp_supplieraftersalelist()
  7649. {
  7650. DataStruct dStruct = GetPostStruct();
  7651. List<string> lw = new List<string>();
  7652. string tid = GetPostString("ctid");
  7653. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7654. string shopname = GetPostString("shopname");
  7655. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7656. string buyernick = GetPostString("buyer_nick");
  7657. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7658. string sellermemo = GetPostString("seller_memo");
  7659. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7660. string orderState = GetPostString("orderState");
  7661. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7662. string afterState = GetPostString("afterstate");
  7663. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7664. string date1 = GetPostString("date1");
  7665. string date2 = GetPostString("date2");
  7666. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7667. if (dw.Length > 0) lw.Add(dw);
  7668. string price1 = GetPostString("price1");
  7669. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7670. string price2 = GetPostString("price2");
  7671. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7672. string reason = GetPostString("reason");
  7673. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7674. string method = GetPostString("method");
  7675. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7676. string handledate1 = GetPostString("handledate1");
  7677. string handledate2 = GetPostString("handledate2");
  7678. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7679. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7680. string handler = GetPostString("handler");
  7681. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7682. string afterdate1 = GetPostString("afterdate1");
  7683. string afterdate2 = GetPostString("afterdate2");
  7684. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7685. if (afterDate.Length > 0) lw.Add(afterDate);
  7686. string customer = GetPostString("customer");
  7687. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7688. string design = GetPostString("design");
  7689. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7690. string afterMemoType = GetPostString("aftermemotype");
  7691. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7692. string vstate = GetPostString("vstate");
  7693. if (vstate.Length > 0)
  7694. {
  7695. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7696. }
  7697. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7698. string supplier = GetPostString("supplier");
  7699. int supid = commonHelper.getSupplierIDByName(supplier);
  7700. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7701. string posCode = CurrentUser.UserPost.Post.Code;
  7702. if (posCode == "Supplier")
  7703. {
  7704. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7705. }
  7706. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7707. {
  7708. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7709. }
  7710. else
  7711. {
  7712. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7713. }
  7714. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7715. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7716. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7717. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7718. writeGridDataTableJson(dStruct.TotalCount, dt);
  7719. }
  7720. public void upd_erp_supverifyaftersale()
  7721. {
  7722. if (UrlPostParmsCheck("id"))
  7723. {
  7724. string id = GetPostString("id");
  7725. int st = GetPostInt("afterstate");
  7726. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7727. CeErpTradeCell entity = null;
  7728. if (ceErpTradeResponsible != null)
  7729. {
  7730. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7731. }
  7732. string afmemo = GetPostString("supmemo");
  7733. string image = GetPostString("image");
  7734. if (entity != null)
  7735. {
  7736. entity.AfterSaleSupplierState = st;
  7737. entity.AfterSaleSupplierMemo = afmemo;
  7738. if (st == 1)
  7739. {
  7740. ceErpTradeResponsible.VerifyState = 1;
  7741. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7742. ceErpTradeResponsible.Update();
  7743. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7744. if (isAll)
  7745. {
  7746. entity.AfterSaleState = 4;
  7747. entity.FinishAfterSaleTime = DateTime.Now;
  7748. }
  7749. }
  7750. else
  7751. {
  7752. CeErpTradeResponsible.dateByTid(entity.ctid);
  7753. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7754. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7755. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7756. if (num <= 1)
  7757. {
  7758. entity.AfterSaleState = 1;
  7759. }
  7760. else
  7761. {
  7762. entity.AfterSaleState = 5;
  7763. }
  7764. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7765. if (ceErpTradeAfterSaleExtend != null)
  7766. {
  7767. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7768. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7769. ceErpTradeAfterSaleExtend.Update();
  7770. }
  7771. else
  7772. {
  7773. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7774. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7775. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7776. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7777. ceErpTradeAfterSaleExtend.Create();
  7778. }
  7779. }
  7780. if (entity.AfterSaleState == 4)
  7781. {
  7782. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7783. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7784. {
  7785. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7786. }
  7787. ApiVo apiVo = new ApiVo();
  7788. apiVo.orderNumber = entity.ctid;
  7789. apiVo.actionName = "afterOver";
  7790. designHelper.API_WorkCore(apiVo); //afterOver
  7791. }
  7792. entity.UpdateTime = DateTime.Now;
  7793. entity.Update();
  7794. returnSuccessMsg("操作成功!");
  7795. CeErpSukuraData.createInfo(entity.ctid, 8);
  7796. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7797. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7798. return;
  7799. }
  7800. returnErrorMsg("找不到订单记录");
  7801. }
  7802. }
  7803. public void upd_erp_masteraftersale()
  7804. {
  7805. if (UrlPostParmsCheck("id"))
  7806. {
  7807. string id = GetPostString("id");
  7808. int st = GetPostInt("afterstate");
  7809. string afmemo = GetPostString("supmemo");
  7810. string image = GetPostString("image");
  7811. string textResult = GetPostString("textResult");
  7812. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7813. if (ceErpTradeResponsible != null)
  7814. {
  7815. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7816. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7817. ceErpTradeResponsible.Update();
  7818. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7819. if (entity != null)
  7820. {
  7821. entity.AfterSaleSupplierState = st;
  7822. entity.AfterSaleSupplierMemo = afmemo;
  7823. if (st == 1)
  7824. {
  7825. }
  7826. else
  7827. {
  7828. CeErpTradeResponsible.dateByTid(entity.ctid);
  7829. //退回到售后
  7830. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7831. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7832. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7833. if (num <= 1)
  7834. {
  7835. entity.AfterSaleState = 1;
  7836. }
  7837. else
  7838. {
  7839. entity.AfterSaleState = 5;
  7840. }
  7841. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7842. if (ceErpTradeAfterSaleExtend != null)
  7843. {
  7844. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7845. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7846. ceErpTradeAfterSaleExtend.Update();
  7847. }
  7848. else
  7849. {
  7850. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7851. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7852. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7853. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7854. ceErpTradeAfterSaleExtend.Create();
  7855. }
  7856. }
  7857. entity.UpdateTime = DateTime.Now;
  7858. entity.Update();
  7859. returnSuccessMsg("操作成功!");
  7860. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7861. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7862. return;
  7863. }
  7864. }
  7865. returnErrorMsg("找不到订单记录");
  7866. }
  7867. }
  7868. public void upd_erp_personaftersale()
  7869. {
  7870. if (UrlPostParmsCheck("id"))
  7871. {
  7872. //林小连
  7873. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7874. {
  7875. upd_erp_masteraftersale();
  7876. return;
  7877. }
  7878. string id = GetPostString("id");
  7879. int st = GetPostInt("afterstate");
  7880. string afmemo = GetPostString("supmemo");
  7881. string image = GetPostString("image");
  7882. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7883. if (ceErpTradeResponsible != null)
  7884. {
  7885. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7886. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7887. ceErpTradeResponsible.Update();
  7888. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7889. if (entity != null)
  7890. {
  7891. entity.AfterSaleSupplierMemo = afmemo;
  7892. entity.AfterSaleSupplierState = st;
  7893. if (st == 1)
  7894. {
  7895. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7896. if (isAll)
  7897. {
  7898. entity.AfterSaleState = 4;
  7899. entity.FinishAfterSaleTime = DateTime.Now;
  7900. }
  7901. }
  7902. else
  7903. {
  7904. CeErpTradeResponsible.dateByTid(entity.ctid);
  7905. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7906. if (ceErpTradeAfterSaleExtend != null)
  7907. {
  7908. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7909. ceErpTradeAfterSaleExtend.Update();
  7910. }
  7911. else
  7912. {
  7913. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7914. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7915. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7916. ceErpTradeAfterSaleExtend.Create();
  7917. }
  7918. //退回到主管
  7919. //entity.AfterSaleState = 2;
  7920. }
  7921. if (entity.AfterSaleState == 4)
  7922. {
  7923. ApiVo apiVo = new ApiVo();
  7924. apiVo.orderNumber = entity.ctid;
  7925. apiVo.actionName = "afterOver";
  7926. designHelper.API_WorkCore(apiVo); //afterOver
  7927. }
  7928. entity.UpdateTime = DateTime.Now;
  7929. entity.Update();
  7930. returnSuccessMsg("操作成功!");
  7931. CeErpSukuraData.createInfo(entity.ctid, 8);
  7932. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7933. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7934. return;
  7935. }
  7936. }
  7937. returnErrorMsg("找不到订单记录");
  7938. }
  7939. }
  7940. public void set_erp_supplierrefundtag()
  7941. {
  7942. if (UrlPostParmsCheck("ctid"))
  7943. {
  7944. string eid = GetPostString("ctid");
  7945. CeErpTradeCell entity = null;
  7946. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7947. if (entity != null)
  7948. {
  7949. entity.IsSupplierRefund = GetPostInt("tag");
  7950. entity.Update();
  7951. returnSuccessMsg("操作成功!");
  7952. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7953. return;
  7954. }
  7955. returnErrorMsg("找不到订单记录");
  7956. }
  7957. }
  7958. public void get_erp_refundlist()
  7959. {
  7960. DataStruct dStruct = GetPostStruct();
  7961. List<string> lw = new List<string>();
  7962. string tid = GetPostString("tid");
  7963. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7964. //string rid = GetPostString("refund_id");
  7965. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7966. string shopname = GetPostString("shopname");
  7967. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7968. string buyernick = GetPostString("buyer_nick");
  7969. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7970. string customer = GetPostString("customer");
  7971. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7972. string design = GetPostString("design");
  7973. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7974. string sellermemo = GetPostString("seller_memo");
  7975. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7976. //string date1 = GetPostString("date1");
  7977. //string date2 = GetPostString("date2");
  7978. //string dateType = GetPostString("dateType");
  7979. //if (dateType.Length > 0)
  7980. //{
  7981. // if (dateType == "1001") dateType = "0";
  7982. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7983. // if (searchDT.Count == 2)
  7984. // {
  7985. // date1 = searchDT[0].ToString();
  7986. // date2 = searchDT[1].ToString();
  7987. // }
  7988. //}
  7989. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7990. //if (dw.Length > 0) lw.Add(dw);
  7991. string redate1 = GetPostString("refunddate1");
  7992. string redate2 = GetPostString("refunddate2");
  7993. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7994. if (dwdate.Length > 0) lw.Add(dwdate);
  7995. string price1 = GetPostString("price1");
  7996. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7997. string price2 = GetPostString("price2");
  7998. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7999. string ispartrefund = GetPostString("ispartrefund");
  8000. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8001. string refundState = GetPostString("refundvstate");
  8002. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8003. int st = GetInt("st");
  8004. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8005. {
  8006. string responsible = GetPostString("responsibleman");
  8007. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8008. lw.Add(string.Format("RefundState>={0}", st));
  8009. string code = CurrentUser.UserPost.Post.Code;
  8010. if (code == "CustomerService")
  8011. {
  8012. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8013. }
  8014. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8015. {
  8016. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8017. }
  8018. else if (code == "Place" || code == "PlaceMr")
  8019. {
  8020. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8021. }
  8022. dStruct.Order = "RefundState asc,created desc";
  8023. }
  8024. else if (st == 10)
  8025. {
  8026. string responsible = GetPostString("responsibleman");
  8027. if (responsible == "空白")
  8028. {
  8029. lw.Add(string.Format("ResponsibleUserName = ''"));
  8030. }
  8031. else if (responsible.Length > 0)
  8032. {
  8033. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8034. }
  8035. lw.Add(string.Format("RefundState>=0"));
  8036. dStruct.Order = "created desc";
  8037. }
  8038. else
  8039. {
  8040. string responsible = GetPostString("responsibleman");
  8041. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8042. lw.Add(string.Format("RefundState={0}", st));
  8043. dStruct.Order = "created desc";
  8044. }
  8045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8046. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8047. dt.Columns.Add("refund_fees");
  8048. foreach (DataRow dr in dt.Rows)
  8049. {
  8050. String status = dr["status"].ToString();
  8051. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8052. {
  8053. dr["refund_fees"] = dr["refund_fee"];
  8054. }
  8055. else
  8056. {
  8057. dr["refund_fees"] = "0.0";
  8058. }
  8059. }
  8060. writeGridDataTableJson(dStruct.TotalCount, dt);
  8061. }
  8062. public void get_erp_refunddesignlist()
  8063. {
  8064. DataStruct dStruct = GetPostStruct();
  8065. List<string> lw = new List<string>();
  8066. string tid = GetPostString("tid");
  8067. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8068. string shopname = GetPostString("shopname");
  8069. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8070. string buyernick = GetPostString("buyer_nick");
  8071. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8072. string customer = GetPostString("customer");
  8073. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8074. string design = GetPostString("design");
  8075. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8076. string sellermemo = GetPostString("seller_memo");
  8077. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8078. string redate1 = GetPostString("refunddate1");
  8079. string redate2 = GetPostString("refunddate2");
  8080. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8081. if (dwdate.Length > 0) lw.Add(dwdate);
  8082. string price1 = GetPostString("price1");
  8083. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8084. string price2 = GetPostString("price2");
  8085. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8086. string ispartrefund = GetPostString("ispartrefund");
  8087. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8088. string designerorg = GetPostString("designerorg");
  8089. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8090. string refundState = GetPostString("refundState");
  8091. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8092. int myOrgid = CurrentUser.UserPost.OrgID;
  8093. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8094. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8095. {
  8096. if (CurrentUser.User.TeamIds.Length > 0)
  8097. {
  8098. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8099. }
  8100. else
  8101. {
  8102. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8103. }
  8104. }
  8105. else if ("SysAdmin".Equals(myOrgCode))
  8106. {
  8107. }
  8108. else
  8109. {
  8110. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8111. {
  8112. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8113. }
  8114. else
  8115. {
  8116. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8117. }
  8118. }
  8119. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8120. dStruct.Order = "created desc";
  8121. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8122. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8123. dt.Columns.Add("refund_fees");
  8124. foreach (DataRow dr in dt.Rows)
  8125. {
  8126. String status = dr["status"].ToString();
  8127. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8128. {
  8129. dr["refund_fees"] = dr["refund_fee"];
  8130. }
  8131. else
  8132. {
  8133. dr["refund_fees"] = "0.0";
  8134. }
  8135. }
  8136. writeGridDataTableJson(dStruct.TotalCount, dt);
  8137. }
  8138. public void handle_erp_refundtag()
  8139. {
  8140. if (UrlPostParmsCheck("refund_id"))
  8141. {
  8142. string eid = GetPostString("refund_id");
  8143. string respMan = GetPostString("ResponsibleName");
  8144. if (respMan.Length <= 0)
  8145. {
  8146. returnErrorMsg("责任人不能为空");
  8147. return;
  8148. }
  8149. CeErpTradeRefund entity = null;
  8150. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8151. if (entity != null)
  8152. {
  8153. entity.ResponsibleUserName = respMan;
  8154. string userid = GetPostString("ResponsibleUserId");
  8155. if (userid.Length > 0)
  8156. {
  8157. entity.ResponsibleUserId = userid;
  8158. }
  8159. entity.Memo = GetPostString("Memo");
  8160. if (respMan.IndexOf("客服") != -1 ||
  8161. respMan.IndexOf("设计师") != -1 ||
  8162. respMan.IndexOf("下单员") != -1)
  8163. {
  8164. entity.RefundState = 2;
  8165. }
  8166. else
  8167. {
  8168. entity.RefundState = 3;
  8169. }
  8170. entity.modified = DateTime.Now;
  8171. entity.Update();
  8172. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8173. returnSuccessMsg("操作成功!");
  8174. return;
  8175. }
  8176. returnErrorMsg("找不到订单记录");
  8177. }
  8178. }
  8179. public void handle_erp_designrefundtag()
  8180. {
  8181. if (UrlPostParmsCheck("refund_id"))
  8182. {
  8183. string eid = GetPostString("refund_id");
  8184. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8185. if (ceErpTradeCellExtend == null)
  8186. {
  8187. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8188. ceErpTradeCellExtend.ctid = eid;
  8189. }
  8190. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8191. if (ceErpTradeCellExtend.ID > 0)
  8192. {
  8193. ceErpTradeCellExtend.Update();
  8194. }
  8195. else
  8196. {
  8197. ceErpTradeCellExtend.Create();
  8198. }
  8199. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8200. returnSuccessMsg("操作成功!");
  8201. return;
  8202. }
  8203. returnErrorMsg("找不到订单记录");
  8204. }
  8205. public void upd_erp_refundverify()
  8206. {
  8207. if (UrlPostParmsCheck("refund_id"))
  8208. {
  8209. string eid = GetPostString("refund_id");
  8210. CeErpTradeRefund entity = null;
  8211. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8212. if (entity != null)
  8213. {
  8214. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8215. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8216. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8217. {
  8218. entity.RefundState = 2;
  8219. }
  8220. else
  8221. {
  8222. entity.RefundState = 3;
  8223. }
  8224. entity.Update();
  8225. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8226. returnSuccessMsg("操作成功!");
  8227. return;
  8228. }
  8229. returnErrorMsg("找不到订单记录");
  8230. }
  8231. }
  8232. public void upd_erp_refundapprove()
  8233. {
  8234. if (UrlPostParmsCheck("refund_id"))
  8235. {
  8236. string eid = GetPostString("refund_id");
  8237. CeErpTradeRefund entity = null;
  8238. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8239. if (entity != null)
  8240. {
  8241. int apr = GetPostInt("approve");
  8242. if (apr == 0)
  8243. {
  8244. entity.RefundState = 1;
  8245. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8246. }
  8247. else if (apr == 1)
  8248. {
  8249. entity.RefundState = 3;
  8250. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8251. }
  8252. entity.modified = DateTime.Now;
  8253. entity.Update();
  8254. returnSuccessMsg("操作成功!");
  8255. return;
  8256. }
  8257. returnErrorMsg("找不到订单记录");
  8258. }
  8259. }
  8260. public void get_erp_billlist()
  8261. {
  8262. DataStruct dStruct = GetPostStruct();
  8263. List<string> lw = new List<string>();
  8264. string title = GetPostString("title");
  8265. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8266. string tid = GetPostString("tid");
  8267. string tids = GetPostString("tids");
  8268. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8269. if (tids.Length > 0)
  8270. {
  8271. tids = "'" + tids + "'";
  8272. tids = tids.Replace(",", "','");
  8273. lw.Add(string.Format("tid in ({0})", tids));
  8274. }
  8275. string shopname = GetPostString("shopname");
  8276. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8277. string buyernick = GetPostString("buyer_nick");
  8278. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8279. string customer = GetPostString("customer");
  8280. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8281. string date1 = GetPostString("date1");
  8282. string date2 = GetPostString("date2");
  8283. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8284. if (dw.Length > 0) lw.Add(dw);
  8285. string price1 = GetPostString("price1");
  8286. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8287. string price2 = GetPostString("price2");
  8288. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8289. string returndate1 = GetPostString("returndate1");
  8290. string returndate2 = GetPostString("returndate2");
  8291. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8292. if (dw1.Length > 0) lw.Add(dw1);
  8293. string billtype = GetPostString("billtype");
  8294. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8295. string billstate = GetPostString("billstate");
  8296. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8297. string usershop = CurrentUser.User.pemShop;
  8298. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8299. dStruct.Order = "createTime desc";
  8300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8301. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8302. //foreach (DataRow dr in dt.Rows)
  8303. //{
  8304. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8305. //}
  8306. writeGridDataTableJson(dStruct.TotalCount, dt);
  8307. }
  8308. public void modify_erp_billinfo()
  8309. {
  8310. if (UrlPostParmsCheck("ID"))
  8311. {
  8312. string eid = GetPostString("ID");
  8313. CeErpBill bill_entity = null;
  8314. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8315. if (bill_entity != null)
  8316. {
  8317. bill_entity.tid = GetPostString("tid");
  8318. bill_entity.title = GetPostString("title");
  8319. bill_entity.tax = GetPostString("tax");
  8320. bill_entity.bank = GetPostString("bank");
  8321. bill_entity.bankac = GetPostString("bankac");
  8322. bill_entity.address = GetPostString("address");
  8323. bill_entity.phone = GetPostString("phone");
  8324. bill_entity.price = GetPostString("price");
  8325. bill_entity.productId = GetPostInt("ProductName");
  8326. bill_entity.num = GetPostInt("num");
  8327. bill_entity.unit = GetPostString("unit");
  8328. bill_entity.type = GetPostString("type");
  8329. bill_entity.sendType = GetPostString("SendType");
  8330. bill_entity.email = GetPostString("email");
  8331. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8332. bill_entity.shopName = GetPostString("ShopName");
  8333. bill_entity.applymemo = GetPostString("applymemo");
  8334. bill_entity.modifyTime = DateTime.Now;
  8335. bill_entity.createTime = DateTime.Now;
  8336. bill_entity.state = 0;
  8337. bill_entity.Update();
  8338. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8339. returnSuccessMsg("发票修改成功!");
  8340. return;
  8341. }
  8342. returnErrorMsg("找不到对应记录");
  8343. }
  8344. }
  8345. public void set_erp_invoicing()
  8346. {
  8347. if (UrlPostParmsCheck("id"))
  8348. {
  8349. try
  8350. {
  8351. string eid = GetPostString("id");
  8352. CeErpBill bill_entity = null;
  8353. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8354. if (bill_entity != null)
  8355. {
  8356. int ComId = GetPostInt("ComId");
  8357. //string memo = GetPostString("Memo");
  8358. int allInfo = GetPostInt("allinfo");
  8359. string clert = CurrentUser.User.Name;
  8360. //string detailValue = GetPostString("detailvalue");
  8361. string billId = bill_entity.billOrderId;
  8362. string[] billIdList = billId.Split(',');
  8363. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8364. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8365. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8366. {
  8367. billCount += 1;
  8368. }
  8369. if (billId.Length <= 0 || billIdList.Length != billCount)
  8370. {
  8371. bill_entity.billOrderId = "";
  8372. string prebill = "ltb";
  8373. for (int idx = 1; idx <= billCount; idx++)
  8374. {
  8375. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8376. string billoid = prebill + idx + dtstr;
  8377. bill_entity.billOrderId += billoid;
  8378. if (idx < billCount)
  8379. {
  8380. bill_entity.billOrderId += ",";
  8381. }
  8382. }
  8383. }
  8384. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8385. if (bill_entity.state == 5)
  8386. {
  8387. string errMsg = bill_entity.failerror;
  8388. string[] errlist = errMsg.Split('|');
  8389. string[] errTags = new string[errlist.Length];
  8390. for (int itag = 0; itag < errlist.Length; itag++)
  8391. {
  8392. if (errlist[itag].Length <= 0) continue;
  8393. errTags[itag] = errlist[itag].Split('&')[0];
  8394. }
  8395. for (int iii = 0; iii < errTags.Length; iii++)
  8396. {
  8397. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8398. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8399. if (billOrderList.Length >= erroBillOrderTag)
  8400. {
  8401. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8402. if (needModifyBillId.Length <= 19)
  8403. {
  8404. needModifyBillId = needModifyBillId + "1";
  8405. }
  8406. else
  8407. {
  8408. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8409. last = last + 1;
  8410. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8411. }
  8412. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8413. }
  8414. }
  8415. }
  8416. bool isHaveBillSucces = false;
  8417. string totalRes = "";
  8418. bill_entity.failerror = "";
  8419. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8420. {
  8421. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8422. totalRes += res;
  8423. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8424. {
  8425. isHaveBillSucces = true;
  8426. bill_entity.comId = ComId;
  8427. bill_entity.state = 1;
  8428. bill_entity.executeTime = DateTime.Now;
  8429. bill_entity.executeUser = clert;
  8430. }
  8431. else
  8432. {
  8433. bill_entity.state = 5;
  8434. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8435. }
  8436. }
  8437. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8438. bill_entity.Update();
  8439. if (isHaveBillSucces)
  8440. {
  8441. StringBuilder sql = new StringBuilder();
  8442. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8443. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8444. }
  8445. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8446. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8447. {
  8448. returnErrorMsg("开票失败");
  8449. }
  8450. else
  8451. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8452. return;
  8453. }
  8454. returnErrorMsg("找不到对应记录");
  8455. }
  8456. catch (Exception ex)
  8457. {
  8458. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8459. returnErrorMsg("操作失败");
  8460. }
  8461. }
  8462. }
  8463. public void get_erp_invoicing_back()
  8464. {
  8465. if (UrlPostParmsCheck("id"))
  8466. {
  8467. try
  8468. {
  8469. string id = GetPostString("id");
  8470. CeErpBill entiy = CeErpBill.Get(id);
  8471. if (entiy != null)
  8472. {
  8473. if (entiy.state == 0)
  8474. {
  8475. returnErrorMsg("发票还未开具");
  8476. return;
  8477. }
  8478. string[] billOrderList = entiy.billOrderId.Split(',');
  8479. int iTag = 0;
  8480. entiy.fplsh = "";
  8481. entiy.fpdm = "";
  8482. entiy.fphm = "";
  8483. foreach (string billOrderId in billOrderList)
  8484. {
  8485. iTag++;
  8486. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8487. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8488. {
  8489. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8490. try
  8491. {
  8492. Invoicing_get_response_Obj iObj = null;
  8493. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8494. if (iObj != null)
  8495. {
  8496. entiy.state = 2;
  8497. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8498. entiy.fpdm += iObj.list[0].c_fpdm;
  8499. entiy.fphm += iObj.list[0].c_fphm;
  8500. if (iTag < billOrderList.Length)
  8501. {
  8502. entiy.fplsh += ",";
  8503. entiy.fpdm += ",";
  8504. entiy.fphm += ",";
  8505. }
  8506. entiy.Update();
  8507. }
  8508. StringBuilder sql = new StringBuilder();
  8509. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8510. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8511. returnSuccessMsg("开票成功");
  8512. }
  8513. catch (Exception ex)
  8514. {
  8515. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8516. }
  8517. return;
  8518. }
  8519. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8520. {
  8521. var res_obj = new
  8522. {
  8523. data = "开票中"
  8524. };
  8525. string ro_json = JsonConvert.SerializeObject(res_obj);
  8526. returnSuccess(ro_json);
  8527. return;
  8528. }
  8529. else
  8530. {
  8531. int eidx = res.IndexOf("c_resultmsg");
  8532. int lidx = res.IndexOf("c_status");
  8533. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8534. entiy.state = 5;
  8535. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8536. entiy.Update();
  8537. returnErrorMsg("开票失败");
  8538. return;
  8539. }
  8540. }
  8541. }
  8542. }
  8543. catch (Exception ex)
  8544. {
  8545. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8546. }
  8547. return;
  8548. }
  8549. }
  8550. public void get_erp_invoicing()
  8551. {
  8552. if (UrlPostParmsCheck("id"))
  8553. {
  8554. try
  8555. {
  8556. string id = GetPostString("id");
  8557. CeErpBill entiy = CeErpBill.Get(id);
  8558. if (entiy != null)
  8559. {
  8560. if (entiy.state == 0)
  8561. {
  8562. returnErrorMsg("发票还未开具");
  8563. return;
  8564. }
  8565. if (entiy.sendType == "纸质发票")
  8566. {
  8567. if (entiy.img.Length <= 0)
  8568. {
  8569. returnErrorMsg("查无纸质发票");
  8570. return;
  8571. }
  8572. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8573. returnSuccess(returnres);
  8574. return;
  8575. }
  8576. string[] billOrderList = entiy.billOrderId.Split(',');
  8577. int iTag = 0;
  8578. string fpUrl = "";
  8579. entiy.fplsh = "";
  8580. entiy.fpdm = "";
  8581. entiy.fphm = "";
  8582. foreach (string billOrderId in billOrderList)
  8583. {
  8584. iTag++;
  8585. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8586. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8587. {
  8588. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8589. Invoicing_get_response_Obj iObj = null;
  8590. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8591. if (iObj != null)
  8592. {
  8593. //entiy.state = 2;
  8594. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8595. entiy.fpdm += iObj.list[0].c_fpdm;
  8596. entiy.fphm += iObj.list[0].c_fphm;
  8597. if (iTag < billOrderList.Length)
  8598. {
  8599. entiy.fplsh += ",";
  8600. entiy.fpdm += ",";
  8601. entiy.fphm += ",";
  8602. }
  8603. entiy.Update();
  8604. fpUrl += iObj.list[0].c_url + ",";
  8605. }
  8606. //returnSuccess(res);
  8607. StringBuilder sql = new StringBuilder();
  8608. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8609. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8610. }
  8611. else
  8612. {
  8613. int eidx = res.IndexOf("c_resultmsg");
  8614. //int lidx = res.IndexOf("c_status");
  8615. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8616. //开票失败
  8617. entiy.state = 5;
  8618. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8619. entiy.Update();
  8620. returnErrorMsg("开票失败");
  8621. return;
  8622. }
  8623. }
  8624. var returnObj = new
  8625. {
  8626. data = fpUrl
  8627. };
  8628. string ro_json = JsonConvert.SerializeObject(returnObj);
  8629. returnSuccess(ro_json);
  8630. }
  8631. }
  8632. catch (Exception ex)
  8633. {
  8634. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8635. }
  8636. return;
  8637. }
  8638. }
  8639. public void save_erp_billimg()
  8640. {
  8641. if (UrlPostParmsCheck("id"))
  8642. {
  8643. string eid = GetPostString("id");
  8644. CeErpBill bill_entity = null;
  8645. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8646. if (bill_entity != null)
  8647. {
  8648. bill_entity.img = GetPostString("img");
  8649. bill_entity.executeTime = DateTime.Now;
  8650. bill_entity.state = 2;
  8651. bill_entity.Update();
  8652. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8653. returnSuccessMsg("保存成功");
  8654. }
  8655. return;
  8656. }
  8657. }
  8658. public void upd_erp_billreturnback()
  8659. {
  8660. if (UrlPostParmsCheck("id"))
  8661. {
  8662. int eid = GetPostInt("id");
  8663. CeErpBill bill_entity = null;
  8664. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8665. if (bill_entity != null)
  8666. {
  8667. bill_entity.state = 3;
  8668. bill_entity.returnReason = GetPostString("reason");
  8669. bill_entity.Update();
  8670. returnSuccessMsg("驳回成功!");
  8671. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8672. }
  8673. return;
  8674. }
  8675. }
  8676. public void cancel_erp_bill()
  8677. {
  8678. if (UrlPostParmsCheck("id"))
  8679. {
  8680. int eid = GetPostInt("id");
  8681. int detailValue = GetPostInt("detailvalue");
  8682. CeErpBill bill_entity = null;
  8683. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8684. string cres = "";
  8685. string gres = "";
  8686. if (bill_entity != null)
  8687. {
  8688. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8689. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8690. {
  8691. int iTag = 0;
  8692. bill_entity.fplsh = "";
  8693. bill_entity.fpdm = "";
  8694. bill_entity.fphm = "";
  8695. foreach (string billOrderId in billOrderList)
  8696. {
  8697. iTag++;
  8698. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8699. if (gres.IndexOf("success") != -1)
  8700. {
  8701. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8702. Invoicing_get_response_Obj iObj = null;
  8703. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8704. if (iObj != null)
  8705. {
  8706. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8707. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8708. bill_entity.fphm += iObj.list[0].c_fphm;
  8709. if (iTag < billOrderList.Length)
  8710. {
  8711. bill_entity.fplsh += ",";
  8712. bill_entity.fpdm += ",";
  8713. bill_entity.fphm += ",";
  8714. }
  8715. bill_entity.Update();
  8716. }
  8717. }
  8718. else
  8719. {
  8720. returnErrorMsg(gres);
  8721. return;
  8722. }
  8723. }
  8724. }
  8725. if (bill_entity.sendType == "纸质发票")
  8726. {
  8727. //作废
  8728. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8729. //if (DateTime.Now.Month == extime.Month)
  8730. //{
  8731. //cres = taobaoHelper.cancel_invoicing(eid);
  8732. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8733. //{
  8734. bill_entity.state = 4;//已作废
  8735. bill_entity.Update();
  8736. returnSuccessMsg("发票已作废");
  8737. return;
  8738. //}
  8739. //else
  8740. //{
  8741. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8742. // bill_entity.Update();
  8743. // returnErrorMsg(cres);
  8744. // return;
  8745. //}
  8746. //}
  8747. //else
  8748. //{
  8749. // returnErrorMsg("纸质发票只能作废本月的发票");
  8750. // return;
  8751. //}
  8752. }
  8753. //红冲
  8754. int redTag = 0;
  8755. string[] fpdmList = bill_entity.fpdm.Split(',');
  8756. string[] fphmList = bill_entity.fphm.Split(',');
  8757. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8758. {
  8759. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8760. return;
  8761. }
  8762. foreach (string billOrderId in billOrderList)
  8763. {
  8764. redTag++;
  8765. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8766. cres += onecres;
  8767. cres += ",";
  8768. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8769. {
  8770. bill_entity.state = 4;//已作废
  8771. //bill_entity.Update();
  8772. //returnSuccessMsg("发票已红冲");
  8773. }
  8774. else if (onecres.IndexOf("重复冲红") != -1)
  8775. {
  8776. bill_entity.state = 4;//已作废
  8777. //bill_entity.Update();
  8778. //returnSuccessMsg("发票已红冲");
  8779. }
  8780. else
  8781. {
  8782. string errmsg = commonHelper.KeepChinese(onecres);
  8783. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8784. }
  8785. }
  8786. bill_entity.Update();
  8787. if (cres.IndexOf("失败") != -1)
  8788. returnErrorMsg("红冲失败");
  8789. else
  8790. returnSuccessMsg("发票已红冲");
  8791. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8792. return;
  8793. }
  8794. return;
  8795. }
  8796. }
  8797. public void del_erp_billorder()
  8798. {
  8799. if (UrlPostParmsCheck("id"))
  8800. {
  8801. string eid = GetPostString("id");
  8802. CeErpBill.Del(eid);
  8803. CeErpBill bill = CeErpBill.Get(eid);
  8804. if (bill != null)
  8805. {
  8806. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8807. }
  8808. returnSuccessMsg("删除成功");
  8809. }
  8810. }
  8811. public void finish_erp_bill()
  8812. {
  8813. if (UrlPostParmsCheck("ids"))
  8814. {
  8815. string eids = GetPostString("ids");
  8816. string[] list = eids.Split(',');
  8817. foreach (string eid in list)
  8818. {
  8819. CeErpBill bill = CeErpBill.Get(eid);
  8820. if (bill != null)
  8821. {
  8822. bill.state = 2;
  8823. bill.Update();
  8824. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8825. }
  8826. }
  8827. returnSuccessMsg("操作成功");
  8828. }
  8829. }
  8830. public void get_erp_returncash()
  8831. {
  8832. DataStruct dStruct = GetPostStruct();
  8833. List<string> lw = new List<string>();
  8834. string tid = GetPostString("tid");
  8835. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8836. string shopname = GetPostString("shopname");
  8837. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8838. string buyernick = GetPostString("buyer_nick");
  8839. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8840. string customer = GetPostString("customer");
  8841. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8842. string returndate1 = GetPostString("returndate1");
  8843. string returndate2 = GetPostString("returndate2");
  8844. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8845. if (dw.Length > 0) lw.Add(dw);
  8846. string finishDate1 = GetPostString("finishdate1");
  8847. string finishDate2 = GetPostString("finishdate2");
  8848. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8849. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8850. string returntype = GetPostString("returntype");
  8851. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8852. string returnvstate = GetPostString("returnvstate");
  8853. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8854. dStruct.Order = "created desc";
  8855. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8856. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8857. writeGridDataTableJson(dStruct.TotalCount, dt);
  8858. }
  8859. public void get_erp_staygoods()
  8860. {
  8861. DataStruct dStruct = GetPostStruct();
  8862. List<string> lw = new List<string>();
  8863. string tid = GetPostString("tid");
  8864. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8865. string shopname = GetPostString("shopname");
  8866. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8867. string wangwang = GetPostString("wangwang");
  8868. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8869. string customer = GetPostString("customer");
  8870. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8871. string returndate1 = GetPostString("returndate1");
  8872. string returndate2 = GetPostString("returndate2");
  8873. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8874. if (dw.Length > 0) lw.Add(dw);
  8875. string finishDate1 = GetPostString("finishdate1");
  8876. string finishDate2 = GetPostString("finishdate2");
  8877. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8878. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8879. string returnvstate = GetPostString("returnvstate");
  8880. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8881. string persuadetype = GetPostString("persuadetype");
  8882. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8883. string customerOrg = GetPostString("customerOrg");
  8884. if (customerOrg.Length > 0)
  8885. {
  8886. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8887. }
  8888. string designerorg = GetPostString("designerorg");
  8889. if (designerorg.Length > 0)
  8890. {
  8891. lw.Add(string.Format("OrgID = {0}", designerorg));
  8892. }
  8893. dStruct.Order = "creata_time desc";
  8894. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8895. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8896. writeGridDataTableJson(dStruct.TotalCount, dt);
  8897. }
  8898. public void upd_erp_staygoods()
  8899. {
  8900. if (UrlPostParmsCheck("id"))
  8901. {
  8902. int eid = GetPostInt("id");
  8903. CeErpStayGoods entity = null;
  8904. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8905. if (entity != null)
  8906. {
  8907. entity.audit_type = 1;
  8908. entity.audit_time = DateTime.Now;
  8909. entity.audit_u_id = CurrentUser.UserID;
  8910. entity.audit_u_name = CurrentUser.UserName;
  8911. entity.Update();
  8912. returnSuccessMsg("审核成功!");
  8913. return;
  8914. }
  8915. returnErrorMsg("找不到订单记录");
  8916. }
  8917. }
  8918. public void upd_erp_stayGoodsback()
  8919. {
  8920. if (UrlPostParmsCheck("id"))
  8921. {
  8922. int eid = GetPostInt("id");
  8923. CeErpStayGoods entity = null;
  8924. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8925. if (entity != null)
  8926. {
  8927. entity.audit_text = GetPostString("reason");
  8928. entity.audit_type = 2;
  8929. entity.audit_time = DateTime.Now;
  8930. entity.audit_u_id = CurrentUser.UserID;
  8931. entity.audit_u_name = CurrentUser.UserName;
  8932. entity.Update();
  8933. returnSuccessMsg("退回成功!");
  8934. return;
  8935. }
  8936. returnErrorMsg("找不到订单记录");
  8937. }
  8938. }
  8939. public void upd_erp_returncashverify()
  8940. {
  8941. if (UrlPostParmsCheck("ID"))
  8942. {
  8943. int eid = GetPostInt("ID");
  8944. CeErpReturnCash entity = null;
  8945. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8946. if (entity != null)
  8947. {
  8948. entity.cashstate = 1;
  8949. entity.verifytime = DateTime.Now;
  8950. entity.verifyuserid = CurrentUser.UserID;
  8951. entity.Update();
  8952. returnSuccessMsg("审核成功!");
  8953. return;
  8954. }
  8955. returnErrorMsg("找不到订单记录");
  8956. }
  8957. }
  8958. public void upd_all_erp_returncashverify()
  8959. {
  8960. if (UrlPostParmsCheck("ID"))
  8961. {
  8962. String[] list = GetPostString("ID").Split(',');
  8963. CeErpReturnCash entity = null;
  8964. for (int i = 0; i < list.Length; i++)
  8965. {
  8966. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8967. if (entity != null)
  8968. {
  8969. if (entity.cashstate == 1)
  8970. {
  8971. returnErrorMsg("已审核过的订单不需要在审核!");
  8972. return;
  8973. }
  8974. entity.cashstate = 1;
  8975. entity.verifytime = DateTime.Now;
  8976. entity.verifyuserid = CurrentUser.UserID;
  8977. entity.Update();
  8978. }
  8979. }
  8980. returnSuccessMsg("审核成功!");
  8981. return;
  8982. }
  8983. }
  8984. public void upd_erp_returncashback()
  8985. {
  8986. if (UrlPostParmsCheck("ID"))
  8987. {
  8988. int eid = GetPostInt("ID");
  8989. CeErpReturnCash entity = null;
  8990. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8991. if (entity != null)
  8992. {
  8993. entity.backreason = GetPostString("reason");
  8994. entity.cashstate = 2;
  8995. entity.verifytime = DateTime.Now;
  8996. entity.verifyuserid = CurrentUser.UserID;
  8997. entity.Update();
  8998. returnSuccessMsg("退回成功!");
  8999. return;
  9000. }
  9001. returnErrorMsg("找不到订单记录");
  9002. }
  9003. }
  9004. public void upd_erp_returnprice()
  9005. {
  9006. if (UrlPostParmsCheck("ID"))
  9007. {
  9008. int eid = GetPostInt("ID");
  9009. CeErpReturnCash entity = null;
  9010. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9011. if (entity != null)
  9012. {
  9013. if (entity.cashstate == 1)
  9014. {
  9015. returnErrorMsg("审核通过了不能改");
  9016. return;
  9017. }
  9018. entity.returnprice = GetPostDouble("returnprice");
  9019. entity.Update();
  9020. returnSuccessMsg("修改成功!");
  9021. return;
  9022. }
  9023. returnErrorMsg("找不到订单记录");
  9024. }
  9025. }
  9026. public void del_erp_returncash()
  9027. {
  9028. if (UrlPostParmsCheck("ID"))
  9029. {
  9030. int eid = GetPostInt("ID");
  9031. CeErpReturnCash.Del(eid);
  9032. returnSuccessMsg("操作成功");
  9033. return;
  9034. }
  9035. }
  9036. public void test_for_do_sql()
  9037. {
  9038. string sql = GetPostString("sqlstr");
  9039. if (sql.Length > 0)
  9040. {
  9041. try
  9042. {
  9043. DbHelper.DbConn.ExecuteNonQuery(sql);
  9044. var res_obj = new
  9045. {
  9046. data = "成功",
  9047. };
  9048. string ro_json = JsonConvert.SerializeObject(res_obj);
  9049. returnSuccess(ro_json);
  9050. }
  9051. catch (Exception ex)
  9052. {
  9053. var res_obj = new
  9054. {
  9055. data = ex.Message,
  9056. };
  9057. string ro_json = JsonConvert.SerializeObject(res_obj);
  9058. returnSuccess(ro_json);
  9059. }
  9060. }
  9061. }
  9062. public void get_user_info()
  9063. {
  9064. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9065. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9066. }
  9067. public void get_total_data()
  9068. {
  9069. int userId = CurrentUser.UserID;
  9070. string sql = "";
  9071. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9072. {
  9073. 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);
  9074. }
  9075. else
  9076. {
  9077. 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 " +
  9078. "(select ID from CE_ErpUser where ID = {0}) d " +
  9079. "left join " +
  9080. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9081. ") a on d.ID = a.id left join " +
  9082. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9083. ") b on a.id = b.id1 left join" +
  9084. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9085. ") c on a.id = c.id2;", userId);
  9086. }
  9087. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9088. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9089. }
  9090. public void get_date_area_total_data2()
  9091. {
  9092. int userId = CurrentUser.UserID;
  9093. string date_type = GetPostString("timetype");
  9094. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9095. string sql = "";
  9096. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9097. {
  9098. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9099. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9100. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9101. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9102. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9103. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9104. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9105. ") a on e.ID = a.id left join " +
  9106. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9107. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9108. ") b on a.id = b.id1 " +
  9109. "left join " +
  9110. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9111. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9112. ") c on a.id = c.id2 " +
  9113. "left join " +
  9114. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9115. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9116. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9117. }
  9118. else
  9119. {
  9120. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9121. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9122. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9123. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9124. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9125. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9126. ") a on e.ID = a.id left join " +
  9127. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9128. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9129. ") c on a.id = c.id2 " +
  9130. "left join " +
  9131. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9132. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9133. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9134. }
  9135. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9136. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9137. }
  9138. public void get_date_area_total_data()
  9139. {
  9140. int userId = CurrentUser.UserID;
  9141. string date_type = GetPostString("timetype");
  9142. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9143. string date1 = searchDT[0].ToString();
  9144. string date2 = searchDT[1].ToString();
  9145. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9146. {
  9147. SqlParameter[] sqlParameter ={
  9148. new SqlParameter("@userId", SqlDbType.Int,4),
  9149. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9150. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9151. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9152. };
  9153. sqlParameter[0].Value = userId;
  9154. sqlParameter[1].Value = date1;
  9155. sqlParameter[2].Value = date2;
  9156. sqlParameter[3].Direction = ParameterDirection.Output;
  9157. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9158. string res = sqlParameter[3].Value.ToString();
  9159. var res_obj = new
  9160. {
  9161. data = res
  9162. };
  9163. string ro_json = JsonConvert.SerializeObject(res_obj);
  9164. returnSuccess(ro_json);
  9165. }
  9166. else
  9167. {
  9168. SqlParameter[] sqlParameter ={
  9169. new SqlParameter("@userId", SqlDbType.Int,4),
  9170. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9171. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9172. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9173. };
  9174. sqlParameter[0].Value = userId;
  9175. sqlParameter[1].Value = date1;
  9176. sqlParameter[2].Value = date2;
  9177. sqlParameter[3].Direction = ParameterDirection.Output;
  9178. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9179. string res = sqlParameter[3].Value.ToString();
  9180. var res_obj = new
  9181. {
  9182. data = res
  9183. };
  9184. string ro_json = JsonConvert.SerializeObject(res_obj);
  9185. returnSuccess(ro_json);
  9186. }
  9187. //writeGridDataViewJson(dt.Rows.Count, dv);
  9188. }
  9189. public void get_order_list()
  9190. {
  9191. string strFields = GetPostString("paraFields");
  9192. string strOrder = GetPostString("paraOrder");
  9193. string strWhere = GetPostString("paraWhere");
  9194. string strPageSize = GetPostString("paraPageSize");
  9195. DataStruct dStruct = GetPostStruct();
  9196. dStruct.PageSize = int.Parse(strPageSize);
  9197. dStruct.Fileds = strFields;
  9198. dStruct.Order = strOrder;
  9199. dStruct.MainWhere = strWhere;
  9200. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9201. writeGridDataTableJson(dStruct.TotalCount, dt);
  9202. }
  9203. ////获取待开始订单列表
  9204. //public void get_wait_design_order_list()
  9205. //{
  9206. // string date_type = GetPostString("date_type");
  9207. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9208. // DataStruct dStruct = GetPostStruct();
  9209. // dStruct.PageSize = 1000;
  9210. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9211. // List<string> lw = new List<string>();
  9212. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9213. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9214. // dStruct.Order = "WaitDesignTime asc";
  9215. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9216. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9217. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9218. //}
  9219. //获取完成单量排名
  9220. public void get_finish_order_count_ranking()
  9221. {
  9222. /* string date_type = GetPostString("date_type");
  9223. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9224. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9225. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9226. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9227. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9228. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9229. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9230. writeGridDataTableJson(0, new DataTable());
  9231. }
  9232. public void get_finish_order_amount_ranking()
  9233. {
  9234. /*string date_type = GetPostString("date_type");
  9235. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9236. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9237. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9238. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9239. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9240. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9241. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9242. writeGridDataTableJson(0, new DataTable());
  9243. }
  9244. public void get_finish_refund_count_ranking()
  9245. {
  9246. string date_type = GetPostString("date_type");
  9247. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9248. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9249. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9250. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9251. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9252. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9253. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9254. writeGridDataTableJson(dt.Rows.Count, dt);
  9255. }
  9256. public void get_finish_refund_amount_ranking()
  9257. {
  9258. string date_type = GetPostString("date_type");
  9259. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9260. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9261. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9262. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9263. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9264. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9265. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9266. writeGridDataTableJson(dt.Rows.Count, dt);
  9267. }
  9268. public void set_erp_finishorder_director()
  9269. {
  9270. if (UrlPostParmsCheck("ctid"))
  9271. {
  9272. string eid = GetPostString("ctid");
  9273. CeErpTradeCell entity = null;
  9274. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9275. if (entity != null)
  9276. {
  9277. entity.OrderState = 8;
  9278. entity.Update();
  9279. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9280. returnSuccessMsg("操作成功!");
  9281. return;
  9282. }
  9283. returnErrorMsg("找不到记录");
  9284. }
  9285. }
  9286. public void get_erp_placeregistlist()
  9287. {
  9288. DataStruct dStruct = GetPostStruct();
  9289. List<string> lw = new List<string>();
  9290. string outsid = GetPostString("outsid");
  9291. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9292. string memo = GetPostString("memo");
  9293. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9294. string filename = GetPostString("filename");
  9295. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9296. string islate = GetPostString("islate");
  9297. if (islate.Length > 0)
  9298. {
  9299. if (islate == "1")
  9300. lw.Add(string.Format("OutLate>0"));
  9301. else
  9302. lw.Add(string.Format("OutLate=0"));
  9303. }
  9304. string placedate1 = GetPostString("placedate1");
  9305. string placedate2 = GetPostString("placedate2");
  9306. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9307. if (dw.Length > 0) lw.Add(dw);
  9308. string deliveryDate1 = GetPostString("deliverydate1");
  9309. string deliveryDate2 = GetPostString("deliverydate2");
  9310. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9311. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9312. dStruct.Order = "ID desc";
  9313. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9314. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9315. writeGridDataTableJson(dStruct.TotalCount, dt);
  9316. }
  9317. public void ins_erp_placeregist()
  9318. {
  9319. if (UrlPostParmsCheck("id"))
  9320. {
  9321. string eid = GetPostString("id");
  9322. CeErpPlaceRegister entity = null;
  9323. if (eid == "0")//新增
  9324. {
  9325. entity = new CeErpPlaceRegister();
  9326. string xdTime = GetPostString("placeTime");
  9327. if (xdTime.Length > 0)
  9328. {
  9329. entity.PlactTime = Convert.ToDateTime(xdTime);
  9330. }
  9331. string fhTime = GetPostString("deliveryTime");
  9332. if (fhTime.Length > 0)
  9333. {
  9334. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9335. }
  9336. string preTime = GetPostString("preOutTime");
  9337. if (preTime.Length > 0)
  9338. {
  9339. entity.PreOutTime = Convert.ToDateTime(preTime);
  9340. }
  9341. entity.DeliveryCount = GetPostInt("deliveryCount");
  9342. entity.ReceiveCount = GetPostInt("receiveCount");
  9343. entity.OutSid = GetPostString("outSid");
  9344. entity.FileName = GetPostString("fileName");
  9345. entity.Memo = GetPostString("memo");
  9346. entity.AddUserId = CurrentUser.UserID;
  9347. entity.CreateTime = DateTime.Now;
  9348. entity.Img = GetPostString("img");
  9349. entity.Supplier = GetPostInt("supplier");
  9350. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9351. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9352. {
  9353. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9354. DateTime dt2 = (DateTime)entity.PreOutTime;
  9355. TimeSpan span = dt1.Subtract(dt2);
  9356. if (span.Days > 0)
  9357. {
  9358. entity.OutLate = span.Days;
  9359. }
  9360. }
  9361. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9362. entity.Create();
  9363. returnSuccessMsg("添加成功!");
  9364. return;
  9365. }
  9366. else //修改
  9367. {
  9368. entity = CeErpPlaceRegister.Get(eid);
  9369. if (entity != null)
  9370. {
  9371. string xdTime = GetPostString("placeTime");
  9372. if (xdTime.Length > 0)
  9373. {
  9374. entity.PlactTime = Convert.ToDateTime(xdTime);
  9375. }
  9376. string fhTime = GetPostString("deliveryTime");
  9377. if (fhTime.Length > 0)
  9378. {
  9379. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9380. }
  9381. string preTime = GetPostString("preOutTime");
  9382. if (preTime.Length > 0)
  9383. {
  9384. entity.PreOutTime = Convert.ToDateTime(preTime);
  9385. }
  9386. entity.DeliveryCount = GetPostInt("deliveryCount");
  9387. entity.ReceiveCount = GetPostInt("receiveCount");
  9388. if (entity.DeliveryCount == entity.ReceiveCount)
  9389. {
  9390. entity.CurState = "已完成";
  9391. }
  9392. else
  9393. {
  9394. entity.CurState = "未完成";
  9395. }
  9396. entity.OutSid = GetPostString("outSid");
  9397. entity.FileName = GetPostString("fileName");
  9398. entity.Memo = GetPostString("memo");
  9399. entity.Img = GetPostString("img");
  9400. entity.Supplier = GetPostInt("supplier");
  9401. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9402. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9403. {
  9404. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9405. DateTime dt2 = (DateTime)entity.PreOutTime;
  9406. TimeSpan span = dt1.Subtract(dt2);
  9407. if (span.Days > 0)
  9408. {
  9409. entity.OutLate = span.Days;
  9410. }
  9411. }
  9412. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9413. entity.Update();
  9414. returnSuccessMsg("修改成功");
  9415. return;
  9416. }
  9417. returnErrorMsg("找不到对应的记录");
  9418. return;
  9419. }
  9420. }
  9421. returnErrorMsg("缺少必要参数");
  9422. }
  9423. public void del_erp_placeregist()
  9424. {
  9425. string eid = GetPostString("id");
  9426. CeErpPlaceRegister.Del(eid);
  9427. returnSuccessMsg("删除成功!");
  9428. return;
  9429. }
  9430. public void ins_erp_placeregistbyorder()
  9431. {
  9432. string ctid = GetPostString("ctid");
  9433. if (ctid.Length > 0)
  9434. {
  9435. StringBuilder sql = new StringBuilder();
  9436. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9437. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9438. if (dt.Rows.Count > 0)
  9439. {
  9440. foreach (DataRow dr in dt.Rows)
  9441. {
  9442. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9443. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9444. entity.AddUserId = CurrentUser.UserID;
  9445. entity.tid = dr["tid"].ToString();
  9446. entity.Did = Convert.ToString(dr["ctid"]);
  9447. entity.splitTag = dr["SplitTag"].ToString();
  9448. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9449. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9450. if (pre_ctid.Length > 0)
  9451. {
  9452. sellmemo = sellmemo.Replace(pre_ctid, "");
  9453. }
  9454. sellmemo = sellmemo.Replace("[", "");
  9455. sellmemo = sellmemo.Replace("]", "");
  9456. entity.FileName = sellmemo;
  9457. string count = dr["ProductCount"].ToString();
  9458. int usecount = commonHelper.getIntCountFromString(count);
  9459. entity.DeliveryCount = usecount;
  9460. entity.CurState = "未完成";
  9461. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9462. {
  9463. entity.Supplier = 24;//dl手提袋定制
  9464. }
  9465. else
  9466. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9467. entity.CreateTime = DateTime.Now;
  9468. entity.Create();
  9469. }
  9470. returnSuccessMsg("操作成功");
  9471. return;
  9472. }
  9473. returnErrorMsg("没有找到对应订单");
  9474. return;
  9475. }
  9476. returnErrorMsg("缺少订单编号");
  9477. return;
  9478. }
  9479. public void get_erp_persuadelist()
  9480. {
  9481. DataStruct dStruct = GetPostStruct();
  9482. List<string> lw = new List<string>();
  9483. string ctid = GetPostString("ctid");
  9484. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9485. string shopname = GetPostString("shopname");
  9486. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9487. string buyernick = GetPostString("buyer_nick");
  9488. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9489. string customer = GetPostString("customer");
  9490. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9491. string returndate1 = GetPostString("returndate1");
  9492. string returndate2 = GetPostString("returndate2");
  9493. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9494. if (dw.Length > 0) lw.Add(dw);
  9495. string finishDate1 = GetPostString("finishdate1");
  9496. string finishDate2 = GetPostString("finishdate2");
  9497. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9498. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9499. string persuadetype = GetPostString("persuadetype");
  9500. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9501. string returnvstate = GetPostString("returnvstate");
  9502. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9503. dStruct.Order = "created desc";
  9504. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9505. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9506. writeGridDataTableJson(dStruct.TotalCount, dt);
  9507. }
  9508. public void upd_erp_returnpersuadeback()
  9509. {
  9510. if (UrlPostParmsCheck("ID"))
  9511. {
  9512. int eid = GetPostInt("ID");
  9513. CeErpPersuade entity = null;
  9514. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9515. if (entity != null)
  9516. {
  9517. entity.backreason = GetPostString("reason");
  9518. entity.pstate = 2;
  9519. entity.verifytime = DateTime.Now;
  9520. entity.verifyuserid = CurrentUser.UserID;
  9521. entity.Update();
  9522. returnSuccessMsg("退回成功!");
  9523. return;
  9524. }
  9525. returnErrorMsg("找不到订单记录");
  9526. }
  9527. }
  9528. public void upd_erp_returnpersuadeverify()
  9529. {
  9530. if (UrlPostParmsCheck("ID"))
  9531. {
  9532. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9533. {
  9534. returnErrorMsg("暂无权限审核");
  9535. return;
  9536. }
  9537. int eid = GetPostInt("ID");
  9538. CeErpPersuade entity = null;
  9539. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9540. if (entity != null)
  9541. {
  9542. entity.pstate = 1;
  9543. entity.verifytime = DateTime.Now;
  9544. entity.verifyuserid = CurrentUser.UserID;
  9545. entity.Update();
  9546. returnSuccessMsg("审核成功!");
  9547. return;
  9548. }
  9549. returnErrorMsg("找不到订单记录");
  9550. }
  9551. }
  9552. public void del_erp_persuade()
  9553. {
  9554. if (UrlPostParmsCheck("ID"))
  9555. {
  9556. int eid = GetPostInt("ID");
  9557. CeErpPersuade.Del(eid);
  9558. returnSuccessMsg("操作成功");
  9559. return;
  9560. }
  9561. }
  9562. public void get_erp_oldcustoupload()
  9563. {
  9564. DataStruct dStruct = GetPostStruct();
  9565. List<string> lw = new List<string>();
  9566. string buyernick = GetPostString("buyer_nick");
  9567. if (buyernick.Length > 0)
  9568. {
  9569. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9570. }
  9571. else
  9572. return;
  9573. dStruct.Order = "pay_time desc";
  9574. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9575. DataTable dt = null;
  9576. dt = WebCache.GetData("view_erptradecell", dStruct);
  9577. writeGridDataTableJson(dStruct.TotalCount, dt);
  9578. }
  9579. public void get_erp_checkorderlist()
  9580. {
  9581. DataStruct dStruct = GetPostStruct();
  9582. List<string> lw = new List<string>();
  9583. string tid = GetPostString("ctid");
  9584. if (tid.Length > 0)
  9585. {
  9586. string select_tid = getTidByCtid(tid);
  9587. lw.Add(string.Format("tid='{0}'", select_tid));
  9588. }
  9589. string shopname = GetPostString("shopname");
  9590. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9591. string buyernick = GetPostString("buyer_nick");
  9592. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9593. string customer = GetPostString("customer");
  9594. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9595. string design = GetPostString("design");
  9596. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9597. string orderState = GetPostString("orderState");
  9598. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9599. string address = GetPostString("address");
  9600. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9601. string sellermemo = GetPostString("seller_memo");
  9602. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9603. string supplier = GetPostString("supplier");
  9604. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9605. {
  9606. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9607. }
  9608. else
  9609. {
  9610. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9611. }
  9612. string date1 = GetPostString("date1");
  9613. string date2 = GetPostString("date2");
  9614. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9615. if (dw.Length > 0) lw.Add(dw);
  9616. string placedate1 = GetPostString("placedate1");
  9617. string placedate2 = GetPostString("placedate2");
  9618. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9619. if (fdw.Length > 0) lw.Add(fdw);
  9620. string price1 = GetPostString("price1");
  9621. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9622. string price2 = GetPostString("price2");
  9623. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9624. string checkst = GetPostString("checkstate");
  9625. if (checkst.Length > 0 && "10".Equals(checkst))
  9626. {
  9627. lw.Add(string.Format("CheckOut>0"));
  9628. }
  9629. else
  9630. {
  9631. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9632. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9633. }
  9634. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9635. {
  9636. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9637. }
  9638. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9639. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9640. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9641. writeGridDataTableJson(dStruct.TotalCount, dt);
  9642. }
  9643. public void ins_erp_startCheck()
  9644. {
  9645. if (UrlPostParmsCheck("ctid"))
  9646. {
  9647. string eid = GetPostString("ctid");
  9648. CeErpTradeCell entity = null;
  9649. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9650. if (entity != null)
  9651. {
  9652. entity.MemoOpt = 4;
  9653. entity.UpdateTime = DateTime.Now;
  9654. entity.Update();
  9655. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9656. CeErpSukuraData.createInfo(entity.ctid, 6);
  9657. returnSuccessMsg("操作成功!");
  9658. return;
  9659. }
  9660. returnErrorMsg("找不到记录");
  9661. }
  9662. }
  9663. public void upd_erp_sendXlw()
  9664. {
  9665. if (UrlPostParmsCheck("ctid"))
  9666. {
  9667. string eid = GetPostString("ctid");
  9668. CeErpTradeCell entity = null;
  9669. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9670. if (entity != null)
  9671. {
  9672. if (entity.IsSendGift == 1)
  9673. {
  9674. returnErrorMsg("请勿重复标记");
  9675. return;
  9676. }
  9677. entity.IsSendGift = 1;
  9678. entity.Update();
  9679. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9680. returnSuccessMsg("操作成功!");
  9681. return;
  9682. }
  9683. returnErrorMsg("找不到记录");
  9684. }
  9685. }
  9686. public void cancel_sendXlw()
  9687. {
  9688. if (UrlPostParmsCheck("ctid"))
  9689. {
  9690. string eid = GetPostString("ctid");
  9691. CeErpTradeCell entity = null;
  9692. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9693. if (entity != null)
  9694. {
  9695. if (entity.IsSendGift == 0)
  9696. {
  9697. returnErrorMsg("未标记小礼物");
  9698. return;
  9699. }
  9700. entity.IsSendGift = 0;
  9701. entity.Update();
  9702. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9703. returnSuccessMsg("操作成功!");
  9704. return;
  9705. }
  9706. returnErrorMsg("找不到记录");
  9707. }
  9708. }
  9709. public void get_erp_designbill()
  9710. {
  9711. DataStruct dStruct = GetPostStruct();
  9712. List<string> lw = new List<string>();
  9713. int isMy = GetInt("my");
  9714. if (isMy == 1)
  9715. {
  9716. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9717. }
  9718. string tid = GetPostString("tid");
  9719. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9720. string userName = GetPostString("design");
  9721. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9722. string price1 = GetPostString("price1");
  9723. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9724. string price2 = GetPostString("price2");
  9725. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9726. string rePrice1 = GetPostString("rePrice1");
  9727. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9728. string rePrice2 = GetPostString("rePrice2");
  9729. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9730. string designerType = GetPostString("designerType");
  9731. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9732. string orderState = GetPostString("orderState");
  9733. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9734. string endTime1 = GetPostString("endTime1");
  9735. string endTime2 = GetPostString("endTime2");
  9736. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9737. if (dw.Length > 0) lw.Add(dw);
  9738. string isDk = GetPostString("isDk");
  9739. if (isDk == "1")
  9740. {
  9741. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9742. }
  9743. else if (isDk == "0")
  9744. {
  9745. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9746. }
  9747. dStruct.Order = "oid, create_time desc";
  9748. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9749. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9750. writeGridDataTableJson(dStruct.TotalCount, dt);
  9751. }
  9752. public void upd_erp_designerbill()
  9753. {
  9754. if (UrlPostParmsCheck("ID"))
  9755. {
  9756. string eid = GetPostString("ID");
  9757. CeErpDesignerBill entity = null;
  9758. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9759. if (entity != null)
  9760. {
  9761. if (GetPostDouble("designerpirce") > 0)
  9762. {
  9763. entity.realPrice = GetPostDouble("designerpirce");
  9764. entity.update_time = DateTime.Now;
  9765. entity.update_u_id = CurrentUser.UserID;
  9766. entity.update_u_name = CurrentUser.UserName;
  9767. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9768. entity.Update();
  9769. returnSuccessMsg("操作成功!");
  9770. return;
  9771. }
  9772. else
  9773. {
  9774. entity.price = GetPostDouble("price");
  9775. entity.update_time = DateTime.Now;
  9776. entity.update_u_id = CurrentUser.UserID;
  9777. entity.update_u_name = CurrentUser.UserName;
  9778. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9779. entity.Update();
  9780. returnSuccessMsg("操作成功!");
  9781. return;
  9782. }
  9783. }
  9784. returnErrorMsg("找不到记录");
  9785. }
  9786. }
  9787. public void audit_erp_designerbill()
  9788. {
  9789. if (UrlPostParmsCheck("ID"))
  9790. {
  9791. string eid = GetPostString("ID");
  9792. CeErpDesignerBill entity = null;
  9793. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9794. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9795. if (entity != null)
  9796. {
  9797. entity.realPrice = GetPostDouble("designerpirce");
  9798. entity.update_time = DateTime.Now;
  9799. entity.update_u_id = CurrentUser.UserID;
  9800. entity.update_u_name = CurrentUser.UserName;
  9801. entity.isAudit = 1;
  9802. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9803. entity.Update();
  9804. if (orderEntity != null)
  9805. {
  9806. orderEntity.IsReadTag = 3;
  9807. orderEntity.Update();
  9808. }
  9809. returnSuccessMsg("操作成功!");
  9810. return;
  9811. }
  9812. returnErrorMsg("找不到记录");
  9813. }
  9814. }
  9815. public void all_audit_erp_designerbill()
  9816. {
  9817. if (UrlPostParmsCheck("idList"))
  9818. {
  9819. string[] list = GetPostString("idList").Split(',');
  9820. CeErpDesignerBill entity = null;
  9821. for (int i = 0; i < list.Length; i++)
  9822. {
  9823. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9824. if (entity == null) return;
  9825. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9826. if (orderEntity == null) return;
  9827. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9828. entity.update_time = DateTime.Now;
  9829. entity.update_u_id = CurrentUser.UserID;
  9830. entity.update_u_name = CurrentUser.UserName;
  9831. entity.isAudit = 1;
  9832. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9833. entity.Update();
  9834. orderEntity.IsReadTag = 3;
  9835. orderEntity.Update();
  9836. }
  9837. returnSuccessMsg("操作成功!");
  9838. return;
  9839. }
  9840. }
  9841. public void get_erp_sameorders()
  9842. {
  9843. if (UrlPostParmsCheck("ctid"))
  9844. {
  9845. string eid = GetPostString("ctid");
  9846. CeErpTradeCell entity = null;
  9847. entity = CeErpTradeCell.GetByCtid(eid);
  9848. if (entity != null)
  9849. {
  9850. StringBuilder sql = new StringBuilder();
  9851. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9852. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9853. var res = new
  9854. {
  9855. data = dt.Rows.Count
  9856. };
  9857. string ro_jsond = JsonConvert.SerializeObject(res);
  9858. returnSuccess(ro_jsond);
  9859. return;
  9860. }
  9861. returnErrorMsg("未找到订单");
  9862. return;
  9863. }
  9864. returnErrorMsg("缺少必要的参数");
  9865. }
  9866. public void get_erp_islasthavesameorder()
  9867. {
  9868. if (UrlPostParmsCheck("ctid"))
  9869. {
  9870. string eid = GetPostString("ctid");
  9871. string[] ctidList = eid.Split(',');
  9872. StringBuilder sql = new StringBuilder();
  9873. string tisCtid = "";
  9874. foreach (string ctid in ctidList)
  9875. {
  9876. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9877. if (entity != null)
  9878. {
  9879. sql = new StringBuilder();
  9880. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9881. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9882. if (dth.Rows.Count > 0)
  9883. {
  9884. tisCtid += entity.ctid;
  9885. tisCtid += ",";
  9886. }
  9887. }
  9888. }
  9889. if (tisCtid.Length > 0)
  9890. {
  9891. var res = new
  9892. {
  9893. data = tisCtid
  9894. };
  9895. string ro_jsond = JsonConvert.SerializeObject(res);
  9896. returnSuccess(ro_jsond);
  9897. }
  9898. else
  9899. {
  9900. var res = new
  9901. {
  9902. data = ""
  9903. };
  9904. string ro_jsond = JsonConvert.SerializeObject(res);
  9905. returnSuccess(ro_jsond);
  9906. }
  9907. return;
  9908. }
  9909. returnErrorMsg("缺少必要的参数");
  9910. }
  9911. public void file_client_down_url()
  9912. {
  9913. if (!UrlPostParmsCheck("userId"))
  9914. {
  9915. returnErrorMsg("缺少必要的参数");
  9916. }
  9917. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9918. }
  9919. public void checkout_form_data()
  9920. {
  9921. if (!UrlPostParmsCheck("tid"))
  9922. {
  9923. returnErrorMsg("缺少必要的参数");
  9924. }
  9925. string tid = GetPostString("tid");
  9926. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9927. if (ceErpOrderFormData != null)
  9928. {
  9929. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9930. returnSuccess(ro_jsond);
  9931. return;
  9932. }
  9933. returnErrorMsg("尚未有文件!");
  9934. }
  9935. public void back_supplier_audit()
  9936. {
  9937. int userId = CurrentUser.UserID;
  9938. StringBuilder sql = new StringBuilder();
  9939. 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);
  9940. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9941. if (dt.Rows.Count > 0)
  9942. {
  9943. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9944. }
  9945. else
  9946. {
  9947. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9948. }
  9949. }
  9950. public void back_supplier_query()
  9951. {
  9952. string eid = GetPostString("ctid");
  9953. if (eid != "")
  9954. {
  9955. StringBuilder sql = new StringBuilder();
  9956. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9957. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9958. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9959. }
  9960. else
  9961. {
  9962. returnErrorMsg("找不到订单记录");
  9963. return;
  9964. }
  9965. }
  9966. public void verified_to_order()
  9967. {
  9968. int userId = CurrentUser.UserID;
  9969. StringBuilder sql = new StringBuilder();
  9970. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9971. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9972. if (dt.Rows.Count > 0)
  9973. {
  9974. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9975. }
  9976. else
  9977. {
  9978. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9979. }
  9980. }
  9981. public void upd_supplier_audit()
  9982. {
  9983. if (UrlPostParmsCheck("ctid"))
  9984. {
  9985. string eid = GetPostString("ctid");
  9986. string reason = GetPostString("returnreason");
  9987. CeErpTradeCell entity = null;
  9988. CeWithdraw withdraw = null;
  9989. withdraw = CeWithdraw.GetByTid(eid);
  9990. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9991. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9992. {
  9993. if (withdraw != null)
  9994. {
  9995. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9996. {
  9997. returnSuccessMsg("您没有权限操作!");
  9998. return;
  9999. }
  10000. else
  10001. {
  10002. if (reason.Equals("1"))
  10003. {
  10004. if (entity.OrderState == -1)
  10005. {
  10006. if (entity.FinishPlaceTime == null)
  10007. {
  10008. entity.OrderState = 2;
  10009. }
  10010. else
  10011. {
  10012. entity.OrderState = 6;
  10013. }
  10014. }
  10015. entity.Update();
  10016. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10017. if (withdraw != null)
  10018. {
  10019. withdraw.status = int.Parse(reason);
  10020. withdraw.Update();
  10021. }
  10022. returnSuccessMsg("操作成功!");
  10023. return;
  10024. }
  10025. else
  10026. {
  10027. withdraw.status = int.Parse(reason);
  10028. withdraw.acknowledgingtime = DateTime.Now;
  10029. withdraw.Update();
  10030. returnSuccessMsg("查看详细请点击线下订单查询");
  10031. return;
  10032. }
  10033. }
  10034. }
  10035. // 第一个字符是 'N'
  10036. }
  10037. if (eid[0] != 'N')
  10038. {
  10039. }
  10040. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10041. {
  10042. entity.IsVerifyToSupplier = false;
  10043. entity.IsReturn = 1;
  10044. entity.ReturnTime = DateTime.Now;
  10045. entity.ReturnReason = reason;
  10046. if (entity.OrderState == 6)
  10047. {
  10048. entity.OrderState = 5;
  10049. }
  10050. entity.Update();
  10051. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10052. if (withdraw != null)
  10053. {
  10054. withdraw.status = int.Parse(reason);
  10055. withdraw.Update();
  10056. }
  10057. returnSuccessMsg("操作成功!");
  10058. return;
  10059. }
  10060. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10061. {
  10062. ;
  10063. if (withdraw != null)
  10064. {
  10065. withdraw.status = int.Parse(reason);
  10066. withdraw.acknowledgingtime = DateTime.Now;
  10067. withdraw.Update();
  10068. returnSuccessMsg("供应商取消撤回!");
  10069. return;
  10070. }
  10071. }
  10072. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10073. {
  10074. if (entity.OrderState == -1)
  10075. {
  10076. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10077. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10078. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10079. {
  10080. returnErrorMsg("台湾客户需填写身份证!");
  10081. return;
  10082. }
  10083. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10084. {
  10085. returnErrorMsg("偏远地区需要填写物流费!");
  10086. return;
  10087. }
  10088. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10089. {
  10090. returnErrorMsg("订单spu没有确认无法通过审核!");
  10091. return;
  10092. }
  10093. if (entity.FinishPlaceTime == null)
  10094. {
  10095. entity.OrderState = 2;
  10096. }
  10097. else
  10098. {
  10099. entity.OrderState = 3;
  10100. }
  10101. commonHelper.getCytPrice(entity);
  10102. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10103. {
  10104. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10105. }
  10106. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10107. {
  10108. entity.OrderState = 6;
  10109. }
  10110. }
  10111. entity.Update();
  10112. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10113. if (withdraw != null)
  10114. {
  10115. withdraw.status = int.Parse(reason);
  10116. withdraw.Update();
  10117. }
  10118. returnSuccessMsg("操作成功!");
  10119. return;
  10120. }
  10121. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10122. {
  10123. if (withdraw == null)
  10124. {
  10125. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10126. return;
  10127. }
  10128. }
  10129. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10130. {
  10131. if (withdraw != null)
  10132. {
  10133. withdraw.status = int.Parse(reason);
  10134. withdraw.acknowledgingtime = DateTime.Now;
  10135. withdraw.Update();
  10136. returnSuccessMsg("查看详细请点击线下订单查询");
  10137. return;
  10138. }
  10139. }
  10140. return;
  10141. }
  10142. }
  10143. //校验报价
  10144. public void refund_order_tip()
  10145. {
  10146. int userid = CurrentUser.UserID;
  10147. int sectionId = CurrentUser.UserPost.OrgID;
  10148. StringBuilder sql = new StringBuilder();
  10149. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10150. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10151. List<string> ids = new List<string>();
  10152. if (dth.Rows.Count > 0)
  10153. {
  10154. foreach (DataRow dr in dth.Rows)
  10155. {
  10156. ids.Add(dr["ID"].ToString());
  10157. }
  10158. try
  10159. {
  10160. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10161. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10162. }
  10163. catch (Exception ex)
  10164. {
  10165. }
  10166. }
  10167. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10168. }
  10169. public void refund_order_Design()
  10170. {
  10171. int userid = CurrentUser.UserID;
  10172. int sectionId = CurrentUser.UserPost.OrgID;
  10173. StringBuilder sql = new StringBuilder();
  10174. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10175. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10176. List<string> ids = new List<string>();
  10177. if (dth.Rows.Count > 0)
  10178. {
  10179. foreach (DataRow dr in dth.Rows)
  10180. {
  10181. ids.Add(dr["ID"].ToString());
  10182. }
  10183. try
  10184. {
  10185. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10186. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10187. }
  10188. catch (Exception ex)
  10189. {
  10190. }
  10191. }
  10192. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10193. }
  10194. public void change_order_info()
  10195. {
  10196. int userid = CurrentUser.UserID;
  10197. StringBuilder sql = new StringBuilder();
  10198. 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);
  10199. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10200. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10201. }
  10202. public void change_win_mome()
  10203. {
  10204. if (UrlPostParmsCheck("id,ctid"))
  10205. {
  10206. string id = GetPostString("id");
  10207. string ctid = GetPostString("ctid");
  10208. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10209. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10210. if (ce == null || ceErpMessageTip == null)
  10211. {
  10212. returnSuccessMsg("未找到对应的订单!");
  10213. return;
  10214. }
  10215. if (ce.OrderState >= 5)
  10216. {
  10217. ceErpMessageTip.isVisit = true;
  10218. ceErpMessageTip.Update();
  10219. returnSuccessMsg("已上传文件无法修改!");
  10220. return;
  10221. }
  10222. int type = GetPostInt("type");
  10223. string content = GetPostString("content");
  10224. if (type == 0)
  10225. {
  10226. content = content.Replace("(", "(");
  10227. content = content.Replace(")", ")");
  10228. string check = MidStrEx(content, "(", ")").Trim();
  10229. if (string.IsNullOrEmpty(check))
  10230. {
  10231. returnSuccessMsg("文件名格式不正确");
  10232. return;
  10233. }
  10234. }
  10235. ce.seller_memo = content;
  10236. ce.Update();
  10237. ceErpMessageTip.isVisit = true;
  10238. ceErpMessageTip.Update();
  10239. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10240. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10241. ApiVo apiVo = new ApiVo();
  10242. apiVo.orderNumber = ce.ctid;
  10243. apiVo.actionName = "demandDesign";
  10244. apiVo.orderRemarks = content;
  10245. apiVo.demandExamine = type + 1;
  10246. designHelper.API_WorkCore(apiVo);//demandDesign
  10247. returnSuccessMsg("修改成功!");
  10248. }
  10249. }
  10250. public static string MidStrEx(string sourse, string startstr, string endstr)
  10251. {
  10252. string result = string.Empty;
  10253. int startindex, endindex;
  10254. try
  10255. {
  10256. startindex = sourse.IndexOf(startstr);
  10257. if (startindex == -1)
  10258. return result;
  10259. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10260. endindex = tmpstr.IndexOf(endstr);
  10261. if (endindex == -1)
  10262. return result;
  10263. result = tmpstr.Remove(endindex);
  10264. }
  10265. catch (Exception ex)
  10266. {
  10267. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10268. }
  10269. return result;
  10270. }
  10271. public void refund_order_list()
  10272. {
  10273. int userid = CurrentUser.UserID;
  10274. int sectionId = CurrentUser.UserPost.OrgID;
  10275. StringBuilder sql = new StringBuilder();
  10276. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10277. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10278. DataStruct dStruct = GetPostStruct();
  10279. DataTable dt = null;
  10280. List<string> ids = new List<string>();
  10281. List<string> tids = new List<string>();
  10282. if (dth.Rows.Count > 0)
  10283. {
  10284. foreach (DataRow dr in dth.Rows)
  10285. {
  10286. tids.Add("'" + dr["tid"].ToString() + "'");
  10287. ids.Add(dr["id"].ToString());
  10288. }
  10289. try
  10290. {
  10291. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10292. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10293. List<string> lw = new List<string>();
  10294. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10295. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10296. dt = WebCache.GetData("view_orderlist", dStruct);
  10297. }
  10298. catch (Exception ex)
  10299. {
  10300. }
  10301. }
  10302. writeGridDataTableJson(dStruct.TotalCount, dt);
  10303. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10304. }
  10305. //新增
  10306. public void order_batch_downloads()
  10307. {
  10308. string ceid = GetPostString("tid");
  10309. String[] tid = ceid.Split(',');
  10310. order_batch_caiyingtong(tid);
  10311. /* (string success, string errors) = UploadFiles(tid);
  10312. returnSuccessMsg(success + errors);*/
  10313. return;
  10314. }
  10315. //报价接口
  10316. public void Get_To_Quote()
  10317. {
  10318. string ceid = GetPostString("ctid");
  10319. if (ceid != null)
  10320. {
  10321. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10322. if (entity != null)
  10323. {
  10324. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10325. {
  10326. return;
  10327. }
  10328. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10329. double price = 0;
  10330. if (cp == null)
  10331. {
  10332. JObject jsonObject12 = new JObject
  10333. {
  10334. { "UserId", "77886" },
  10335. { "Pwd", "lt666888" },
  10336. { "Filename", entity.seller_memo }
  10337. };
  10338. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10339. JObject jsonObjects1 = JObject.Parse(response1);
  10340. string ms1g = (string)jsonObjects1["msg"];
  10341. if (ms1g == "报价成功")
  10342. {
  10343. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10344. string data = (string)jsonObject1["price"];
  10345. 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 + "');";
  10346. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10347. returnSuccessMsg("获取报价成功:" + data);
  10348. price = Convert.ToDouble(data);
  10349. }
  10350. else
  10351. {
  10352. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10353. return;
  10354. }
  10355. }
  10356. String[] beizhu = entity.seller_memo.Split('-');
  10357. String chanp = "";
  10358. if (beizhu.Length > 0)
  10359. {
  10360. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10361. }
  10362. else
  10363. {
  10364. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10365. }
  10366. JObject jsonObject = new JObject
  10367. {
  10368. { "UserId", "77886" },
  10369. { "Pwd", "lt666888" },
  10370. { "Filename", chanp }
  10371. };
  10372. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10373. JObject jsonObjects = JObject.Parse(response);
  10374. string msg = (string)jsonObjects["msg"];
  10375. if (msg == "报价成功")
  10376. {
  10377. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10378. string data = (string)jsonObject1["price"];
  10379. 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 + "');";
  10380. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10381. returnSuccessMsg("获取报价成功:" + data);
  10382. price = Convert.ToDouble(data);
  10383. }
  10384. else
  10385. {
  10386. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10387. return;
  10388. }
  10389. if (price > 0)
  10390. {
  10391. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10392. if (ceErpTradeCellExtend == null)
  10393. {
  10394. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10395. ceErpTradeCellExtend.ctid = entity.ctid;
  10396. ceErpTradeCellExtend.payment_cyt = price;
  10397. ceErpTradeCellExtend.Create();
  10398. }
  10399. else
  10400. {
  10401. ceErpTradeCellExtend.payment_cyt = price;
  10402. ceErpTradeCellExtend.Update();
  10403. }
  10404. }
  10405. return;
  10406. }
  10407. }
  10408. else
  10409. {
  10410. returnErrorMsg("请至少选择一条数据");
  10411. return;
  10412. }
  10413. }
  10414. //新增
  10415. public void order_To_Supplier()
  10416. {
  10417. string ceid = GetPostString("tid");
  10418. String[] tid = ceid.Split(',');
  10419. if (tid.Length > 0)
  10420. {
  10421. try
  10422. {
  10423. for (int i = 0; i < tid.Length; i++)
  10424. {
  10425. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10426. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10427. entity.SupplierId = suid;
  10428. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10429. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10430. entity.Update();
  10431. }
  10432. }
  10433. catch (Exception ex)
  10434. {
  10435. returnErrorMsg("自动匹配供应商失败");
  10436. return;
  10437. }
  10438. }
  10439. else
  10440. {
  10441. returnErrorMsg("请至少选择一条数据");
  10442. return;
  10443. }
  10444. returnSuccessMsg("自动匹配供应商成功");
  10445. return;
  10446. }
  10447. public (string, string) UploadFiles(string[] urls)
  10448. {
  10449. string success = "";
  10450. string errors = "";
  10451. int userid = CurrentUser.UserID;
  10452. foreach (string url in urls)
  10453. {
  10454. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10455. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10456. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10457. {
  10458. JObject jsonObject = new JObject
  10459. {
  10460. { "Userid", "77886" },
  10461. { "pwd", "cyt86435015" },
  10462. { "content", base64FileContent },
  10463. { "ext", Path.GetExtension(fileName) }
  10464. };
  10465. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10466. JObject jsonObjects = JObject.Parse(response);
  10467. string msg = (string)jsonObjects["msg"];
  10468. if (msg.Equals("上传成功"))
  10469. {
  10470. success += url + " 上传成功";
  10471. }
  10472. else
  10473. {
  10474. errors += url + " 上传失败";
  10475. }
  10476. }
  10477. else
  10478. {
  10479. errors += url + " 格式出现问题";
  10480. }
  10481. }
  10482. if (urls.Length == 0)
  10483. {
  10484. return (success, errors);
  10485. }
  10486. return (success, errors);
  10487. }
  10488. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10489. {
  10490. return true; //总是接受
  10491. }
  10492. public static string HttpPost(string url, string param = null)
  10493. {
  10494. HttpWebRequest request;
  10495. //如果是发送HTTPS请求
  10496. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10497. {
  10498. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10499. request = WebRequest.Create(url) as HttpWebRequest;
  10500. request.ProtocolVersion = HttpVersion.Version10;
  10501. }
  10502. else
  10503. {
  10504. request = WebRequest.Create(url) as HttpWebRequest;
  10505. }
  10506. request.Method = "POST";
  10507. request.ContentType = "application/json";
  10508. request.Accept = "*/*";
  10509. request.Timeout = 120000;
  10510. request.AllowAutoRedirect = false;
  10511. StreamWriter requestStream = null;
  10512. WebResponse response = null;
  10513. string responseStr = null;
  10514. try
  10515. {
  10516. requestStream = new StreamWriter(request.GetRequestStream());
  10517. requestStream.Write(param);
  10518. requestStream.Close();
  10519. response = request.GetResponse();
  10520. if (response != null)
  10521. {
  10522. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10523. responseStr = reader.ReadToEnd();
  10524. reader.Close();
  10525. }
  10526. }
  10527. catch (Exception ex)
  10528. {
  10529. return ex.Message;
  10530. }
  10531. finally
  10532. {
  10533. request = null;
  10534. requestStream = null;
  10535. response = null;
  10536. }
  10537. return responseStr;
  10538. }
  10539. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10540. {
  10541. string base64FileContent;
  10542. string fileName;
  10543. using (WebClient webClient = new WebClient())
  10544. {
  10545. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10546. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10547. {
  10548. using (Stream stream = response.GetResponseStream())
  10549. {
  10550. using (MemoryStream memoryStream = new MemoryStream())
  10551. {
  10552. stream.CopyTo(memoryStream);
  10553. byte[] fileBytes = memoryStream.ToArray();
  10554. base64FileContent = Convert.ToBase64String(fileBytes);
  10555. fileName = response.Headers["Content-Disposition"];
  10556. if (!string.IsNullOrEmpty(fileName))
  10557. {
  10558. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10559. if (index >= 0)
  10560. {
  10561. fileName = fileName.Substring(index + 9).Trim('\"');
  10562. }
  10563. }
  10564. else
  10565. {
  10566. fileName = Path.GetFileName(downloadUrl);
  10567. }
  10568. }
  10569. }
  10570. }
  10571. }
  10572. return (fileName, base64FileContent);
  10573. }
  10574. //新增
  10575. public void order_batch_caiyingtong(string[] downloadUrls)
  10576. {
  10577. try
  10578. {
  10579. //遍历文件
  10580. DataStruct dStruct = GetPostStruct();
  10581. DataTable dt = null;
  10582. int userid = CurrentUser.UserID;
  10583. List<string> ids = new List<string>();//失败组
  10584. List<string> tids = new List<string>();
  10585. using (WebClient webClient = new WebClient())
  10586. {
  10587. foreach (var url in downloadUrls)
  10588. {
  10589. try
  10590. {
  10591. tids.Add("'" + url + "'");
  10592. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10593. if (entity != null)
  10594. {
  10595. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10596. if (cp == null)
  10597. {
  10598. JObject jsonObject = new JObject
  10599. {
  10600. { "Userid", "77886" },
  10601. { "pwd", "lt666888" },
  10602. { "Filename",entity.seller_memo }
  10603. };
  10604. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10605. JObject jsonObjects = JObject.Parse(response);
  10606. string msg = (string)jsonObjects["msg"];
  10607. if (msg == "报价成功")
  10608. {
  10609. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10610. DownloadAndConvertToBase64(url1);
  10611. }
  10612. else
  10613. {
  10614. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10615. }
  10616. }
  10617. else
  10618. {
  10619. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10620. JObject jsonObject = new JObject
  10621. {
  10622. { "Userid", "77886" },
  10623. { "pwd", "lt666888" },
  10624. { "Filename",chanp }
  10625. };
  10626. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10627. JObject jsonObjects = JObject.Parse(response);
  10628. string msg = (string)jsonObjects["msg"];
  10629. if (msg == "报价成功")
  10630. {
  10631. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10632. DownloadAndConvertToBase64(url1);
  10633. }
  10634. else
  10635. {
  10636. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10637. }
  10638. }
  10639. }
  10640. // 上传文件到FTP
  10641. }
  10642. catch (Exception ex)
  10643. {
  10644. Console.WriteLine($"An error occurred: {ex.Message}");
  10645. }
  10646. }
  10647. List<string> lw = new List<string>();
  10648. lw.Add(string.Format("( OrderState < 6 )"));
  10649. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10650. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10651. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10652. if (dt.Rows.Count > 0)
  10653. {
  10654. foreach (DataRow dr in dt.Rows)
  10655. {
  10656. ids.Add(dr["ctid"].ToString());
  10657. }
  10658. }
  10659. String ErrorMsgs = "";
  10660. foreach (String id in ids)
  10661. {
  10662. ErrorMsgs += id + ",";
  10663. }
  10664. if (ErrorMsgs.Length > 1)
  10665. {
  10666. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10667. }
  10668. if (ErrorMsgs.Length < 1)
  10669. {
  10670. ErrorMsgs = "上传成功";
  10671. returnSuccessMsg(ErrorMsgs);
  10672. }
  10673. else
  10674. {
  10675. returnErrorMsg("以下订单" + ErrorMsgs);
  10676. }
  10677. }
  10678. // 删除文件夹及其内容
  10679. /* Directory.Delete(localDirectory, true);*/
  10680. }
  10681. catch { }
  10682. }
  10683. public void get_center_data()
  10684. {
  10685. int userId = CurrentUser.UserID;
  10686. string postCode = CurrentUser.UserPost.Post.Code;
  10687. List<string> lw = new List<string>();
  10688. List<string> ww = new List<string>();
  10689. DateTime currentTime = DateTime.Now;
  10690. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10691. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10692. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10693. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10694. string sql = " SELECT ";
  10695. string startTime = "2023-10-01 11:22:31";
  10696. //设计
  10697. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10698. {
  10699. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10700. 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));
  10701. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10702. 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));
  10703. }
  10704. //客服
  10705. else if (postCode == "CustomerService" || postCode == "Director")
  10706. {
  10707. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10708. 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));
  10709. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10710. 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));
  10711. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10712. 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));
  10713. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10714. 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));
  10715. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10716. 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));
  10717. }
  10718. //售后
  10719. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10720. {
  10721. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10722. 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));
  10723. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10724. 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));
  10725. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10726. 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));
  10727. }
  10728. //下单部
  10729. else if (postCode == "Place" || postCode == "PlaceMr")
  10730. {
  10731. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10732. 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));
  10733. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10734. 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));
  10735. }
  10736. //车间
  10737. else if (postCode == "Supplier")
  10738. {
  10739. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10740. 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));
  10741. }
  10742. DataTable dt = new DataTable();
  10743. if (lw.Count > 0)
  10744. {
  10745. sql += string.Join(" , ", lw);
  10746. sql += " FROM ";
  10747. sql += string.Join(" , ", ww);
  10748. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10749. }
  10750. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10751. }
  10752. public void get_center_data_list()
  10753. {
  10754. int userId = CurrentUser.UserID;
  10755. string postCode = CurrentUser.UserPost.Post.Code;
  10756. string shopIds = CurrentUser.User.pemShop;
  10757. DataStruct dStruct = GetPostStruct();
  10758. List<string> lw = new List<string>();
  10759. DateTime currentTime = DateTime.Now;
  10760. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10761. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10762. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10763. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10764. string startTime = "2023-10-01 11:22:31";
  10765. int order_type = GetPostInt("order_type");
  10766. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10767. {
  10768. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10769. if (order_type == 0)
  10770. {
  10771. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10772. }
  10773. else if (order_type == 3)
  10774. {
  10775. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10776. }
  10777. else
  10778. {
  10779. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10780. }
  10781. }
  10782. //客服
  10783. if (postCode == "CustomerService" || postCode == "Director")
  10784. {
  10785. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10786. if (order_type == 0)
  10787. {
  10788. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10789. }
  10790. else if (order_type == 1)
  10791. {
  10792. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10793. }
  10794. else if (order_type == 2)
  10795. {
  10796. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10797. }
  10798. else if (order_type == 3)
  10799. {
  10800. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10801. }
  10802. else if (order_type == 4)
  10803. {
  10804. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10805. }
  10806. else
  10807. {
  10808. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10809. }
  10810. }
  10811. //售后
  10812. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10813. {
  10814. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10815. if (shopIds != "")
  10816. {
  10817. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10818. }
  10819. if (order_type == 2)
  10820. {
  10821. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10822. }
  10823. else if (order_type == 4)
  10824. {
  10825. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10826. }
  10827. else if (order_type == 5)
  10828. {
  10829. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10830. }
  10831. else
  10832. {
  10833. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10834. }
  10835. }
  10836. //下单部
  10837. if (postCode == "Place" || postCode == "PlaceMr")
  10838. {
  10839. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10840. if (shopIds != "")
  10841. {
  10842. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10843. }
  10844. else if (order_type == 1)
  10845. {
  10846. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10847. }
  10848. else if (order_type == 2)
  10849. {
  10850. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10851. }
  10852. else
  10853. {
  10854. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10855. }
  10856. }
  10857. //车间
  10858. if (postCode == "Supplier")
  10859. {
  10860. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10861. if (order_type == 5)
  10862. {
  10863. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10864. }
  10865. else
  10866. {
  10867. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10868. }
  10869. }
  10870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10871. dStruct.Fileds = "tid,ctid";
  10872. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10873. writeGridDataTableJson(dStruct.TotalCount, dt);
  10874. }
  10875. public void aftersale_audit_master()
  10876. {
  10877. if (UrlPostParmsCheck("ctid"))
  10878. {
  10879. string ctid = GetPostString("ctid");
  10880. if (ctid.Length > 0)
  10881. {
  10882. bool result = aftersale_data_change(ctid);
  10883. if (result)
  10884. {
  10885. returnSuccessMsg("修改成功!");
  10886. return;
  10887. }
  10888. }
  10889. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10890. }
  10891. }
  10892. public void aftersale_batch_audit_master()
  10893. {
  10894. if (UrlPostParmsCheck("ctids"))
  10895. {
  10896. string ctids = GetPostString("ctids");
  10897. if (ctids.Length > 0)
  10898. {
  10899. List<string> list = new List<string>();
  10900. string[] ctid_list = ctids.Split(',');
  10901. foreach (var item in ctid_list)
  10902. {
  10903. bool result = aftersale_data_change(item);
  10904. if (!result)
  10905. {
  10906. list.Add(item);
  10907. }
  10908. }
  10909. if (list.Count > 0)
  10910. {
  10911. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10912. return;
  10913. }
  10914. returnSuccessMsg("修改成功!");
  10915. return;
  10916. }
  10917. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10918. }
  10919. }
  10920. public bool aftersale_data_change(string ctid)
  10921. {
  10922. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10923. if (ceErpTradeCell != null)
  10924. {
  10925. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10926. ceErpTradeCell.AfterSaleSupplierState = 0;
  10927. StringBuilder sql = new StringBuilder();
  10928. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10929. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10930. CeErpTradeResponsible.DelByTid(ctid, 0);
  10931. 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 == "不理赔")
  10932. {
  10933. CeErpTradeResponsible.DelByTid(ctid, 1);
  10934. ceErpTradeCell.AfterSaleSupplierState = 1;
  10935. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10936. ceErpTradeCell.AfterSaleState = 4;
  10937. }
  10938. else
  10939. {
  10940. ceErpTradeCell.AfterSaleState = 3;
  10941. }
  10942. bool needCyt = false;
  10943. if (dt != null)
  10944. {
  10945. if (dt.Rows.Count == 1)
  10946. {
  10947. bool isEnd = false;
  10948. foreach (DataRow dr in dt.Rows)
  10949. {
  10950. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10951. {
  10952. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10953. isEnd = true;
  10954. }
  10955. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10956. {
  10957. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10958. isEnd = true;
  10959. }
  10960. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10961. {
  10962. needCyt = true;
  10963. }
  10964. }
  10965. if (isEnd)
  10966. {
  10967. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10968. ceErpTradeCell.AfterSaleState = 4;
  10969. ceErpTradeCell.AfterSaleSupplierState = 1;
  10970. }
  10971. }
  10972. else
  10973. {
  10974. bool isAll = true;
  10975. foreach (DataRow dr in dt.Rows)
  10976. {
  10977. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10978. {
  10979. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10980. continue;
  10981. }
  10982. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10983. {
  10984. string path = "";
  10985. int OrgID = 0;
  10986. if (!Convert.IsDBNull(dr["OrgPath"]))
  10987. {
  10988. path = dr["OrgPath"].ToString();
  10989. }
  10990. if (!Convert.IsDBNull(dr["OrgID"]))
  10991. {
  10992. OrgID = Convert.ToInt32(dr["OrgID"]);
  10993. }
  10994. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10995. {
  10996. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10997. continue;
  10998. }
  10999. }
  11000. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11001. {
  11002. needCyt = true;
  11003. }
  11004. isAll = false;
  11005. }
  11006. if (isAll)
  11007. {
  11008. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11009. ceErpTradeCell.AfterSaleState = 4;
  11010. ceErpTradeCell.AfterSaleSupplierState = 1;
  11011. }
  11012. }
  11013. }
  11014. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11015. {
  11016. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11017. }
  11018. if (ceErpTradeCell.AfterSaleState == 4)
  11019. {
  11020. ApiVo apiVo = new ApiVo();
  11021. apiVo.orderNumber = ceErpTradeCell.ctid;
  11022. apiVo.actionName = "afterOver";
  11023. designHelper.API_WorkCore(apiVo); //afterOver
  11024. }
  11025. ceErpTradeCell.Update();
  11026. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11027. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11028. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11029. return true;
  11030. }
  11031. return false;
  11032. }
  11033. public void get_erp_wechatorder()
  11034. {
  11035. DataStruct dStruct = GetPostStruct();
  11036. List<string> lw = new List<string>();
  11037. string tid = GetPostString("tid");
  11038. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11039. string shopname = GetPostString("shopname");
  11040. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11041. string buyernick = GetPostString("buyer_nick");
  11042. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11043. string customer = GetPostString("customer");
  11044. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11045. string returndate1 = GetPostString("returndate1");
  11046. string returndate2 = GetPostString("returndate2");
  11047. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11048. if (dw.Length > 0) lw.Add(dw);
  11049. string finishDate1 = GetPostString("finishdate1");
  11050. string finishDate2 = GetPostString("finishdate2");
  11051. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11052. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11053. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11054. dStruct.Order = "created desc";
  11055. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11056. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11057. writeGridDataTableJson(dStruct.TotalCount, dt);
  11058. }
  11059. public void get_erp_wechatlist_sumprice()
  11060. {
  11061. DataStruct dStruct = GetPostStruct();
  11062. List<string> lw = new List<string>();
  11063. string tid = GetPostString("tid");
  11064. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11065. string shopname = GetPostString("shopname");
  11066. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11067. string buyernick = GetPostString("buyer_nick");
  11068. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11069. string customer = GetPostString("customer");
  11070. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11071. string returndate1 = GetPostString("returndate1");
  11072. string returndate2 = GetPostString("returndate2");
  11073. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11074. if (dw.Length > 0) lw.Add(dw);
  11075. string finishDate1 = GetPostString("finishdate1");
  11076. string finishDate2 = GetPostString("finishdate2");
  11077. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11078. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11079. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11080. string mainWhere = string.Join(" and ", lw.ToArray());
  11081. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11082. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11083. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11084. decimal total = 0;
  11085. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11086. {
  11087. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11088. }
  11089. var res = new
  11090. {
  11091. data = total
  11092. };
  11093. string ro_jsond = JsonConvert.SerializeObject(res);
  11094. returnSuccess(ro_jsond);
  11095. return;
  11096. }
  11097. public void get_erp_qr_waitdeliverylist()
  11098. {
  11099. DataStruct dStruct = GetPostStruct();
  11100. List<string> lw = new List<string>();
  11101. string tid = GetPostString("ctid");
  11102. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11103. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11104. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11105. var res_objz = new
  11106. {
  11107. restype = 1,
  11108. data = dt
  11109. };
  11110. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11111. returnSuccess(ro_jsonz);
  11112. }
  11113. public void get_erp_yield_list()
  11114. {
  11115. DataStruct dStruct = GetPostStruct();
  11116. List<string> lw = new List<string>();
  11117. string tid = GetPostString("ctid");
  11118. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11119. string shopname = GetPostString("shopname");
  11120. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11121. string buyernick = GetPostString("buyer_nick");
  11122. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11123. //if (tid.Length == 0 && buyernick.Length == 0)
  11124. //{
  11125. // lw.Add(string.Format("IsRefund<={0}", 1));
  11126. //}
  11127. string customer = GetPostString("customer");
  11128. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11129. string design = GetPostString("design");
  11130. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11131. string orderState = GetPostString("orderState");
  11132. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11133. string address = GetPostString("address");
  11134. 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));
  11135. string sellermemo = GetPostString("seller_memo");
  11136. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11137. string supplier = GetPostString("supplier");
  11138. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11139. string OrderArea = GetPostString("order_area");
  11140. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11141. string placedate1 = GetPostString("placedate1");
  11142. string placedate2 = GetPostString("placedate2");
  11143. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11144. if (fdw.Length > 0) lw.Add(fdw);
  11145. string price1 = GetPostString("price1");
  11146. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11147. string price2 = GetPostString("price2");
  11148. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11149. string unusualCon = GetPostString("unusualcon");
  11150. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11151. string posTag = CurrentUser.UserPost.Post.Code;
  11152. if (posTag == "Supplier")
  11153. {
  11154. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11155. }
  11156. lw.Add(string.Format("OrderState = 6 "));
  11157. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11158. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11159. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11160. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11161. writeGridDataTableJson(dStruct.TotalCount, dt);
  11162. }
  11163. public void change_erp_sup_state()
  11164. {
  11165. if (UrlPostParmsCheck("ctid"))
  11166. {
  11167. string ctid = GetPostString("ctid");
  11168. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11169. if (ceErpTradeCell != null)
  11170. {
  11171. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11172. if (ceErpTradeCellExtend == null)
  11173. {
  11174. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11175. ceErpTradeCellExtend.ctid = ctid;
  11176. ceErpTradeCellExtend.SupState = 1;
  11177. ceErpTradeCellExtend.Create();
  11178. }
  11179. else
  11180. {
  11181. ceErpTradeCellExtend.SupState = 1;
  11182. ceErpTradeCellExtend.Update();
  11183. }
  11184. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11185. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11186. return;
  11187. }
  11188. returnErrorMsg("找不到订单");
  11189. }
  11190. }
  11191. public void supplier_all_downs()
  11192. {
  11193. if (UrlPostParmsCheck("tids"))
  11194. {
  11195. string tids = GetPostString("tids");
  11196. if (tids != null && tids.Length > 0)
  11197. {
  11198. StringBuilder sql = new StringBuilder();
  11199. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11200. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11201. sql = new StringBuilder();
  11202. 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, "下载设计文件");
  11203. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11204. string[] list = tids.Split(',');
  11205. foreach (string ctid in list)
  11206. {
  11207. CeErpSukuraData.createInfo(ctid, 3);
  11208. }
  11209. designHelper.api_approveDesign(tids); //approveDesign
  11210. returnSuccessMsg("下载成功!");
  11211. return;
  11212. }
  11213. returnErrorMsg("下载订单更新失败");
  11214. }
  11215. }
  11216. public void uploaderFileSuccess()
  11217. {
  11218. if (UrlPostParmsCheck("fileName"))
  11219. {
  11220. string fileName = GetPostString("fileName");
  11221. ApiVo apiVo = new ApiVo();
  11222. apiVo.orderNumber = fileName;
  11223. apiVo.actionName = "finishDesign";
  11224. designHelper.API_WorkCore(apiVo);//finishDesign
  11225. returnSuccessMsg("");
  11226. }
  11227. }
  11228. public void get_sample2_order()
  11229. {
  11230. if (UrlPostParmsCheck("ctid"))
  11231. {
  11232. string ctid = GetPostString("ctid");
  11233. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11234. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11235. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11236. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11237. double total = 0.0;
  11238. double order_price = 0.0;
  11239. if (dt_bu.Rows.Count > 0)
  11240. {
  11241. foreach (DataRow dr in dt_bu.Rows)
  11242. {
  11243. total += Convert.ToDouble(dr["payment"]);
  11244. }
  11245. }
  11246. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11247. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11248. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11249. string tid = ctid.Replace("S_", "");
  11250. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11251. double paymant = 0.0;
  11252. if (entity != null)
  11253. {
  11254. paymant = entity.payment;
  11255. }
  11256. string return_reason = "";
  11257. if (dt_after != null && dt_after.Rows.Count > 0)
  11258. {
  11259. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11260. }
  11261. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11262. }
  11263. }
  11264. public void get_erp_design_status()
  11265. {
  11266. string designName = GetPostString("designName");
  11267. DataStruct dStruct = GetPostStruct();
  11268. if (designName.Length > 0)
  11269. {
  11270. 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";
  11271. sql_user += " and Name like '%" + designName + "%'";
  11272. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11273. List<string> ids_list = new List<string>();
  11274. if (user_table.Rows.Count > 0)
  11275. {
  11276. foreach (DataRow item in user_table.Rows)
  11277. {
  11278. ids_list.Add(item["id"].ToString());
  11279. string ids_s = item["TeamIds"].ToString();
  11280. if (ids_s.Length > 0)
  11281. {
  11282. ids_list.AddRange(ids_s.Split(','));
  11283. }
  11284. }
  11285. }
  11286. HashSet<string> set = new HashSet<string>(ids_list);
  11287. ids_list = set.ToList();
  11288. if (ids_list.Count > 0)
  11289. {
  11290. 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));
  11291. dStruct.MainWhere = sql;
  11292. DataTable dt = null;
  11293. dt = WebCache.GetData("view_ErpUser", dStruct);
  11294. writeGridDataTableJson(dStruct.TotalCount, dt);
  11295. }
  11296. }
  11297. }
  11298. public void change_erp_order_price()
  11299. {
  11300. string ctid = GetPostString("ctid");
  11301. double price = GetPostDouble("price");
  11302. if (ctid.Length > 0)
  11303. {
  11304. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11305. if (ceErpTradeCellExtend == null)
  11306. {
  11307. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11308. ceErpTradeCellExtend.ctid = ctid;
  11309. ceErpTradeCellExtend.payment_cyt = price;
  11310. ceErpTradeCellExtend.Create();
  11311. }
  11312. else
  11313. {
  11314. ceErpTradeCellExtend.payment_cyt = price;
  11315. ceErpTradeCellExtend.Update();
  11316. }
  11317. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11318. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11319. {
  11320. ceErpDataSendOrderInfo.isSync = false;
  11321. ceErpDataSendOrderInfo.Update();
  11322. }
  11323. if (ceErpDataSendOrderInfo == null)
  11324. {
  11325. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11326. ceErpDataSendOrderInfo.isSync = false;
  11327. ceErpDataSendOrderInfo.ctid = ctid;
  11328. ceErpDataSendOrderInfo.Create();
  11329. }
  11330. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11331. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11332. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11333. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11334. {
  11335. dataSendOrderBean dataSendOrderBean = null;
  11336. foreach (DataRow item in dth.Rows)
  11337. {
  11338. try
  11339. {
  11340. dataSendOrderBean = new dataSendOrderBean();
  11341. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11342. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11343. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11344. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11345. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11346. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11347. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11348. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11349. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11350. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11351. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11352. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11353. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11354. if (result != null)
  11355. {
  11356. if ("0".Equals(result.errcode))
  11357. {
  11358. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11359. }
  11360. else
  11361. {
  11362. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11363. }
  11364. }
  11365. }
  11366. catch (Exception ex)
  11367. {
  11368. }
  11369. }
  11370. }
  11371. returnSuccessMsg("修改成功!");
  11372. return;
  11373. }
  11374. returnErrorMsg("找不到订单");
  11375. }
  11376. public void find_he_together()
  11377. {
  11378. string ctid = GetPostString("ctid");
  11379. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11380. List<string> list = new List<string>();
  11381. if (ceErpTradeCell != null)
  11382. {
  11383. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11384. {
  11385. 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);
  11386. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11387. if (table != null && table.Rows.Count > 0)
  11388. {
  11389. foreach (TableRow row in table.Rows)
  11390. {
  11391. }
  11392. }
  11393. }
  11394. }
  11395. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11396. }
  11397. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11398. {
  11399. //chy----19
  11400. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11401. //GD-CYT-----64
  11402. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11403. //ZHX----3
  11404. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11405. //JK----97
  11406. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11407. //ZT----70
  11408. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11409. //GD-CYTUV---126
  11410. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11411. //LHCY-----98
  11412. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11413. //XD-----90
  11414. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11415. //CYCY-----14
  11416. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11417. };
  11418. //其他改名
  11419. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11420. {
  11421. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11422. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11423. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11424. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11425. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11426. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11427. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11428. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11429. };
  11430. //不统计
  11431. List<int> no_suppliers = new List<int>()
  11432. {
  11433. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11434. };
  11435. //配件单
  11436. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11437. {
  11438. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11439. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11440. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11441. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11442. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11443. {"旗杆",new List<string>(){ "班旗" } },
  11444. {"牙签",new List<string>(){ "不干胶" } }
  11445. };
  11446. public void get_place_order_data()
  11447. {
  11448. string date1 = GetPostString("date1");
  11449. string date2 = GetPostString("date2");
  11450. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11451. DateTime start = DateTime.Parse(starttime);
  11452. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11453. DateTime end = DateTime.Parse(endtime);
  11454. if (date1 != null && date1.Length > 0)
  11455. {
  11456. DateTime dateTime = DateTime.Parse(date1);
  11457. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11458. start = DateTime.Parse(starttime);
  11459. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11460. end = DateTime.Parse(endtime);
  11461. }
  11462. if (date2 != null && date2.Length > 0)
  11463. {
  11464. DateTime dateTime = DateTime.Parse(date2);
  11465. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11466. end = DateTime.Parse(endtime);
  11467. }
  11468. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierName is not null ", starttime, endtime);
  11469. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11470. //不干胶-----1,卡片-----29
  11471. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11472. foreach (DataRow row in data.Rows)
  11473. {
  11474. int productId = Convert.ToInt32(row["ProductId"]);
  11475. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11476. if (no_suppliers.Contains(supplierId))
  11477. {
  11478. continue;
  11479. }
  11480. string seller_memo = row["seller_memo"].ToString();
  11481. bool ispj = false;//是否配件单
  11482. bool isfirst = true;//第一个配
  11483. maps.Keys.ForEach(key =>
  11484. {
  11485. //备注包含配件
  11486. if (seller_memo.Contains(key) && isfirst)
  11487. {
  11488. List<string> list = maps[key];
  11489. ispj = true;
  11490. isfirst = false;
  11491. for (int i = 0; i < list.Count; i++)
  11492. {
  11493. if (seller_memo.Contains(list[i]))
  11494. {
  11495. ispj = false;
  11496. break;
  11497. }
  11498. }
  11499. }
  11500. });
  11501. if (ispj)
  11502. {
  11503. continue;
  11504. }
  11505. seller_memo = seller_memo.Replace("UV", "uv");
  11506. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11507. //吊牌归到卡片
  11508. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11509. seller_memo = seller_memo.Replace("卡套", "卡片");
  11510. seller_memo = seller_memo.Replace("封套", "卡片");
  11511. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11512. seller_memo = seller_memo.Replace("腰封", "卡片");
  11513. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11514. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11515. seller_memo = seller_memo.Replace("横幅", "条幅");
  11516. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11517. string map_key = "";
  11518. string type = "";
  11519. if (supplierMap.ContainsKey(supplierId))
  11520. {
  11521. foreach (var kvp in supplierMap[supplierId])
  11522. {
  11523. if (seller_memo.Contains(kvp.Key))
  11524. {
  11525. map_key = kvp.Value;
  11526. type = kvp.Value;
  11527. break;
  11528. }
  11529. }
  11530. }
  11531. if (map_key == "")
  11532. {
  11533. type = "其他";
  11534. map_key = "其他";
  11535. }
  11536. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11537. {
  11538. map_key = suppliers[supplierId];
  11539. }
  11540. if (supplierId == 70)
  11541. {
  11542. supplierId = 70;
  11543. }
  11544. map_key += "_" + row["SupplierName"].ToString();
  11545. Dictionary<string, int> map = null;
  11546. if (other_map.ContainsKey(map_key))
  11547. {
  11548. other_map.TryGetValue(map_key, out map);
  11549. }
  11550. else
  11551. {
  11552. map = new Dictionary<string, int>();
  11553. map.Add("dayDev", 0);//当天出货
  11554. map.Add("dayTotal", 0);//下单总数
  11555. map.Add("payTotal", 0);//500以上
  11556. map.Add("today", 0);//当天出货数量
  11557. map.Add("unusua", 0);//异常数
  11558. other_map.Add(map_key, map);
  11559. other_map.TryGetValue(map_key, out map);
  11560. }
  11561. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11562. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11563. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11564. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11565. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11566. {
  11567. map["dayTotal"]++;
  11568. if (supplierId == 97)
  11569. {
  11570. supplierId = 97;
  11571. }
  11572. }
  11573. if (Convert.ToDecimal(row["payment"]) >= 500)
  11574. {
  11575. map["payTotal"]++;
  11576. }
  11577. bool istoday = false;
  11578. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11579. {
  11580. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11581. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11582. {
  11583. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11584. {
  11585. map["today"]++;
  11586. }
  11587. }
  11588. else
  11589. {
  11590. if (supplierId == 80)
  11591. {
  11592. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11593. {
  11594. map["today"]++;
  11595. }
  11596. }
  11597. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11598. {
  11599. map["today"]++;
  11600. istoday = true;
  11601. }
  11602. }
  11603. }
  11604. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11605. {
  11606. map["unusua"]++;
  11607. }
  11608. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11609. //GD-CYT-----64
  11610. DateTime two = palceTimeStart.AddHours(14);
  11611. DateTime three = palceTimeStart.AddHours(15);
  11612. DateTime four = palceTimeStart.AddHours(16);
  11613. DateTime six = palceTimeStart.AddHours(18);
  11614. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11615. {
  11616. //下午四点前 500-1000
  11617. string count = row["ProductCount"].ToString();
  11618. if (count != null && count.Length > 0)
  11619. {
  11620. int productCount = commonHelper.getPlaceProductCount(count);
  11621. if (productCount >= 500 && productCount <= 1000)
  11622. {
  11623. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11624. {
  11625. map["dayDev"]++;
  11626. }
  11627. }
  11628. }
  11629. }
  11630. //UV
  11631. else if ("uv".Equals(type))
  11632. {
  11633. //ZT----70
  11634. //ZHX----3
  11635. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11636. {
  11637. map["dayDev"]++;
  11638. }
  11639. //JK----97
  11640. //HZX----105
  11641. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11642. {
  11643. map["dayDev"]++;
  11644. }
  11645. }
  11646. //帆布---52|条幅---27
  11647. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11648. {
  11649. //LHCY-----98
  11650. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11651. {
  11652. map["dayDev"]++;
  11653. }
  11654. }
  11655. //条幅
  11656. else if ("条幅".Equals(type))
  11657. {
  11658. //XD-----90
  11659. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11660. {
  11661. map["dayDev"]++;
  11662. }
  11663. }
  11664. //桌布
  11665. else if ("桌布".Equals(type))
  11666. {
  11667. //XD-----90
  11668. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11669. {
  11670. map["dayDev"]++;
  11671. }
  11672. }
  11673. //DL---10
  11674. //AYTW---119
  11675. //FS-CYT-DY ----80
  11676. //JK----97
  11677. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11678. {
  11679. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11680. {
  11681. map["dayDev"]++;
  11682. if (supplierId == 80 && istoday)
  11683. {
  11684. Debug.WriteLine(seller_memo);
  11685. }
  11686. }
  11687. }
  11688. // QC---121
  11689. else if (supplierId == 121)
  11690. {
  11691. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11692. {
  11693. map["dayDev"]++;
  11694. }
  11695. }
  11696. }
  11697. DataTable dt = new DataTable();
  11698. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11699. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11700. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11701. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11702. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11703. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11704. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11705. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11706. other_map.Keys.ForEach(key =>
  11707. {
  11708. DataRow dr = dt.NewRow();
  11709. Dictionary<string, int> map = other_map[key];
  11710. string[] key_list = key.Split('_');
  11711. dr[0] = key_list[0];
  11712. dr[1] = key_list[1];
  11713. if (key_list.Length > 2)
  11714. {
  11715. dr[1] += "(" + key_list[2] + ")";
  11716. }
  11717. dr[2] = map["dayTotal"];
  11718. dr[3] = map["payTotal"];
  11719. dr[4] = map["today"];
  11720. dr[5] = map["unusua"];
  11721. dr[6] = map["dayDev"];
  11722. double rate = 0.00;
  11723. if (map["dayDev"] > 0)
  11724. {
  11725. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11726. }
  11727. dr[7] = rate.ToString();
  11728. dt.Rows.Add(dr);
  11729. });
  11730. DataView dv = new DataView(dt);
  11731. dv.Sort = "SupplierName";
  11732. //dv.Sort = "AllOrder desc";
  11733. DataTable dtNew = dv.ToTable();
  11734. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11735. }
  11736. public void check_order_desing_info()
  11737. {
  11738. string ctid = GetPostString("ctid");
  11739. if (!string.IsNullOrEmpty(ctid))
  11740. {
  11741. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11742. if (ceErpTradeCell != null)
  11743. {
  11744. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11745. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11746. return;
  11747. }
  11748. returnErrorMsg("找不到订单");
  11749. return;
  11750. }
  11751. returnErrorMsg("找不到订单");
  11752. }
  11753. public void get_timeout_detail()
  11754. {
  11755. string poscode = CurrentUser.UserPost.Post.Code;
  11756. DataStruct dStruct = GetPostStruct();
  11757. List<string> lw = new List<string>();
  11758. string id = GetPostString("id");
  11759. string pay_date1 = GetPostString("pay_date1");
  11760. string pay_date2 = GetPostString("pay_date2");
  11761. int type = GetPostInt("type");
  11762. if (type == 0)
  11763. {
  11764. if (pay_date1.Length > 0)
  11765. {
  11766. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11767. }
  11768. if (pay_date2.Length > 0)
  11769. {
  11770. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11771. }
  11772. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11773. }
  11774. if (type == 1)
  11775. {
  11776. if (pay_date1.Length > 0)
  11777. {
  11778. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11779. }
  11780. if (pay_date2.Length > 0)
  11781. {
  11782. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11783. }
  11784. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11785. }
  11786. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11787. DataTable dt = null;
  11788. dt = WebCache.GetData("view_orderlist", dStruct);
  11789. writeGridDataTableJson(dStruct.TotalCount, dt);
  11790. }
  11791. public void saveUrgentChargePrice()
  11792. {
  11793. string ctid = GetPostString("ctid");
  11794. if (!string.IsNullOrEmpty(ctid))
  11795. {
  11796. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11797. if (ceErpTradeCell != null)
  11798. {
  11799. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11800. if (prices <= 100)
  11801. {
  11802. returnErrorMsg("此订单金额不足100元,无法加急。");
  11803. return;
  11804. }
  11805. double price = GetPostDouble("price");
  11806. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11807. if (ceErpTradeCellExtend == null)
  11808. {
  11809. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11810. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11811. }
  11812. ceErpTradeCellExtend.urgentCharge = price;
  11813. if (ceErpTradeCellExtend.ID > 0)
  11814. {
  11815. ceErpTradeCellExtend.Update();
  11816. }
  11817. else
  11818. {
  11819. ceErpTradeCellExtend.Save();
  11820. }
  11821. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11822. returnSuccessMsg("修改成功!");
  11823. return;
  11824. }
  11825. returnErrorMsg("找不到订单");
  11826. return;
  11827. }
  11828. returnErrorMsg("找不到订单");
  11829. }
  11830. public void finish_erp_order()
  11831. {
  11832. string ctid = GetPostString("ctid");
  11833. if (!string.IsNullOrEmpty(ctid))
  11834. {
  11835. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11836. {
  11837. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11838. if (ceErpTradeCell != null)
  11839. {
  11840. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11841. ceErpTradeCell.Update();
  11842. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11843. returnSuccessMsg("修改成功!");
  11844. return;
  11845. }
  11846. }
  11847. }
  11848. returnErrorMsg("找不到订单");
  11849. }
  11850. public void get_trade_order_list()
  11851. {
  11852. string tid = GetPostString("tid");
  11853. if (!string.IsNullOrEmpty(tid))
  11854. {
  11855. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11856. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11857. writeGridDataTableJson(data.Rows.Count, data);
  11858. return;
  11859. }
  11860. returnErrorMsg("找不到订单");
  11861. }
  11862. public void save_cell_spu()
  11863. {
  11864. string ctid = GetPostString("ctid");
  11865. string spu_id = GetPostString("spu_id");
  11866. if (!string.IsNullOrEmpty(ctid))
  11867. {
  11868. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11869. if (ceErpTradeCellExtend == null)
  11870. {
  11871. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11872. ceErpTradeCellExtend.ctid = ctid;
  11873. }
  11874. ceErpTradeCellExtend.spu_id = spu_id;
  11875. if (!string.IsNullOrEmpty(spu_id))
  11876. {
  11877. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11878. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11879. }
  11880. if (ceErpTradeCellExtend.ID == 0)
  11881. {
  11882. ceErpTradeCellExtend.Create();
  11883. }
  11884. else
  11885. {
  11886. ceErpTradeCellExtend.Update();
  11887. }
  11888. returnSuccessMsg("修改成功!");
  11889. return;
  11890. }
  11891. returnErrorMsg("找不到订单");
  11892. }
  11893. public void change_express_info()
  11894. {
  11895. string ctid = GetPostString("ctid");
  11896. string transNo = GetPostString("transNo");
  11897. string transCom = GetPostString("transCom");
  11898. if (!string.IsNullOrEmpty(ctid))
  11899. {
  11900. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11901. if (ceErpTradeCellExtend == null)
  11902. {
  11903. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11904. ceErpTradeCellExtend.ctid = ctid;
  11905. }
  11906. ceErpTradeCellExtend.modExpressNo = transNo;
  11907. ceErpTradeCellExtend.modExpressCom = transCom;
  11908. ceErpTradeCellExtend.readMod = 2;
  11909. if (ceErpTradeCellExtend.ID == 0)
  11910. {
  11911. ceErpTradeCellExtend.Create();
  11912. }
  11913. else
  11914. {
  11915. ceErpTradeCellExtend.Update();
  11916. }
  11917. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11918. returnSuccessMsg("修改成功!");
  11919. return;
  11920. }
  11921. returnErrorMsg("找不到订单");
  11922. }
  11923. public void get_change_express_list()
  11924. {
  11925. DataStruct dStruct = GetPostStruct();
  11926. List<string> lw = new List<string>();
  11927. int st = 2;
  11928. string tid = GetPostString("ctid");
  11929. if (tid.Length > 0)
  11930. {
  11931. string select_tid = getTidByCtid(tid);
  11932. lw.Add(string.Format("tid='{0}'", select_tid));
  11933. }
  11934. string shopname = GetPostString("shopname");
  11935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11936. string buyernick = GetPostString("buyer_nick");
  11937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11938. string sellermemo = GetPostString("seller_memo");
  11939. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11940. string supplier = GetPostString("supplier");
  11941. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11942. string customer = GetPostString("customer");
  11943. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11944. string design = GetPostString("design");
  11945. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11946. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11947. string poscode = CurrentUser.UserPost.Post.Code;
  11948. if (poscode != "SysAdmin")
  11949. {
  11950. string shopid = CurrentUser.User.pemShop;
  11951. lw.Add(string.Format("shopId in ({0})", shopid));
  11952. }
  11953. lw.Add("readMod = 2");
  11954. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11955. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11956. writeGridDataTableJson(dStruct.TotalCount, dt);
  11957. }
  11958. public void deal_express_complete()
  11959. {
  11960. string ctid = GetPostString("ctid");
  11961. if (!string.IsNullOrEmpty(ctid))
  11962. {
  11963. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11964. if (ceErpTradeCellExtend == null)
  11965. {
  11966. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11967. ceErpTradeCellExtend.ctid = ctid;
  11968. }
  11969. ceErpTradeCellExtend.readMod = 1;
  11970. if (ceErpTradeCellExtend.ID == 0)
  11971. {
  11972. ceErpTradeCellExtend.Create();
  11973. }
  11974. else
  11975. {
  11976. ceErpTradeCellExtend.Update();
  11977. }
  11978. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11979. returnSuccessMsg("修改成功!");
  11980. return;
  11981. }
  11982. returnErrorMsg("找不到订单");
  11983. }
  11984. public void aftersale_return_visit()
  11985. {
  11986. string ctid = GetPostString("ctid");
  11987. if (!string.IsNullOrEmpty(ctid))
  11988. {
  11989. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11990. if (ceErpTradeCellExtend == null)
  11991. {
  11992. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11993. ceErpTradeCellExtend.ctid = ctid;
  11994. }
  11995. ceErpTradeCellExtend.returnVisit = 1;
  11996. if (ceErpTradeCellExtend.ID == 0)
  11997. {
  11998. ceErpTradeCellExtend.Create();
  11999. }
  12000. else
  12001. {
  12002. ceErpTradeCellExtend.Update();
  12003. }
  12004. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12005. if (ceErpTradeAfterSaleExtend != null)
  12006. {
  12007. ceErpTradeAfterSaleExtend.TextResult = "";
  12008. ceErpTradeAfterSaleExtend.Update();
  12009. }
  12010. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12011. returnSuccessMsg("修改成功!");
  12012. return;
  12013. }
  12014. returnErrorMsg("找不到订单");
  12015. }
  12016. public void orderPlaceInfo()
  12017. {
  12018. string ctids = GetPostString("ctids");
  12019. string[] list = ctids.Split(',');
  12020. foreach (string ctid in list)
  12021. {
  12022. CeErpSukuraData.createInfo(ctid, 3);
  12023. }
  12024. StringBuilder sql = new StringBuilder();
  12025. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12026. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12027. designHelper.api_approveDesign(ctids); //approveDesign
  12028. returnSuccessMsg("");
  12029. }
  12030. public void get_issue_list()
  12031. {
  12032. DataStruct dStruct = GetPostStruct();
  12033. List<string> lw = new List<string>();
  12034. int st = 2;
  12035. string tid = GetPostString("ctid");
  12036. if (tid.Length > 0)
  12037. {
  12038. string select_tid = getTidByCtid(tid);
  12039. lw.Add(string.Format("tid='{0}'", select_tid));
  12040. }
  12041. string shopname = GetPostString("shopname");
  12042. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12043. string buyernick = GetPostString("buyer_nick");
  12044. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12045. string sellermemo = GetPostString("seller_memo");
  12046. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12047. string supplier = GetPostString("supplier");
  12048. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12049. string customer = GetPostString("customer");
  12050. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12051. string design = GetPostString("design");
  12052. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12053. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12054. string poscode = CurrentUser.UserPost.Post.Code;
  12055. if (poscode != "SysAdmin")
  12056. {
  12057. string shopid = CurrentUser.User.pemShop;
  12058. lw.Add(string.Format("shopId in ({0})", shopid));
  12059. }
  12060. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12061. {
  12062. lw.Add("IssueState = 1");
  12063. }
  12064. else
  12065. {
  12066. string iisstate = GetPostString("iisstate");
  12067. if ("1".Equals(iisstate))
  12068. {
  12069. lw.Add("IssueState =1");
  12070. }
  12071. else if ("2".Equals(iisstate))
  12072. {
  12073. lw.Add("IssueState = 2");
  12074. }
  12075. else
  12076. {
  12077. lw.Add("IssueState > 0");
  12078. }
  12079. }
  12080. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12081. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12082. writeGridDataTableJson(dStruct.TotalCount, dt);
  12083. }
  12084. public void saveIssueContent()
  12085. {
  12086. string ctid = GetPostString("ctid");
  12087. if (!string.IsNullOrEmpty(ctid))
  12088. {
  12089. string content = GetPostString("content");
  12090. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12091. if (ceErpTradeAfterSaleExtend == null)
  12092. {
  12093. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12094. ceErpTradeAfterSaleExtend.tid = ctid;
  12095. }
  12096. ceErpTradeAfterSaleExtend.IssueContent = content;
  12097. ceErpTradeAfterSaleExtend.IssueState = 1;
  12098. if (ceErpTradeAfterSaleExtend.ID > 0)
  12099. {
  12100. ceErpTradeAfterSaleExtend.Update();
  12101. }
  12102. else
  12103. {
  12104. ceErpTradeAfterSaleExtend.Create();
  12105. }
  12106. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12107. returnSuccessMsg("添加成功!");
  12108. return;
  12109. }
  12110. returnErrorMsg("找不到订单");
  12111. }
  12112. public void dealIssueContent()
  12113. {
  12114. string ctid = GetPostString("ctid");
  12115. if (!string.IsNullOrEmpty(ctid))
  12116. {
  12117. string content = GetPostString("content");
  12118. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12119. if (ceErpTradeAfterSaleExtend != null)
  12120. {
  12121. ceErpTradeAfterSaleExtend.IssueState = 2;
  12122. ceErpTradeAfterSaleExtend.Update();
  12123. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12124. returnSuccessMsg("修改完成!");
  12125. return;
  12126. }
  12127. }
  12128. returnErrorMsg("找不到订单");
  12129. }
  12130. public void set_tid_attachments()
  12131. {
  12132. string tid = GetPostString("tid");
  12133. string atta = GetPostString("atta");
  12134. if (!string.IsNullOrEmpty(tid))
  12135. {
  12136. if (string.IsNullOrEmpty(atta))
  12137. {
  12138. returnErrorMsg("文件地址为空");
  12139. return;
  12140. }
  12141. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12142. if (ceErpTradeCell != null)
  12143. {
  12144. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12145. if (ceErpTrade == null)
  12146. {
  12147. returnErrorMsg("找不到订单");
  12148. return;
  12149. }
  12150. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12151. bool isSend = false;
  12152. if (dt != null && dt.Rows.Count > 0)
  12153. {
  12154. foreach (DataRow row in dt.Rows)
  12155. {
  12156. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12157. {
  12158. isSend = true;
  12159. }
  12160. }
  12161. if (isSend)
  12162. {
  12163. returnErrorMsg("已发货无法修改");
  12164. return;
  12165. }
  12166. ceErpTrade.Attachments = atta;
  12167. ceErpTrade.Update();
  12168. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12169. returnSuccessMsg("上传成功!");
  12170. return;
  12171. }
  12172. }
  12173. }
  12174. returnErrorMsg("找不到订单");
  12175. }
  12176. public void get_tid_attachments()
  12177. {
  12178. string tid = GetPostString("tid");
  12179. if (!string.IsNullOrEmpty(tid))
  12180. {
  12181. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12182. if (ceErpTradeCell != null)
  12183. {
  12184. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12185. if (ceErpTrade == null)
  12186. {
  12187. returnErrorMsg("找不到订单");
  12188. return;
  12189. }
  12190. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12191. return;
  12192. }
  12193. }
  12194. returnErrorMsg("找不到订单");
  12195. }
  12196. public void check_erp_sameorders()
  12197. {
  12198. if (UrlPostParmsCheck("ctid"))
  12199. {
  12200. string eid = GetPostString("ctid");
  12201. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12202. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12203. if (entity != null && ceErpTrade != null)
  12204. {
  12205. if (entity.OrderState > 6)
  12206. {
  12207. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12208. return;
  12209. }
  12210. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12211. List<string> ids = new List<string>();
  12212. if (dt != null && dt.Rows.Count > 1)
  12213. {
  12214. bool needhe = true;
  12215. foreach (DataRow dr in dt.Rows)
  12216. {
  12217. ids.Add("'" + dr["ctid"] + "'");
  12218. /* //备注有合包
  12219. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12220. {
  12221. needhe = true;
  12222. }
  12223. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12224. {
  12225. needhe = true;
  12226. }
  12227. //顺丰快递
  12228. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12229. {
  12230. needhe = true;
  12231. }*/
  12232. }
  12233. if (!needhe)
  12234. {
  12235. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12236. return;
  12237. }
  12238. StringBuilder sql = new StringBuilder();
  12239. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12240. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12241. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12242. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12243. foreach (DataRow dr in dt.Rows)
  12244. {
  12245. dr["dstate"] = 0;
  12246. dr["dnumber"] = 0;
  12247. foreach (DataRow row in dt1.Rows)
  12248. {
  12249. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12250. {
  12251. dr["dstate"] = 2;
  12252. dr["default"] = 1;
  12253. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12254. }
  12255. }
  12256. if (eid.Equals(dr["ctid"].ToString()))
  12257. {
  12258. dr["dstate"] = 1;
  12259. dr["default"] = 1;
  12260. }
  12261. }
  12262. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12263. return;
  12264. }
  12265. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12266. return;
  12267. }
  12268. returnErrorMsg("未找到订单");
  12269. return;
  12270. }
  12271. returnErrorMsg("缺少必要的参数");
  12272. }
  12273. public void get_mark_number()
  12274. {
  12275. string eid = GetPostString("ctid");
  12276. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12277. if (entity != null)
  12278. {
  12279. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12280. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12281. int current = 1;
  12282. if (ceErpDeliverMark == null)
  12283. {
  12284. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12285. List<string> ids = new List<string>();
  12286. if (dt != null && dt.Rows.Count > 1)
  12287. {
  12288. foreach (DataRow dr in dt.Rows)
  12289. {
  12290. ids.Add("'" + dr["ctid"] + "'");
  12291. }
  12292. //查询已有的编号
  12293. StringBuilder sql = new StringBuilder();
  12294. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12295. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12296. if (dt1 == null || dt1.Rows.Count == 0)
  12297. {
  12298. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12299. List<int> list_number = new List<int>();
  12300. foreach (DataRow row in numbers.Rows)
  12301. {
  12302. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12303. }
  12304. //查询空余编号
  12305. for (int i = 0; i < list_number.Count + 2; i++)
  12306. {
  12307. if (!list_number.Contains(current))
  12308. {
  12309. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12310. //防止查询过程中有新数据生成
  12311. if (ceErpDeliverMark1 == null)
  12312. {
  12313. break;
  12314. }
  12315. }
  12316. current++;
  12317. }
  12318. }
  12319. else
  12320. {
  12321. foreach (DataRow row in dt1.Rows)
  12322. {
  12323. current = Convert.ToInt32(row["markNumber"]);
  12324. }
  12325. }
  12326. ceErpDeliverMark = new CeErpDeliverMark();
  12327. ceErpDeliverMark.ctid = eid;
  12328. ceErpDeliverMark.createtime = DateTime.Now;
  12329. if (ceErpTrade != null)
  12330. {
  12331. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12332. }
  12333. ceErpDeliverMark.markNumber = current;
  12334. ceErpDeliverMark.Create();
  12335. }
  12336. }
  12337. else
  12338. {
  12339. current = ceErpDeliverMark.markNumber;
  12340. }
  12341. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12342. return;
  12343. }
  12344. }
  12345. public void aftersaleCytSend()
  12346. {
  12347. string ctid = GetPostString("ctid");
  12348. if (!string.IsNullOrEmpty(ctid))
  12349. {
  12350. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12351. if (ceErpTradeCell != null)
  12352. {
  12353. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12354. }
  12355. returnSuccessMsg("推送成功");
  12356. return;
  12357. }
  12358. returnErrorMsg("缺少必要的参数");
  12359. }
  12360. public void packOrderInfo()
  12361. {
  12362. string ctids = GetPostString("ctids");
  12363. if (!string.IsNullOrEmpty(ctids))
  12364. {
  12365. string[] ctid_list = ctids.Split(',');
  12366. if (ctid_list.Length > 20)
  12367. {
  12368. returnErrorMsg("单次下载次数不能超过20个");
  12369. return;
  12370. }
  12371. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12372. StringBuilder sql = new StringBuilder();
  12373. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12374. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12375. int supplierId = 0;
  12376. StringBuilder insterSql = new StringBuilder();
  12377. for (int i = 0; i < dt.Rows.Count; i++)
  12378. {
  12379. DataRow row = dt.Rows[i];
  12380. if (i == 0)
  12381. {
  12382. supplierId = Convert.ToInt32(row["SupplierId"]);
  12383. }
  12384. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12385. {
  12386. returnErrorMsg("同车间的订单才能一起打包");
  12387. return;
  12388. }
  12389. int orderState = Convert.ToInt32(row["OrderState"]);
  12390. if (orderState != 5)
  12391. {
  12392. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12393. return;
  12394. }
  12395. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12396. }
  12397. CeErpPackData ceErpPackData = new CeErpPackData();
  12398. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12399. ceErpPackData.supplierId = supplierId;
  12400. ceErpPackData.createtime = DateTime.Now;
  12401. ceErpPackData.createBy = CurrentUser.UserID;
  12402. ceErpPackData.createName = CurrentUser.UserName;
  12403. ceErpPackData.Create();
  12404. if (ceErpPackData.ID > 0)
  12405. {
  12406. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12407. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12408. }
  12409. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12410. returnSuccessMsg("打包成功");
  12411. return;
  12412. }
  12413. returnErrorMsg("缺少必要的参数");
  12414. }
  12415. public void rePackOrderInfo()
  12416. {
  12417. string id = GetPostString("id");
  12418. if (!string.IsNullOrEmpty(id))
  12419. {
  12420. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12421. if (ceErpPackData == null)
  12422. {
  12423. returnSuccessMsg("查无数据");
  12424. return;
  12425. }
  12426. ceErpPackData.upStatus = 0;
  12427. ceErpPackData.message = "";
  12428. ceErpPackData.Update();
  12429. returnSuccessMsg("打包成功");
  12430. return;
  12431. }
  12432. returnErrorMsg("缺少必要的参数");
  12433. }
  12434. public void backPackOrderInfo()
  12435. {
  12436. string id = GetPostString("id");
  12437. if (!string.IsNullOrEmpty(id))
  12438. {
  12439. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12440. if (ceErpPackData == null)
  12441. {
  12442. returnSuccessMsg("查无数据");
  12443. return;
  12444. }
  12445. ceErpPackData.upStatus = 4;
  12446. ceErpPackData.Update();
  12447. List<string> list = new List<string>();
  12448. StringBuilder sql = new StringBuilder();
  12449. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12450. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12451. for (int i = 0; i < dt.Rows.Count; i++)
  12452. {
  12453. DataRow row = dt.Rows[i];
  12454. list.Add("'" + row["ctid"].ToString() + "'");
  12455. }
  12456. string textCtids = string.Join(",", list);
  12457. 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));
  12458. 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, "无法打包退回"));
  12459. returnSuccessMsg("退回成功");
  12460. return;
  12461. }
  12462. returnErrorMsg("缺少必要的参数");
  12463. }
  12464. public void addPackDownNum()
  12465. {
  12466. string id = GetPostString("id");
  12467. if (!string.IsNullOrEmpty(id))
  12468. {
  12469. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12470. returnSuccessMsg("下载成功");
  12471. return;
  12472. }
  12473. returnErrorMsg("缺少必要的参数");
  12474. }
  12475. public void get_pack_list()
  12476. {
  12477. DataStruct dStruct = GetPostStruct();
  12478. List<string> lw = new List<string>();
  12479. string supplier = GetPostString("supplier");
  12480. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12481. string posTag = CurrentUser.UserPost.Post.Code;
  12482. if (posTag == "Supplier")
  12483. {
  12484. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12485. }
  12486. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12487. dStruct.Order = "createtime desc";
  12488. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12489. writeGridDataTableJson(dStruct.TotalCount, dt);
  12490. }
  12491. public void get_pack_order_list()
  12492. {
  12493. string packId = GetPostString("packId");
  12494. if (string.IsNullOrEmpty(packId))
  12495. {
  12496. returnErrorMsg("缺少必要的参数");
  12497. return;
  12498. }
  12499. StringBuilder sql = new StringBuilder();
  12500. 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);
  12501. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12502. if (dt == null || dt.Rows.Count == 0)
  12503. {
  12504. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12505. return;
  12506. }
  12507. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12508. return;
  12509. }
  12510. public void get_supplier_product_time_list()
  12511. {
  12512. DataStruct dStruct = GetPostStruct();
  12513. List<string> lw = new List<string>();
  12514. string supplier = GetPostString("supplier");
  12515. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12516. string posTag = CurrentUser.UserPost.Post.Code;
  12517. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12518. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12519. writeGridDataTableJson(dStruct.TotalCount, dt);
  12520. }
  12521. public void saveSupplierProductTime()
  12522. {
  12523. string productId = GetPostString("productId");
  12524. if (string.IsNullOrEmpty(productId))
  12525. {
  12526. returnErrorMsg("缺少必要的参数");
  12527. return;
  12528. }
  12529. string productName = GetPostString("productName");
  12530. int supplierId = GetPostInt("supplierId");
  12531. if (supplierId == 0)
  12532. {
  12533. returnErrorMsg("缺少必要的参数");
  12534. return;
  12535. }
  12536. int quantity = GetPostInt("quantity");
  12537. int sendDay = GetPostInt("sendTime");
  12538. string supplierName = GetPostString("supplierName");
  12539. string craft = GetPostString("craft");
  12540. string deadLine = GetPostString("deadLine");
  12541. string dayDeadLine = GetPostString("dayDeadLine");
  12542. try
  12543. {
  12544. int eid = GetPostInt("eid");
  12545. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12546. if (ceErpSupplierProductTime == null)
  12547. {
  12548. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12549. }
  12550. ceErpSupplierProductTime.productId = productId;
  12551. ceErpSupplierProductTime.productName = productName;
  12552. ceErpSupplierProductTime.supplierId = supplierId;
  12553. ceErpSupplierProductTime.supplierName = supplierName;
  12554. ceErpSupplierProductTime.craft = craft;
  12555. ceErpSupplierProductTime.sendDay = sendDay;
  12556. ceErpSupplierProductTime.quantity = quantity;
  12557. if (!string.IsNullOrEmpty(deadLine))
  12558. {
  12559. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12560. }
  12561. if (!string.IsNullOrEmpty(dayDeadLine))
  12562. {
  12563. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12564. }
  12565. if (ceErpSupplierProductTime.ID == 0)
  12566. {
  12567. ceErpSupplierProductTime.Save();
  12568. }
  12569. else
  12570. {
  12571. ceErpSupplierProductTime.Update();
  12572. }
  12573. }
  12574. catch (Exception e)
  12575. {
  12576. }
  12577. returnSuccessMsg("保存成功");
  12578. return;
  12579. }
  12580. public void delSupplierProductTime()
  12581. {
  12582. int eid = GetPostInt("eid");
  12583. if (eid > 0)
  12584. {
  12585. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12586. if (ceErpSupplierProductTime == null)
  12587. {
  12588. returnErrorMsg("查无数据");
  12589. return;
  12590. }
  12591. ceErpSupplierProductTime.Delete();
  12592. returnSuccessMsg("保存成功");
  12593. return;
  12594. }
  12595. returnErrorMsg("缺少必要的参数");
  12596. }
  12597. public void getExpressInfo()
  12598. {
  12599. string ctid = GetPostString("ctid");
  12600. if (!string.IsNullOrEmpty(ctid))
  12601. {
  12602. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12603. if (ceErpTradeCell != null)
  12604. {
  12605. string outSid = ceErpTradeCell.OutSid;
  12606. if (outSid.Length > 0)
  12607. {
  12608. 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);
  12609. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12610. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12611. return;
  12612. }
  12613. }
  12614. returnErrorMsg("查无记录");
  12615. return;
  12616. }
  12617. returnErrorMsg("缺少必要的参数");
  12618. }
  12619. public void getExpressPostData()
  12620. {
  12621. string express = GetPostString("express");
  12622. if (!string.IsNullOrEmpty(express))
  12623. {
  12624. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12625. if (ceErpExpressInfo != null)
  12626. {
  12627. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12628. return;
  12629. }
  12630. }
  12631. returnErrorMsg("缺少必要的参数");
  12632. }
  12633. public void checkSupplierOrder()
  12634. {
  12635. string ctids = GetPostString("ctids");
  12636. if (ctids != null)
  12637. {
  12638. List<string> list = new List<string>();
  12639. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12640. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12641. for (int i = 0; i < dt.Rows.Count; i++)
  12642. {
  12643. DataRow row = dt.Rows[i];
  12644. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12645. {
  12646. continue;
  12647. }
  12648. list.Add(row["seller_memo"].ToString());
  12649. }
  12650. if (list.Count > 0)
  12651. {
  12652. 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, "点击下载按钮"));
  12653. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12654. return;
  12655. }
  12656. }
  12657. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12658. return;
  12659. }
  12660. public void addPersonId()
  12661. {
  12662. string tid = GetPostString("tid");
  12663. string personId = GetPostString("personId");
  12664. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12665. if (ceErpTrade != null)
  12666. {
  12667. ceErpTrade.receiver_zip = personId;
  12668. ceErpTrade.Update();
  12669. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12670. returnSuccessMsg("保存成功");
  12671. return;
  12672. }
  12673. returnErrorMsg("缺少必要的参数");
  12674. }
  12675. public void addDeliveryPaymant()
  12676. {
  12677. string tid = GetPostString("tid");
  12678. string paymant = GetPostString("paymant");
  12679. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12680. if (ceErpTrade != null)
  12681. {
  12682. if (!string.IsNullOrEmpty(paymant))
  12683. {
  12684. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12685. }
  12686. ceErpTrade.Update();
  12687. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12688. returnSuccessMsg("保存成功");
  12689. return;
  12690. }
  12691. returnErrorMsg("缺少必要的参数");
  12692. }
  12693. public void saveCellFile()
  12694. {
  12695. string tid = GetPostString("tid");
  12696. string ctid = GetPostString("ctid");
  12697. string urls = GetPostString("urls");
  12698. string type = GetPostString("type");
  12699. string del = GetPostString("del");
  12700. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12701. {
  12702. if ("1".Equals(del))
  12703. {
  12704. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12705. }
  12706. string[] list = urls.Split(',');
  12707. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12708. {
  12709. foreach (string item in list)
  12710. {
  12711. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12712. ceErpTradeCellFile.Create();
  12713. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12714. }
  12715. }
  12716. returnSuccessMsg("保存成功");
  12717. return;
  12718. }
  12719. returnErrorMsg("缺少必要的参数");
  12720. }
  12721. public void getCellFile()
  12722. {
  12723. string tid = GetPostString("tid");
  12724. string ctid = GetPostString("ctid");
  12725. string type = GetPostString("type");
  12726. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12727. {
  12728. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12729. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12730. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12731. return;
  12732. }
  12733. returnErrorMsg("缺少必要的参数");
  12734. }
  12735. public void delCellFile()
  12736. {
  12737. string id = GetPostString("id");
  12738. if (string.IsNullOrEmpty(id))
  12739. {
  12740. returnErrorMsg("缺少必要的参数");
  12741. return;
  12742. }
  12743. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12744. CeErpTradeCellFile.delByID(id);
  12745. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12746. returnSuccessMsg("保存成功");
  12747. }
  12748. }
  12749. }