sync.order.cs 715 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. using NPOI.POIFS.Properties;
  51. using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
  52. using static SiteCore.taoObj.Api_tmc_refund_info_Obj;
  53. using System.Threading.Tasks;
  54. using SiteCore.taoObj.WebApi;
  55. using System.Web.UI.WebControls.WebParts;
  56. namespace SiteCore.Handler
  57. {
  58. public partial class sync
  59. {
  60. public void get_erp_orderlist()
  61. {
  62. string poscode = CurrentUser.UserPost.Post.Code;
  63. DataStruct dStruct = GetPostStruct();
  64. //commonHelper.sendSpuData(CeErpTradeCell.GetByCtid("C1_2701711344045006369"),CeErpTradeCellExtend.getByTid("C1_2701711344045006369"));
  65. //commonHelper.setDeliveryUnusualOrder2();
  66. //string a = SecurityHelper.DecryptSymmetric("NNM8SwEgcu/yE70NElUXSQ==");
  67. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  68. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  69. //banniuApiHelper.sendLogisticsInfo(null);
  70. //commonHelper.autoDistributeToSupplier(CeErpTradeCell.GetByCode("260112211259328680"));
  71. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  72. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  73. //int sid = commonHelper.autoDistributeToSupplier(entity);
  74. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  75. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1776912122000,\"deliveryType\":\"OFFLINE\",\"discountFee\":5.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1777564800000,\"lines\":[{\"dividePostFee\":0.0,\"latestDeliveryTime\":1777564799999,\"mark2\":[],\"num\":7,\"outerId\":\"\",\"payment\":65.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/490100363/O1CN014sHEYw1EYItkQ1CXw_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":10.0,\"refOlId\":\"3297756000720015269\",\"refSkuId\":\"0\",\"refSpuId\":\"1013527964388\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":9.2857,\"singleFee\":9.29,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"车贴定制宠物logo图案转印贴纸小狗diy创意商标车窗萌宠水晶标签\",\"totalFee\":65.0,\"totalPrice\":70.0,\"totalSellPrice\":65.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1776913673000,\"openBuyerId\":\"AAG5RHraABkUZRPgSx3AaocL\",\"openBuyerNick\":\"绿**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1776912119000,\"payTime\":1776912120000,\"payment\":65.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"大连市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"甘井子区\",\"receiverId\":\"84b8064ffac769db909772facb5e84fb$\",\"receiverState\":\"辽宁省\",\"receiverTown\":\"凌水街道\",\"refOid\":\"3297756000720015269\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"120x120mm+120x150mm-2款各1个-UV转印贴-彩色-模切-绿葡萄妲己-龙井\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"sysTags\":[],\"totalFee\":65.0,\"totalPrice\":70.0,\"totalSellPrice\":65.0,\"type\":\"SALE\"}}");
  76. //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}}");
  77. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  78. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  79. //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}]}}");
  80. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  81. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  82. string tids = File.ReadAllText(path);
  83. List<string> list = tids.Split(',').ToList();
  84. int index = 0;
  85. foreach (string item in list)
  86. {
  87. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  88. try
  89. {
  90. 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);
  91. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  92. {
  93. 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);
  94. }
  95. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  96. List<string> tidList = new List<string>();
  97. if (dataTable != null && dataTable.Rows.Count > 0)
  98. {
  99. foreach (DataRow row in dataTable.Rows)
  100. {
  101. tidList.Add("'" + row["tid"].ToString() + "'");
  102. }
  103. }
  104. if (tidList.Count > 0)
  105. {
  106. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  107. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  108. if (dataTable != null && dataTable.Rows.Count > 0)
  109. {
  110. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  111. if (count > 0)
  112. {
  113. Debug.WriteLine(index++);
  114. continue;
  115. }
  116. }
  117. }
  118. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  119. }
  120. catch (Exception e)
  121. {
  122. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  123. }
  124. Debug.WriteLine(index++);
  125. }*/
  126. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  127. List<string> lw = new List<string>();
  128. string tid = GetPostString("ctid");
  129. string date1 = GetPostString("date1");
  130. //12-1 修改
  131. string urgent = GetPostString("urgent");
  132. string back = GetPostString("back");
  133. string offlineSearch = GetPostString("offlineSearch");
  134. int paramsCount = 0;
  135. if (!string.IsNullOrWhiteSpace(urgent))
  136. {
  137. if (urgent.Equals("true"))
  138. {
  139. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  140. }
  141. }
  142. if (!string.IsNullOrWhiteSpace(back))
  143. {
  144. if (back.Equals("true"))
  145. {
  146. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  147. }
  148. }
  149. if (!string.IsNullOrWhiteSpace(offlineSearch))
  150. {
  151. if (offlineSearch.Equals("true"))
  152. {
  153. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  154. }
  155. }
  156. //end
  157. string date2 = GetPostString("date2");
  158. string buyernick = GetPostString("buyer_nick");
  159. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  160. {
  161. if (tid.Length <= 0 && buyernick.Length <= 0)
  162. {
  163. return;
  164. }
  165. }
  166. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  167. {
  168. if (tid.Length > 0)
  169. {
  170. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  171. if (ceErpTradeCell != null)
  172. {
  173. tid = ceErpTradeCell.tid;
  174. }
  175. List<string> select_tid = getTidByCtidMore(tid);
  176. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  177. }
  178. if (buyernick.Length > 0)
  179. {
  180. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  181. }
  182. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  183. if (dw.Length > 0)
  184. {
  185. lw.Add(dw);
  186. }
  187. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  188. {
  189. string usershop = "0," + CurrentUser.User.pemShop;
  190. lw.Add(string.Format("ShopId in ({0})", usershop));
  191. }
  192. }
  193. else
  194. {
  195. if (ex_psize == 0)
  196. {
  197. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  198. }
  199. if (PKey != "admin" && poscode != "SysAdmin")
  200. {
  201. string usershop = "0," + CurrentUser.User.pemShop;
  202. lw.Add(string.Format("ShopId in ({0})", usershop));
  203. paramsCount++;
  204. }
  205. }
  206. string uploaddate1 = GetPostString("uploaddate1");
  207. string uploaddate2 = GetPostString("uploaddate2");
  208. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  209. if (update.Length > 0) lw.Add(update);
  210. string deliverydate1 = GetPostString("deliverydate1");
  211. string deliverydate2 = GetPostString("deliverydate2");
  212. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  213. if (deliverydate.Length > 0)
  214. {
  215. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  216. };
  217. string shopname = GetPostString("shopname");
  218. if (shopname.Length > 0)
  219. {
  220. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  221. if (ceErpShop != null)
  222. {
  223. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  224. }
  225. }
  226. string addwechat = GetPostString("addwechat");
  227. if (addwechat.Length > 0)
  228. {
  229. int addWt = Convert.ToInt32(addwechat);
  230. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  231. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  232. }
  233. string customer = GetPostString("customer");
  234. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  235. string design = GetPostString("design");
  236. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  237. string orderState = GetPostString("orderState");
  238. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  239. string address = GetPostString("address");
  240. 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));
  241. string sellermemo = GetPostString("seller_memo");
  242. if (sellermemo.Length > 0)
  243. {
  244. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  245. }
  246. string otherMemo = GetPostString("otherMemo");
  247. if (otherMemo.Length > 0)
  248. {
  249. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  250. }
  251. string backReason = GetPostString("backReason");
  252. if (backReason.Length > 0)
  253. {
  254. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  255. }
  256. string apdate1 = GetPostString("apdate1");
  257. string apdate2 = GetPostString("apdate2");
  258. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  259. if (dwap.Length > 0) lw.Add(dwap);
  260. string price1 = GetPostString("price1");
  261. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  262. string price2 = GetPostString("price2");
  263. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  264. string isoldcustomer = GetPostString("isoldcus");
  265. string buyer_id = GetPostString("buyer_id");
  266. if (buyer_id.Length > 0) lw.Add(string.Format("buyer_id = '{0}'", buyer_id));
  267. string spudata = GetPostString("spudata");
  268. if ("0".Equals(spudata))
  269. {
  270. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  271. }
  272. if ("1".Equals(spudata))
  273. {
  274. lw.Add(string.Format("spu_id <> ''"));
  275. }
  276. string finishdate1 = GetPostString("finishdate1");
  277. string finishdate2 = GetPostString("finishdate2");
  278. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  279. bool isFinish = false;
  280. if (finishdate.Length > 0)
  281. {
  282. lw.Add(finishdate);
  283. isFinish = true;
  284. paramsCount++;
  285. }
  286. if (isoldcustomer.Length > 0)
  287. {
  288. if ("2".Equals(isoldcustomer))
  289. {
  290. lw.Add(string.Format("VipCustomer=1"));
  291. }
  292. else
  293. {
  294. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  295. }
  296. }
  297. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  298. if (ex_psize > 0)
  299. {
  300. int UserID = CurrentUser.UserID;
  301. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  302. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  303. {
  304. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  305. }
  306. dStruct.Order = "pay_time desc";
  307. }
  308. string isNew = GetPostString("isNew");
  309. if (isNew == "true")
  310. {
  311. lw.Add(string.Format("IsNew = {0}", 1));
  312. }
  313. string overtime = GetPostString("overtime");
  314. if (overtime == "1")
  315. {
  316. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  317. }
  318. String usePost = CurrentUser.UserPost.Post.Code;
  319. if (usePost.Equals("Operation") == true)
  320. {
  321. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  322. }
  323. else
  324. {
  325. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  326. }
  327. //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";
  328. if (dStruct.PageSize == 100000)
  329. {
  330. dStruct.Order = "";
  331. }
  332. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  333. DataTable dt = null;
  334. string tablename = "view_orderlist";
  335. if (isFinish)
  336. {
  337. tablename = "view_orderlist_end";
  338. }
  339. dt = WebCache.GetData(tablename, dStruct);
  340. if (dt != null && dt.Rows.Count > 0)
  341. {
  342. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  343. foreach (DataRow dr in dt.Rows)
  344. {
  345. try
  346. {
  347. if (dr["refund_fees"] != null)
  348. {
  349. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  350. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  351. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  352. if (payment == refund_fees)
  353. {
  354. dr["refund_fees"] = Math.Round(refund_fees, 2);
  355. }
  356. else if (refund_fees == total_fee)
  357. {
  358. dr["refund_fees"] = payment;
  359. }
  360. else
  361. {
  362. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  363. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  364. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  365. }
  366. }
  367. // 对象操作
  368. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  369. ceErpTradeCell.ctid = dr["ctid"].ToString();
  370. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  371. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  372. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  373. if (dStruct.PageSize != 100000)
  374. {
  375. if (dr["DispatchSort"].ToString() == "2")
  376. {
  377. dr["gongchuang"] = 200;
  378. }
  379. else if ("外协".Equals(dr["ToType"].ToString()))
  380. {
  381. dr["gongchuang"] = 200;
  382. }
  383. else if ("内部".Equals(dr["ToType"].ToString()))
  384. {
  385. dr["gongchuang"] = -1;
  386. }
  387. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  388. {
  389. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  390. dr["gongchuang"] = response.code;
  391. }
  392. }
  393. }
  394. catch (NullReferenceException ex)
  395. {
  396. // 处理空引用异常
  397. dr["refund_fees"] = "0.00";
  398. }
  399. }
  400. }
  401. writeGridDataTableJson(dStruct.TotalCount, dt);
  402. }
  403. public void get_erp_orderlist_sumprice()
  404. {
  405. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  406. return;
  407. List<string> lw = new List<string>();
  408. string tid = GetPostString("ctid");
  409. string date1 = GetPostString("date1");
  410. string date2 = GetPostString("date2");
  411. if (tid.Length > 0 || date1.Length > 0)
  412. {
  413. lw.Add(string.Format("ctid like '%{0}%'", tid));
  414. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  415. if (dw.Length > 0) lw.Add(dw);
  416. }
  417. else
  418. {
  419. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  420. }
  421. string shopname = GetPostString("shopname");
  422. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  423. string buyernick = GetPostString("buyer_nick");
  424. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  425. string customer = GetPostString("customer");
  426. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  427. string design = GetPostString("design");
  428. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  429. string orderState = GetPostString("orderState");
  430. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  431. string address = GetPostString("address");
  432. 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));
  433. string sellermemo = GetPostString("seller_memo");
  434. if (sellermemo.Length > 0)
  435. {
  436. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  437. }
  438. string apdate1 = GetPostString("apdate1");
  439. string apdate2 = GetPostString("apdate2");
  440. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  441. if (dwap.Length > 0) lw.Add(dwap);
  442. string price1 = GetPostString("price1");
  443. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  444. string price2 = GetPostString("price2");
  445. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  446. string isoldcustomer = GetPostString("isoldcus");
  447. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  448. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  449. if (PKey != "admin")
  450. {
  451. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  452. lw.Add(string.Format("shopId in ({0})", usershop));
  453. }
  454. //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";
  455. string mainWhere = string.Join(" and ", lw.ToArray());
  456. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  457. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  458. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  459. decimal total = 0;
  460. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  461. {
  462. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  463. }
  464. var res = new
  465. {
  466. data = total
  467. };
  468. string ro_jsond = JsonConvert.SerializeObject(res);
  469. returnSuccess(ro_jsond);
  470. return;
  471. }
  472. public void get_erp_CustomerServiceGather()
  473. {
  474. string userWhere = "", orderWhere = "";
  475. List<string> lw = new List<string>();
  476. string customer = GetPostString("customer");
  477. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  478. string shopname = GetPostString("shopname");
  479. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  480. string date1 = GetPostString("date1");
  481. string date2 = GetPostString("date2");
  482. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  483. if (dw.Length > 0) lw.Add(dw);
  484. orderWhere = string.Join(" and ", lw.ToArray());
  485. 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 " +
  486. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  487. "left join " +
  488. "( " +
  489. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  490. ") as b on a.ID = b.CustomerUserId " +
  491. "left join " +
  492. "( " +
  493. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  494. ") as d on a.ID = d.CustomerUserId " +
  495. "left join " +
  496. "( " +
  497. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  498. ") as e on a.ID = e.CustomerUserId " +
  499. "left join " +
  500. "( " +
  501. " select CustomerUserId, RefundCount, RefundSum from " +
  502. " ( " +
  503. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  504. " from CE_ErpTradeRefund a " +
  505. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  506. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  507. " group by CustomerUserId " +
  508. " ) as a " +
  509. ") as f on a.ID = f.CustomerUserId " +
  510. "where a.PostCode = 'CustomerService'",
  511. userWhere, orderWhere);
  512. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  513. writeGridDataTableJson(dt.Rows.Count, dt);
  514. //writeGridDataTableJson(dt.Rows.Count, dt);
  515. }
  516. //设计汇总
  517. public void get_erp_DesignerGather()
  518. {
  519. string userWhere = "", orderWhere = "";
  520. List<string> lw = new List<string>();
  521. string Designer = GetPostString("designer");
  522. int org = GetPostInt("org");
  523. if (Designer.Length > 0)
  524. {
  525. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  526. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  527. }
  528. else if (org > 0)
  529. {
  530. userWhere = string.Format(" where OrgID ={0}", org);
  531. }
  532. string shopname = GetPostString("shopname");
  533. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  534. string state = GetPostString("state");
  535. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  536. string OrderArea = GetPostString("order_area");
  537. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  538. string date1 = GetPostString("date1");
  539. string date2 = GetPostString("date2");
  540. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  541. if (dw.Length > 0) lw.Add(dw);
  542. string UpDate1 = GetPostString("UpDate1");
  543. string UpDate2 = GetPostString("UpDate2");
  544. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  545. if (dw.Length > 0) lw.Add(dw);
  546. orderWhere = string.Join(" and ", lw.ToArray());
  547. 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 (" +
  548. "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 " +
  549. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  550. "left join " +
  551. "( " +
  552. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  553. ") as b on a.ID = b.DesignUserId " +
  554. "left join " +
  555. "( " +
  556. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  557. ") as d on a.ID = d.DesignUserId " +
  558. "left join " +
  559. "( " +
  560. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  561. ") as e on a.ID = e.DesignUserId " +
  562. "left join " +
  563. "( " +
  564. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  565. ") as g on a.ID = g.DesignUserId " +
  566. "left join " +
  567. "( " +
  568. " select CustomerUserId, RefundCount, RefundSum from " +
  569. " ( " +
  570. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  571. " from CE_ErpTradeRefund a " +
  572. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  573. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  574. " group by CustomerUserId " +
  575. " ) as a " +
  576. ") as f on a.ID = f.CustomerUserId " +
  577. "where a.PostCode = 'Designer') as z",
  578. userWhere, orderWhere);
  579. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  580. writeGridDataTableJson(dt.Rows.Count, dt);
  581. }
  582. //删除tradecell的订单
  583. public void del_erp_cellorder()
  584. {
  585. if (UrlPostParmsCheck("ctid"))
  586. {
  587. string eid = GetPostString("ctid");
  588. CeErpTradeCell.DelByCtid(eid);
  589. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  590. returnSuccessMsg("删除成功");
  591. }
  592. }
  593. public void clear_erp_refundstate()
  594. {
  595. if (UrlPostParmsCheck("ids"))
  596. {
  597. string eids = GetPostString("ids");
  598. string[] ctidList = eids.Split(',');
  599. foreach (string ctid in ctidList)
  600. {
  601. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  602. if (entity != null)
  603. {
  604. entity.IsRefund = 0;
  605. entity.Update();
  606. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  607. }
  608. else
  609. continue;
  610. }
  611. returnSuccessMsg("操作成功");
  612. return;
  613. }
  614. returnErrorMsg("缺少必要参数");
  615. }
  616. public void set_erp_urgency()
  617. {
  618. if (UrlPostParmsCheck("ctid"))
  619. {
  620. string eid = GetPostString("ctid");
  621. CeErpTradeCell entity = null;
  622. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  623. if (entity != null)
  624. {
  625. double prices = commonHelper.calculationPrice(entity);
  626. if (prices <= 100)
  627. {
  628. returnErrorMsg("此订单金额不足100元,无法加急。");
  629. return;
  630. }
  631. string utime = GetPostString("urgencytime");
  632. if (utime.Length > 0)
  633. {
  634. entity.UrgencyTime = Convert.ToDateTime(utime);
  635. }
  636. else
  637. {
  638. returnErrorMsg("请选择加急时间");
  639. return;
  640. }
  641. if (entity.OrderState <= 4)
  642. {
  643. //entity.seller_memo = entity.seller_memo + "-加急";
  644. string smemo = entity.seller_memo;
  645. int kindex = smemo.IndexOf(")");
  646. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  647. if (lastoneStr != "-")
  648. {
  649. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  650. }
  651. string prememo = smemo.Substring(0, kindex + 2);
  652. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  653. int lastkindex = lastmemo.IndexOf("(");
  654. DateTime urgtime = Convert.ToDateTime(utime);
  655. string newlastmemo = "";
  656. if (lastkindex == 0)
  657. {
  658. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  659. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  660. }
  661. else
  662. {
  663. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  664. }
  665. entity.seller_memo = prememo + newlastmemo;
  666. }
  667. entity.IsUrgency = true;
  668. entity.UpdateTime = DateTime.Now;
  669. entity.Update();
  670. ApiVo apiVo = new ApiVo();
  671. apiVo.orderNumber = entity.ctid;
  672. apiVo.actionName = "changeDesign";
  673. apiVo.orderRemarks = entity.seller_memo;
  674. apiVo.remarkSign = 3;
  675. designHelper.API_WorkCore(apiVo); //changeDesign
  676. CeErpSukuraData.createInfo(entity.ctid, 7);
  677. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  678. returnSuccessMsg("设置成功!");
  679. return;
  680. }
  681. returnErrorMsg("找不到记录");
  682. }
  683. }
  684. public void set_erp_reset()
  685. {
  686. if (UrlPostParmsCheck("ctid"))
  687. {
  688. string eid = GetPostString("ctid");
  689. CeErpTradeCell entity = null;
  690. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  691. if (entity != null)
  692. {
  693. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  694. {
  695. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  696. {
  697. returnErrorMsg("财务要求已下单已发货无法重置");
  698. return;
  699. }
  700. }
  701. entity.IsUrgency = false;
  702. entity.seller_memo = "";
  703. entity.OtherMemo = "";
  704. entity.OrderState = 0;
  705. entity.IsReturn = 0;
  706. //entity.IsRefund = 0;
  707. entity.MemoOpt = 0;
  708. entity.AfterSaleState = 0;
  709. entity.AfterSaleResponsible = "";
  710. entity.AfterSaleUserId = 0;
  711. entity.IsNeedBill = 0;
  712. entity.CustomerUserId = 0;
  713. entity.DesignUserId = 0;
  714. entity.SupplierId = 0;
  715. entity.PlaceUserId = 0;
  716. entity.ptid = "";
  717. entity.IsSample = 0;
  718. entity.IsXianHuo = 0;
  719. entity.isDianziOrder = 0;
  720. entity.DispatchSort = 0;
  721. entity.IsVerifyToSupplier = false;
  722. entity.FinishPlaceTime = null;
  723. entity.Update();
  724. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  725. if (trade != null)
  726. {
  727. trade.seller_memo = "";
  728. trade.Update();
  729. }
  730. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  731. returnSuccessMsg("重置成功!");
  732. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  733. if (desginBill != null)
  734. {
  735. desginBill.isDel = 1;
  736. desginBill.Update();
  737. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  738. }
  739. ApiVo apiVo = new ApiVo();
  740. apiVo.orderNumber = entity.ctid;
  741. apiVo.actionName = "resetDesign";
  742. designHelper.API_WorkCore(apiVo);//resetDesign
  743. return;
  744. }
  745. returnErrorMsg("找不到记录");
  746. }
  747. }
  748. public void save_erp_sellermemo()
  749. {
  750. if (UrlPostParmsCheck("ctid"))
  751. {
  752. string ctid = GetPostString("ctid");
  753. CeErpTradeCell entity = null;
  754. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  755. if (entity != null)
  756. {
  757. string memo = GetPostString("seller_memo");
  758. string qn_memo = GetPostString("qn_memo");
  759. memo = memo.Replace(" ", "");
  760. if (memo.Contains("补差"))
  761. {
  762. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  763. return;
  764. }
  765. List<string> bitList = new List<string>
  766. {
  767. "\\","/",":","*","?", "\"","<" ,">","|"
  768. };
  769. bool isIn = false;
  770. foreach (string bit in bitList)
  771. {
  772. if (memo.Contains(bit))
  773. {
  774. isIn = true;
  775. }
  776. }
  777. if (isIn)
  778. {
  779. returnErrorMsg("不能使用 一些符合作为文件名");
  780. return;
  781. }
  782. if (entity.seller_memo != memo)
  783. {
  784. if (entity.IsSample == 2)
  785. {
  786. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  787. return;
  788. }
  789. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  790. {
  791. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  792. {
  793. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  794. return;
  795. }
  796. /*if (CurrentUser.UserPost.Post.Code != "Place")
  797. {
  798. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  799. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  800. {
  801. returnErrorMsg("售前系统订单无法再此修改!");
  802. return;
  803. }
  804. }*/
  805. }
  806. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  807. }
  808. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  809. {
  810. if (entity.OrderState >= 5)
  811. {
  812. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  813. return;
  814. }
  815. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  816. if (string.IsNullOrEmpty(delMemo))
  817. {
  818. returnErrorMsg("备注不规范,无法识别");
  819. return;
  820. }
  821. memo = delMemo;
  822. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  823. }
  824. //commonHelper.getCytPrice(entity);
  825. int memoopt = GetPostInt("MemoOpt");
  826. Boolean ismemoopt = false;
  827. if (memoopt > 0)
  828. {
  829. string stropt = "";
  830. if (memoopt == 1)
  831. {
  832. stropt = "“改稿”";
  833. ismemoopt = true;
  834. }
  835. else if (memoopt == 2)
  836. {
  837. stropt = "“定稿”";
  838. }
  839. else if (memoopt == 3)
  840. {
  841. stropt = "“查货”";
  842. CeErpSukuraData.createInfo(entity.ctid, 6);
  843. }
  844. entity.MemoOpt = Convert.ToInt32(memoopt);
  845. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  846. }
  847. if (entity.OrderState < 5)
  848. {
  849. memo = memo.Replace("(", "(");
  850. memo = memo.Replace(")", ")");
  851. }
  852. /* if (entity.OrderState < 3)
  853. {
  854. entity.DispatchSort = 0;
  855. }*/
  856. entity.seller_memo = memo;
  857. entity.UpdateTime = DateTime.Now;
  858. entity.Update();
  859. ApiVo apiVo = new ApiVo();
  860. apiVo.orderNumber = entity.ctid;
  861. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  862. apiVo.orderRemarks = memo;
  863. apiVo.remarkSign = memoopt;
  864. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  865. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  866. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  867. {
  868. //dataHelper.api_orderBack(entity.ctid, "0", "");
  869. }
  870. if (entity.seller_memo.Contains("改稿"))
  871. {
  872. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  873. }
  874. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  875. returnSuccessMsg("保存成功!");
  876. return;
  877. }
  878. returnErrorMsg("找不到记录");
  879. }
  880. }
  881. public void ins_erp_checkorder()
  882. {
  883. if (UrlPostParmsCheck("ctid"))
  884. {
  885. string ctid = GetPostString("ctid");
  886. CeErpTradeCell entity = null;
  887. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  888. if (entity != null)
  889. {
  890. if (entity.OrderState < 6)
  891. {
  892. returnErrorMsg("下单完成后才可查货");
  893. return;
  894. }
  895. /*if (entity.OrderState > 6)
  896. {
  897. returnErrorMsg("订单已发货");
  898. return;
  899. }*/
  900. if (entity.FinishPlaceTime != null)
  901. {
  902. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  903. {
  904. returnErrorMsg("下单时间不足,无法查货");
  905. return;
  906. }
  907. }
  908. entity.MemoOpt = 3;
  909. entity.CheckOrderTime = DateTime.Now;
  910. entity.UpdateTime = DateTime.Now;
  911. entity.Update();
  912. CeErpSukuraData.createInfo(entity.ctid, 6);
  913. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  914. returnSuccessMsg("操作成功!");
  915. return;
  916. }
  917. returnErrorMsg("找不到记录");
  918. }
  919. }
  920. public void save_erp_othermemo()
  921. {
  922. if (UrlPostParmsCheck("ctid"))
  923. {
  924. string ctid = GetPostString("ctid");
  925. CeErpTradeCell entity = null;
  926. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  927. if (entity != null)
  928. {
  929. entity.OtherMemo = GetPostString("otherMemo");
  930. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  931. {
  932. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  933. StringBuilder sql = new StringBuilder();
  934. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  935. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  936. if (dt != null && dt.Rows.Count > 0)
  937. {
  938. foreach (DataRow dr in dt.Rows)
  939. {
  940. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  941. {
  942. //品类一直
  943. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  944. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  945. if (ceErpSampleCustomer == null)
  946. {
  947. ceErpSampleCustomer = new CeErpSampleCustomer();
  948. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  949. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  950. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  951. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  952. ceErpSampleCustomer.shopId = entity.ShopId;
  953. }
  954. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  955. ceErpSampleCustomer.lastTid = entity.tid;
  956. if (ceErpSampleCustomer.ID > 0)
  957. {
  958. ceErpSampleCustomer.Update();
  959. }
  960. else
  961. {
  962. ceErpSampleCustomer.Create();
  963. }
  964. }
  965. }
  966. }
  967. }
  968. //if (entity.IsOldCustomer == 1)
  969. //{
  970. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  971. //{
  972. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  973. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  974. //}
  975. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  976. //{
  977. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  978. // {
  979. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  980. // {
  981. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  982. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  983. // }
  984. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  985. // {
  986. // entity.OrderState = 2;
  987. // entity.DesignUserId = 0;
  988. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  989. // }
  990. // else
  991. // {
  992. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  993. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  994. // }
  995. // }
  996. //}
  997. //}
  998. entity.UpdateTime = DateTime.Now;
  999. entity.Update();
  1000. returnSuccessMsg("保存成功!");
  1001. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  1002. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  1003. if (entity.OtherMemo.Contains("改稿"))
  1004. {
  1005. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1006. }
  1007. return;
  1008. }
  1009. returnErrorMsg("找不到记录");
  1010. }
  1011. }
  1012. public void save_erp_customermemo()
  1013. {
  1014. if (UrlPostParmsCheck("ctid"))
  1015. {
  1016. string ctid = GetPostString("ctid");
  1017. CeErpTradeCell entity = null;
  1018. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1019. if (entity != null)
  1020. {
  1021. entity.UpdateTime = DateTime.Now;
  1022. entity.CustomerMemo = GetPostString("CustomerMemo");
  1023. entity.Update();
  1024. ApiVo apiVo = new ApiVo();
  1025. apiVo.orderNumber = entity.ctid;
  1026. apiVo.actionName = "followRemarks";
  1027. apiVo.orderRemarks = entity.CustomerMemo;
  1028. designHelper.API_WorkCore(apiVo);//followRemarks
  1029. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1030. returnSuccessMsg("保存成功!");
  1031. return;
  1032. }
  1033. returnErrorMsg("找不到记录");
  1034. }
  1035. }
  1036. public void upd_erp_addmemotag()
  1037. {
  1038. if (UrlPostParmsCheck("ctid"))
  1039. {
  1040. ;
  1041. string eid = GetPostString("ctid");
  1042. string sfTagstr = GetPostString("memotag");
  1043. CeErpTradeCell entity = null;
  1044. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1045. if (entity != null)
  1046. {
  1047. ApiVo apiVo = new ApiVo();
  1048. if (entity.OrderState == 0)
  1049. {
  1050. returnErrorMsg("请先领单");
  1051. return;
  1052. }
  1053. //撤销顺丰
  1054. if (sfTagstr == "撤销顺丰")
  1055. {
  1056. entity.IsSF = 0;
  1057. string reMsg = "";
  1058. string oldmemo = entity.seller_memo;
  1059. if (entity.OrderState < 5)
  1060. {
  1061. oldmemo = oldmemo.Replace("顺丰到付", "");
  1062. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1063. entity.seller_memo = oldmemo;
  1064. }
  1065. else
  1066. {
  1067. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1068. {
  1069. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1070. }
  1071. }
  1072. entity.Update();
  1073. apiVo.orderNumber = entity.ctid;
  1074. apiVo.actionName = "orderRemarks";
  1075. apiVo.orderRemarks = entity.seller_memo;
  1076. apiVo.isSf = entity.IsSF.ToString();
  1077. designHelper.API_WorkCore(apiVo);//orderRemarks
  1078. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1079. returnSuccessMsg("撤销成功!" + reMsg);
  1080. return;
  1081. }
  1082. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1083. {
  1084. //string oldmemo = entity.seller_memo;
  1085. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1086. string sfStr = GetPostString("memotag");
  1087. string smemo = entity.seller_memo;
  1088. int kindex = smemo.IndexOf(")");
  1089. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1090. if (lastoneStr != "-")
  1091. {
  1092. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1093. }
  1094. string prememo = smemo.Substring(0, kindex + 2);
  1095. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1096. int lastkindex = lastmemo.IndexOf("(");
  1097. string newlastmemo = "";
  1098. if (lastkindex == 0)
  1099. {
  1100. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1101. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1102. }
  1103. else
  1104. {
  1105. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1106. }
  1107. entity.seller_memo = prememo + newlastmemo;
  1108. }
  1109. string sfTagMSg = "";
  1110. if (sfTagstr == "顺丰寄付")
  1111. {
  1112. entity.IsSF = 1;
  1113. sfTagMSg = "顺丰寄付";
  1114. }
  1115. else if (sfTagstr == "顺丰到付")
  1116. {
  1117. entity.IsSF = 2;
  1118. sfTagMSg = "顺丰到付";
  1119. }
  1120. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1121. {
  1122. string deliveryWayName = "";
  1123. if (sfTagstr == "撤销顺丰")
  1124. {
  1125. sfTagstr = "普通快递";
  1126. }
  1127. if (sfTagstr == "顺丰寄付")
  1128. {
  1129. sfTagstr = "顺丰特快寄付";
  1130. }
  1131. if (sfTagstr == "顺丰到付")
  1132. {
  1133. sfTagstr = "顺丰特快到付";
  1134. }
  1135. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1136. if ("修改失败".Equals(result))
  1137. {
  1138. returnErrorMsg("修改失败");
  1139. return;
  1140. }
  1141. }
  1142. entity.Update();
  1143. apiVo = new ApiVo();
  1144. apiVo.orderNumber = entity.ctid;
  1145. apiVo.actionName = "orderRemarks";
  1146. apiVo.orderRemarks = entity.seller_memo;
  1147. apiVo.isSf = entity.IsSF.ToString();
  1148. designHelper.API_WorkCore(apiVo);//orderRemarks
  1149. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1150. returnSuccessMsg("标记成功!");
  1151. return;
  1152. }
  1153. returnErrorMsg("找不到记录");
  1154. }
  1155. }
  1156. public void upd_erp_ordertag()
  1157. {
  1158. if (UrlPostParmsCheck("ctid"))
  1159. {
  1160. string eid = GetPostString("ctid");
  1161. CeErpTradeCell entity = null;
  1162. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1163. if (entity != null)
  1164. {
  1165. int tag = GetPostInt("wechattag");
  1166. //if(tag==4 && entity.IsSample == 2)
  1167. //{
  1168. // returnErrorMsg("补差价单不能标记微信单");
  1169. // return;
  1170. //}
  1171. entity.wechatTag = tag;
  1172. entity.Update();
  1173. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1174. if (tag == 1)
  1175. {
  1176. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1177. if (cash == null)
  1178. {
  1179. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1180. cash = new CeErpReturnCash();
  1181. cash.tid = entity.tid;
  1182. cash.seller_nick = main.seller_nick;
  1183. cash.payment = trade.payment;
  1184. cash.buyer_nick = main.buyer_nick;
  1185. cash.cashstate = 0;
  1186. cash.rtype = "微信返现";
  1187. cash.returnprice = 0;
  1188. cash.created = DateTime.Now;
  1189. cash.con = "订单标记微信单";
  1190. cash.img = "";
  1191. cash.applyuserid = CurrentUser.UserID;
  1192. cash.Create();
  1193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1194. }
  1195. else
  1196. {
  1197. cash.cashstate = 0;
  1198. cash.Update();
  1199. }
  1200. CeErpSukuraData.createInfo(entity.ctid, 9);
  1201. }
  1202. else if (tag == 2)
  1203. {
  1204. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1205. if (cash == null)
  1206. {
  1207. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1208. cash = new CeErpReturnCash();
  1209. cash.tid = entity.tid;
  1210. cash.seller_nick = main.seller_nick;
  1211. cash.payment = trade.payment;
  1212. cash.buyer_nick = main.buyer_nick;
  1213. cash.cashstate = 0;
  1214. cash.rtype = "推购返现";
  1215. cash.returnprice = 5;
  1216. cash.created = DateTime.Now;
  1217. cash.con = "订单标记推购单";
  1218. cash.img = "";
  1219. cash.applyuserid = CurrentUser.UserID;
  1220. cash.Create();
  1221. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1222. }
  1223. else
  1224. {
  1225. cash.cashstate = 0;
  1226. cash.Update();
  1227. }
  1228. CeErpSukuraData.createInfo(entity.ctid, 9);
  1229. }
  1230. else if (tag == 3)
  1231. {
  1232. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1233. if (pers == null)
  1234. {
  1235. pers = new CeErpPersuade();
  1236. pers.ctid = entity.ctid;
  1237. pers.pstate = 0;
  1238. pers.created = DateTime.Now;
  1239. pers.applyuserid = CurrentUser.UserID;
  1240. pers.Create();
  1241. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1242. }
  1243. else
  1244. {
  1245. pers.pstate = 0;
  1246. pers.Update();
  1247. }
  1248. }
  1249. else if (tag == 4 || tag == 5)
  1250. {
  1251. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1252. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1253. if (pers == null)
  1254. {
  1255. pers = CeErpStayGoods.GetByTid(entity.tid);
  1256. }
  1257. if (pers == null)
  1258. {
  1259. pers = new CeErpStayGoods();
  1260. pers.t_id = entity.tid;
  1261. pers.ctid = entity.ctid;
  1262. pers.status = "待审核";
  1263. pers.audit_type = 0;
  1264. if (tag == 4)
  1265. {
  1266. pers.stay_type = "微信推购";
  1267. }
  1268. else
  1269. {
  1270. pers.stay_type = "旺旺推购";
  1271. }
  1272. if (entity.IsXianHuo == 0)
  1273. {
  1274. pers.product_id = entity.ProductId;
  1275. }
  1276. pers.wangwang = main.buyer_nick;
  1277. pers.shop_name = main.seller_nick;
  1278. pers.creata_time = DateTime.Now;
  1279. pers.create_u_id = CurrentUser.UserID;
  1280. pers.create_u_name = CurrentUser.UserName;
  1281. pers.Create();
  1282. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1283. }
  1284. else
  1285. {
  1286. pers.ctid = entity.ctid;
  1287. pers.audit_type = 0;
  1288. pers.Update();
  1289. }
  1290. CeErpSukuraData.createInfo(entity.ctid, 10);
  1291. }
  1292. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1293. returnSuccessMsg("标记成功!");
  1294. return;
  1295. }
  1296. returnErrorMsg("找不到记录");
  1297. }
  1298. }
  1299. public void upd_erp_ordertag_cancel()
  1300. {
  1301. if (UrlPostParmsCheck("ctid"))
  1302. {
  1303. string eid = GetPostString("ctid");
  1304. CeErpTradeCell entity = null;
  1305. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1306. if (entity != null)
  1307. {
  1308. entity.wechatTag = 0;
  1309. entity.Update();
  1310. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1311. if (pers != null)
  1312. {
  1313. pers.status = "取消推购";
  1314. pers.audit_type = 3;
  1315. pers.Update();
  1316. }
  1317. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1318. returnSuccessMsg("标记成功!");
  1319. return;
  1320. }
  1321. returnErrorMsg("找不到记录");
  1322. }
  1323. }
  1324. public void upd_erp_addweichattag()
  1325. {
  1326. if (UrlPostParmsCheck("ctid"))
  1327. {
  1328. ;
  1329. string eid = GetPostString("ctid");
  1330. CeErpTradeCell entity = null;
  1331. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1332. if (entity != null)
  1333. {
  1334. if (entity.IsAddWechat > 0)
  1335. {
  1336. returnErrorMsg("此单已经标记过了");
  1337. return;
  1338. }
  1339. 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);
  1340. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1341. if (dt.Rows.Count > 0)
  1342. {
  1343. entity.IsAddWechat = 2;
  1344. }
  1345. else
  1346. {
  1347. entity.IsAddWechat = 1;
  1348. }
  1349. entity.Update();
  1350. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1351. returnSuccessMsg("标记成功!");
  1352. return;
  1353. }
  1354. returnErrorMsg("找不到记录");
  1355. }
  1356. }
  1357. public void upd_erp_getmyorder()
  1358. {
  1359. if (UrlPostParmsCheck("ctid"))
  1360. {
  1361. string eid = GetPostString("ctid");
  1362. CeErpTradeCell entity = null;
  1363. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1364. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1365. /*if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1366. {
  1367. returnErrorMsg("台湾客户需填写身份证号!");
  1368. return;
  1369. }*/
  1370. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1371. {
  1372. returnErrorMsg("偏远地区需要填写物流费!");
  1373. return;
  1374. }
  1375. if (entity != null)
  1376. {
  1377. if (entity.ctid.IndexOf("C") != -1)
  1378. {
  1379. StringBuilder sql = new StringBuilder();
  1380. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1381. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1382. if (dt.Rows.Count > 0)
  1383. {
  1384. decimal total = 0;
  1385. foreach (DataRow dr in dt.Rows)
  1386. {
  1387. total += Convert.ToDecimal(dr["payment"]);
  1388. }
  1389. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1390. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1391. {
  1392. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1393. return;
  1394. }
  1395. }
  1396. }
  1397. if (entity.OrderState == -1)
  1398. {
  1399. returnErrorMsg("待审核订单无法领取!");
  1400. return;
  1401. }
  1402. entity.CustomerUserId = CurrentUser.UserID;
  1403. if (entity.OrderState < 2)
  1404. {
  1405. entity.OrderState = 2;
  1406. if (entity.ShopId != 0)
  1407. {
  1408. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1409. }
  1410. }
  1411. entity.UpdateTime = DateTime.Now;
  1412. entity.Update();
  1413. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1414. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1415. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1416. {
  1417. //dataHelper.api_orderBack(entity.ctid, "0", "");
  1418. }
  1419. returnSuccessMsg("领单成功!");
  1420. return;
  1421. }
  1422. returnErrorMsg("找不到记录");
  1423. }
  1424. }
  1425. public void getmyorder_from_init()
  1426. {
  1427. if (UrlPostParmsCheck("ctid"))
  1428. {
  1429. string eid = GetPostString("ctid");
  1430. CeErpTradeCell entity = null;
  1431. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1432. if (entity != null)
  1433. {
  1434. string sellerMemo = GetPostString("sellerMemo");
  1435. if (sellerMemo.Length > 0)
  1436. {
  1437. entity.seller_memo = sellerMemo;
  1438. }
  1439. string oterhMemo = GetPostString("otherMemo");
  1440. if (oterhMemo.Length > 0)
  1441. {
  1442. entity.OtherMemo = oterhMemo;
  1443. }
  1444. int urg = GetPostInt("urgency");
  1445. entity.IsUrgency = (urg == 1 ? true : false);
  1446. int wechat = GetPostInt("wechat");
  1447. int command = GetPostInt("command");
  1448. if (wechat == 1)
  1449. {
  1450. entity.wechatTag = 1;
  1451. }
  1452. if (command == 1)
  1453. {
  1454. entity.wechatTag = 2;
  1455. }
  1456. string pPro = GetPostString("pprofession");
  1457. if (pPro.Length > 0)
  1458. {
  1459. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1460. string spro = GetPostString("profession");
  1461. if (spro.Length > 0)
  1462. {
  1463. entity.ProfessionId = Convert.ToInt32(spro);
  1464. }
  1465. }
  1466. string proId = GetPostString("productId");
  1467. if (proId.Length > 0)
  1468. {
  1469. entity.ProductId = Convert.ToInt32(proId);
  1470. }
  1471. entity.Material = GetPostString("material");
  1472. entity.Craft = GetPostString("craft");
  1473. entity.CustomerUserId = CurrentUser.UserID;
  1474. if (entity.OrderState < 2)
  1475. {
  1476. entity.OrderState = 2;
  1477. if (entity.ShopId != 0)
  1478. {
  1479. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1480. }
  1481. }
  1482. entity.Update();
  1483. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1484. returnSuccessMsg("领单成功!");
  1485. return;
  1486. }
  1487. returnErrorMsg("找不到记录");
  1488. }
  1489. }
  1490. public void upd_erp_setrelationorder()
  1491. {
  1492. if (UrlPostParmsCheck("ctid"))
  1493. {
  1494. ;
  1495. string eid = GetPostString("ctid");
  1496. string ftid = GetPostString("ftid");
  1497. CeErpTradeCell entity = null;
  1498. CeErpTradeCell fentity = null;
  1499. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1500. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1501. if (fentity == null)
  1502. {
  1503. returnErrorMsg("找不到关联的主订单");
  1504. return;
  1505. }
  1506. if (entity != null)
  1507. {
  1508. if (entity.OrderState >= 5)
  1509. {
  1510. returnErrorMsg("本单已经设计完成无法关联");
  1511. return;
  1512. }
  1513. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1514. {
  1515. returnErrorMsg("线下单续审核后才能关联!");
  1516. return;
  1517. }
  1518. entity.ptid = ftid;
  1519. entity.OrderState = fentity.OrderState;
  1520. //entity.status = fentity.status;
  1521. entity.CustomerUserId = fentity.CustomerUserId;
  1522. entity.DesignUserId = fentity.DesignUserId;
  1523. entity.seller_memo = "补差价单:" + ftid;
  1524. entity.IsSample = 2;
  1525. entity.Update();
  1526. ApiVo apiVo = new ApiVo();
  1527. apiVo.orderNumber = ftid;
  1528. apiVo.payment = entity.payment;
  1529. apiVo.actionName = "repairDesign";
  1530. designHelper.API_WorkCore(apiVo);//repairDesign
  1531. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1532. returnSuccessMsg("关联成功!");
  1533. return;
  1534. }
  1535. else
  1536. returnErrorMsg("找不到记录");
  1537. }
  1538. }
  1539. public void download_erp_neworder()
  1540. {
  1541. string seller = GetPostString("seller_nick");
  1542. string tid = GetPostString("tid");
  1543. if (seller.Length <= 0 || tid.Length <= 0)
  1544. {
  1545. returnErrorMsg("数据错误");
  1546. }
  1547. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1548. //{
  1549. // returnErrorMsg("找不到店铺Sessionkey");
  1550. //}
  1551. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1552. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1553. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1554. if (res.IndexOf("refOid") == -1)
  1555. {
  1556. returnErrorMsg("下载订单数据失败");
  1557. return;
  1558. }
  1559. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1560. returnSuccessMsg("下载完成");
  1561. //tmcHelper.createNewOrder(res);
  1562. //CeErpTrade entr = null;
  1563. //entr = CeErpTrade.Get(tid);
  1564. //if (entr != null)
  1565. //{
  1566. // returnSuccess("下载成功");
  1567. // //下载成功之后,Cell表生成对应的订单;
  1568. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1569. //}
  1570. //else
  1571. //{
  1572. // returnErrorMsg("下载失败或者创建订单失败");
  1573. //}
  1574. }
  1575. public void set_erp_atersale()
  1576. {
  1577. if (UrlPostParmsCheck("ctid"))
  1578. {
  1579. string eid = GetPostString("ctid");
  1580. string reason = GetPostString("AfterSaleReason");
  1581. CeErpTradeCell entity = null;
  1582. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1583. if (entity != null)
  1584. {
  1585. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1586. {
  1587. returnErrorMsg("此订单已经在售后");
  1588. return;
  1589. }*/
  1590. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1591. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1592. entity.AfterSaleTime = DateTime.Now;
  1593. entity.HandleTime = null;
  1594. entity.Update();
  1595. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1596. returnSuccessMsg("转售后成功!");
  1597. return;
  1598. }
  1599. returnErrorMsg("找不到记录");
  1600. }
  1601. }
  1602. public void set_erp_withdraw()
  1603. {
  1604. if (UrlPostParmsCheck("ctid"))
  1605. {
  1606. try
  1607. {
  1608. string eid = GetPostString("ctid");//商品id
  1609. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1610. CeWithdraw ceWithdrawSelect = null;
  1611. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1612. if (ceWithdrawSelect != null)
  1613. {
  1614. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1615. {
  1616. ceWithdrawSelect.status = -1;
  1617. ceWithdrawSelect.Update();
  1618. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1619. returnSuccessMsg("重新发起审核成功");
  1620. return;
  1621. }
  1622. else
  1623. {
  1624. returnSuccessMsg("请勿重复申请!");
  1625. return;
  1626. }
  1627. }
  1628. else
  1629. {
  1630. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1631. if (string.IsNullOrEmpty(CustomerUserId))
  1632. {
  1633. CustomerUserId = "-1";
  1634. }
  1635. int Userid = CurrentUser.UserID;//用户id
  1636. CeWithdraw ceWithdraw = new CeWithdraw();
  1637. ceWithdraw.tid = eid;
  1638. ceWithdraw.userid = Userid;
  1639. ceWithdraw.providerid = CustomerUserId;
  1640. ceWithdraw.status = 3;
  1641. ceWithdraw.creationtime = DateTime.Now;
  1642. ceWithdraw.Create();
  1643. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1644. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1645. return;
  1646. }
  1647. }
  1648. catch
  1649. {
  1650. returnErrorMsg("申请撤回订单失败");
  1651. return;
  1652. }
  1653. }
  1654. }
  1655. public void ins_erp_billinfo()
  1656. {
  1657. if (UrlPostParmsCheck("ctid"))
  1658. {
  1659. string eid = GetPostString("ctid");
  1660. CeErpTradeCell entity = null;
  1661. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1662. if (entity != null)
  1663. {
  1664. CeErpBill bill = CeErpBill.GetByTid(eid);
  1665. bool isHave = false;
  1666. if (bill != null)
  1667. {
  1668. isHave = true;
  1669. if (bill.state != 4)
  1670. {
  1671. returnErrorMsg("此单已经申请过发票了");
  1672. return;
  1673. }
  1674. }
  1675. if (entity.IsNeedBill == 0)
  1676. {
  1677. entity.IsNeedBill = 1;
  1678. }
  1679. entity.Update();
  1680. string errjson = "";
  1681. try
  1682. {
  1683. CeErpBill bill_entity = new CeErpBill();
  1684. bill_entity.tid = entity.tid;
  1685. bill_entity.title = GetPostString("title");
  1686. string taxstr = GetPostString("tax");
  1687. taxstr = taxstr.Replace(" ", "");
  1688. bill_entity.tax = taxstr;
  1689. bill_entity.bank = GetPostString("bank");
  1690. string bankacstr = GetPostString("bankac");
  1691. bankacstr = bankacstr.Replace(" ", "");
  1692. bill_entity.bankac = bankacstr;
  1693. bill_entity.address = GetPostString("address");
  1694. bill_entity.phone = GetPostString("phone");
  1695. bill_entity.price = GetPostString("price");
  1696. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1697. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1698. {
  1699. billCount += 1;
  1700. }
  1701. string prebill = "ltb";
  1702. for (int idx = 1; idx <= 1; idx++)
  1703. {
  1704. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1705. string billoid = prebill + idx + dtstr;
  1706. bill_entity.billOrderId += billoid;
  1707. if (idx < billCount)
  1708. {
  1709. bill_entity.billOrderId += ",";
  1710. }
  1711. }
  1712. bill_entity.productId = GetPostInt("ProductName");
  1713. bill_entity.num = GetPostInt("num");
  1714. bill_entity.unit = GetPostString("unit");
  1715. bill_entity.type = GetPostString("type");
  1716. bill_entity.sendType = GetPostString("SendType");
  1717. bill_entity.email = GetPostString("email");
  1718. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1719. bill_entity.shopName = GetPostString("ShopName");
  1720. bill_entity.applymemo = GetPostString("applyMemo");
  1721. bill_entity.createTime = DateTime.Now;
  1722. bill_entity.state = 0;
  1723. bill_entity.userId = CurrentUser.UserID;
  1724. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1725. bill_entity.Create();
  1726. }
  1727. catch (Exception ex)
  1728. {
  1729. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1730. returnErrorMsg("创建发票出错!");
  1731. return;
  1732. }
  1733. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1734. returnSuccessMsg("发票申请成功!");
  1735. return;
  1736. }
  1737. returnErrorMsg("找不到记录");
  1738. }
  1739. }
  1740. public void ins_erp_neworder()
  1741. {
  1742. if (UrlPostParmsCheck("receiver_name"))
  1743. {
  1744. CeErpTrade entity = new CeErpTrade();
  1745. string plat_form = GetPostString("platform");
  1746. string preStr = "N_";
  1747. if (plat_form == "拼多多")
  1748. {
  1749. preStr = "P_";
  1750. }
  1751. else if (plat_form == "阿里巴巴")
  1752. {
  1753. preStr = "A_";
  1754. }
  1755. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1756. entity.seller_nick = GetPostString("seller_nick");
  1757. entity.buyer_nick = GetPostString("buyer_nick");
  1758. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1759. entity.total_fee = entity.payment;
  1760. entity.pay_time = DateTime.Now;
  1761. entity.status = "NOT_SHIPPED";
  1762. entity.receiver_name = GetPostString("receiver_name");
  1763. entity.receiver_mobile = GetPostString("receiver_mobile");
  1764. entity.receiver_state = GetPostString("receiver_state");
  1765. entity.receiver_city = GetPostString("receiver_city");
  1766. entity.receiver_district = GetPostString("receiver_district");
  1767. entity.receiver_address = GetPostString("receiver_address");
  1768. if (entity.receiver_state == "" || entity.receiver_city == "")
  1769. {
  1770. returnErrorMsg("收件地址不能为空");
  1771. return;
  1772. }
  1773. int shopId = 0;
  1774. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1775. if (nShop != null)
  1776. {
  1777. shopId = nShop.ID;
  1778. }
  1779. if (shopId != 34 && entity.payment == 0)
  1780. {
  1781. returnErrorMsg("公司自用的单金额才能为0");
  1782. return;
  1783. }
  1784. entity.Create();
  1785. CeErpTradeCell entitycell = new CeErpTradeCell();
  1786. entitycell.ctid = entity.tid;
  1787. entitycell.tid = entity.tid;
  1788. entitycell.ShopId = shopId;
  1789. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1790. entitycell.OrderState = 0;
  1791. entitycell.pay_time = entity.pay_time;
  1792. entitycell.IsOffLineOrder = 1;
  1793. entitycell.Create();
  1794. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1795. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1796. return;
  1797. }
  1798. }
  1799. public void ins_erp_neworder2()
  1800. {
  1801. if (UrlPostParmsCheck("receiver_name"))
  1802. {
  1803. //string plat_form = GetPostString("platform");
  1804. string preStr = "X_";
  1805. string memo = GetPostString("memo");
  1806. string productId = GetPostString("productId");
  1807. string primg = GetPostString("proofimg");
  1808. string sellerNick = GetPostString("seller_nick");
  1809. string addFrom = GetPostString("addfrom");
  1810. if (addFrom == "1")
  1811. {
  1812. preStr = "N_";
  1813. }
  1814. int shopId = 0;
  1815. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1816. if (nShop != null)
  1817. {
  1818. shopId = nShop.ID;
  1819. }
  1820. else
  1821. {
  1822. returnErrorMsg("找不到对应店铺");
  1823. return;
  1824. }
  1825. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1826. {
  1827. returnErrorMsg("必须上传付款凭证");
  1828. return;
  1829. }
  1830. CeErpTrade entity = new CeErpTrade();
  1831. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1832. entity.seller_nick = sellerNick;
  1833. entity.buyer_nick = GetPostString("buyer_nick");
  1834. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1835. entity.total_fee = entity.payment;
  1836. entity.pay_time = DateTime.Now;
  1837. entity.status = "NOT_SHIPPED";
  1838. entity.receiver_name = GetPostString("receiver_name");
  1839. entity.receiver_mobile = GetPostString("receiver_mobile");
  1840. entity.receiver_state = GetPostString("receiver_state");
  1841. entity.receiver_city = GetPostString("receiver_city");
  1842. entity.receiver_district = GetPostString("receiver_district");
  1843. entity.receiver_address = GetPostString("receiver_address");
  1844. entity.seller_memo = memo;
  1845. entity.orderFrom = 20;
  1846. entity.orderType = 15;
  1847. if (entity.receiver_state == "" || entity.receiver_city == "")
  1848. {
  1849. returnErrorMsg("收件地址不能为空");
  1850. return;
  1851. }
  1852. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1853. {
  1854. returnErrorMsg("公司自用的单金额才能为0");
  1855. return;
  1856. }
  1857. entity.Create();
  1858. string toWhere = GetPostString("towhere");
  1859. string oldOrder = GetPostString("oldOrder");
  1860. CeErpTradeCell entitycell = new CeErpTradeCell();
  1861. entitycell.ctid = entity.tid;
  1862. //唯一标识
  1863. entitycell.OrderSn = entity.tid;
  1864. string orderSn = commonHelper.generateDateTimeRandomNos();
  1865. if (orderSn != "")
  1866. {
  1867. entitycell.OrderSn = orderSn;
  1868. }
  1869. entitycell.tid = entity.tid;
  1870. //if (preStr == "X_")
  1871. //{
  1872. entitycell.IsOffLineOrder = 1;
  1873. if ("1".Equals(oldOrder))
  1874. {
  1875. entitycell.IsOldCustomer = 1;
  1876. }
  1877. //}
  1878. entitycell.CustomerUserId = CurrentUser.UserID;
  1879. entitycell.PayProofImg = primg;
  1880. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1881. entitycell.ProductId = Convert.ToInt32(productId);
  1882. entitycell.ShopId = shopId;
  1883. entitycell.UpdateTime = DateTime.Now;
  1884. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1885. if (entitycell.ProductId > 0)
  1886. {
  1887. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1888. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1889. {
  1890. entitycell.NewProduct = 1;
  1891. }
  1892. }
  1893. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1894. {
  1895. entitycell.IsXianHuo = 1;
  1896. }
  1897. entitycell.pay_time = entity.pay_time;
  1898. if (toWhere == "1")
  1899. {
  1900. entitycell.OrderState = 2;
  1901. }
  1902. else
  1903. {
  1904. entitycell.OrderState = 6;
  1905. entitycell.FinishPlaceTime = entitycell.pay_time;
  1906. }
  1907. if (shopId == 94)
  1908. {
  1909. entitycell.OrderState = 4;
  1910. entitycell.WaitDesignTime = entitycell.pay_time;
  1911. entitycell.StartDesignTime = entitycell.pay_time;
  1912. entitycell.DesignUserId = 218;
  1913. }
  1914. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114 && shopId != 158))
  1915. {
  1916. entitycell.OrderState = -1;//修改12-5
  1917. CeWithdraw ceWithdraw = new CeWithdraw();
  1918. ceWithdraw.tid = entity.tid;
  1919. ceWithdraw.providerid = "-1";
  1920. ceWithdraw.status = -1;
  1921. ceWithdraw.creationtime = DateTime.Now;
  1922. ceWithdraw.userid = 4634;
  1923. ceWithdraw.Create();
  1924. }
  1925. entitycell.Create();
  1926. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1927. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1928. {
  1929. addPlaceRegist(entitycell, CurrentUser.UserID);
  1930. }
  1931. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1932. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1933. return;
  1934. }
  1935. }
  1936. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1937. {
  1938. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1939. entity.PlactTime = tradecell.pay_time;
  1940. entity.AddUserId = userid;
  1941. entity.FileName = tradecell.seller_memo;
  1942. entity.Supplier = 24;
  1943. entity.CreateTime = DateTime.Now;
  1944. entity.Did = tradecell.ctid;
  1945. entity.tid = tradecell.tid;
  1946. entity.splitTag = tradecell.SplitTag;
  1947. entity.CurState = "未完成";
  1948. entity.Create();
  1949. }
  1950. public void get_erp_offlinelist()
  1951. {
  1952. DataStruct dStruct = GetPostStruct();
  1953. List<string> lw = new List<string>();
  1954. string tid = GetPostString("ctid");
  1955. string date1 = GetPostString("date1");
  1956. string date2 = GetPostString("date2");
  1957. if (tid.Length > 0 || date1.Length > 0)
  1958. {
  1959. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1960. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1961. if (dw.Length > 0) lw.Add(dw);
  1962. }
  1963. else
  1964. {
  1965. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1966. }
  1967. string shopname = GetPostString("shopname");
  1968. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1969. string buyernick = GetPostString("buyer_nick");
  1970. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1971. string customer = GetPostString("customer");
  1972. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1973. string design = GetPostString("design");
  1974. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1975. string orderState = GetPostString("orderState");
  1976. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1977. string address = GetPostString("address");
  1978. 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));
  1979. string sellermemo = GetPostString("seller_memo");
  1980. if (sellermemo.Length > 0)
  1981. {
  1982. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1983. }
  1984. string price1 = GetPostString("price1");
  1985. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1986. string price2 = GetPostString("price2");
  1987. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1988. //if (PKey != "admin")
  1989. //{
  1990. // string usershop = CurrentUser.User.pemShop;
  1991. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1992. //}
  1993. //if (ex_psize > 0)
  1994. //{
  1995. dStruct.Order = "pay_time desc";
  1996. //}
  1997. //else
  1998. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1999. lw.Add(string.Format("IsOffLineOrder=1"));
  2000. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2001. DataTable dt = null;
  2002. dt = WebCache.GetData("view_erptradecell", dStruct);
  2003. writeGridDataTableJson(dStruct.TotalCount, dt);
  2004. }
  2005. public void get_erp_returncashrecord()
  2006. {
  2007. DataStruct dStruct = GetPostStruct();
  2008. List<string> lw = new List<string>();
  2009. string tid = GetPostString("ctid");
  2010. if (tid.Length > 0)
  2011. {
  2012. lw.Add(string.Format("tid like '%{0}%'", tid));
  2013. dStruct.Order = "id desc";
  2014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2015. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2016. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2017. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2018. return;
  2019. }
  2020. returnErrorMsg("id数据错误!");
  2021. }
  2022. public void ins_erp_returncashrecord()
  2023. {
  2024. if (UrlPostParmsCheck("tid"))
  2025. {
  2026. string tid = GetPostString("tid");
  2027. string retype = GetPostString("type");
  2028. StringBuilder sql = new StringBuilder();
  2029. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2030. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2031. if (dt.Rows.Count > 0)
  2032. {
  2033. returnErrorMsg("相同返现类型记录已存在");
  2034. return;
  2035. }
  2036. CeErpReturnCash entity = new CeErpReturnCash();
  2037. entity.tid = tid;
  2038. entity.seller_nick = GetPostString("seller_nick");
  2039. string pment = GetPostString("payment");
  2040. if (pment.Length > 0)
  2041. {
  2042. entity.payment = Convert.ToDouble(pment);
  2043. }
  2044. entity.buyer_nick = GetPostString("buyer_nick");
  2045. entity.cashstate = 0;
  2046. entity.rtype = retype;
  2047. string rPrice = GetPostString("returnprice");
  2048. if (rPrice.Length > 0)
  2049. {
  2050. entity.returnprice = Convert.ToDouble(rPrice);
  2051. }
  2052. entity.created = DateTime.Now;
  2053. entity.con = GetPostString("con");
  2054. entity.img = GetPostString("img");
  2055. entity.applyuserid = CurrentUser.UserID;
  2056. entity.Create();
  2057. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2058. returnSuccessMsg("操作成功!");
  2059. return;
  2060. }
  2061. }
  2062. public void set_erp_predelivery()
  2063. {
  2064. if (UrlPostParmsCheck("ctid"))
  2065. {
  2066. string eid = GetPostString("ctid");
  2067. CeErpTradeCell entity = null;
  2068. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2069. if (entity != null)
  2070. {
  2071. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2072. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2073. //{
  2074. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2075. // return;
  2076. //}
  2077. entity.IsPreDelivery = 1;
  2078. entity.Update();
  2079. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2080. returnSuccessMsg("预发货成功!");
  2081. return;
  2082. //string shop = GetPostString("seller_nick");
  2083. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2084. //string comName = GetPostString("comName");
  2085. //string comCode = GetPostString("comCode");
  2086. //string outSid = GetPostString("outSid");//运单号
  2087. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2088. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2089. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2090. //string apires = "";
  2091. //if (deliveryType == "虚拟发货")
  2092. //{
  2093. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2094. //}
  2095. //else
  2096. //{
  2097. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2098. //}
  2099. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2100. ////{
  2101. //if (apires.IndexOf("发货成功") != -1)
  2102. //{
  2103. // if (deliveryType != "虚拟发货")
  2104. // {
  2105. // //还要插入快递信息到 快递信息表
  2106. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2107. // exinfo.tid = eid;
  2108. // exinfo.out_sid = outSid;
  2109. // exinfo.company_code = comCode;
  2110. // exinfo.company_name = comName;
  2111. // exinfo.delivery_memo = deliveryMemo;
  2112. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2113. // exinfo.deliveryType = deliveryType;
  2114. // exinfo.Create();
  2115. // }
  2116. // returnSuccessMsg("发货成功!");
  2117. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2118. //}
  2119. //else
  2120. //{
  2121. // returnErrorMsg("淘宝发货失败!!");
  2122. //}
  2123. //return;
  2124. }
  2125. returnErrorMsg("找不到订单记录");
  2126. }
  2127. }
  2128. public void get_erp_unusuallist()
  2129. {
  2130. DataStruct dStruct = GetPostStruct();
  2131. List<string> lw = new List<string>();
  2132. string tid = GetPostString("ctid");
  2133. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2134. string shopname = GetPostString("shopname");
  2135. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2136. string buyernick = GetPostString("buyer_nick");
  2137. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2138. string ResponsibleMan = GetPostString("responsible");
  2139. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2140. string date1 = GetPostString("date1");
  2141. string date2 = GetPostString("date2");
  2142. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2143. if (dw.Length > 0) lw.Add(dw);
  2144. string price1 = GetPostString("price1");
  2145. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2146. string price2 = GetPostString("price2");
  2147. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2148. string orderState = GetPostString("orderState");
  2149. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2150. string sellermemo = GetPostString("seller_memo");
  2151. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2152. lw.Add(string.Format("UnusualTag > 0"));
  2153. lw.Add(string.Format("IsRefund<={0}", 1));
  2154. dStruct.Order = "pay_time desc";
  2155. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2156. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2157. writeGridDataTableJson(dStruct.TotalCount, dt);
  2158. }
  2159. public void set_erp_unusualtonomal()
  2160. {
  2161. if (UrlPostParmsCheck("ctid"))
  2162. {
  2163. string eid = GetPostString("ctid");
  2164. CeErpTradeCell entity = null;
  2165. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2166. if (entity != null)
  2167. {
  2168. entity.UnusualTag = -1;
  2169. entity.Update();
  2170. returnSuccessMsg("忽略成功!");
  2171. return;
  2172. }
  2173. returnErrorMsg("找不到记录");
  2174. }
  2175. }
  2176. public void ins_erp_unusualreason()
  2177. {
  2178. if (UrlPostParmsCheck("ctid"))
  2179. {
  2180. string eid = GetPostString("ctid");
  2181. CeErpTradeCell entity = null;
  2182. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2183. if (entity != null)
  2184. {
  2185. entity.MemoOpt = 4;
  2186. entity.UnusualCon = GetPostString("con");
  2187. entity.Update();
  2188. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2189. if (trade != null)
  2190. {
  2191. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2192. }
  2193. //查货是否超时
  2194. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2195. if (ceErpTradeCellExtend == null)
  2196. {
  2197. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2198. ceErpTradeCellExtend.ctid = entity.ctid;
  2199. }
  2200. if (ceErpTradeCellExtend.CheckTime != null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2201. {
  2202. ceErpTradeCellExtend.CheckOut += 1;
  2203. }
  2204. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2205. if (ceErpTradeCellExtend.ID > 0)
  2206. {
  2207. ceErpTradeCellExtend.Update();
  2208. }
  2209. else
  2210. {
  2211. ceErpTradeCellExtend.Create();
  2212. }
  2213. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2214. returnSuccessMsg("操作成功!");
  2215. return;
  2216. }
  2217. returnErrorMsg("找不到记录");
  2218. }
  2219. }
  2220. public void upd_erp_sampleorder()
  2221. {
  2222. if (UrlPostParmsCheck("ctid"))
  2223. {
  2224. string eid = GetPostString("ctid");
  2225. string[] eArr = eid.Split(',');
  2226. if (eArr.Length > 1)
  2227. {
  2228. List<string> eLst = new List<string>();
  2229. for (int i = 0; i < eArr.Length; i++)
  2230. {
  2231. eLst.Add("'" + eArr[i] + "'");
  2232. }
  2233. eid = string.Join(",", eLst.ToArray());
  2234. }
  2235. else
  2236. {
  2237. eid = "'" + eid + "'";
  2238. }
  2239. StringBuilder sql = new StringBuilder();
  2240. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2241. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2242. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2243. if (dt.Rows.Count > 0)
  2244. {
  2245. string errmsg = "";
  2246. foreach (DataRow dr in dt.Rows)
  2247. {
  2248. StringBuilder sqlsb = new StringBuilder();
  2249. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2250. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2251. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2252. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2253. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2254. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2255. {
  2256. continue;
  2257. }
  2258. else
  2259. {
  2260. string emsg = commonHelper.KeepChinese(apires);
  2261. errmsg += emsg;
  2262. }*/
  2263. }
  2264. if (errmsg.Length > 0)
  2265. {
  2266. returnErrorMsg(errmsg);
  2267. return;
  2268. }
  2269. returnSuccessMsg("操作成功");
  2270. return;
  2271. }
  2272. returnErrorMsg("找不到记录");
  2273. }
  2274. }
  2275. public void upd_erp_transcustomer()
  2276. {
  2277. if (UrlPostParmsCheck("ctid"))
  2278. {
  2279. string eid = GetPostString("ctid");
  2280. int userid = GetPostInt("CustomerUserId");
  2281. CeErpTradeCell entity = null;
  2282. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2283. if (entity != null)
  2284. {
  2285. //string[] mlist = entity.seller_memo.Split('-');
  2286. //string sql = "select * from view_erpuser where id=" + userid;
  2287. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2288. //if (dt != null && dt.Rows.Count > 0)
  2289. //{
  2290. // string nmemo = "";
  2291. // for(int i = 0; i < mlist.Length - 1; i++)
  2292. // {
  2293. // nmemo += mlist[i];
  2294. // nmemo += "-";
  2295. // }
  2296. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2297. // entity.seller_memo = nmemo;
  2298. //}
  2299. entity.CustomerUserId = userid;
  2300. entity.Update();
  2301. returnSuccessMsg("操作成功!");
  2302. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2303. return;
  2304. }
  2305. returnErrorMsg("找不到记录");
  2306. }
  2307. }
  2308. public void upd_erp_transdesigner()
  2309. {
  2310. if (UrlPostParmsCheck("ctid"))
  2311. {
  2312. string eids = GetPostString("ctid");
  2313. string[] ctidList = eids.Split(',');
  2314. int userid = GetPostInt("DesignUserId");
  2315. foreach (string ctid in ctidList)
  2316. {
  2317. CeErpTradeCell entity = null;
  2318. CeErpDesignerBill entitys = null;
  2319. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2320. entitys = CeErpDesignerBill.GetByTid(ctid);
  2321. if (entity != null)
  2322. {
  2323. if (entity.OrderState > 4)
  2324. {
  2325. continue;
  2326. }
  2327. //存在退款不能流转
  2328. if (entity.IsRefund > 0)
  2329. {
  2330. continue;
  2331. }
  2332. entity.DesignUserId = userid;
  2333. entity.WaitDesignTime = DateTime.Now;
  2334. entity.Update();
  2335. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2336. }
  2337. }
  2338. returnSuccessMsg("操作成功!");
  2339. }
  2340. }
  2341. public void upd_erp_distributedesigner()
  2342. {
  2343. if (UrlPostParmsCheck("ctid"))
  2344. {
  2345. string eid = GetPostString("ctid");
  2346. int userid = GetPostInt("DesignUserId");
  2347. string reason = GetPostString("reason");
  2348. string[] idlist = eid.Split(',');
  2349. if (idlist.Length <= 0)
  2350. {
  2351. returnErrorMsg("订单不能为空");
  2352. return;
  2353. }
  2354. foreach (string ctid in idlist)
  2355. {
  2356. CeErpTradeCell entity = null;
  2357. CeErpDesignerBill entitys = null;
  2358. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2359. else continue;
  2360. if (entity != null)
  2361. {
  2362. if (userid == 2125 || userid == 3542)
  2363. { }
  2364. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2365. {
  2366. returnErrorMsg("金额错误的订单无法指派");
  2367. return;
  2368. }
  2369. if (entity.OrderState >= 5)
  2370. {
  2371. returnErrorMsg("已经设计完成无法指派");
  2372. return;
  2373. }
  2374. if (entity.OrderState == -1)
  2375. {
  2376. returnErrorMsg("审核中的订单无法指派");
  2377. return;
  2378. }
  2379. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2380. {
  2381. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2382. return;
  2383. }
  2384. List<int> userIds = new List<int>()
  2385. {
  2386. 157 ,159 ,1479 ,73
  2387. };
  2388. //157赖橙帆 159林晨 73 静之颖
  2389. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && !userIds.Contains(CurrentUser.UserID))
  2390. {
  2391. returnErrorMsg("指派设计共创无法再次指派!");
  2392. return;
  2393. }
  2394. entity.OrderState = 3;
  2395. if (entity.SupplierId == 0)
  2396. {
  2397. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2398. entity.SupplierId = suid;
  2399. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2400. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2401. }
  2402. if (userid == 2125 && entity.seller_memo != "")
  2403. {
  2404. //apiDesign.API_GetPrintData_CreateOrder(entity);
  2405. }
  2406. List<int> shopIds = new List<int>() { 17, 21, 52, 54, 64, 63, 66, 49, 67, 105, 35, 57, 53, 65, 87, 140, 26, 45, 2, 77, 122, 121, 153, 154, 158 };
  2407. if (userid == 3542 && entity.seller_memo != "")
  2408. {
  2409. string userPost = CurrentUser.UserPost.Post.Code;
  2410. if (CurrentUser.UserID == 4516 || CurrentUser.UserID == 159 || CurrentUser.UserID == 157 || shopIds.Contains(entity.ShopId))
  2411. {
  2412. userPost = "SysAdmin";
  2413. }
  2414. if (CurrentUser.UserID == 159 || CurrentUser.UserID == 157)
  2415. {
  2416. saveAssignLog(reason, entity);
  2417. }
  2418. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2419. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2420. if (response.msg != "设计共创:成功")
  2421. {
  2422. returnErrorMsg(response.msg);
  2423. return;
  2424. }
  2425. entity.DispatchSort = 2;
  2426. }
  2427. else
  2428. {
  2429. if (entity.DispatchSort == 2)
  2430. {
  2431. ApiVo apiVo = new ApiVo();
  2432. apiVo.actionName = "closeDesign";
  2433. apiVo.orderNumber = entity.ctid;
  2434. designHelper.API_WorkCore(apiVo);//closeDesign
  2435. }
  2436. entity.DispatchSort = 0;
  2437. }
  2438. entity.DesignUserId = userid;
  2439. entity.WaitDesignTime = DateTime.Now;
  2440. entity.UpdateTime = DateTime.Now;
  2441. entity.Update();
  2442. string name = commonHelper.getUserNameById(userid);
  2443. commonHelper.UpdateRelationOrder(entity.ctid);
  2444. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2445. }
  2446. }
  2447. returnSuccessMsg("操作成功!");
  2448. return;
  2449. }
  2450. }
  2451. public string getTidByCtid(string ctid)
  2452. {
  2453. string tid = "";
  2454. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2455. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2456. if (dataTable != null && dataTable.Rows.Count > 0)
  2457. {
  2458. tid = dataTable.Rows[0]["tid"].ToString();
  2459. }
  2460. return tid;
  2461. }
  2462. public List<string> getTidByCtidMore(string ctid)
  2463. {
  2464. 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);
  2465. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2466. List<string> list = new List<string>();
  2467. if (dataTable != null && dataTable.Rows.Count > 0)
  2468. {
  2469. foreach (DataRow item in dataTable.Rows)
  2470. {
  2471. list.Add("'" + item["tid"].ToString() + "'");
  2472. }
  2473. }
  2474. return list;
  2475. }
  2476. public List<string> getTidByCtidLike(string ctid)
  2477. {
  2478. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2479. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2480. List<string> list = new List<string>();
  2481. if (dataTable != null && dataTable.Rows.Count > 0)
  2482. {
  2483. foreach (DataRow item in dataTable.Rows)
  2484. {
  2485. list.Add("'" + item["tid"].ToString() + "'");
  2486. }
  2487. }
  2488. return list;
  2489. }
  2490. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2491. {
  2492. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2493. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2494. List<string> list = new List<string>();
  2495. if (dataTable != null && dataTable.Rows.Count > 0)
  2496. {
  2497. foreach (DataRow item in dataTable.Rows)
  2498. {
  2499. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2500. {
  2501. continue;
  2502. }
  2503. list.Add("'" + item["receiverId"].ToString() + "'");
  2504. }
  2505. }
  2506. return list;
  2507. }
  2508. public void get_erp_myorderlist()
  2509. {
  2510. DataStruct dStruct = GetPostStruct();
  2511. List<string> lw = new List<string>();
  2512. string tid = GetPostString("ctid");
  2513. if (tid.Length > 0)
  2514. {
  2515. string select_tid = getTidByCtid(tid);
  2516. lw.Add(string.Format("tid='{0}'", select_tid));
  2517. }
  2518. else
  2519. {
  2520. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2521. }
  2522. //12-1 修改
  2523. string urgent = GetPostString("urgent");
  2524. string back = GetPostString("back");
  2525. string offlineSearch = GetPostString("offlineSearch");
  2526. if (!string.IsNullOrWhiteSpace(urgent))
  2527. {
  2528. if (urgent.Equals("true"))
  2529. {
  2530. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2531. }
  2532. }
  2533. if (!string.IsNullOrWhiteSpace(back))
  2534. {
  2535. if (back.Equals("true"))
  2536. {
  2537. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2538. }
  2539. }
  2540. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2541. {
  2542. if (offlineSearch.Equals("true"))
  2543. {
  2544. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2545. }
  2546. }
  2547. //end
  2548. string shopname = GetPostString("shopname");
  2549. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2550. string buyernick = GetPostString("buyer_nick");
  2551. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2552. string design = GetPostString("design");
  2553. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2554. string orderState = GetPostString("orderState");
  2555. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2556. string sellermemo = GetPostString("seller_memo");
  2557. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2558. string date1 = GetPostString("date1");
  2559. string date2 = GetPostString("date2");
  2560. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2561. if (dw.Length > 0) lw.Add(dw);
  2562. string price1 = GetPostString("price1");
  2563. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2564. string price2 = GetPostString("price2");
  2565. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2566. string urgency = GetPostString("urgency");
  2567. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2568. string after = GetPostString("after");
  2569. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2570. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2571. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2572. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2573. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2574. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2575. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2576. if (dt != null && dt.Rows.Count > 0)
  2577. {
  2578. foreach (DataRow dr in dt.Rows)
  2579. {
  2580. try
  2581. {
  2582. // 对象操作
  2583. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2584. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2585. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2586. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2587. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2588. if (dStruct.PageSize != 100000)
  2589. {
  2590. if (dr["DispatchSort"].ToString() == "2")
  2591. {
  2592. dr["gongchuang"] = 200;
  2593. }
  2594. else if ("外协".Equals(dr["ToType"].ToString()))
  2595. {
  2596. dr["gongchuang"] = 200;
  2597. }
  2598. else if ("内部".Equals(dr["ToType"].ToString()))
  2599. {
  2600. dr["gongchuang"] = -1;
  2601. }
  2602. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2603. {
  2604. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2605. dr["gongchuang"] = response.code;
  2606. }
  2607. }
  2608. }
  2609. catch (NullReferenceException ex)
  2610. {
  2611. }
  2612. }
  2613. }
  2614. writeGridDataTableJson(dStruct.TotalCount, dt);
  2615. }
  2616. public void get_erp_myreturnorderlist()
  2617. {
  2618. DataStruct dStruct = GetPostStruct();
  2619. List<string> lw = new List<string>();
  2620. string tid = GetPostString("ctid");
  2621. if (tid.Length > 0)
  2622. {
  2623. string select_tid = getTidByCtid(tid);
  2624. lw.Add(string.Format("tid='{0}'", select_tid));
  2625. }
  2626. else
  2627. {
  2628. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2629. }
  2630. string shopname = GetPostString("shopname");
  2631. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2632. string buyernick = GetPostString("buyer_nick");
  2633. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2634. string design = GetPostString("design");
  2635. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2636. string orderState = GetPostString("orderState");
  2637. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2638. string sellermemo = GetPostString("seller_memo");
  2639. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2640. string date1 = GetPostString("date1");
  2641. string date2 = GetPostString("date2");
  2642. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2643. if (dw.Length > 0) lw.Add(dw);
  2644. string price1 = GetPostString("price1");
  2645. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2646. string price2 = GetPostString("price2");
  2647. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2648. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2649. {
  2650. lw.Add(string.Format("CusOrgID = 94"));
  2651. }
  2652. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2653. {
  2654. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2655. }
  2656. else
  2657. {
  2658. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2659. }
  2660. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2661. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2662. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2663. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2664. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2665. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2666. if (dt != null && dt.Rows.Count > 0)
  2667. {
  2668. foreach (DataRow dr in dt.Rows)
  2669. {
  2670. try
  2671. {
  2672. // 对象操作
  2673. if (dStruct.PageSize != 100000)
  2674. {
  2675. if (dr["DispatchSort"].ToString() == "2")
  2676. {
  2677. dr["gongchuang"] = 200;
  2678. }
  2679. else if ("外协".Equals(dr["ToType"].ToString()))
  2680. {
  2681. dr["gongchuang"] = 200;
  2682. }
  2683. else if ("内部".Equals(dr["ToType"].ToString()))
  2684. {
  2685. dr["gongchuang"] = -1;
  2686. }
  2687. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2688. {
  2689. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2690. dr["gongchuang"] = response.code;
  2691. }
  2692. }
  2693. }
  2694. catch (NullReferenceException ex)
  2695. {
  2696. // 处理空引用异常
  2697. }
  2698. }
  2699. }
  2700. writeGridDataTableJson(dStruct.TotalCount, dt);
  2701. }
  2702. public void get_erp_myorderlist_pregather()
  2703. {
  2704. string date1 = GetPostString("date1");
  2705. string date2 = GetPostString("date2");
  2706. int userId = CurrentUser.UserID; //客服id
  2707. string orderWhere = "";
  2708. List<string> lw = new List<string>();
  2709. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2710. if (dw.Length > 0) lw.Add(dw);
  2711. lw.Add(string.Format("CustomerUserId={0}", userId));
  2712. lw.Add(string.Format("OrderState<9"));
  2713. orderWhere = string.Join(" and ", lw.ToArray());
  2714. string orderWhere2 = "";
  2715. List<string> lw2 = new List<string>();
  2716. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2717. if (dw2.Length > 0) lw2.Add(dw2);
  2718. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2719. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2720. string sql = string.Format("select *" +
  2721. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2722. "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 " +
  2723. "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 " +
  2724. "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");
  2725. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2726. //writeGridDataTableJson(dt.Rows.Count, dt);
  2727. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2728. }
  2729. public void upd_erp_publishorder()
  2730. {
  2731. if (UrlPostParmsCheck("ctid"))
  2732. {
  2733. string eid = GetPostString("ctid");
  2734. CeErpTradeCell entity = null;
  2735. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2736. if (entity != null)
  2737. {
  2738. entity.OrderState = 0; //发布后,变为待抢单
  2739. entity.Update();
  2740. commonHelper.UpdateRelationOrder(entity.ctid);
  2741. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2742. returnSuccessMsg("发布成功!");
  2743. return;
  2744. }
  2745. returnErrorMsg("找不到记录");
  2746. }
  2747. }
  2748. public void get_erp_my_tiporder()
  2749. {
  2750. StringBuilder sql = new StringBuilder();
  2751. int userId = 0;
  2752. if (CurrentUser != null) userId = CurrentUser.UserID;
  2753. string posCode = CurrentUser.UserPost.Post.Code;
  2754. string isTipedAfterSaleVerify = GetPostString("af");
  2755. DataTable dt = new DataTable();
  2756. if (posCode != "Supplier")
  2757. {
  2758. if (posCode == "CustomerService" || posCode == "Director")
  2759. {
  2760. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2761. }
  2762. else if (posCode == "Place" || posCode == "PlaceMr")
  2763. {
  2764. }
  2765. else
  2766. {
  2767. string teamIds = CurrentUser.User.TeamIds;
  2768. if (teamIds == "")
  2769. {
  2770. teamIds = "0";
  2771. }
  2772. 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);
  2773. }
  2774. if (sql.Length > 0)
  2775. {
  2776. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2777. }
  2778. }
  2779. if (dt.Rows.Count <= 0)
  2780. {
  2781. string key = "aftersale_order_" + userId;
  2782. if (RedisHelper.HasKey(key))
  2783. {
  2784. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2785. dt.Columns.Add("ctid", typeof(string));
  2786. dt.Columns.Add("IsReadTag", typeof(int));
  2787. foreach (var i in list)
  2788. {
  2789. DataRow data = dt.NewRow();
  2790. data["ctid"] = i;
  2791. data["IsReadTag"] = 4;
  2792. dt.Rows.Add(data);
  2793. }
  2794. RedisHelper.StringDelete(key);
  2795. }
  2796. }
  2797. if (dt.Rows.Count <= 0)
  2798. {
  2799. sql = new StringBuilder();
  2800. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2801. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2802. }
  2803. if (posCode == "Supplier")
  2804. {
  2805. string ids = CurrentUser.User.pemVend;
  2806. if (ids != null && ids.Length > 0)
  2807. {
  2808. string[] ids_list = ids.Split(',');
  2809. foreach (var item in ids_list)
  2810. {
  2811. string key = "return_order_" + item;
  2812. if (RedisHelper.HasKey(key))
  2813. {
  2814. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2815. dt.Columns.Add("ctid", typeof(string));
  2816. dt.Columns.Add("IsReadTag", typeof(int));
  2817. foreach (var i in list)
  2818. {
  2819. DataRow data = dt.NewRow();
  2820. data["ctid"] = i;
  2821. data["IsReadTag"] = 1;
  2822. dt.Rows.Add(data);
  2823. }
  2824. RedisHelper.StringDelete(key);
  2825. }
  2826. }
  2827. }
  2828. if (dt.Rows.Count <= 0)
  2829. {
  2830. sql = new StringBuilder();
  2831. 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);
  2832. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2833. }
  2834. }
  2835. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2836. }
  2837. public void reset_erp_tiporder()
  2838. {
  2839. string ids = GetPostString("ids");
  2840. string[] ctidList = ids.Split(',');
  2841. foreach (string ctid in ctidList)
  2842. {
  2843. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2844. if (enty != null)
  2845. {
  2846. enty.IsReadTag = 0;
  2847. enty.Update();
  2848. }
  2849. }
  2850. returnSuccessMsg("成功!");
  2851. return;
  2852. }
  2853. public void get_erp_designlist()
  2854. {
  2855. DataStruct dStruct = GetPostStruct();
  2856. List<string> lw = new List<string>();
  2857. string tid = GetPostString("ctid");
  2858. if (tid.Length > 0)
  2859. {
  2860. string select_tid = getTidByCtid(tid);
  2861. lw.Add(string.Format("tid='{0}'", select_tid));
  2862. }
  2863. string shopname = GetPostString("shopname");
  2864. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2865. string buyernick = GetPostString("buyer_nick");
  2866. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2867. string customer = GetPostString("customer");
  2868. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2869. string design = GetPostString("design");
  2870. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2871. string orderState = GetPostString("orderState");
  2872. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2873. lw.Add(string.Format("OrderState<6"));
  2874. string address = GetPostString("address");
  2875. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2876. string sellermemo = GetPostString("seller_memo");
  2877. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2878. string date1 = GetPostString("date1");
  2879. string date2 = GetPostString("date2");
  2880. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2881. if (dw.Length > 0) lw.Add(dw);
  2882. string apdate1 = GetPostString("apdate1");
  2883. string apdate2 = GetPostString("apdate2");
  2884. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2885. if (dwap.Length > 0) lw.Add(dwap);
  2886. string price1 = GetPostString("price1");
  2887. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2888. string price2 = GetPostString("price2");
  2889. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2890. string designTime = GetPostString("designtime");
  2891. if (designTime.Length > 0)
  2892. {
  2893. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2894. }
  2895. string usershop = CurrentUser.User.pemShop;
  2896. if (usershop.Length > 0)
  2897. {
  2898. lw.Add(string.Format("shopId in ({0})", usershop));
  2899. }
  2900. int myOrgid = CurrentUser.UserPost.OrgID;
  2901. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2902. if (myOrgCode.IndexOf("Designer") != -1)
  2903. {
  2904. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2905. {
  2906. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2907. }
  2908. else
  2909. {
  2910. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2911. }
  2912. }
  2913. else
  2914. {
  2915. string orgId = GetPostString("designerhd");
  2916. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2917. }
  2918. if (tid.Length > 0 || buyernick.Length > 0)
  2919. {
  2920. lw.Add(string.Format("OrderState >= 3"));
  2921. }
  2922. else
  2923. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2924. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2925. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2926. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2927. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2928. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2929. if (dt != null && dt.Rows.Count > 0)
  2930. {
  2931. foreach (DataRow dr in dt.Rows)
  2932. {
  2933. try
  2934. {
  2935. // 对象操作
  2936. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2937. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2938. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2939. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2940. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2941. if (dStruct.PageSize != 100000)
  2942. {
  2943. if (dr["DispatchSort"].ToString() == "2")
  2944. {
  2945. dr["gongchuang"] = 200;
  2946. }
  2947. else if ("外协".Equals(dr["ToType"].ToString()))
  2948. {
  2949. dr["gongchuang"] = 200;
  2950. }
  2951. else if ("内部".Equals(dr["ToType"].ToString()))
  2952. {
  2953. dr["gongchuang"] = -1;
  2954. }
  2955. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2956. {
  2957. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2958. dr["gongchuang"] = response.code;
  2959. }
  2960. }
  2961. }
  2962. catch (NullReferenceException ex)
  2963. {
  2964. }
  2965. }
  2966. }
  2967. writeGridDataTableJson(dStruct.TotalCount, dt);
  2968. }
  2969. public void get_erp_mydesignlist()
  2970. {
  2971. DataStruct dStruct = GetPostStruct();
  2972. List<string> lw = new List<string>();
  2973. string tid = GetPostString("ctid");
  2974. if (tid.Length > 0)
  2975. {
  2976. string select_tid = getTidByCtid(tid);
  2977. lw.Add(string.Format("tid='{0}'", select_tid));
  2978. }
  2979. string shopname = GetPostString("shopname");
  2980. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2981. string buyernick = GetPostString("buyer_nick");
  2982. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2983. string customer = GetPostString("customer");
  2984. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2985. string orderState = GetPostString("orderState");
  2986. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2987. //lw.Add(string.Format("OrderState<6"));
  2988. string date1 = GetPostString("date1");
  2989. string date2 = GetPostString("date2");
  2990. string dw = GetDateWhere("pay_time", date1, date2);
  2991. if (dw.Length > 0) lw.Add(dw);
  2992. string apdate1 = GetPostString("apdate1");
  2993. string apdate2 = GetPostString("apdate2");
  2994. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2995. if (dwap.Length > 0) lw.Add(dwap);
  2996. string price1 = GetPostString("price1");
  2997. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2998. string price2 = GetPostString("price2");
  2999. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3000. string olddownload = GetPostString("olddown");
  3001. if (olddownload == "1")
  3002. {
  3003. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  3004. }
  3005. else if (olddownload == "2")
  3006. {
  3007. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  3008. }
  3009. string sellermemo = GetPostString("seller_memo");
  3010. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3011. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  3012. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  3013. {
  3014. if (CurrentUser.User.TeamIds.Length > 0)
  3015. {
  3016. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  3017. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3018. else
  3019. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3020. }
  3021. else
  3022. {
  3023. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3024. }
  3025. }
  3026. if (tid.Length <= 0)
  3027. {
  3028. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3029. }
  3030. lw.Add(string.Format("IsReturn!=3"));
  3031. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3032. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3033. string teamids = CurrentUser.User.TeamIds.ToString();
  3034. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3035. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3036. if (dt != null && dt.Rows.Count > 0)
  3037. {
  3038. foreach (DataRow dr in dt.Rows)
  3039. {
  3040. try
  3041. {
  3042. // 对象操作
  3043. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3044. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3045. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3046. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3047. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3048. if (dStruct.PageSize != 100000)
  3049. {
  3050. if (dr["DispatchSort"].ToString() == "2")
  3051. {
  3052. dr["gongchuang"] = 200;
  3053. }
  3054. else if ("外协".Equals(dr["ToType"].ToString()))
  3055. {
  3056. dr["gongchuang"] = 200;
  3057. }
  3058. else if ("内部".Equals(dr["ToType"].ToString()))
  3059. {
  3060. dr["gongchuang"] = -1;
  3061. }
  3062. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3063. {
  3064. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3065. dr["gongchuang"] = response.code;
  3066. }
  3067. }
  3068. }
  3069. catch (NullReferenceException ex)
  3070. {
  3071. }
  3072. }
  3073. }
  3074. writeGridDataTableJson(dStruct.TotalCount, dt);
  3075. }
  3076. public void set_erp_startdesign()
  3077. {
  3078. if (UrlPostParmsCheck("ctid"))
  3079. {
  3080. string eid = GetPostString("ctid");
  3081. CeErpTradeCell entity = null;
  3082. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3083. if (entity != null)
  3084. {
  3085. if (entity.OrderState != 3)
  3086. {
  3087. returnErrorMsg("请刷新,订单已经设计了");
  3088. return;
  3089. }
  3090. entity.StartDesignTime = DateTime.Now;
  3091. entity.OrderState = 4;
  3092. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3093. {
  3094. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3095. entity.SupplierId = suid;
  3096. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3097. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3098. }
  3099. entity.UpdateTime = DateTime.Now;
  3100. //entity.MakeSupplier = suname;
  3101. entity.Update();
  3102. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3103. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3104. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3105. commonHelper.getCytPrice(entity);
  3106. returnSuccessMsg("操作成功!");
  3107. return;
  3108. }
  3109. returnErrorMsg("找不到记录");
  3110. }
  3111. }
  3112. public void ins_erp_designselfmemo()
  3113. {
  3114. if (UrlPostParmsCheck("ctid"))
  3115. {
  3116. string eid = GetPostString("ctid");
  3117. string con = GetPostString("con");
  3118. CeErpTradeCell entity = null;
  3119. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3120. if (entity != null)
  3121. {
  3122. entity.DesignSelfMemo = con;
  3123. entity.Update();
  3124. returnSuccessMsg("操作成功!");
  3125. return;
  3126. }
  3127. returnErrorMsg("找不到记录");
  3128. }
  3129. }
  3130. public void ins_erp_designprice()
  3131. {
  3132. if (UrlPostParmsCheck("ctid"))
  3133. {
  3134. string eid = GetPostString("ctid");
  3135. int uid = CurrentUser.UserID;
  3136. string userName = CurrentUser.UserName;
  3137. CeErpTradeCell entity = null;
  3138. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3139. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3140. if (entitys == null)
  3141. {
  3142. entitys = new CeErpDesignerBill();
  3143. }
  3144. if (entity != null)
  3145. {
  3146. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3147. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3148. entity.StartDesignTime = DateTime.Now;
  3149. entity.OrderState = 4;
  3150. string suname = "";
  3151. if (entity.SupplierId == 0)
  3152. {
  3153. int sid = commonHelper.autoDistributeToSupplier(entity);
  3154. entity.SupplierId = sid;
  3155. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3156. }
  3157. entity.Update();
  3158. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3159. if (ceErpUserPost != null)
  3160. {
  3161. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3162. if (ceErpPost != null)
  3163. {
  3164. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3165. {
  3166. entitys.tid = entity.ctid;
  3167. entitys.oid = entity.tid;
  3168. entitys.uid = uid;
  3169. entitys.userName = userName;
  3170. entitys.designerType = 1;
  3171. entitys.designerTypeText = "内部设计师";
  3172. entitys.price = Convert.ToDouble(GetPostString("price"));
  3173. entitys.designNum = GetPostInt("designNum");
  3174. entitys.modifyNum = GetPostInt("modifyNum");
  3175. entitys.designSize = GetPostString("designSize");
  3176. entitys.modifySize = GetPostString("modifySize");
  3177. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3178. {
  3179. entitys.create_time = DateTime.Now;
  3180. entitys.create_u_id = uid;
  3181. entitys.create_u_name = userName;
  3182. entitys.Save();
  3183. }
  3184. else
  3185. {
  3186. entitys.update_time = DateTime.Now;
  3187. entitys.update_u_id = uid;
  3188. entitys.update_u_name = userName;
  3189. entitys.Update();
  3190. }
  3191. }
  3192. }
  3193. }
  3194. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3195. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3196. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3197. if (suname != "")
  3198. {
  3199. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3200. }
  3201. commonHelper.getCytPrice(entity);
  3202. returnSuccessMsg("操作成功!");
  3203. return;
  3204. }
  3205. returnErrorMsg("找不到记录");
  3206. }
  3207. }
  3208. public void upload_erp_filecomplete()
  3209. {
  3210. if (UrlPostParmsCheck("ctid"))
  3211. {
  3212. string eid = GetPostString("ctid");
  3213. CeErpTradeCell entity = null;
  3214. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3215. if (entity != null)
  3216. {
  3217. entity.OrderState = 5; //设计完成
  3218. entity.Update();
  3219. returnSuccessMsg(eid + "上传成功,设计完成!");
  3220. return;
  3221. }
  3222. returnErrorMsg("找不到订单记录");
  3223. }
  3224. }
  3225. public void get_erp_designovertimelist()
  3226. {
  3227. DataStruct dStruct = GetPostStruct();
  3228. List<string> lw = new List<string>();
  3229. string tid = GetPostString("ctid");
  3230. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3231. string shopname = GetPostString("shopname");
  3232. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3233. string buyernick = GetPostString("buyer_nick");
  3234. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3235. string ResponsibleMan = GetPostString("responsible");
  3236. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3237. string date1 = GetPostString("date1");
  3238. string date2 = GetPostString("date2");
  3239. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3240. if (dw.Length > 0) lw.Add(dw);
  3241. string price1 = GetPostString("price1");
  3242. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3243. string price2 = GetPostString("price2");
  3244. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3245. string orderState = GetPostString("orderState");
  3246. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3247. string sellermemo = GetPostString("seller_memo");
  3248. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3249. lw.Add(string.Format("UnusualTag=3"));
  3250. lw.Add(string.Format("IsRefund<={0}", 1));
  3251. dStruct.Order = "WaitDesignTime desc";
  3252. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3253. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3254. writeGridDataTableJson(dStruct.TotalCount, dt);
  3255. }
  3256. //设计管理 获取抢单大厅列表
  3257. public void get_erp_grabinglist()
  3258. {
  3259. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3260. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3261. bool oldOrder = false;
  3262. if (org != null)
  3263. {
  3264. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3265. }
  3266. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3267. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3268. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3269. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3270. //先处理订单数据
  3271. if (dt.Rows.Count > 0)
  3272. {
  3273. Dictionary<string, int> design = null;
  3274. int count = 0;
  3275. foreach (DataRow row in dt.Rows)
  3276. {
  3277. if (map.ContainsKey(row["ShopId"].ToString()))
  3278. {
  3279. map.TryGetValue(row["ShopId"].ToString(), out design);
  3280. }
  3281. else
  3282. {
  3283. design = new Dictionary<string, int>();
  3284. }
  3285. if (design.ContainsKey(row["ProductId"].ToString()))
  3286. {
  3287. design.TryGetValue(row["ProductId"].ToString(), out count);
  3288. }
  3289. count++;
  3290. design[row["ProductId"].ToString()] = count;
  3291. map[row["ShopId"].ToString()] = design;
  3292. }
  3293. }
  3294. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3295. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3296. //把店铺排序和技能排序分类
  3297. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3298. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3299. if (design_dt.Rows.Count > 0)
  3300. {
  3301. Dictionary<string, string> design = null;
  3302. List<string> shopIds = null;
  3303. foreach (DataRow row in design_dt.Rows)
  3304. {
  3305. if ("0".Equals(row["designId"].ToString()))
  3306. {
  3307. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3308. {
  3309. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3310. }
  3311. else
  3312. {
  3313. shopIds = new List<string>();
  3314. }
  3315. shopIds.Add(row["shopId"].ToString());
  3316. shop_orders[row["orders"].ToString()] = shopIds;
  3317. }
  3318. else
  3319. {
  3320. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3321. {
  3322. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3323. }
  3324. else
  3325. {
  3326. design = new Dictionary<string, string>();
  3327. }
  3328. design[row["orders"].ToString()] = row["designId"].ToString();
  3329. design_orders[row["shopId"].ToString()] = design;
  3330. }
  3331. }
  3332. //处理成key value后根据key排序
  3333. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3334. foreach (List<string> val in shop_orders.Values)
  3335. {
  3336. if (val != null)
  3337. {
  3338. foreach (string key in val)
  3339. {
  3340. if (design_orders.ContainsKey(key.ToString()))
  3341. {
  3342. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3343. }
  3344. }
  3345. }
  3346. }
  3347. }
  3348. //校验哪个优先级有订单
  3349. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3350. foreach (string key in shop_orders.Keys)
  3351. {
  3352. List<string> ids = null;
  3353. shop_orders.TryGetValue(key, out ids);
  3354. //id为shopid
  3355. foreach (string id in ids)
  3356. {
  3357. Dictionary<string, int> list = null;
  3358. Dictionary<string, string> desing = null;
  3359. map.TryGetValue(id, out list);
  3360. design_orders.TryGetValue(id, out desing);
  3361. if (list != null && desing != null)
  3362. {
  3363. foreach (var item in desing)
  3364. {
  3365. int count = 0;
  3366. if (list.ContainsKey(item.Value))
  3367. {
  3368. list.TryGetValue(item.Value, out count);
  3369. if (count > 0)
  3370. {
  3371. designIds[id] = item.Value;
  3372. break;
  3373. }
  3374. }
  3375. }
  3376. }
  3377. }
  3378. if (designIds.Count > 0)
  3379. {
  3380. break;
  3381. }
  3382. }
  3383. DataTable table = new DataTable();
  3384. table.Columns.Add("tid", typeof(string));
  3385. table.Columns.Add("ctid", typeof(string));
  3386. table.Columns.Add("seller_nick", typeof(string));
  3387. table.Columns.Add("productName", typeof(string));
  3388. table.Columns.Add("pay_time", typeof(string));
  3389. table.Columns.Add("seller_memo", typeof(string));
  3390. if (designIds.Count > 0)
  3391. {
  3392. string shopId = "";
  3393. string productId = "";
  3394. foreach (var designInfo in designIds)
  3395. {
  3396. shopId = designInfo.Key;
  3397. productId = designInfo.Value;
  3398. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3399. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3400. if (dt.Rows.Count > 0)
  3401. {
  3402. foreach (DataRow row in dt.Rows)
  3403. {
  3404. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3405. {
  3406. DataRow data = table.NewRow();
  3407. data["ctid"] = row["ctid"].ToString();
  3408. data["tid"] = row["tid"].ToString();
  3409. data["seller_nick"] = ceErpShop.ShopName;
  3410. data["pay_time"] = row["pay_time"].ToString();
  3411. data["seller_memo"] = row["seller_memo"].ToString();
  3412. data["productName"] = ceErpProduct.PType;
  3413. table.Rows.Add(data);
  3414. }
  3415. }
  3416. }
  3417. }
  3418. }
  3419. writeGridDataTableJson(table.Rows.Count, table);
  3420. }
  3421. private object rushLockObject = new object();
  3422. public void set_erp_grabingorder()
  3423. {
  3424. if (UrlPostParmsCheck("ctid"))
  3425. {
  3426. int total = CurrentUser.User.Person.Total;
  3427. int userId = CurrentUser.User.ID;
  3428. int noFinish = CurrentUser.User.Person.NoFinish;
  3429. int finalization = CurrentUser.User.Person.Finalization;
  3430. string eids = GetPostString("ctid");
  3431. string key = "RushKey_" + userId;
  3432. int count = 0;
  3433. if (erpRedis.RedisHelper.KeyExists(key))
  3434. {
  3435. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3436. if (redisCount != null)
  3437. {
  3438. count = Convert.ToInt32(redisCount);
  3439. }
  3440. }
  3441. if (count >= total)
  3442. {
  3443. returnErrorMsg("半小时内已经抢" + total + "单");
  3444. return;
  3445. }
  3446. string[] ctidlist = eids.Split(',');
  3447. if (count + ctidlist.Length > total)
  3448. {
  3449. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3450. return;
  3451. }
  3452. int itag = 0;
  3453. lock (rushLockObject)
  3454. {
  3455. if (ctidlist.Length > 0)
  3456. {
  3457. string[] dtList = new string[ctidlist.Length];
  3458. for (int i = 0; i < ctidlist.Length; i++)
  3459. {
  3460. dtList[i] = "'" + ctidlist[i] + "'";
  3461. }
  3462. 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"));
  3463. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3464. if (dt_user.Rows.Count > 0)
  3465. {
  3466. int doing = 0;//未定稿
  3467. int finish = 0;//已完成
  3468. foreach (DataRow dr in dt_user.Rows)
  3469. {
  3470. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3471. {
  3472. doing++;
  3473. }
  3474. else
  3475. {
  3476. finish++;
  3477. }
  3478. }
  3479. if (doing >= noFinish)
  3480. {
  3481. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3482. return;
  3483. }
  3484. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3485. {
  3486. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3487. return;
  3488. }
  3489. }
  3490. //校验选择单子状态
  3491. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3492. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3493. if (dt.Rows.Count > 0)
  3494. {
  3495. List<string> list = new List<string>();
  3496. foreach (DataRow dr in dt.Rows)
  3497. {
  3498. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3499. {
  3500. list.Add(dr["ctid"].ToString());
  3501. }
  3502. }
  3503. if (list.Count > 0)
  3504. {
  3505. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3506. return;
  3507. }
  3508. }
  3509. foreach (string ctid in ctidlist)
  3510. {
  3511. CeErpTradeCell entity = null;
  3512. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3513. if (entity != null)
  3514. {
  3515. entity.OrderState = 3;
  3516. entity.DesignUserId = CurrentUser.UserID;
  3517. entity.WaitDesignTime = DateTime.Now;
  3518. entity.StartDesignTime = DateTime.Now;
  3519. entity.Update();
  3520. commonHelper.UpdateRelationOrder(entity.ctid);
  3521. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3522. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3523. itag++;
  3524. }
  3525. }
  3526. }
  3527. }
  3528. count += ctidlist.Length;
  3529. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3530. if (itag == 0)
  3531. returnErrorMsg("没有找到相关订单");
  3532. else
  3533. returnSuccessMsg("抢单成功!");
  3534. return;
  3535. }
  3536. }
  3537. public void get_erp_waitorderlist()
  3538. {
  3539. DataStruct dStruct = GetPostStruct();
  3540. List<string> lw = new List<string>();
  3541. string tid = GetPostString("ctid");
  3542. if (tid.Length > 0)
  3543. {
  3544. string select_tid = getTidByCtid(tid);
  3545. lw.Add(string.Format("tid='{0}'", select_tid));
  3546. }
  3547. string shopname = GetPostString("shopname");
  3548. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3549. string buyernick = GetPostString("buyer_nick");
  3550. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3551. string customer = GetPostString("customer");
  3552. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3553. string design = GetPostString("design");
  3554. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3555. string orderState = GetPostString("orderState");
  3556. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3557. string supplier = GetPostString("supplier");
  3558. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3559. string sellermemo = GetPostString("seller_memo");
  3560. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3561. string otherMemo = GetPostString("otherMemo");
  3562. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3563. string address = GetPostString("address");
  3564. 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));
  3565. string date1 = GetPostString("date1");
  3566. string date2 = GetPostString("date2");
  3567. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3568. if (dw.Length > 0) lw.Add(dw);
  3569. string price1 = GetPostString("price1");
  3570. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3571. string price2 = GetPostString("price2");
  3572. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3573. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3574. lw.Add(string.Format("IsSample != 2 "));
  3575. lw.Add(string.Format("OrderState = 5 "));
  3576. lw.Add(string.Format("IsRefund<={0}", 1));
  3577. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3578. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3579. string pagesize = GetPostString("pagesize");
  3580. if (pagesize != null)
  3581. {
  3582. dStruct.PageSize = 200;
  3583. }
  3584. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3585. List<string> tids = new List<string>();
  3586. if (dt != null)
  3587. {
  3588. dt.Columns.Add("compenPrice", typeof(double));
  3589. foreach (DataRow dr in dt.Rows)
  3590. {
  3591. if (Convert.IsDBNull(dr["compenPrice"]))
  3592. {
  3593. dr["compenPrice"] = 0;
  3594. }
  3595. tids.Add("'" + dr["tid"].ToString() + "'");
  3596. 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();
  3597. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3598. {
  3599. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3600. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3601. entity.SupplierId = suid;
  3602. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3603. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3604. entity.Update();
  3605. }
  3606. }
  3607. }
  3608. if (tids.Count > 0)
  3609. {
  3610. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3611. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3612. if (dt_price != null && dt_price.Rows.Count > 0)
  3613. {
  3614. foreach (DataRow dr in dt_price.Rows)
  3615. {
  3616. foreach (DataRow row in dt.Rows)
  3617. {
  3618. if (row["tid"].Equals(dr["ptid"]))
  3619. {
  3620. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3621. break;
  3622. }
  3623. }
  3624. }
  3625. }
  3626. }
  3627. writeGridDataTableJson(dStruct.TotalCount, dt);
  3628. }
  3629. public void get_erp_supplierwaitorderlist()
  3630. {
  3631. DataStruct dStruct = GetPostStruct();
  3632. List<string> lw = new List<string>();
  3633. string tid = GetPostString("ctid");
  3634. if (tid.Length > 0)
  3635. {
  3636. string select_tid = getTidByCtid(tid);
  3637. lw.Add(string.Format("tid='{0}'", select_tid));
  3638. }
  3639. string shopname = GetPostString("shopname");
  3640. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3641. string sellermemo = GetPostString("seller_memo");
  3642. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3643. string date1 = GetPostString("date1");
  3644. string date2 = GetPostString("date2");
  3645. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3646. if (dw.Length > 0) lw.Add(dw);
  3647. lw.Add(string.Format("OrderState = 5 "));
  3648. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3649. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3650. {
  3651. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3652. }
  3653. string supplier = GetPostString("supplier");
  3654. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3655. {
  3656. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3657. }
  3658. lw.Add(string.Format("IsRefund<={0}", 1));
  3659. dStruct.Order = "FinishDesignTime desc";
  3660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3661. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3662. if (dt != null)
  3663. {
  3664. foreach (DataRow dr in dt.Rows)
  3665. {
  3666. 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();
  3667. }
  3668. }
  3669. writeGridDataTableJson(dStruct.TotalCount, dt);
  3670. }
  3671. public void upd_erp_verifytosupplier()
  3672. {
  3673. if (UrlPostParmsCheck("ctid"))
  3674. {
  3675. string eids = GetPostString("ctid");
  3676. CeErpTradeCell entity = null;
  3677. string[] eidsList = eids.Split(',');
  3678. if (eidsList.Length <= 0)
  3679. {
  3680. returnErrorMsg("订单号不能空");
  3681. return;
  3682. }
  3683. List<string> tLst = new List<string>();
  3684. foreach (string ctidstr in eidsList)
  3685. {
  3686. tLst.Add("'" + ctidstr + "'");
  3687. CeErpDataSendOrderInfo.createObject(ctidstr);
  3688. }
  3689. string needtids = string.Join(",", tLst.ToArray());
  3690. StringBuilder sql = new StringBuilder();
  3691. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3692. 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);
  3693. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3694. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3695. returnSuccessMsg("操作成功!");
  3696. return;
  3697. /**foreach (string ctidstr in eidsList)
  3698. {
  3699. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3700. if (entity != null)
  3701. {
  3702. if (entity.SupplierId == 0)
  3703. {
  3704. continue;
  3705. }
  3706. entity.IsVerifyToSupplier = true;
  3707. if (entity.IsReturn == 1) //1是供应商打回
  3708. {
  3709. entity.IsReturn = 0;
  3710. }
  3711. entity.FinishPlaceTime = DateTime.Now;
  3712. entity.PlaceUserId = CurrentUser.UserID;
  3713. entity.Update();
  3714. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3715. }
  3716. }
  3717. returnSuccessMsg("操作成功!");
  3718. return;**/
  3719. }
  3720. }
  3721. public void upd_erp_supplierback()
  3722. {
  3723. if (UrlPostParmsCheck("ctid"))
  3724. {
  3725. string eid = GetPostString("ctid");
  3726. string reason = GetPostString("returnreason");
  3727. CeErpTradeCell entity = null;
  3728. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3729. if (entity != null)
  3730. {
  3731. string message = "操作成功!";
  3732. string isDown = "";
  3733. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3734. {
  3735. message = eid + "订单有被点击下载。请注意沟通是否已下载完!";
  3736. isDown = "被点击下载";
  3737. }
  3738. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3739. {
  3740. string key = "return_order_" + entity.SupplierId;
  3741. List<string> list = new List<string>();
  3742. if (RedisHelper.HasKey(key))
  3743. {
  3744. object data = RedisHelper.StringGet(key);
  3745. list = Convert.ToString(data).Split(',').ToList();
  3746. }
  3747. list.Add(eid);
  3748. RedisHelper.StringSet(key, string.Join(",", list));
  3749. }
  3750. entity.IsVerifyToSupplier = false;
  3751. entity.IsReturn = 1;
  3752. entity.IsHaveNewOrder = 0;
  3753. entity.ReturnTime = DateTime.Now;
  3754. entity.ReturnReason = reason;
  3755. if (entity.OrderState == 6)
  3756. {
  3757. entity.OrderState = 5;
  3758. }
  3759. entity.Update();
  3760. CeErpSukuraData.createInfo(entity.ctid, 5);
  3761. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3762. returnSuccessMsg(message);
  3763. return;
  3764. }
  3765. returnErrorMsg("找不到订单记录");
  3766. }
  3767. }
  3768. public void upd_erp_toaftersaleorder()
  3769. {
  3770. if (UrlPostParmsCheck("ctid"))
  3771. {
  3772. string eid = GetPostString("ctid");
  3773. string reason = GetPostString("returnreason");
  3774. CeErpTradeCell entity = null;
  3775. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3776. if (entity != null)
  3777. {
  3778. if (entity.isAfterSaleOrder != 1)
  3779. {
  3780. returnErrorMsg("带S的售后单才能打回给售后");
  3781. return;
  3782. }
  3783. if (entity.OrderState >= 5)
  3784. {
  3785. returnErrorMsg("已经设计完成了不能打回给售后");
  3786. return;
  3787. }
  3788. entity.OrderState = 0;
  3789. entity.IsReturn = 3;
  3790. entity.ReturnTime = DateTime.Now;
  3791. entity.UpdateTime = DateTime.Now;
  3792. entity.ReturnReason = reason;
  3793. entity.Update();
  3794. CeErpSukuraData.createInfo(entity.ctid, 5);
  3795. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3796. returnSuccessMsg("操作成功!");
  3797. return;
  3798. }
  3799. returnErrorMsg("找不到订单记录");
  3800. }
  3801. }
  3802. public void upd_erp_aftersaletodesign()
  3803. {
  3804. if (UrlPostParmsCheck("ctid"))
  3805. {
  3806. string eid = GetPostString("ctid");
  3807. CeErpTradeCell entity = null;
  3808. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3809. if (entity != null)
  3810. {
  3811. entity.OrderState = 3;
  3812. entity.IsReturn = 0;
  3813. entity.UpdateTime = DateTime.Now;
  3814. entity.Update();
  3815. CeErpSukuraData.createInfo(entity.ctid, 5);
  3816. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3817. returnSuccessMsg("操作成功!");
  3818. return;
  3819. }
  3820. returnErrorMsg("找不到订单记录");
  3821. }
  3822. }
  3823. public void assign_erp_supplier()
  3824. {
  3825. if (UrlPostParmsCheck("ctid"))
  3826. {
  3827. string eids = GetPostString("ctid");
  3828. int sid = GetPostInt("SupplierName");
  3829. string fromTag = GetPostString("tag");
  3830. string[] eidList = eids.Split(',');
  3831. if (eidList.Length <= 0)
  3832. {
  3833. returnErrorMsg("指派不能为空");
  3834. return;
  3835. }
  3836. string errMsg = "";
  3837. string suname = commonHelper.getSupplierNameById(sid);
  3838. foreach (string ctid in eidList)
  3839. {
  3840. CeErpTradeCell entity = null;
  3841. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3842. if (entity != null)
  3843. {
  3844. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3845. {
  3846. errMsg += (ctid + "指派失败!!!");
  3847. continue;
  3848. }
  3849. entity.SupplierId = sid;
  3850. entity.Update();
  3851. commonHelper.UpdateRelationOrder(entity.ctid);
  3852. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3853. if (entity.OrderState >= 6)
  3854. {
  3855. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3856. //{
  3857. // string msl = entity.MakeSupplier;
  3858. // string[] mslist = msl.Split(',');
  3859. // 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);
  3860. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3861. //}
  3862. //else
  3863. //{
  3864. StringBuilder sql = new StringBuilder();
  3865. 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);
  3866. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3867. //}
  3868. }
  3869. }
  3870. else
  3871. {
  3872. continue;
  3873. }
  3874. }
  3875. if (errMsg.Length > 0)
  3876. {
  3877. returnErrorMsg(errMsg);
  3878. return;
  3879. }
  3880. returnSuccessMsg("操作成功!");
  3881. return;
  3882. }
  3883. }
  3884. public void assign_erp_makesupplier()
  3885. {
  3886. if (UrlPostParmsCheck("ctid"))
  3887. {
  3888. string eids = GetPostString("ctid");
  3889. string sname = GetPostString("SupplierName");
  3890. string[] eidList = eids.Split(',');
  3891. if (eidList.Length <= 0)
  3892. {
  3893. returnErrorMsg("指派不能为空");
  3894. return;
  3895. }
  3896. List<string> tLst = new List<string>();
  3897. foreach (string ctid in eidList)
  3898. {
  3899. CeErpTradeCell entity = null;
  3900. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3901. if (entity != null)
  3902. {
  3903. entity.MakeSupplier = sname;
  3904. entity.Update();
  3905. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3906. tLst.Add("'" + ctid + "'");
  3907. }
  3908. else
  3909. {
  3910. continue;
  3911. }
  3912. }
  3913. string ctids = string.Join(",", tLst.ToArray());
  3914. StringBuilder sql2 = new StringBuilder();
  3915. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3916. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3917. returnSuccessMsg("操作成功!");
  3918. return;
  3919. }
  3920. }
  3921. public void ins_erp_returnreason()
  3922. {
  3923. if (UrlPostParmsCheck("ctid"))
  3924. {
  3925. string eid = GetPostString("ctid");
  3926. CeErpTradeCell entity = null;
  3927. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3928. string userpost = CurrentUser.UserPost.Post.Code;
  3929. if (entity != null)
  3930. {
  3931. bool isPlace = false;
  3932. if (entity.OrderState > 6)
  3933. {
  3934. returnErrorMsg("已发货无法打回!");
  3935. return;
  3936. }
  3937. if (entity.OrderState == 6)
  3938. {
  3939. isPlace = true;
  3940. }
  3941. bool isNeedUpdateCell2 = false;
  3942. if (entity.OrderState >= 6)
  3943. {
  3944. isNeedUpdateCell2 = true;
  3945. }
  3946. int returnTag = 2;
  3947. if (userpost == "Supplier")
  3948. {
  3949. returnTag = 1;
  3950. }
  3951. int toType = GetPostInt("totype");
  3952. string fromType = "3";
  3953. if (entity.OrderState < 5)
  3954. {
  3955. fromType = "3";
  3956. }
  3957. else
  3958. {
  3959. fromType = "4";
  3960. }
  3961. if (entity.IsXianHuo == 0)
  3962. {
  3963. if (returnTag == 2)
  3964. {
  3965. if (toType == 1)
  3966. {
  3967. entity.OrderState = 0;
  3968. entity.ReturnUserType = 1;
  3969. string clearman = GetPostString("clearman");
  3970. if (!string.IsNullOrEmpty(clearman))
  3971. {
  3972. entity.DesignUserId = 0;
  3973. }
  3974. }
  3975. else
  3976. {
  3977. entity.OrderState = 3;
  3978. entity.ReturnUserType = 2;
  3979. }
  3980. entity.IsReadTag = 1;
  3981. }
  3982. else if (returnTag == 1)
  3983. {
  3984. entity.OrderState = 5;
  3985. }
  3986. entity.IsVerifyToSupplier = false;
  3987. }
  3988. if (entity.IsXianHuo == 1)
  3989. {
  3990. entity.OrderState = 5;
  3991. }
  3992. entity.UnusualTag = 0;
  3993. entity.UnusualTime = null;
  3994. entity.UnusualCon = "";
  3995. entity.IsReturn = returnTag;
  3996. entity.ReturnTime = DateTime.Now;
  3997. entity.UpdateTime = DateTime.Now;
  3998. entity.ReturnReason = GetPostString("returnreason");
  3999. entity.Update();
  4000. if (entity.OrderState == 3)
  4001. {
  4002. ApiVo apiVo = new ApiVo();
  4003. apiVo.orderNumber = entity.ctid;
  4004. apiVo.actionName = "rebutDesign";
  4005. apiVo.orderRemarks = entity.ReturnReason;
  4006. designHelper.API_WorkCore(apiVo);//rebutDesign
  4007. }
  4008. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  4009. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  4010. {
  4011. //dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  4012. }
  4013. //CeErpSukuraData.createInfo(entity.ctid, 5);
  4014. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4015. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4016. if (isPlace)
  4017. {
  4018. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4019. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4020. if (dth != null && dth.Rows.Count > 0)
  4021. {
  4022. dataSendOrderBean dataSendOrderBean = null;
  4023. foreach (DataRow item in dth.Rows)
  4024. {
  4025. try
  4026. {
  4027. dataSendOrderBean = new dataSendOrderBean();
  4028. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4029. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4030. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4031. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4032. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4033. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4034. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4035. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4036. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4037. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4038. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4039. dataSendOrderBean.Radio1723534706288 = "打回";
  4040. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4041. if (result != null)
  4042. {
  4043. if ("0".Equals(result.errcode))
  4044. {
  4045. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4046. }
  4047. else
  4048. {
  4049. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4050. }
  4051. }
  4052. }
  4053. catch (Exception ex)
  4054. {
  4055. }
  4056. }
  4057. }
  4058. }
  4059. returnSuccessMsg("操作成功!");
  4060. return;
  4061. }
  4062. returnErrorMsg("找不到订单记录");
  4063. }
  4064. }
  4065. public void batch_ins_erp_returnreason()
  4066. {
  4067. if (UrlPostParmsCheck("ctids"))
  4068. {
  4069. string ctids = GetPostString("ctids");
  4070. if (!string.IsNullOrEmpty(ctids))
  4071. {
  4072. List<string> ctid_list = ctids.Split(',').ToList();
  4073. CeErpTradeCell entity = null;
  4074. List<string> message_list = new List<string>();
  4075. foreach (string eid in ctid_list)
  4076. {
  4077. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4078. string userpost = CurrentUser.UserPost.Post.Code;
  4079. if (entity != null)
  4080. {
  4081. bool isPlace = false;
  4082. if (entity.OrderState > 6)
  4083. {
  4084. message_list.Add(eid + ":已发货无法打回!");
  4085. continue;
  4086. }
  4087. if (entity.OrderState == 6)
  4088. {
  4089. isPlace = true;
  4090. }
  4091. bool isNeedUpdateCell2 = false;
  4092. if (entity.OrderState >= 6)
  4093. {
  4094. isNeedUpdateCell2 = true;
  4095. }
  4096. int returnTag = 2;
  4097. if (userpost == "Supplier")
  4098. {
  4099. returnTag = 1;
  4100. }
  4101. int toType = GetPostInt("totype");
  4102. string fromType = "3";
  4103. if (entity.OrderState < 5)
  4104. {
  4105. fromType = "3";
  4106. }
  4107. else
  4108. {
  4109. fromType = "4";
  4110. }
  4111. if (entity.IsXianHuo == 0)
  4112. {
  4113. if (returnTag == 2)
  4114. {
  4115. if (toType == 1)
  4116. {
  4117. entity.OrderState = 0;
  4118. entity.ReturnUserType = 1;
  4119. string clearman = GetPostString("clearman");
  4120. if (!string.IsNullOrEmpty(clearman))
  4121. {
  4122. entity.DesignUserId = 0;
  4123. }
  4124. }
  4125. else
  4126. {
  4127. entity.OrderState = 3;
  4128. entity.ReturnUserType = 2;
  4129. }
  4130. entity.IsReadTag = 1;
  4131. }
  4132. else if (returnTag == 1)
  4133. {
  4134. entity.OrderState = 5;
  4135. }
  4136. entity.IsVerifyToSupplier = false;
  4137. }
  4138. if (entity.IsXianHuo == 1)
  4139. {
  4140. entity.OrderState = 5;
  4141. }
  4142. entity.UnusualTag = 0;
  4143. entity.UnusualTime = null;
  4144. entity.UnusualCon = "";
  4145. entity.IsReturn = returnTag;
  4146. entity.ReturnTime = DateTime.Now;
  4147. entity.UpdateTime = DateTime.Now;
  4148. entity.ReturnReason = GetPostString("returnreason");
  4149. entity.Update();
  4150. if (entity.OrderState == 3)
  4151. {
  4152. ApiVo apiVo = new ApiVo();
  4153. apiVo.orderNumber = entity.ctid;
  4154. apiVo.actionName = "rebutDesign";
  4155. apiVo.orderRemarks = entity.ReturnReason;
  4156. designHelper.API_WorkCore(apiVo);//rebutDesign
  4157. }
  4158. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  4159. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  4160. {
  4161. //dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  4162. }
  4163. //CeErpSukuraData.createInfo(entity.ctid, 5);
  4164. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4165. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4166. if (isPlace)
  4167. {
  4168. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4169. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4170. if (dth != null && dth.Rows.Count > 0)
  4171. {
  4172. dataSendOrderBean dataSendOrderBean = null;
  4173. foreach (DataRow item in dth.Rows)
  4174. {
  4175. try
  4176. {
  4177. dataSendOrderBean = new dataSendOrderBean();
  4178. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4179. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4180. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4181. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4182. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4183. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4184. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4185. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4186. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4187. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4188. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4189. dataSendOrderBean.Radio1723534706288 = "打回";
  4190. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4191. if (result != null)
  4192. {
  4193. if ("0".Equals(result.errcode))
  4194. {
  4195. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4196. }
  4197. else
  4198. {
  4199. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4200. }
  4201. }
  4202. }
  4203. catch (Exception ex)
  4204. {
  4205. }
  4206. }
  4207. }
  4208. }
  4209. }
  4210. }
  4211. returnSuccessMsg(message_list.Count > 0 ? string.Join("、", message_list) : "操作成功");
  4212. return;
  4213. }
  4214. returnErrorMsg("找不到订单记录");
  4215. }
  4216. }
  4217. public void cyt_erp_returnreason()
  4218. {
  4219. if (UrlPostParmsCheck("ctid"))
  4220. {
  4221. string eid = GetPostString("ctid");
  4222. CeErpTradeCell entity = null;
  4223. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4224. string userpost = CurrentUser.UserPost.Post.Code;
  4225. if (entity != null)
  4226. {
  4227. if (entity.OrderState > 6)
  4228. {
  4229. returnErrorMsg("已发货无法打回!");
  4230. return;
  4231. }
  4232. JObject jsonObject = new JObject
  4233. {
  4234. { "Userid", "77886" },
  4235. { "Pwd", "lt666888" },
  4236. { "LTOrderId",eid }
  4237. };
  4238. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4239. JObject jsonObjects = JObject.Parse(response);
  4240. string msg = (string)jsonObjects["msg"];
  4241. if (msg != "取消成功")
  4242. {
  4243. returnErrorMsg(msg);
  4244. return;
  4245. }
  4246. bool isNeedUpdateCell2 = false;
  4247. if (entity.OrderState >= 6)
  4248. {
  4249. isNeedUpdateCell2 = true;
  4250. }
  4251. int returnTag = 2;
  4252. if (userpost == "Supplier")
  4253. {
  4254. returnTag = 1;
  4255. }
  4256. if (entity.IsXianHuo == 0)
  4257. {
  4258. if (returnTag == 2)
  4259. {
  4260. int toType = GetPostInt("totype");
  4261. if (toType == 1)
  4262. {
  4263. entity.OrderState = 0;
  4264. entity.ReturnUserType = 1;
  4265. }
  4266. else
  4267. {
  4268. entity.OrderState = 4;
  4269. entity.ReturnUserType = 2;
  4270. }
  4271. entity.IsReadTag = 1;
  4272. }
  4273. else if (returnTag == 1)
  4274. {
  4275. entity.OrderState = 5;
  4276. }
  4277. entity.IsVerifyToSupplier = false;
  4278. }
  4279. entity.UnusualTag = 0;
  4280. entity.UnusualTime = null;
  4281. entity.UnusualCon = "";
  4282. entity.IsReturn = returnTag;
  4283. entity.ReturnTime = DateTime.Now;
  4284. entity.ReturnReason = GetPostString("returnreason");
  4285. entity.Update();
  4286. if (entity.OrderState == 4)
  4287. {
  4288. ApiVo apiVo = new ApiVo();
  4289. apiVo.orderNumber = entity.ctid;
  4290. apiVo.actionName = "rebutDesign";
  4291. apiVo.orderRemarks = entity.ReturnReason;
  4292. designHelper.API_WorkCore(apiVo);//rebutDesign
  4293. }
  4294. CeErpSukuraData.createInfo(entity.ctid, 5);
  4295. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4296. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4297. if (isNeedUpdateCell2)
  4298. {
  4299. if (entity.MakeSupplier.IndexOf(",") != -1)
  4300. {
  4301. StringBuilder sql2 = new StringBuilder();
  4302. 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);
  4303. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4304. }
  4305. else
  4306. {
  4307. StringBuilder sql2 = new StringBuilder();
  4308. 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);
  4309. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4310. }
  4311. }
  4312. returnSuccessMsg("操作成功!");
  4313. return;
  4314. }
  4315. returnErrorMsg("找不到订单记录");
  4316. }
  4317. }
  4318. public void upd_erp_xianhuoreturntag()
  4319. {
  4320. if (UrlPostParmsCheck("ctid"))
  4321. {
  4322. string eids = GetPostString("ctid");
  4323. string[] ctids = eids.Split(',');
  4324. foreach (string ctid in ctids)
  4325. {
  4326. CeErpTradeCell entity = null;
  4327. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4328. if (entity != null)
  4329. {
  4330. entity.IsReturn = 0;
  4331. entity.Update();
  4332. CeErpSukuraData.createInfo(entity.ctid, 5);
  4333. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4334. }
  4335. }
  4336. returnSuccessMsg("操作成功!");
  4337. return;
  4338. }
  4339. }
  4340. public void get_erp_waitdeliverylist()
  4341. {
  4342. DataStruct dStruct = GetPostStruct();
  4343. List<string> lw = new List<string>();
  4344. string tid = GetPostString("ctid");
  4345. if (tid.Length > 0)
  4346. {
  4347. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4348. if (tid.Length > 5)
  4349. {
  4350. List<string> tids = getTidByCtidLike(tid);
  4351. if (tids.Count > 0 && tids.Count < 10)
  4352. {
  4353. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4354. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4355. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4356. {
  4357. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4358. }*/
  4359. }
  4360. }
  4361. lw.Add(tid_sql);
  4362. }
  4363. string shopname = GetPostString("shopname");
  4364. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4365. string buyernick = GetPostString("buyer_nick");
  4366. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4367. //if (tid.Length == 0 && buyernick.Length == 0)
  4368. //{
  4369. // lw.Add(string.Format("IsRefund<={0}", 1));
  4370. //}
  4371. string customer = GetPostString("customer");
  4372. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4373. string design = GetPostString("design");
  4374. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4375. string orderState = GetPostString("orderState");
  4376. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4377. string address = GetPostString("address");
  4378. 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));
  4379. string sellermemo = GetPostString("seller_memo");
  4380. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4381. string supplier = GetPostString("supplier");
  4382. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4383. string OrderArea = GetPostString("order_area");
  4384. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4385. string placedate1 = GetPostString("placedate1");
  4386. string placedate2 = GetPostString("placedate2");
  4387. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4388. if (fdw.Length > 0) lw.Add(fdw);
  4389. string price1 = GetPostString("price1");
  4390. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4391. string price2 = GetPostString("price2");
  4392. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4393. string unusualCon = GetPostString("unusualcon");
  4394. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4395. string otherMemo = GetPostString("otherMemo");
  4396. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4397. string posTag = CurrentUser.UserPost.Post.Code;
  4398. if (posTag == "Supplier")
  4399. {
  4400. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4401. }
  4402. else
  4403. {
  4404. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4405. {
  4406. string usershop = CurrentUser.User.pemShop;
  4407. lw.Add(string.Format("ShopId in ({0})", usershop));
  4408. }
  4409. }
  4410. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4411. lw.Add(string.Format("type != 'PDD' "));
  4412. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4413. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4414. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4415. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4416. writeGridDataTableJson(dStruct.TotalCount, dt);
  4417. }
  4418. public void get_erp_changedeliverylist()
  4419. {
  4420. DataStruct dStruct = GetPostStruct();
  4421. List<string> lw = new List<string>();
  4422. string tid = GetPostString("ctid");
  4423. if (tid.Length > 0)
  4424. {
  4425. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4426. if (tid.Length > 5)
  4427. {
  4428. List<string> tids = getTidByCtidLike(tid);
  4429. if (tids.Count > 0 && tids.Count < 10)
  4430. {
  4431. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4432. }
  4433. }
  4434. lw.Add(tid_sql);
  4435. }
  4436. string shopname = GetPostString("shopname");
  4437. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4438. string buyernick = GetPostString("buyer_nick");
  4439. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4440. //if (tid.Length == 0 && buyernick.Length == 0)
  4441. //{
  4442. // lw.Add(string.Format("IsRefund<={0}", 1));
  4443. //}
  4444. string customer = GetPostString("customer");
  4445. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4446. string design = GetPostString("design");
  4447. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4448. string orderState = GetPostString("orderState");
  4449. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4450. string address = GetPostString("address");
  4451. 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));
  4452. string sellermemo = GetPostString("seller_memo");
  4453. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4454. string supplier = GetPostString("supplier");
  4455. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4456. string OrderArea = GetPostString("order_area");
  4457. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4458. string placedate1 = GetPostString("placedate1");
  4459. string placedate2 = GetPostString("placedate2");
  4460. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4461. if (fdw.Length > 0) lw.Add(fdw);
  4462. string price1 = GetPostString("price1");
  4463. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4464. string price2 = GetPostString("price2");
  4465. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4466. string unusualCon = GetPostString("unusualcon");
  4467. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4468. string otherMemo = GetPostString("otherMemo");
  4469. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4470. string posTag = CurrentUser.UserPost.Post.Code;
  4471. if (posTag == "Supplier")
  4472. {
  4473. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4474. }
  4475. else
  4476. {
  4477. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4478. {
  4479. string usershop = CurrentUser.User.pemShop;
  4480. lw.Add(string.Format("ShopId in ({0})", usershop));
  4481. }
  4482. }
  4483. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4484. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4485. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4486. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4487. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4488. /*if (tid.Length > 0)
  4489. {
  4490. List<string> tids = new List<string>();
  4491. if (dt != null && dt.Rows.Count > 0)
  4492. {
  4493. foreach (DataRow item in dt.Rows)
  4494. {
  4495. tids.Add("'" + item["tid"] + "'");
  4496. }
  4497. }
  4498. if (tids.Count > 0)
  4499. {
  4500. lw.RemoveAt(0);
  4501. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4502. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4503. dt = WebCache.GetData("view_erptradecell", dStruct);
  4504. }
  4505. }*/
  4506. writeGridDataTableJson(dStruct.TotalCount, dt);
  4507. }
  4508. public void get_erp_pddderiving()
  4509. {
  4510. DataStruct dStruct = GetPostStruct();
  4511. List<string> lw = new List<string>();
  4512. string tid = GetPostString("ctid");
  4513. if (tid.Length > 0)
  4514. {
  4515. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4516. if (tid.Length > 5)
  4517. {
  4518. List<string> tids = getTidByCtidLike(tid);
  4519. if (tids.Count > 0 && tids.Count < 10)
  4520. {
  4521. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4522. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4523. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4524. {
  4525. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4526. }*/
  4527. }
  4528. }
  4529. lw.Add(tid_sql);
  4530. }
  4531. string shopname = GetPostString("shopname");
  4532. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4533. string buyernick = GetPostString("buyer_nick");
  4534. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4535. //if (tid.Length == 0 && buyernick.Length == 0)
  4536. //{
  4537. // lw.Add(string.Format("IsRefund<={0}", 1));
  4538. //}
  4539. string customer = GetPostString("customer");
  4540. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4541. string design = GetPostString("design");
  4542. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4543. string orderState = GetPostString("orderState");
  4544. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4545. string address = GetPostString("address");
  4546. 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));
  4547. string sellermemo = GetPostString("seller_memo");
  4548. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4549. string supplier = GetPostString("supplier");
  4550. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4551. string OrderArea = GetPostString("order_area");
  4552. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4553. string placedate1 = GetPostString("placedate1");
  4554. string placedate2 = GetPostString("placedate2");
  4555. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4556. if (fdw.Length > 0) lw.Add(fdw);
  4557. string price1 = GetPostString("price1");
  4558. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4559. string price2 = GetPostString("price2");
  4560. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4561. string unusualCon = GetPostString("unusualcon");
  4562. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4563. string posTag = CurrentUser.UserPost.Post.Code;
  4564. if (posTag == "Supplier")
  4565. {
  4566. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4567. }
  4568. else
  4569. {
  4570. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4571. {
  4572. string usershop = CurrentUser.User.pemShop;
  4573. lw.Add(string.Format("ShopId in ({0})", usershop));
  4574. }
  4575. }
  4576. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4577. lw.Add(string.Format("type = 'PDD' "));
  4578. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4579. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4580. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4581. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4582. /*if (tid.Length > 0)
  4583. {
  4584. List<string> tids = new List<string>();
  4585. if (dt != null && dt.Rows.Count > 0)
  4586. {
  4587. foreach (DataRow item in dt.Rows)
  4588. {
  4589. tids.Add("'" + item["tid"] + "'");
  4590. }
  4591. }
  4592. if (tids.Count > 0)
  4593. {
  4594. lw.RemoveAt(0);
  4595. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4596. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4597. dt = WebCache.GetData("view_erptradecell", dStruct);
  4598. }
  4599. }*/
  4600. writeGridDataTableJson(dStruct.TotalCount, dt);
  4601. }
  4602. public void get_erp_jdderiving()
  4603. {
  4604. DataStruct dStruct = GetPostStruct();
  4605. List<string> lw = new List<string>();
  4606. string tid = GetPostString("ctid");
  4607. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  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='{0}'", buyernick));
  4612. //if (tid.Length == 0 && buyernick.Length == 0)
  4613. //{
  4614. // lw.Add(string.Format("IsRefund<={0}", 1));
  4615. //}
  4616. string customer = GetPostString("customer");
  4617. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4618. string design = GetPostString("design");
  4619. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4620. string orderState = GetPostString("orderState");
  4621. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4622. string address = GetPostString("address");
  4623. 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));
  4624. string sellermemo = GetPostString("seller_memo");
  4625. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4626. string supplier = GetPostString("supplier");
  4627. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4628. string OrderArea = GetPostString("order_area");
  4629. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4630. string placedate1 = GetPostString("placedate1");
  4631. string placedate2 = GetPostString("placedate2");
  4632. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4633. if (fdw.Length > 0) lw.Add(fdw);
  4634. string price1 = GetPostString("price1");
  4635. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4636. string price2 = GetPostString("price2");
  4637. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4638. string unusualCon = GetPostString("unusualcon");
  4639. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4640. string posTag = CurrentUser.UserPost.Post.Code;
  4641. if (posTag == "Supplier")
  4642. {
  4643. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4644. }
  4645. lw.Add(string.Format("OrderState = 6 "));
  4646. lw.Add(string.Format("type = 'JD' "));
  4647. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4648. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4649. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4650. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4651. writeGridDataTableJson(dStruct.TotalCount, dt);
  4652. }
  4653. public void get_erp_demoorderlist()
  4654. {
  4655. DataStruct dStruct = GetPostStruct();
  4656. List<string> lw = new List<string>();
  4657. string tid = GetPostString("ctid");
  4658. if (tid.Length > 0)
  4659. {
  4660. string select_tid = getTidByCtid(tid);
  4661. lw.Add(string.Format("tid='{0}'", select_tid));
  4662. }
  4663. string shopname = GetPostString("shopname");
  4664. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4665. string buyernick = GetPostString("buyer_nick");
  4666. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4667. string customer = GetPostString("customer");
  4668. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4669. string design = GetPostString("design");
  4670. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4671. string orderState = GetPostString("orderState");
  4672. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4673. string address = GetPostString("address");
  4674. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4675. string sellermemo = GetPostString("seller_memo");
  4676. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4677. string supplier = GetPostString("supplier");
  4678. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4679. string OrderArea = GetPostString("order_area");
  4680. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4681. string date1 = GetPostString("date1");
  4682. string date2 = GetPostString("date2");
  4683. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4684. if (dw.Length > 0) lw.Add(dw);
  4685. string price1 = GetPostString("price1");
  4686. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4687. string price2 = GetPostString("price2");
  4688. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4689. string posTag = CurrentUser.UserPost.Post.Code;
  4690. if (posTag == "Supplier")
  4691. {
  4692. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4693. }
  4694. //lw.Add(string.Format("OrderState = 6 "));
  4695. lw.Add(string.Format("IsSample={0}", 3));
  4696. lw.Add(string.Format("IsRefund<={0}", 1));
  4697. dStruct.Order = "pay_time desc";
  4698. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4699. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4700. writeGridDataTableJson(dStruct.TotalCount, dt);
  4701. }
  4702. public void save_erp_checkmemo()
  4703. {
  4704. if (UrlPostParmsCheck("ctid"))
  4705. {
  4706. string ctid = GetPostString("ctid");
  4707. CeErpTradeCell entity = null;
  4708. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4709. if (entity != null)
  4710. {
  4711. entity.CheckMemo = GetPostString("CheckMemo");
  4712. entity.Update();
  4713. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4714. if (trade != null)
  4715. {
  4716. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4717. }
  4718. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4719. returnSuccessMsg("保存成功!");
  4720. return;
  4721. }
  4722. returnErrorMsg("找不到记录");
  4723. }
  4724. }
  4725. public void get_erp_returnlist()
  4726. {
  4727. DataStruct dStruct = GetPostStruct();
  4728. List<string> lw = new List<string>();
  4729. string tid = GetPostString("ctid");
  4730. if (tid.Length > 0)
  4731. {
  4732. string select_tid = getTidByCtid(tid);
  4733. lw.Add(string.Format("tid='{0}'", select_tid));
  4734. }
  4735. string shopname = GetPostString("shopname");
  4736. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4737. string buyernick = GetPostString("buyer_nick");
  4738. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4739. string customer = GetPostString("customer");
  4740. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4741. string design = GetPostString("design");
  4742. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4743. string orderState = GetPostString("orderState");
  4744. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4745. string address = GetPostString("address");
  4746. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4747. string sellermemo = GetPostString("seller_memo");
  4748. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4749. string supplier = GetPostString("supplier");
  4750. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4751. string date1 = GetPostString("date1");
  4752. string date2 = GetPostString("date2");
  4753. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4754. if (dw.Length > 0) lw.Add(dw);
  4755. string bdate1 = GetPostString("backdate1");
  4756. string bdate2 = GetPostString("backdate2");
  4757. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4758. if (dw_back.Length > 0) lw.Add(dw_back);
  4759. string price1 = GetPostString("price1");
  4760. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4761. string price2 = GetPostString("price2");
  4762. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4763. lw.Add(string.Format("IsReturn>0"));
  4764. lw.Add(string.Format("IsXianHuo=0"));
  4765. lw.Add(string.Format("IsReturn!=3"));
  4766. string backtype = GetPostString("backtype");
  4767. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4768. dStruct.Order = "FinishDesignTime desc";
  4769. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4770. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4771. writeGridDataTableJson(dStruct.TotalCount, dt);
  4772. }
  4773. public void get_erp_today_sumreturn()
  4774. {
  4775. DataStruct dStruct = GetPostStruct();
  4776. List<string> lw = new List<string>();
  4777. string bdate1 = GetPostString("returnTimeS");
  4778. string bdate2 = GetPostString("returnTimeE");
  4779. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4780. if (dw_back.Length > 0) lw.Add(dw_back);
  4781. lw.Add(string.Format("IsReturn=0"));
  4782. lw.Add(string.Format("IsXianHuo=0"));
  4783. string mainWhere = string.Join(" and ", lw.ToArray());
  4784. string sql = "";
  4785. if (dw_back.Length > 0)
  4786. {
  4787. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4788. }
  4789. else
  4790. {
  4791. 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 + "'";
  4792. }
  4793. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4794. decimal total = 0, today_finish = 0;
  4795. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4796. {
  4797. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4798. }
  4799. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4800. {
  4801. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4802. }
  4803. var res = new
  4804. {
  4805. data = total,
  4806. data1 = today_finish,
  4807. };
  4808. string ro_jsond = JsonConvert.SerializeObject(res);
  4809. returnSuccess(ro_jsond);
  4810. return;
  4811. }
  4812. public void get_erp_allreturnlist()
  4813. {
  4814. DataStruct dStruct = GetPostStruct();
  4815. List<string> lw = new List<string>();
  4816. string tid = GetPostString("ctid");
  4817. if (tid.Length > 0)
  4818. {
  4819. string select_tid = getTidByCtid(tid);
  4820. lw.Add(string.Format("tid='{0}'", select_tid));
  4821. }
  4822. string shopname = GetPostString("shopname");
  4823. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4824. string buyernick = GetPostString("buyer_nick");
  4825. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4826. string customer = GetPostString("customer");
  4827. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4828. string design = GetPostString("design");
  4829. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4830. string orderState = GetPostString("orderState");
  4831. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4832. string address = GetPostString("address");
  4833. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4834. string sellermemo = GetPostString("seller_memo");
  4835. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4836. string supplier = GetPostString("supplier");
  4837. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4838. string date1 = GetPostString("date1");
  4839. string date2 = GetPostString("date2");
  4840. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4841. if (dw.Length > 0) lw.Add(dw);
  4842. string bdate1 = GetPostString("backdate1");
  4843. string bdate2 = GetPostString("backdate2");
  4844. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4845. if (dw_back.Length > 0) lw.Add(dw_back);
  4846. string price1 = GetPostString("price1");
  4847. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4848. string price2 = GetPostString("price2");
  4849. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4850. string backreason = GetPostString("backreason");
  4851. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4852. lw.Add(string.Format("IsXianHuo=0"));
  4853. lw.Add(string.Format("ReturnTime != ''"));
  4854. string backtype = GetPostString("backtype");
  4855. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4856. string posTag = CurrentUser.UserPost.Post.Code;
  4857. if (posTag == "Supplier")
  4858. {
  4859. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4860. }
  4861. else
  4862. {
  4863. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4864. {
  4865. string usershop = CurrentUser.User.pemShop;
  4866. lw.Add(string.Format("ShopId in ({0})", usershop));
  4867. }
  4868. }
  4869. dStruct.Order = "FinishDesignTime desc";
  4870. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4871. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4872. writeGridDataTableJson(dStruct.TotalCount, dt);
  4873. }
  4874. public void get_erp_aftersalereturnlist()
  4875. {
  4876. DataStruct dStruct = GetPostStruct();
  4877. List<string> lw = new List<string>();
  4878. string tid = GetPostString("ctid");
  4879. if (tid.Length > 0)
  4880. {
  4881. string select_tid = getTidByCtid(tid);
  4882. lw.Add(string.Format("tid='{0}'", select_tid));
  4883. }
  4884. string shopname = GetPostString("shopname");
  4885. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4886. string buyernick = GetPostString("buyer_nick");
  4887. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4888. string customer = GetPostString("customer");
  4889. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4890. string design = GetPostString("design");
  4891. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4892. string orderState = GetPostString("orderState");
  4893. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4894. string address = GetPostString("address");
  4895. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4896. string sellermemo = GetPostString("seller_memo");
  4897. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4898. string supplier = GetPostString("supplier");
  4899. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4900. string date1 = GetPostString("date1");
  4901. string date2 = GetPostString("date2");
  4902. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4903. if (dw.Length > 0) lw.Add(dw);
  4904. string bdate1 = GetPostString("backdate1");
  4905. string bdate2 = GetPostString("backdate2");
  4906. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4907. if (dw_back.Length > 0) lw.Add(dw_back);
  4908. string price1 = GetPostString("price1");
  4909. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4910. string price2 = GetPostString("price2");
  4911. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4912. lw.Add(string.Format("IsReturn=3"));
  4913. string backtype = GetPostString("backtype");
  4914. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4915. string backreason = GetPostString("backreason");
  4916. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4917. dStruct.Order = "ReturnTime desc";
  4918. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4919. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4920. writeGridDataTableJson(dStruct.TotalCount, dt);
  4921. }
  4922. public void get_erp_xianhuoreturnlist()
  4923. {
  4924. DataStruct dStruct = GetPostStruct();
  4925. List<string> lw = new List<string>();
  4926. string tid = GetPostString("ctid");
  4927. if (tid.Length > 0)
  4928. {
  4929. string select_tid = getTidByCtid(tid);
  4930. lw.Add(string.Format("tid='{0}'", select_tid));
  4931. }
  4932. string shopname = GetPostString("shopname");
  4933. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4934. string buyernick = GetPostString("buyer_nick");
  4935. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4936. string customer = GetPostString("customer");
  4937. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4938. string design = GetPostString("design");
  4939. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4940. string orderState = GetPostString("orderState");
  4941. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4942. string address = GetPostString("address");
  4943. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4944. string sellermemo = GetPostString("seller_memo");
  4945. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4946. string supplier = GetPostString("supplier");
  4947. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4948. string OrderArea = GetPostString("order_area");
  4949. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4950. string date1 = GetPostString("date1");
  4951. string date2 = GetPostString("date2");
  4952. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4953. if (dw.Length > 0) lw.Add(dw);
  4954. string price1 = GetPostString("price1");
  4955. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4956. string price2 = GetPostString("price2");
  4957. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4958. string posTag = CurrentUser.UserPost.Post.Code;
  4959. if (posTag == "Supplier")
  4960. {
  4961. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4962. }
  4963. lw.Add(string.Format("OrderState=6 "));
  4964. lw.Add(string.Format("IsXianHuo=1 "));
  4965. lw.Add(string.Format("IsReturn>0 "));
  4966. lw.Add(string.Format("IsReturn < 3"));
  4967. lw.Add(string.Format("IsRefund<={0}", 1));
  4968. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4969. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4970. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4971. writeGridDataTableJson(dStruct.TotalCount, dt);
  4972. }
  4973. public void set_erp_orderdelivery()
  4974. {
  4975. if (UrlPostParmsCheck("ctid"))
  4976. {
  4977. string eid = GetPostString("ctid");
  4978. CeErpTradeCell entity = null;
  4979. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4980. if (entity != null)
  4981. {
  4982. if (entity.OrderState >= 7)
  4983. {
  4984. returnErrorMsg("此单已发货,无需重复发货");
  4985. return;
  4986. }
  4987. if (entity.OrderState != 6)
  4988. {
  4989. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4990. return;
  4991. }
  4992. string shop = GetPostString("seller_nick");
  4993. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4994. string comName = GetPostString("comName");
  4995. string comCode = GetPostString("comCode");
  4996. string outSid = GetPostString("outSid");
  4997. string deliveryType = GetPostString("deliveryType");
  4998. string deliveryMemo = GetPostString("deliveryMemo");
  4999. outSid = outSid.Trim();
  5000. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5001. if (mainEn == null)
  5002. {
  5003. returnErrorMsg("找不到原始订单记录");
  5004. return;
  5005. }
  5006. bool isInitOrderDeliv = false;
  5007. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  5008. {
  5009. isInitOrderDeliv = true;
  5010. }
  5011. string apires = "";
  5012. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  5013. 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)
  5014. {
  5015. apires = "发货成功true";
  5016. }
  5017. else
  5018. {
  5019. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5020. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid, entity.ctid);
  5021. }
  5022. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  5023. {
  5024. entity.OrderState = 7;//发货后订单已发货
  5025. entity.OutSid = outSid;
  5026. entity.MemoOpt = 0;
  5027. entity.UpdateTime = DateTime.Now;
  5028. entity.FinishDeliveryTime = DateTime.Now;
  5029. entity.Update();
  5030. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  5031. commonHelper.UpdateRelationOrder(entity.ctid);
  5032. //还要插入快递信息到 快递信息表
  5033. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5034. exinfo.tid = eid;
  5035. exinfo.out_sid = outSid;
  5036. exinfo.company_code = comCode;
  5037. exinfo.company_name = comName;
  5038. exinfo.delivery_memo = deliveryMemo;
  5039. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5040. exinfo.deliveryType = deliveryType;
  5041. exinfo.printUser = CurrentUser.UserName;
  5042. exinfo.print_time = DateTime.Now;
  5043. exinfo.Create();
  5044. returnSuccessMsg("发货操作成功!");
  5045. commonHelper.UpdateRelationOrder(entity.ctid);
  5046. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  5047. CeErpSukuraData.createInfo(entity.ctid, 4);
  5048. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126 || entity.SupplierId == 96)
  5049. {
  5050. commonHelper.sendCytExpress(exinfo);
  5051. }
  5052. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5053. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  5054. }
  5055. else
  5056. {
  5057. string errmsg = commonHelper.KeepChinese(apires);
  5058. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  5059. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  5060. }
  5061. return;
  5062. }
  5063. returnErrorMsg("找不到订单记录");
  5064. }
  5065. }
  5066. public void set_erp_multidelivery()
  5067. {
  5068. string eids = GetPostString("tids");
  5069. string[] eidList = eids.Split(',');
  5070. if (eidList.Length <= 0)
  5071. {
  5072. returnErrorMsg("发货不能为空");
  5073. return;
  5074. }
  5075. foreach (string ctid in eidList)
  5076. {
  5077. if (ctid.Length <= 0) continue;
  5078. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  5079. if (expInfo != null)
  5080. {
  5081. StringBuilder sql = new StringBuilder();
  5082. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  5083. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5084. if (dt.Rows.Count > 0)
  5085. {
  5086. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  5087. {
  5088. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  5089. expInfo.state = "异常";
  5090. expInfo.isMultiDelivery = 1;
  5091. expInfo.Update();
  5092. continue;
  5093. }
  5094. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  5095. {
  5096. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  5097. expInfo.state = "异常";
  5098. expInfo.Update();
  5099. continue;
  5100. }
  5101. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  5102. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  5103. bool isInitOrderDeliv = false;
  5104. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  5105. {
  5106. isInitOrderDeliv = true;
  5107. expInfo.isMultiDelivery = 1;
  5108. }
  5109. if (ctid.IndexOf("N") != -1)
  5110. {
  5111. StringBuilder sqlbucha = new StringBuilder();
  5112. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  5113. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  5114. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  5115. commonHelper.UpdateRelationOrder(ctid);
  5116. expInfo.delivery_memo = "发货成功";
  5117. expInfo.state = "发货成功";
  5118. expInfo.isMultiDelivery = 1;
  5119. expInfo.Update();
  5120. }
  5121. else
  5122. {
  5123. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  5124. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid, ctid);
  5125. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  5126. {
  5127. expInfo.delivery_memo = "发货成功";
  5128. expInfo.state = "发货成功";
  5129. expInfo.isMultiDelivery = 1;
  5130. expInfo.Update();
  5131. commonHelper.UpdateRelationOrder(ctid);
  5132. CeErpSukuraData.createInfo(ctid, 4);
  5133. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  5134. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  5135. }
  5136. else
  5137. {
  5138. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  5139. expInfo.state = "异常";
  5140. expInfo.Update();
  5141. }
  5142. }
  5143. }
  5144. }
  5145. }
  5146. returnSuccessMsg("操作完成");
  5147. }
  5148. public void reset_erp_memoopt()
  5149. {
  5150. if (UrlPostParmsCheck("ctid"))
  5151. {
  5152. string eid = GetPostString("ctid");
  5153. CeErpTradeCell entity = null;
  5154. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5155. if (entity != null)
  5156. {
  5157. string stropt = "";
  5158. if (entity.MemoOpt == 1)
  5159. {
  5160. stropt = "“改稿”";
  5161. }
  5162. else if (entity.MemoOpt == 2)
  5163. {
  5164. stropt = "“定稿”";
  5165. }
  5166. else if (entity.MemoOpt == 3)
  5167. {
  5168. stropt = "“完成查货”";
  5169. CeErpSukuraData.createInfo(entity.ctid, 6);
  5170. }
  5171. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  5172. entity.UpdateTime = DateTime.Now;
  5173. entity.MemoOpt = 0;
  5174. entity.Update();
  5175. returnSuccessMsg("操作成功!");
  5176. return;
  5177. }
  5178. returnErrorMsg("找不到记录");
  5179. }
  5180. }
  5181. public void get_erp_deliveryunusual()
  5182. {
  5183. DataStruct dStruct = GetPostStruct();
  5184. List<string> lw = new List<string>();
  5185. string tid = GetPostString("ctid");
  5186. if (tid.Length > 0)
  5187. {
  5188. string select_tid = getTidByCtid(tid);
  5189. lw.Add(string.Format("tid='{0}'", select_tid));
  5190. }
  5191. string shopname = GetPostString("shopname");
  5192. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5193. string buyernick = GetPostString("buyer_nick");
  5194. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5195. string customer = GetPostString("customer");
  5196. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5197. string design = GetPostString("design");
  5198. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5199. string sellermemo = GetPostString("seller_memo");
  5200. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5201. string supplier = GetPostString("supplier");
  5202. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5203. string date1 = GetPostString("date1");
  5204. string date2 = GetPostString("date2");
  5205. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5206. if (dw.Length > 0) lw.Add(dw);
  5207. string placedate1 = GetPostString("placedate1");
  5208. string placedate2 = GetPostString("placedate2");
  5209. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5210. if (dw_place.Length > 0) lw.Add(dw_place);
  5211. string price1 = GetPostString("price1");
  5212. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5213. string price2 = GetPostString("price2");
  5214. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5215. string unusualCon = GetPostString("unusualcon");
  5216. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5217. string posTag = CurrentUser.UserPost.Post.Code;
  5218. if (posTag == "Supplier")
  5219. {
  5220. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5221. }
  5222. lw.Add(string.Format("OrderState = 6"));
  5223. lw.Add(string.Format("UnusualTag = 5"));
  5224. lw.Add(string.Format("IsRefund<={0}", 1));
  5225. dStruct.Order = "FinishPlaceTime desc";
  5226. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5227. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5228. writeGridDataTableJson(dStruct.TotalCount, dt);
  5229. }
  5230. public void get_erp_deliveryedlist()
  5231. {
  5232. DataStruct dStruct = GetPostStruct();
  5233. List<string> lw = new List<string>();
  5234. string tid = GetPostString("ctid");
  5235. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5236. string shopname = GetPostString("shopname");
  5237. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5238. string buyernick = GetPostString("buyer_nick");
  5239. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5240. string customer = GetPostString("customer");
  5241. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5242. string design = GetPostString("design");
  5243. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5244. string sellermemo = GetPostString("seller_memo");
  5245. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5246. string logistics = GetPostString("logistics");
  5247. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5248. string date1 = GetPostString("date1");
  5249. string date2 = GetPostString("date2");
  5250. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5251. //if (dw.Length > 0) lw.Add(dw);
  5252. string placedate1 = GetPostString("placedate1");
  5253. string placedate2 = GetPostString("placedate2");
  5254. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5255. if (fdw.Length > 0) lw.Add(fdw);
  5256. string devdate1 = GetPostString("deliverydate1");
  5257. string devdate2 = GetPostString("deliverydate2");
  5258. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5259. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5260. string price1 = GetPostString("price1");
  5261. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5262. string price2 = GetPostString("price2");
  5263. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5264. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5265. {
  5266. if (tid.Length > 0)
  5267. {
  5268. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5269. if (tid.Length > 5)
  5270. {
  5271. List<string> tids = getTidByCtidLike(tid);
  5272. if (tids.Count > 0 && tids.Count < 10)
  5273. {
  5274. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5275. }
  5276. }
  5277. lw.Add(tid_sql);
  5278. }
  5279. if (buyernick.Length > 0)
  5280. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5281. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5282. if (dw.Length > 0) lw.Add(dw);
  5283. }
  5284. else
  5285. {
  5286. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5287. }
  5288. string posTag = CurrentUser.UserPost.Post.Code;
  5289. if (posTag == "Supplier")
  5290. {
  5291. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5292. }
  5293. else
  5294. {
  5295. string supplier = GetPostString("supplier");
  5296. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5297. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5298. {
  5299. string usershop = CurrentUser.User.pemShop;
  5300. lw.Add(string.Format("ShopId in ({0})", usershop));
  5301. }
  5302. }
  5303. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5304. lw.Add(string.Format("type != 'PDD' "));
  5305. lw.Add(string.Format("IsRefund!={0}", 2));
  5306. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5307. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5308. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5309. /*if (tid.Length > 0)
  5310. {
  5311. List<string> tids = new List<string>();
  5312. if (dt != null && dt.Rows.Count > 0)
  5313. {
  5314. foreach (DataRow item in dt.Rows)
  5315. {
  5316. tids.Add("'" + item["tid"] + "'");
  5317. }
  5318. }
  5319. if (tids.Count > 0)
  5320. {
  5321. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5322. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5323. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5324. dt = WebCache.GetData("view_erptradecell", dStruct);
  5325. }
  5326. }*/
  5327. if (dt != null)
  5328. {
  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. }
  5334. writeGridDataTableJson(dStruct.TotalCount, dt);
  5335. }
  5336. public void get_erp_pdddeliveryed()
  5337. {
  5338. DataStruct dStruct = GetPostStruct();
  5339. List<string> lw = new List<string>();
  5340. string tid = GetPostString("ctid");
  5341. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5342. string shopname = GetPostString("shopname");
  5343. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5344. string buyernick = GetPostString("buyer_nick");
  5345. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5346. string customer = GetPostString("customer");
  5347. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5348. string design = GetPostString("design");
  5349. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5350. string sellermemo = GetPostString("seller_memo");
  5351. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5352. string logistics = GetPostString("logistics");
  5353. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5354. string date1 = GetPostString("date1");
  5355. string date2 = GetPostString("date2");
  5356. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5357. //if (dw.Length > 0) lw.Add(dw);
  5358. string placedate1 = GetPostString("placedate1");
  5359. string placedate2 = GetPostString("placedate2");
  5360. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5361. if (fdw.Length > 0) lw.Add(fdw);
  5362. string devdate1 = GetPostString("deliverydate1");
  5363. string devdate2 = GetPostString("deliverydate2");
  5364. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5365. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5366. string price1 = GetPostString("price1");
  5367. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5368. string price2 = GetPostString("price2");
  5369. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5370. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5371. {
  5372. if (tid.Length > 0)
  5373. {
  5374. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5375. if (tid.Length > 5)
  5376. {
  5377. List<string> tids = getTidByCtidLike(tid);
  5378. if (tids.Count > 0 && tids.Count < 10)
  5379. {
  5380. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5381. }
  5382. }
  5383. lw.Add(tid_sql);
  5384. }
  5385. if (buyernick.Length > 0)
  5386. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5387. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5388. if (dw.Length > 0) lw.Add(dw);
  5389. }
  5390. else
  5391. {
  5392. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5393. }
  5394. string posTag = CurrentUser.UserPost.Post.Code;
  5395. if (posTag == "Supplier")
  5396. {
  5397. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5398. }
  5399. else
  5400. {
  5401. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5402. {
  5403. string usershop = CurrentUser.User.pemShop;
  5404. lw.Add(string.Format("ShopId in ({0})", usershop));
  5405. }
  5406. string supplier = GetPostString("supplier");
  5407. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5408. }
  5409. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5410. lw.Add(string.Format("type = 'PDD' "));
  5411. lw.Add(string.Format("IsRefund!={0}", 2));
  5412. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5414. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5415. /* if (tid.Length > 0)
  5416. {
  5417. List<string> tids = new List<string>();
  5418. if (dt != null && dt.Rows.Count > 0)
  5419. {
  5420. foreach (DataRow item in dt.Rows)
  5421. {
  5422. tids.Add("'" + item["tid"] + "'");
  5423. }
  5424. }
  5425. if (tids.Count > 0)
  5426. {
  5427. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5428. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5429. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5430. dt = WebCache.GetData("view_erptradecell", dStruct);
  5431. }
  5432. }*/
  5433. foreach (DataRow dr in dt.Rows)
  5434. {
  5435. 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();
  5436. }
  5437. writeGridDataTableJson(dStruct.TotalCount, dt);
  5438. }
  5439. public void get_erp_jddeliveryed()
  5440. {
  5441. DataStruct dStruct = GetPostStruct();
  5442. List<string> lw = new List<string>();
  5443. string tid = GetPostString("ctid");
  5444. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5445. string shopname = GetPostString("shopname");
  5446. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5447. string buyernick = GetPostString("buyer_nick");
  5448. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5449. string customer = GetPostString("customer");
  5450. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5451. string design = GetPostString("design");
  5452. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5453. string sellermemo = GetPostString("seller_memo");
  5454. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5455. string date1 = GetPostString("date1");
  5456. string date2 = GetPostString("date2");
  5457. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5458. //if (dw.Length > 0) lw.Add(dw);
  5459. string placedate1 = GetPostString("placedate1");
  5460. string placedate2 = GetPostString("placedate2");
  5461. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5462. if (fdw.Length > 0) lw.Add(fdw);
  5463. string devdate1 = GetPostString("deliverydate1");
  5464. string devdate2 = GetPostString("deliverydate2");
  5465. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5466. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5467. string price1 = GetPostString("price1");
  5468. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5469. string price2 = GetPostString("price2");
  5470. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5471. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5472. {
  5473. if (tid.Length > 0)
  5474. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5475. if (buyernick.Length > 0)
  5476. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5477. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5478. if (dw.Length > 0) lw.Add(dw);
  5479. }
  5480. else
  5481. {
  5482. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5483. }
  5484. string posTag = CurrentUser.UserPost.Post.Code;
  5485. if (posTag == "Supplier")
  5486. {
  5487. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5488. }
  5489. else
  5490. {
  5491. string supplier = GetPostString("supplier");
  5492. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5493. }
  5494. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5495. lw.Add(string.Format("type = 'JD' "));
  5496. lw.Add(string.Format("IsRefund!={0}", 2));
  5497. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5498. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5499. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5500. foreach (DataRow dr in dt.Rows)
  5501. {
  5502. 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();
  5503. }
  5504. writeGridDataTableJson(dStruct.TotalCount, dt);
  5505. }
  5506. public void get_erp_allplacelist()
  5507. {
  5508. DataStruct dStruct = GetPostStruct();
  5509. List<string> lw = new List<string>();
  5510. string tid = GetPostString("ctid");
  5511. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5512. string shopname = GetPostString("shopname");
  5513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5514. string buyernick = GetPostString("buyer_nick");
  5515. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5516. string customer = GetPostString("customer");
  5517. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5518. string design = GetPostString("design");
  5519. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5520. string sellermemo = GetPostString("seller_memo");
  5521. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5522. string supplier = GetPostString("supplier");
  5523. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5524. string date1 = GetPostString("date1");
  5525. string date2 = GetPostString("date2");
  5526. string pldate1 = GetPostString("placedate1");
  5527. string pldate2 = GetPostString("placedate2");
  5528. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5529. //if (dw.Length > 0) lw.Add(dw);
  5530. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5531. {
  5532. if (tid.Length > 0)
  5533. {
  5534. string select_tid = getTidByCtid(tid);
  5535. lw.Add(string.Format("tid='{0}'", select_tid));
  5536. }
  5537. if (buyernick.Length > 0)
  5538. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5539. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5540. if (dw.Length > 0) lw.Add(dw);
  5541. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5542. if (dw_place.Length > 0) lw.Add(dw_place);
  5543. }
  5544. else
  5545. {
  5546. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5547. {
  5548. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5549. }
  5550. }
  5551. string price1 = GetPostString("price1");
  5552. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5553. string price2 = GetPostString("price2");
  5554. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5555. string posTag = CurrentUser.UserPost.Post.Code;
  5556. if (posTag == "Supplier")
  5557. {
  5558. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5559. }
  5560. lw.Add(string.Format("OrderState >= 6"));
  5561. lw.Add(string.Format("IsSample != 2 "));
  5562. //lw.Add(string.Format("isDianziOrder = 0 "));
  5563. lw.Add(string.Format("SupplierId > 0 "));
  5564. //lw.Add(string.Format("IsRefund<={0}", 1));
  5565. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5566. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5567. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5568. foreach (DataRow dr in dt.Rows)
  5569. {
  5570. 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();
  5571. }
  5572. writeGridDataTableJson(dStruct.TotalCount, dt);
  5573. }
  5574. public void get_erp_financeallplacelist()
  5575. {
  5576. DataStruct dStruct = GetPostStruct();
  5577. List<string> lw = new List<string>();
  5578. string tid = GetPostString("ctid");
  5579. string shopname = GetPostString("shopname");
  5580. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5581. string buyernick = GetPostString("buyer_nick");
  5582. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5583. string customer = GetPostString("customer");
  5584. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5585. string design = GetPostString("design");
  5586. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5587. string sellermemo = GetPostString("seller_memo");
  5588. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5589. string supplier = GetPostString("supplier");
  5590. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5591. string date1 = GetPostString("date1");
  5592. string date2 = GetPostString("date2");
  5593. string pldate1 = GetPostString("placedate1");
  5594. string pldate2 = GetPostString("placedate2");
  5595. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5596. {
  5597. if (tid.Length > 0)
  5598. {
  5599. string select_tid = getTidByCtid(tid);
  5600. lw.Add(string.Format("tid='{0}'", select_tid));
  5601. }
  5602. if (buyernick.Length > 0)
  5603. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5604. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5605. if (dw.Length > 0) lw.Add(dw);
  5606. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5607. if (dw_place.Length > 0) lw.Add(dw_place);
  5608. }
  5609. else
  5610. {
  5611. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5612. {
  5613. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5614. }
  5615. }
  5616. string price1 = GetPostString("price1");
  5617. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5618. string price2 = GetPostString("price2");
  5619. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5620. string posTag = CurrentUser.UserPost.Post.Code;
  5621. if (posTag == "Supplier")
  5622. {
  5623. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5624. }
  5625. //lw.Add(string.Format("OrderState >= 6"));
  5626. lw.Add(string.Format("IsSample != 2 "));
  5627. lw.Add(string.Format("isDianziOrder = 0 "));
  5628. //lw.Add(string.Format("IsRefund<={0}", 1));
  5629. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5630. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5631. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5632. foreach (DataRow dr in dt.Rows)
  5633. {
  5634. 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();
  5635. }
  5636. writeGridDataTableJson(dStruct.TotalCount, dt);
  5637. }
  5638. public void get_erp_expresslist()
  5639. {
  5640. int listtype = GetInt("ltype");
  5641. DataStruct dStruct = GetPostStruct();
  5642. List<string> lw = new List<string>();
  5643. string tid = GetPostString("tid");
  5644. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5645. string outsid = GetPostString("out_sid");
  5646. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5647. string importer = GetPostString("ImportUserName");
  5648. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5649. string file = GetPostString("import_file");
  5650. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5651. string printman = GetPostString("printman");
  5652. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5653. string date1 = GetPostString("date1");
  5654. string date2 = GetPostString("date2");
  5655. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5656. if (dw.Length > 0) lw.Add(dw);
  5657. string fdate1 = GetPostString("finishdate1");
  5658. string fdate2 = GetPostString("finishdate2");
  5659. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5660. if (fdw.Length > 0) lw.Add(fdw);
  5661. string supplierId = GetPostString("supplierId");
  5662. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5663. if (listtype == 1)
  5664. {
  5665. lw.Add(string.Format("importUserId !=0"));
  5666. }
  5667. string posTag = CurrentUser.UserPost.Post.Code;
  5668. if (posTag == "Supplier")
  5669. {
  5670. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5671. }
  5672. if (dStruct.PageSize != 100000)
  5673. {
  5674. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5675. }
  5676. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5677. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5678. writeGridDataTableJson(dStruct.TotalCount, dt);
  5679. }
  5680. public void set_erp_buchaorderdelivery()
  5681. {
  5682. if (UrlPostParmsCheck("ctid"))
  5683. {
  5684. string eid = GetPostString("ctid");
  5685. CeErpTradeCell entity = null;
  5686. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5687. if (entity != null)
  5688. {
  5689. if (entity.IsSample != 2)
  5690. {
  5691. returnErrorMsg("补差价单才能标记为已发货");
  5692. return;
  5693. }
  5694. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5695. entity.OrderState = 7;
  5696. entity.Update();
  5697. returnSuccessMsg("操作成功!");
  5698. return;
  5699. }
  5700. returnErrorMsg("找不到记录");
  5701. }
  5702. }
  5703. public void get_stdtemplates()
  5704. {
  5705. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5706. //string res = taobaoHelper.test();
  5707. string res = apiHelper.API_PrintTemplate();
  5708. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5709. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5710. {
  5711. int sidx = res.IndexOf("error_code");
  5712. int eidx = res.IndexOf("success");
  5713. string msg = res.Substring(sidx, eidx - sidx);
  5714. returnErrorMsg(msg);
  5715. return;
  5716. }
  5717. if (res.Length <= 0)
  5718. {
  5719. returnErrorMsg("模板数据为空!");
  5720. return;
  5721. }
  5722. ReturnSuccess(res);
  5723. }
  5724. public void cancel_print_order()
  5725. {
  5726. if (UrlPostParmsCheck("ctid"))
  5727. {
  5728. string ctid = GetPostString("ctid");
  5729. CeErpTradeCell entity = null;
  5730. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5731. if (entity != null)
  5732. {
  5733. string res = "";
  5734. string code = entity.LastBillWaybillCode;
  5735. if (code == "")
  5736. {
  5737. code = entity.OutSid;
  5738. }
  5739. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5740. XLog.SaveLog(0, "取消面单" + res);
  5741. }
  5742. }
  5743. }
  5744. public void set_erp_printwaybill()
  5745. {
  5746. if (UrlPostParmsCheck("ctid"))
  5747. {
  5748. string ctid = GetPostString("ctid");
  5749. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5750. string cpName = GetPostString("cpname");
  5751. string isTogether = GetPostString("together");
  5752. string printType = GetPostString("printType");
  5753. //var res_obj = new
  5754. //{
  5755. // restype = 1,
  5756. // 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\"}"
  5757. //};
  5758. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5759. //ReturnSuccess(ro_json);
  5760. //return;
  5761. bool isUseLastWayBillCode = false;
  5762. CeErpTradeCell entity = null;
  5763. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5764. if (entity != null)
  5765. {
  5766. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5767. {
  5768. isUseLastWayBillCode = true;
  5769. }
  5770. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5771. {
  5772. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5773. return;
  5774. }
  5775. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5776. {
  5777. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5778. return;
  5779. }
  5780. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5781. {
  5782. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5783. return;
  5784. }
  5785. }
  5786. string res = "";
  5787. Api_waybill_code_response_Obj fullObj = null;
  5788. string pData_str = "";
  5789. string curUseWayBillCode = "";
  5790. if (isUseLastWayBillCode == false)
  5791. {
  5792. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5793. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5794. if (res.IndexOf("failure") != -1)
  5795. {
  5796. //int idx = res.IndexOf("sub_message");
  5797. //int idx2 = res.IndexOf("flag");
  5798. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5799. string errMsgNeed = commonHelper.KeepChinese(res);
  5800. var res_objd = new
  5801. {
  5802. restype = 0,
  5803. data = "获取面单失败" + errMsgNeed
  5804. };
  5805. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5806. returnSuccess(ro_jsond);
  5807. if (res.IndexOf("停发") != -1)
  5808. {
  5809. entity.UnusualCon = "物流停发";
  5810. entity.Update();
  5811. }
  5812. //returnErrorMsg("获取面单失败,"+emsg);
  5813. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5814. return;
  5815. }
  5816. else if (res.IndexOf("errorMsg") != -1)
  5817. {
  5818. //int idx = res.IndexOf("errorMsg");
  5819. //int idx2 = res.IndexOf("}]}");
  5820. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5821. string errMsgNeed = commonHelper.KeepChinese(res);
  5822. var res_objf = new
  5823. {
  5824. restype = 0,
  5825. data = "获取面单失败2" + errMsgNeed
  5826. };
  5827. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5828. if (res.IndexOf("停发") != -1)
  5829. {
  5830. entity.UnusualCon = "物流停发";
  5831. entity.Update();
  5832. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5833. if (trade != null)
  5834. {
  5835. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5836. }
  5837. }
  5838. returnSuccess(ro_jsonf);
  5839. //returnErrorMsg("获取面单失败," + emsg);
  5840. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5841. return;
  5842. }
  5843. try
  5844. {
  5845. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5846. //res = res.Replace(" ", "");
  5847. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5848. }
  5849. catch (Exception ex)
  5850. {
  5851. XLog.SaveLog(0, "生成fullObj" + res);
  5852. var res_objf = new
  5853. {
  5854. restype = 0,
  5855. data = "生成fullObj发生错误" + ex.Message
  5856. };
  5857. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5858. returnSuccess(ro_jsonf);
  5859. return;
  5860. }
  5861. if (fullObj.response.data.content.Count > 0)
  5862. {
  5863. ContentItem codeObj = fullObj.response.data.content[0];
  5864. if (cpCode.IndexOf("SFFQ-") != -1)
  5865. {
  5866. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5867. }
  5868. else
  5869. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5870. curUseWayBillCode = codeObj.waybillCode;
  5871. }
  5872. else
  5873. {
  5874. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5875. var res_objf = new
  5876. {
  5877. restype = 0,
  5878. data = "生成fullObj找不到快递单号waybillCode"
  5879. };
  5880. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5881. returnSuccess(ro_jsonf);
  5882. return;
  5883. }
  5884. }
  5885. else
  5886. {
  5887. //使用上次打印的快递单号
  5888. if (cpCode == "SFFQ-LY")
  5889. {
  5890. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5891. }
  5892. else
  5893. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5894. curUseWayBillCode = entity.LastBillWaybillCode;
  5895. }
  5896. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5897. {
  5898. var res_obje = new
  5899. {
  5900. restype = 0,
  5901. data = "获取加密打印数据失败"
  5902. };
  5903. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5904. returnSuccess(ro_jsone);
  5905. entity.LastBillCpCode = cpCode;
  5906. entity.LastBillWaybillCode = curUseWayBillCode;
  5907. entity.Update();
  5908. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5909. //returnErrorMsg("获取加密打印数据失败");
  5910. return;
  5911. }
  5912. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5913. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5914. string btnType = "";
  5915. string errorMsg = "";
  5916. if (entity != null)
  5917. {
  5918. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5919. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5920. //cpcode是 YTO-CAINIAO
  5921. //string comCode = cpCode.Split('-')[0].ToString();
  5922. string apires = "";
  5923. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5924. //isTogether=2是新的合包弹窗
  5925. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5926. {
  5927. if (ctid.IndexOf("N") != -1)
  5928. {
  5929. apires = "发货成功";
  5930. }
  5931. else
  5932. {
  5933. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode, entity.ctid);
  5934. }
  5935. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5936. //打单后发货
  5937. StringBuilder sql = new StringBuilder();
  5938. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5939. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5940. {
  5941. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5942. }
  5943. else
  5944. {
  5945. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5946. }
  5947. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5948. foreach (DataRow row in dt.Rows)
  5949. {
  5950. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5951. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5952. {
  5953. try
  5954. {
  5955. btnType = "待发货";
  5956. entity.OutSid = curUseWayBillCode;
  5957. entity.OrderState = 7;
  5958. entity.IsUrgency = false;
  5959. entity.LastBillCpCode = "";
  5960. entity.LastBillWaybillCode = "";
  5961. entity.FinishDeliveryTime = DateTime.Now;
  5962. entity.IsReturn = 0;
  5963. entity.MemoOpt = 0;
  5964. entity.UpdateTime = DateTime.Now;
  5965. entity.Update();
  5966. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5967. //还要插入快递信息到 快递信息表
  5968. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5969. exinfo.tid = entity.ctid;
  5970. exinfo.out_sid = curUseWayBillCode;
  5971. exinfo.company_code = cpCode;
  5972. exinfo.company_name = cpName;
  5973. exinfo.supplierUserName = supplierName;
  5974. exinfo.deliveryType = "发货成功";
  5975. exinfo.print_time = DateTime.Now;
  5976. exinfo.printUser = CurrentUser.UserName;
  5977. exinfo.postData = pData_str;
  5978. exinfo.Create();
  5979. commonHelper.UpdateRelationOrder(entity.ctid);
  5980. CeErpSukuraData.createInfo(ctid, 4);
  5981. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5982. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126 || entity.SupplierId == 96)
  5983. {
  5984. commonHelper.sendCytExpress(exinfo);
  5985. }
  5986. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5987. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5988. }
  5989. catch (Exception ex)
  5990. {
  5991. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5992. }
  5993. }
  5994. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5995. {
  5996. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5997. if (entity.OrderState == 6)
  5998. {
  5999. entity.OrderState = 7;
  6000. }
  6001. entity.UpdateTime = DateTime.Now;
  6002. entity.FinishDeliveryTime = DateTime.Now;
  6003. btnType = "已发货";
  6004. entity.Update();
  6005. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  6006. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6007. exinfo.tid = entity.ctid;
  6008. exinfo.out_sid = curUseWayBillCode;
  6009. exinfo.company_code = cpCode;
  6010. exinfo.company_name = cpName;
  6011. exinfo.supplierUserName = supplierName;
  6012. exinfo.deliveryType = "发货成功";
  6013. exinfo.print_time = DateTime.Now;
  6014. exinfo.printUser = CurrentUser.UserName;
  6015. exinfo.postData = pData_str;
  6016. exinfo.Create();
  6017. commonHelper.UpdateRelationOrder(entity.ctid);
  6018. CeErpSukuraData.createInfo(entity.ctid, 4);
  6019. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126 || entity.SupplierId == 96)
  6020. {
  6021. commonHelper.sendCytExpress(exinfo);
  6022. }
  6023. //不处理
  6024. }
  6025. else
  6026. {
  6027. entity.UpdateTime = DateTime.Now;
  6028. entity.LastBillCpCode = cpCode;
  6029. entity.LastBillWaybillCode = curUseWayBillCode;
  6030. entity.Update();
  6031. string errmsg = commonHelper.KeepChinese(apires);
  6032. var res_objz = new
  6033. {
  6034. restype = 0,
  6035. data = "打单后发货失败"
  6036. };
  6037. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6038. returnSuccess(ro_jsonz);
  6039. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  6040. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  6041. return;
  6042. }
  6043. }
  6044. }
  6045. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  6046. {
  6047. string ctids = GetPostString("ctids");
  6048. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  6049. List<string> list = new List<string>();
  6050. List<string> send_list = new List<string>();
  6051. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  6052. CeErpTrade ceErpTrade = new CeErpTrade();
  6053. //可合包的合并一起发货
  6054. if (dt == null && string.IsNullOrEmpty(ctids))
  6055. {
  6056. var res_objz = new
  6057. {
  6058. restype = 0,
  6059. data = "打单后发货失败"
  6060. };
  6061. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6062. returnSuccess(ro_jsonz);
  6063. return;
  6064. }
  6065. if (!string.IsNullOrEmpty(ctids))
  6066. {
  6067. StringBuilder sql = new StringBuilder();
  6068. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  6069. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  6070. }
  6071. foreach (DataRow row in dt.Rows)
  6072. {
  6073. list.Add("'" + row["ctid"] + "'");
  6074. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  6075. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  6076. if (ctid.IndexOf("N") != -1)
  6077. {
  6078. apires = "发货成功";
  6079. }
  6080. else
  6081. {
  6082. if (!send_list.Contains(ceErpTrade.tid))
  6083. {
  6084. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode, ctid);
  6085. }
  6086. else
  6087. {
  6088. apires = "发货成功";
  6089. }
  6090. }
  6091. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  6092. {
  6093. send_list.Add(ceErpTrade.tid);
  6094. try
  6095. {
  6096. btnType = "待发货";
  6097. ceErpTradeCell.OutSid = curUseWayBillCode;
  6098. ceErpTradeCell.OrderState = 7;
  6099. ceErpTradeCell.IsUrgency = false;
  6100. ceErpTradeCell.LastBillCpCode = "";
  6101. ceErpTradeCell.LastBillWaybillCode = "";
  6102. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  6103. ceErpTradeCell.IsReturn = 0;
  6104. ceErpTradeCell.MemoOpt = 0;
  6105. ceErpTradeCell.UpdateTime = DateTime.Now;
  6106. ceErpTradeCell.Update();
  6107. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  6108. //还要插入快递信息到 快递信息表
  6109. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6110. exinfo.tid = ceErpTradeCell.ctid;
  6111. exinfo.out_sid = curUseWayBillCode;
  6112. exinfo.company_code = cpCode;
  6113. exinfo.company_name = cpName;
  6114. exinfo.supplierUserName = supplierName;
  6115. exinfo.deliveryType = "发货成功";
  6116. exinfo.print_time = DateTime.Now;
  6117. exinfo.printUser = CurrentUser.UserName;
  6118. exinfo.postData = pData_str;
  6119. exinfo.Create();
  6120. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  6121. CeErpSukuraData.createInfo(ctid, 4);
  6122. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  6123. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126 || entity.SupplierId == 96)
  6124. {
  6125. commonHelper.sendCytExpress(exinfo);
  6126. }
  6127. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  6128. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6129. }
  6130. catch (Exception ex)
  6131. {
  6132. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  6133. }
  6134. }
  6135. else
  6136. {
  6137. ceErpTradeCell.UpdateTime = DateTime.Now;
  6138. ceErpTradeCell.LastBillCpCode = cpCode;
  6139. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  6140. ceErpTradeCell.Update();
  6141. string errmsg = commonHelper.KeepChinese(apires);
  6142. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  6143. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  6144. }
  6145. }
  6146. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  6147. }
  6148. }
  6149. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  6150. var res_obj = new
  6151. {
  6152. restype = 1,
  6153. data = pData_str,
  6154. errorMsg
  6155. };
  6156. string ro_json = JsonConvert.SerializeObject(res_obj);
  6157. ReturnSuccess(ro_json);
  6158. return;
  6159. }
  6160. }
  6161. private string GetUTF8String(byte[] vs)
  6162. {
  6163. throw new NotImplementedException();
  6164. }
  6165. public void set_erp_printwaybill_cn()
  6166. {
  6167. if (UrlPostParmsCheck("ctid"))
  6168. {
  6169. string ctid = GetPostString("ctid");
  6170. string cpCode = GetPostString("cpcode");
  6171. string cpName = GetPostString("cpname");
  6172. string tempUrl = GetPostString("tempurl");
  6173. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6174. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  6175. //string res = taobaoHelper.test();
  6176. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6177. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  6178. {
  6179. int sidx = res.IndexOf("errorMsg");
  6180. int eidx = res.IndexOf("}");
  6181. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  6182. var res_objzxx = new
  6183. {
  6184. restype = 0,
  6185. data = msg
  6186. };
  6187. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  6188. returnSuccess(ro_jsonzxx);
  6189. //returnErrorMsg(msg);
  6190. return;
  6191. }
  6192. int idx = res.IndexOf("waybillCode");
  6193. int idx2 = res.IndexOf("printData");
  6194. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  6195. string eid = GetPostString("ctid");
  6196. CeErpTradeCell entity = null;
  6197. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6198. if (entity != null)
  6199. {
  6200. string osid = entity.OutSid;
  6201. entity.OutSid = osid + "," + outsid;
  6202. entity.FinishDeliveryTime = DateTime.Now;
  6203. entity.OrderState = 7;
  6204. entity.UpdateTime = DateTime.Now;
  6205. entity.IsReturn = 0;
  6206. entity.Update();
  6207. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6208. exinfo.tid = entity.ctid;
  6209. exinfo.out_sid = outsid;
  6210. exinfo.company_code = cpCode;
  6211. exinfo.company_name = cpName;
  6212. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6213. exinfo.deliveryType = "发货成功";
  6214. exinfo.print_time = DateTime.Now;
  6215. exinfo.printUser = CurrentUser.UserName;
  6216. exinfo.Create();
  6217. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126 || entity.SupplierId == 96)
  6218. {
  6219. commonHelper.sendCytExpress(exinfo);
  6220. }
  6221. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6222. }
  6223. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6224. var res_objz = new
  6225. {
  6226. restype = 1,
  6227. data = res
  6228. };
  6229. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6230. returnSuccess(ro_jsonz);
  6231. //ReturnSuccess(res);
  6232. }
  6233. }
  6234. ////打单,打印面单 获取面单号
  6235. //public void set_erp_printwaybill()
  6236. //{
  6237. // if (UrlPostParmsCheck("ctid"))
  6238. // {
  6239. // string ctid = GetPostString("ctid");
  6240. // string cpCode = GetPostString("cpcode");
  6241. // string tempUrl = GetPostString("tempurl");
  6242. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6243. // //string res = taobaoHelper.test();
  6244. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6245. // if (res.IndexOf("error_response") != -1)
  6246. // {
  6247. // int sidx = res.IndexOf("sub_msg");
  6248. // int eidx = res.IndexOf("request_id");
  6249. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6250. // returnErrorMsg(msg);
  6251. // return;
  6252. // }
  6253. // int idx = res.IndexOf("waybill_code");
  6254. // int idx2 = res.IndexOf("}]}");
  6255. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6256. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6257. // ReturnSuccess(res);
  6258. // }
  6259. //}
  6260. public void cancel_erp_aftersale()
  6261. {
  6262. if (UrlPostParmsCheck("ctid"))
  6263. {
  6264. string eid = GetPostString("ctid");
  6265. CeErpTradeCell entity = null;
  6266. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6267. if (entity != null)
  6268. {
  6269. //有过处理的售后,取消也不能删除 售 字,保留
  6270. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6271. {
  6272. entity.AfterSaleState = 4;
  6273. }
  6274. else
  6275. entity.AfterSaleState = 0;
  6276. entity.UpdateTime = DateTime.Now;
  6277. entity.Update();
  6278. returnSuccessMsg("操作成功!");
  6279. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6280. return;
  6281. }
  6282. returnErrorMsg("找不到订单记录");
  6283. }
  6284. }
  6285. public void get_erp_aftersalelist()
  6286. {
  6287. DataStruct dStruct = GetPostStruct();
  6288. List<string> lw = new List<string>();
  6289. int st = GetInt("st");
  6290. string tid = GetPostString("ctid");
  6291. if (st == 3)
  6292. {
  6293. if (tid.Length > 0)
  6294. {
  6295. string select_tid = getTidByCtid(tid);
  6296. lw.Add(string.Format("tid='{0}'", select_tid));
  6297. }
  6298. }
  6299. else
  6300. {
  6301. if (tid.Length > 0)
  6302. {
  6303. string select_tid = getTidByCtid(tid);
  6304. lw.Add(string.Format("tid='{0}'", select_tid));
  6305. }
  6306. }
  6307. string shopname = GetPostString("shopname");
  6308. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6309. string buyernick = GetPostString("buyer_nick");
  6310. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6311. string sellermemo = GetPostString("seller_memo");
  6312. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6313. string orderState = GetPostString("orderState");
  6314. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6315. string afterState = GetPostString("afterstate");
  6316. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6317. string date1 = GetPostString("date1");
  6318. string date2 = GetPostString("date2");
  6319. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6320. if (dw.Length > 0) lw.Add(dw);
  6321. string price1 = GetPostString("price1");
  6322. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6323. string price2 = GetPostString("price2");
  6324. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6325. //lw.Add(string.Format("IsRefund!={0}", 1));
  6326. string reason = GetPostString("reason");
  6327. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6328. string method = GetPostString("method");
  6329. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6330. string handler = GetPostString("handler");
  6331. if (handler.Length > 0)
  6332. {
  6333. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6334. }
  6335. string handledate1 = GetPostString("handledate1");
  6336. string handledate2 = GetPostString("handledate2");
  6337. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6338. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6339. string finish1 = GetPostString("finishdate1");
  6340. string finish2 = GetPostString("finishdate2");
  6341. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6342. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6343. string afterdate1 = GetPostString("afterdate1");
  6344. string afterdate2 = GetPostString("afterdate2");
  6345. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6346. if (afterDate.Length > 0) lw.Add(afterDate);
  6347. string supplier = GetPostString("supplier");
  6348. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6349. string responsible = GetPostString("responsibleman");
  6350. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6351. string customer = GetPostString("customer");
  6352. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6353. string design = GetPostString("design");
  6354. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6355. string afterMemoType = GetPostString("aftermemotype");
  6356. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6357. string posCode = CurrentUser.UserPost.Post.Code;
  6358. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6359. //{
  6360. // string vstate = GetPostString("vstate");
  6361. // if (vstate.Length > 0)
  6362. // {
  6363. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6364. // }
  6365. // if (posCode == "Supplier")
  6366. // {
  6367. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6368. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6369. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6370. // }
  6371. // else
  6372. // {
  6373. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6374. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6375. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6376. // {
  6377. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6378. // }
  6379. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6380. // {
  6381. // int orgid = CurrentUser.UserPost.OrgID;
  6382. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6383. // }
  6384. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6385. // {
  6386. // string shopid = CurrentUser.User.pemShop;
  6387. // lw.Add(string.Format("shopId in ({0})", shopid));
  6388. // }
  6389. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6390. // //{
  6391. // // int org_id = CurrentUser.UserPost.OrgID;
  6392. // // lw.Add(string.Format("OrgID={0}", org_id));
  6393. // //}
  6394. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6395. // }
  6396. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6397. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6398. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6399. //}
  6400. if (st == 5)
  6401. {
  6402. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6403. {
  6404. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6405. {
  6406. string shopid = CurrentUser.User.pemShop;
  6407. lw.Add(string.Format("shopId in ({0})", shopid));
  6408. }
  6409. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6410. {
  6411. int mrOrgid = CurrentUser.UserPost.OrgID;
  6412. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6413. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6414. }
  6415. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6416. //{
  6417. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6418. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6419. //}
  6420. else
  6421. {
  6422. string userIdStr = "";
  6423. if (posCode == "CustomerService")
  6424. {
  6425. userIdStr = CurrentUser.UserID + "_k";
  6426. }
  6427. else if (posCode == "Designer" || posCode == "wxDesigner")
  6428. {
  6429. userIdStr = CurrentUser.UserID + "_s";
  6430. }
  6431. else if (posCode == "Place")
  6432. {
  6433. userIdStr = CurrentUser.UserID + "_x";
  6434. }
  6435. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6436. }
  6437. }
  6438. string placedate1 = GetPostString("placedate1");
  6439. string placedate2 = GetPostString("placedate2");
  6440. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6441. if (dwplace.Length > 0) lw.Add(dwplace);
  6442. string supState = GetPostString("supState");
  6443. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6444. string searchType = GetPostString("searchType");
  6445. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6446. {
  6447. lw.Add(string.Format("BackNum>1"));
  6448. }
  6449. lw.Add(string.Format("AfterSaleState>0"));
  6450. if (ex_psize > 0)
  6451. {
  6452. if (CurrentUser.UserPost.Post.Code == "Finance")
  6453. dStruct.Order = "pay_time desc";
  6454. else
  6455. dStruct.Order = "HandleTime desc";
  6456. }
  6457. else
  6458. dStruct.Order = "HandleTime desc";
  6459. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6460. DataTable dt = WebCache.GetData("view_test", dStruct);
  6461. writeGridDataTableJson(dStruct.TotalCount, dt);
  6462. }
  6463. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6464. //{
  6465. // lw.Add(string.Format("AfterSaleState=4"));
  6466. // string code = CurrentUser.UserPost.Post.Code;
  6467. // if (code == "CustomerService")
  6468. // {
  6469. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6470. // }
  6471. // else if (code == "Designer" || code == "DesignerMr")
  6472. // {
  6473. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6474. // }
  6475. // else if (code == "Place" || code == "PlaceMr")
  6476. // {
  6477. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6478. // }
  6479. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6480. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6481. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6482. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6483. //}
  6484. //else //处理中的售后,待处理和处理中合并
  6485. //{
  6486. // if (afterState.Length <= 0)
  6487. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6488. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6489. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6490. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6491. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6492. //}
  6493. }
  6494. public void get_erp_disagreeftersalelist()
  6495. {
  6496. DataStruct dStruct = GetPostStruct();
  6497. List<string> lw = new List<string>();
  6498. int st = 2;
  6499. string tid = GetPostString("ctid");
  6500. if (tid.Length > 0)
  6501. {
  6502. string select_tid = getTidByCtid(tid);
  6503. lw.Add(string.Format("tid='{0}'", select_tid));
  6504. }
  6505. string shopname = GetPostString("shopname");
  6506. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6507. string buyernick = GetPostString("buyer_nick");
  6508. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6509. string sellermemo = GetPostString("seller_memo");
  6510. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6511. string orderState = GetPostString("orderState");
  6512. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6513. string afterState = GetPostString("afterstate");
  6514. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6515. string date1 = GetPostString("date1");
  6516. string date2 = GetPostString("date2");
  6517. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6518. if (dw.Length > 0) lw.Add(dw);
  6519. string price1 = GetPostString("price1");
  6520. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6521. string price2 = GetPostString("price2");
  6522. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6523. //lw.Add(string.Format("IsRefund!={0}", 1));
  6524. string reason = GetPostString("reason");
  6525. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6526. string method = GetPostString("method");
  6527. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6528. string handler = GetPostString("handler");
  6529. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6530. string handledate1 = GetPostString("handledate1");
  6531. string handledate2 = GetPostString("handledate2");
  6532. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6533. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6534. string afterdate1 = GetPostString("afterdate1");
  6535. string afterdate2 = GetPostString("afterdate2");
  6536. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6537. if (afterDate.Length > 0) lw.Add(afterDate);
  6538. string backdate1 = GetPostString("backdate1");
  6539. string backdate2 = GetPostString("backdate2");
  6540. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6541. if (backDate.Length > 0) lw.Add(backDate);
  6542. string supplier = GetPostString("supplier");
  6543. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6544. string responsible = GetPostString("responsibleman");
  6545. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6546. string customer = GetPostString("customer");
  6547. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6548. string design = GetPostString("design");
  6549. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6550. string afterSaleMemo = GetPostString("afterSaleMemo");
  6551. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6552. string afterMemoType = GetPostString("aftermemotype");
  6553. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6554. string aftersakereason = GetPostString("aftersakereason");
  6555. if (aftersakereason.Length > 0)
  6556. {
  6557. if (aftersakereason == "1")
  6558. {
  6559. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6560. }
  6561. if (aftersakereason == "2")
  6562. {
  6563. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6564. }
  6565. }
  6566. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6567. string poscode = CurrentUser.UserPost.Post.Code;
  6568. if (poscode != "SysAdmin")
  6569. {
  6570. string shopid = CurrentUser.User.pemShop;
  6571. lw.Add(string.Format("shopId in ({0})", shopid));
  6572. }
  6573. string searchType = GetPostString("searchType");
  6574. if (searchType == "wait")
  6575. {
  6576. lw.Add(string.Format("HandleTime is null"));
  6577. }
  6578. if (searchType == "handling")
  6579. {
  6580. lw.Add(string.Format("HandleTime is not null "));
  6581. }
  6582. if (searchType == "back" || searchType == "puBack")
  6583. {
  6584. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6585. }
  6586. if (searchType == "reBack")
  6587. {
  6588. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6589. }
  6590. if (searchType == "moreBack")
  6591. {
  6592. lw.Add(string.Format("backNum > 1"));
  6593. }
  6594. lw.Add(string.Format("(AfterSaleState=5)"));
  6595. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6596. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6597. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6598. writeGridDataTableJson(dStruct.TotalCount, dt);
  6599. }
  6600. public void get_erp_handlingaftersalelist()
  6601. {
  6602. DataStruct dStruct = GetPostStruct();
  6603. List<string> lw = new List<string>();
  6604. int st = 2;
  6605. string tid = GetPostString("ctid");
  6606. if (tid.Length > 0)
  6607. {
  6608. string select_tid = getTidByCtid(tid);
  6609. lw.Add(string.Format("tid='{0}'", select_tid));
  6610. }
  6611. string shopname = GetPostString("shopname");
  6612. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6613. string buyernick = GetPostString("buyer_nick");
  6614. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6615. string sellermemo = GetPostString("seller_memo");
  6616. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6617. string orderState = GetPostString("orderState");
  6618. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6619. string searchType = GetPostString("searchType");
  6620. string afterState = GetPostString("afterstate");
  6621. if (searchType != "documentary")
  6622. {
  6623. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6624. }
  6625. string date1 = GetPostString("date1");
  6626. string date2 = GetPostString("date2");
  6627. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6628. if (dw.Length > 0) lw.Add(dw);
  6629. string price1 = GetPostString("price1");
  6630. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6631. string price2 = GetPostString("price2");
  6632. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6633. //lw.Add(string.Format("IsRefund!={0}", 1));
  6634. string reason = GetPostString("reason");
  6635. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6636. string method = GetPostString("method");
  6637. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6638. string handler = GetPostString("handler");
  6639. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6640. string handledate1 = GetPostString("handledate1");
  6641. string handledate2 = GetPostString("handledate2");
  6642. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6643. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6644. string afterdate1 = GetPostString("afterdate1");
  6645. string afterdate2 = GetPostString("afterdate2");
  6646. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6647. if (afterDate.Length > 0) lw.Add(afterDate);
  6648. string supplier = GetPostString("supplier");
  6649. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6650. string responsible = GetPostString("responsibleman");
  6651. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6652. string customer = GetPostString("customer");
  6653. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6654. string design = GetPostString("design");
  6655. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6656. string afterSaleMemo = GetPostString("afterSaleMemo");
  6657. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6658. string afterMemoType = GetPostString("aftermemotype");
  6659. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6660. string afterresult = GetPostString("afterresult");
  6661. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6662. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6663. string poscode = CurrentUser.UserPost.Post.Code;
  6664. if (poscode != "SysAdmin")
  6665. {
  6666. string shopid = CurrentUser.User.pemShop;
  6667. lw.Add(string.Format("shopId in ({0})", shopid));
  6668. }
  6669. if (searchType == "wait")
  6670. {
  6671. lw.Add(string.Format("HandleTime is null"));
  6672. }
  6673. if (searchType == "documentary")
  6674. {
  6675. lw.Add(string.Format(" AfterSaleState > 2 AND HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' AND AfterSalSend = 0 "));
  6676. afterState = "2";
  6677. }
  6678. if (searchType == "handling")
  6679. {
  6680. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6681. }
  6682. if (searchType == "back" || searchType == "puBack")
  6683. {
  6684. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6685. }
  6686. if (searchType == "reBack")
  6687. {
  6688. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6689. }
  6690. if (afterState.Length <= 0)
  6691. {
  6692. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6693. }
  6694. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6695. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6696. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6697. writeGridDataTableJson(dStruct.TotalCount, dt);
  6698. }
  6699. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6700. //public void get_erp_back_handlingaftersalelist()
  6701. //{
  6702. // DataStruct dStruct = GetPostStruct();
  6703. // List<string> lw = new List<string>();
  6704. // string tid = GetPostString("ctid");
  6705. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6706. // string shopname = GetPostString("shopname");
  6707. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6708. // string buyernick = GetPostString("buyer_nick");
  6709. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6710. // string sellermemo = GetPostString("seller_memo");
  6711. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6712. // string orderState = GetPostString("orderState");
  6713. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6714. // string afterState = GetPostString("afterstate");
  6715. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6716. // string date1 = GetPostString("date1");
  6717. // string date2 = GetPostString("date2");
  6718. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6719. // if (dw.Length > 0) lw.Add(dw);
  6720. // string price1 = GetPostString("price1");
  6721. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6722. // string price2 = GetPostString("price2");
  6723. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6724. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6725. // string reason = GetPostString("reason");
  6726. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6727. // string method = GetPostString("method");
  6728. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6729. // string handler = GetPostString("handler");
  6730. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6731. // string handledate1 = GetPostString("handledate1");
  6732. // string handledate2 = GetPostString("handledate2");
  6733. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6734. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6735. // string afterdate1 = GetPostString("afterdate1");
  6736. // string afterdate2 = GetPostString("afterdate2");
  6737. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6738. // if (afterDate.Length > 0) lw.Add(afterDate);
  6739. // string supplier = GetPostString("supplier");
  6740. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6741. // string responsible = GetPostString("responsibleman");
  6742. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6743. // string customer = GetPostString("customer");
  6744. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6745. // string design = GetPostString("design");
  6746. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6747. // string afterMemoType = GetPostString("aftermemotype");
  6748. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6749. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6750. // if (afterState.Length <= 0)
  6751. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6752. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6753. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6754. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6755. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6756. //}
  6757. public void get_erp_aftersaleverifylist()
  6758. {
  6759. DataStruct dStruct = GetPostStruct();
  6760. List<string> lw = new List<string>();
  6761. string tid = GetPostString("ctid");
  6762. if (tid.Length > 0)
  6763. {
  6764. string select_tid = getTidByCtid(tid);
  6765. lw.Add(string.Format("otid='{0}'", select_tid));
  6766. }
  6767. string shopname = GetPostString("shopname");
  6768. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6769. string buyernick = GetPostString("buyer_nick");
  6770. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6771. string sellermemo = GetPostString("seller_memo");
  6772. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6773. string orderState = GetPostString("orderState");
  6774. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6775. //lw.Add(string.Format("IsRefund!={0}", 1));
  6776. string reason = GetPostString("reason");
  6777. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6778. string method = GetPostString("method");
  6779. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6780. string handler = GetPostString("handler");
  6781. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6782. string handledate1 = GetPostString("handledate1");
  6783. string handledate2 = GetPostString("handledate2");
  6784. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6785. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6786. string finish1 = GetPostString("finishdate1");
  6787. string finish2 = GetPostString("finishdate2");
  6788. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6789. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6790. string supplier = GetPostString("supplier");
  6791. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6792. string responsible = GetPostString("responsibleman");
  6793. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6794. string posCode = CurrentUser.UserPost.Post.Code;
  6795. string vstate = GetPostString("vstate");
  6796. if (vstate.Length > 0)
  6797. {
  6798. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6799. }
  6800. if (posCode == "Supplier")
  6801. {
  6802. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6803. lw.Add(string.Format("VerifyState = 0"));
  6804. lw.Add("type = 1");
  6805. lw.Add(string.Format("AfterSaleState={0}", 3));
  6806. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6807. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6808. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6809. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6810. writeGridDataTableJson(dStruct.TotalCount, dt);
  6811. }
  6812. else if (posCode == "logistics")
  6813. {
  6814. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6815. lw.Add(string.Format("VerifyState = 0"));
  6816. lw.Add("type = 2");
  6817. lw.Add(string.Format("AfterSaleState={0}", 3));
  6818. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6819. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6820. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6821. writeGridDataTableJson(dStruct.TotalCount, dt);
  6822. }
  6823. else
  6824. {
  6825. lw.Add(string.Format("(AfterSaleState = 3)"));
  6826. lw.Add("type = 0");
  6827. string reasonState = GetPostString("reasonState");
  6828. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6829. {
  6830. if (reasonState == "2")
  6831. {
  6832. lw.Add("VerifyState = 3");
  6833. }
  6834. else if (reasonState == "1")
  6835. {
  6836. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6837. }
  6838. else
  6839. {
  6840. lw.Add("VerifyState in (0,3)");
  6841. }
  6842. //不加条件,可以看全部
  6843. }
  6844. 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")
  6845. {
  6846. int orgid = CurrentUser.UserPost.OrgID;
  6847. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6848. if (string.IsNullOrEmpty(manageOrgId))
  6849. {
  6850. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6851. }
  6852. else
  6853. {
  6854. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6855. }
  6856. if (reasonState == "1")
  6857. {
  6858. lw.Add("VerifyState = 3");
  6859. }
  6860. else if (reasonState == "2")
  6861. {
  6862. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6863. }
  6864. else
  6865. {
  6866. }
  6867. }
  6868. else
  6869. {
  6870. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6871. }
  6872. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6873. //{
  6874. // int org_id = CurrentUser.UserPost.OrgID;
  6875. // lw.Add(string.Format("OrgID={0}", org_id));
  6876. //}
  6877. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6878. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6879. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6880. writeGridDataTableJson(dStruct.TotalCount, dt);
  6881. }
  6882. }
  6883. public void get_erp_finishaftersalelist()
  6884. {
  6885. DataStruct dStruct = GetPostStruct();
  6886. List<string> lw = new List<string>();
  6887. int st = 4;
  6888. string tid = GetPostString("ctid");
  6889. if (tid.Length > 0)
  6890. {
  6891. string select_tid = getTidByCtid(tid);
  6892. lw.Add(string.Format("otid='{0}'", select_tid));
  6893. }
  6894. string shopname = GetPostString("shopname");
  6895. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6896. //lw.Add(string.Format("IsRefund!={0}", 1));
  6897. string reason = GetPostString("reason");
  6898. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6899. string method = GetPostString("method");
  6900. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6901. string buyernick = GetPostString("buyer_nick");
  6902. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6903. string handler = GetPostString("handler");
  6904. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6905. string handledate1 = GetPostString("handledate1");
  6906. string handledate2 = GetPostString("handledate2");
  6907. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6908. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6909. string finish1 = GetPostString("finishdate1");
  6910. string finish2 = GetPostString("finishdate2");
  6911. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6912. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6913. string supplier = GetPostString("supplier");
  6914. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6915. string responsible = GetPostString("responsibleman");
  6916. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6917. string vstate = GetPostString("vstate");
  6918. if (vstate.Length > 0)
  6919. {
  6920. if ("3".Equals(vstate))
  6921. {
  6922. lw.Add(string.Format("IsTem=1"));
  6923. }
  6924. else
  6925. {
  6926. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6927. }
  6928. }
  6929. lw.Add(string.Format("AfterSaleState=4"));
  6930. string code = CurrentUser.UserPost.Post.Code;
  6931. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6932. {
  6933. //不加条件,可以看全部
  6934. }
  6935. else if (code == "Supplier")
  6936. {
  6937. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6938. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6939. lw.Add("type = 1");
  6940. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6941. }
  6942. else if (code == "logistics")
  6943. {
  6944. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6945. lw.Add("type = 2");
  6946. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6947. }
  6948. 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")
  6949. {
  6950. lw.Add("type = 0");
  6951. int orgid = CurrentUser.UserPost.OrgID;
  6952. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6953. if (string.IsNullOrEmpty(manageOrgIds))
  6954. {
  6955. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6956. }
  6957. else
  6958. {
  6959. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6960. }
  6961. }
  6962. else
  6963. {
  6964. lw.Add("type = 0");
  6965. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6966. }
  6967. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6968. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6969. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6970. writeGridDataTableJson(dStruct.TotalCount, dt);
  6971. }
  6972. public void handle_erp_aftersale()
  6973. {
  6974. if (UrlPostParmsCheck("ctid"))
  6975. {
  6976. string eid = GetPostString("ctid");
  6977. string responStr = GetPostString("AfterSaleResponsible");
  6978. if (responStr.Length <= 0)
  6979. {
  6980. returnErrorMsg("售后责任人不能为空");
  6981. return;
  6982. }
  6983. bool isDesign = false;
  6984. double designFree = 0.00;
  6985. int responsibleId = 0;
  6986. CeErpTradeCell entity = null;
  6987. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6988. if (entity != null)
  6989. {
  6990. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6991. string afterMethod = GetPostString("AfterSaleMethod");
  6992. if (isNeedNewOrder == 1)
  6993. {
  6994. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6995. bool ishav = true;
  6996. if (newentity == null)
  6997. {
  6998. newentity = entity.Clone() as CeErpTradeCell;
  6999. ishav = false;
  7000. newentity.ctid = "S_" + entity.ctid;
  7001. newentity.OrderState = 0;
  7002. //唯一标识
  7003. newentity.OrderSn = newentity.ctid;
  7004. string orderSn = commonHelper.generateDateTimeRandomNos();
  7005. if (orderSn != "")
  7006. {
  7007. newentity.OrderSn = orderSn;
  7008. }
  7009. }
  7010. newentity.UpdateTime = DateTime.Now;
  7011. newentity.AfterSaleState = 0;
  7012. newentity.AfterSaleMethod = afterMethod;
  7013. if (!ishav)
  7014. {
  7015. string memo_str = newentity.seller_memo;
  7016. memo_str = memo_str.Replace("(", "(");
  7017. memo_str = memo_str.Replace(")", ")");
  7018. int sIndex = memo_str.IndexOf("(");
  7019. int eIndex = memo_str.IndexOf(")");
  7020. if (sIndex == -1 || eIndex == -1)
  7021. {
  7022. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  7023. return;
  7024. }
  7025. string first = memo_str.Substring(0, sIndex + 1);
  7026. string memoCtid = newentity.OrderSn;
  7027. //if (memoCtid.IndexOf("C") != -1)
  7028. //{
  7029. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  7030. //if (CIdx.IndexOf("+") != -1)
  7031. //{
  7032. //CIdx = "C" + CIdx.Split('+')[1];
  7033. //}
  7034. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  7035. //}
  7036. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  7037. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  7038. string newMemo = first + memoCtid + last;
  7039. newentity.seller_memo = newMemo;
  7040. newentity.FinishPlaceTime = null;
  7041. newentity.UnusualTag = 0;
  7042. newentity.UnusualCon = "";
  7043. newentity.UnusualTime = null;
  7044. newentity.AfterSaleMemo = "";
  7045. newentity.AfterSaleMethod = afterMethod;
  7046. newentity.AfterSalePreTime = null;
  7047. newentity.AfterSaleReason = "";
  7048. newentity.AfterSaleResponsible = "";
  7049. newentity.AfterSaleState = 0;
  7050. newentity.AfterSaleTime = null;
  7051. newentity.AfterSaleUserId = 0;
  7052. newentity.AfterSaleSupplierState = 0;
  7053. newentity.LastBillWaybillCode = "";
  7054. newentity.LastBillCpCode = "";
  7055. newentity.FinishAfterSaleTime = null;
  7056. newentity.HandleTime = null;
  7057. newentity.IsSF = 0;
  7058. newentity.IsOldCustomer = 0;
  7059. newentity.UrgencyTime = null;
  7060. newentity.ResponsibleUserId = "";
  7061. newentity.IsVerifyToSupplier = false;
  7062. newentity.payment = 0;
  7063. newentity.CheckMemo = "";
  7064. newentity.OutSid = "";
  7065. newentity.CheckOrderTime = null;
  7066. newentity.MemoOpt = 0;
  7067. newentity.IsReturn = 0;
  7068. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  7069. }
  7070. newentity.isAfterSaleOrder = 1;
  7071. newentity.IsRefund = 0;
  7072. string receiveMobile = GetPostString("receiver_mobile");
  7073. if (receiveMobile.Length > 0)
  7074. {
  7075. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  7076. if (trade != null)
  7077. {
  7078. trade.receiver_name = GetPostString("receiver_name");
  7079. trade.receiver_mobile = receiveMobile;
  7080. trade.receiver_state = GetPostString("receiver_state");
  7081. trade.receiver_city = GetPostString("receiver_city");
  7082. trade.receiver_district = GetPostString("receiver_district");
  7083. trade.receiver_address = GetPostString("receiver_address");
  7084. newentity.IsOffLineOrder = 1;
  7085. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  7086. }
  7087. }
  7088. string st = GetPostString("ToState");
  7089. if (st.Length > 0)
  7090. {
  7091. if (newentity.OrderState <= 3)
  7092. {
  7093. newentity.WaitDesignTime = DateTime.Now;
  7094. newentity.StartDesignTime = null;
  7095. newentity.FinishDesignTime = null;
  7096. newentity.OrderState = 3;
  7097. if (st == "下单员")
  7098. {
  7099. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  7100. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  7101. {
  7102. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  7103. }
  7104. }
  7105. else
  7106. {
  7107. newentity.WaitDesignTime = DateTime.Now;
  7108. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  7109. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7110. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  7111. {
  7112. DataRow user = dt1.Rows[0];
  7113. //找主管
  7114. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  7115. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7116. if (dt != null && dt.Rows.Count > 0)
  7117. {
  7118. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  7119. newentity.DesignUserId = designMr;
  7120. string key = "aftersale_order_" + designMr;
  7121. if (RedisHelper.HasKey(key))
  7122. {
  7123. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  7124. list.Add(newentity.ctid);
  7125. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  7126. }
  7127. }
  7128. //账号正常
  7129. if (user["State"].ToString() == "0")
  7130. {
  7131. newentity.DesignUserId = entity.DesignUserId;
  7132. string key = "aftersale_order_" + entity.DesignUserId;
  7133. if (RedisHelper.HasKey(key))
  7134. {
  7135. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  7136. list.Add(newentity.ctid);
  7137. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  7138. }
  7139. }
  7140. }
  7141. }
  7142. }
  7143. if (entity.IsXianHuo == 1)
  7144. {
  7145. newentity.OrderState = 6;
  7146. entity.FinishPlaceTime = DateTime.Now;
  7147. }
  7148. }
  7149. if (ishav)
  7150. {
  7151. newentity.Update();
  7152. }
  7153. else
  7154. {
  7155. newentity.Create();
  7156. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  7157. newCellExtend.ctid = newentity.ctid;
  7158. newCellExtend.orderFrom = 20;
  7159. newCellExtend.orderType = 30;
  7160. if (st == "下单员")
  7161. {
  7162. }
  7163. else
  7164. {
  7165. newCellExtend.ReprintTime = DateTime.Now;
  7166. }
  7167. newCellExtend.Create();
  7168. }
  7169. if (st != "下单员")
  7170. {
  7171. if (entity.DispatchSort == 2)
  7172. {
  7173. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  7174. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  7175. }
  7176. }
  7177. }
  7178. //处理售后扩展
  7179. string resIdStr = GetPostString("ResponsibleUserId");
  7180. string refundFees = GetPostString("refundFrees");
  7181. int IsComplain = GetPostInt("isComplain");
  7182. int IsBad = GetPostInt("isBad");
  7183. string IsOriginal = GetPostString("isOriginal");
  7184. double diffResultPrice = GetPostDouble("diffResultPrice");
  7185. string textResult = GetPostString("textResult");
  7186. string supplierResponsible = GetPostString("supplierResponsible");
  7187. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  7188. if (ceErpTradeAfterSaleExtend == null)
  7189. {
  7190. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7191. ceErpTradeAfterSaleExtend.tid = eid;
  7192. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7193. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7194. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7195. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7196. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7197. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7198. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7199. ceErpTradeAfterSaleExtend.Create();
  7200. }
  7201. else
  7202. {
  7203. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  7204. {
  7205. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  7206. }
  7207. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7208. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7209. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7210. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7211. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7212. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7213. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7214. ceErpTradeAfterSaleExtend.Update();
  7215. }
  7216. int gysid = GetPostInt("ResponsibleSupId");
  7217. if (entity.AfterSaleUserId == 0)
  7218. {
  7219. entity.AfterSaleUserId = CurrentUser.UserID;
  7220. }
  7221. entity.ResponsibleUserId = resIdStr;
  7222. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7223. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7224. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7225. {
  7226. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7227. int backNum = 0;
  7228. if (number != null)
  7229. {
  7230. backNum = number.BackNum;
  7231. }
  7232. char[] separator = { ',' };
  7233. string[] sArray = resIdStr.Split(separator);
  7234. string[] refundFreeList = { };
  7235. if (refundFees.Length > 0)
  7236. {
  7237. refundFreeList = refundFees.Split(separator);
  7238. }
  7239. int index = -1;
  7240. List<int> responsibleIds = new List<int>();
  7241. foreach (string i in sArray)
  7242. {
  7243. index++;
  7244. if (i.Length <= 0) continue;
  7245. char[] separator2 = { '_' };
  7246. string idstr = i.Split(separator2)[0];
  7247. string idtype = i.Split(separator2)[1];
  7248. double refudFree = 0;
  7249. if (refundFreeList.Length > 0)
  7250. {
  7251. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7252. }
  7253. if (idtype == "s")
  7254. {
  7255. isDesign = true;
  7256. designFree = refudFree;
  7257. }
  7258. int userId = Convert.ToInt32(idstr);
  7259. int type = 0;
  7260. if (idtype == "g")
  7261. {
  7262. type = 1;
  7263. }
  7264. if (idtype == "w")
  7265. {
  7266. type = 2;
  7267. }
  7268. if (idtype == "t")
  7269. {
  7270. type = 3;
  7271. }
  7272. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7273. if (ceErpTradeResponsible == null)
  7274. {
  7275. ceErpTradeResponsible = new CeErpTradeResponsible();
  7276. ceErpTradeResponsible.tid = eid;
  7277. ceErpTradeResponsible.UserId = userId;
  7278. ceErpTradeResponsible.createdTime = DateTime.Now;
  7279. ceErpTradeResponsible.type = type;
  7280. if (type == 1)
  7281. {
  7282. ceErpTradeResponsible.IsSup = 1;
  7283. }
  7284. if (type == 2)
  7285. {
  7286. ceErpTradeResponsible.IsFlow = 1;
  7287. }
  7288. }
  7289. int state = 0;
  7290. //已认可的不需要再次认可
  7291. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7292. {
  7293. state = 1;
  7294. }
  7295. ceErpTradeResponsible.RefundFee = refudFree;
  7296. ceErpTradeResponsible.VerifyState = state;
  7297. if (userId == 2125 || idtype == "w")
  7298. {
  7299. ceErpTradeResponsible.VerifyState = 1;
  7300. }
  7301. if (idtype == "w" && userId == 101)
  7302. {
  7303. ceErpTradeResponsible.VerifyState = state;
  7304. }
  7305. if (ceErpTradeResponsible.ID > 0)
  7306. {
  7307. ceErpTradeResponsible.Update();
  7308. }
  7309. else
  7310. {
  7311. ceErpTradeResponsible.Create();
  7312. }
  7313. if (isDesign)
  7314. {
  7315. responsibleId = ceErpTradeResponsible.ID;
  7316. }
  7317. responsibleIds.Add(ceErpTradeResponsible.ID);
  7318. }
  7319. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7320. CeErpTradeResponsible.NumByTid(backNum, eid);
  7321. }
  7322. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7323. if (ceErpTradeCellExtend != null)
  7324. {
  7325. ceErpTradeCellExtend.returnVisit = 0;
  7326. ceErpTradeCellExtend.Update();
  7327. }
  7328. if (entity.HandleTime != null)
  7329. {
  7330. if (entity.AfterSaleState == 1)
  7331. {
  7332. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7333. }
  7334. else
  7335. {
  7336. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7337. }
  7338. }
  7339. else
  7340. {
  7341. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7342. entity.HandleTime = DateTime.Now;
  7343. }
  7344. bool isCompale = false;
  7345. if (entity.AfterSaleState == 5)
  7346. {
  7347. isCompale = true;
  7348. entity.AfterSaleState = 3;
  7349. }
  7350. entity.AfterSaleSupplierState = 0;
  7351. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7352. {
  7353. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7354. }
  7355. string sImgs = GetPostString("img");
  7356. entity.AfterSaleSupplierImg = sImgs;
  7357. entity.supRefundType = GetPostString("supRefundType");
  7358. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7359. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7360. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7361. entity.AfterSaleMemoType = GetPostString("MemoType");
  7362. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7363. {
  7364. //entity.AfterSaleSupplierState = 2;
  7365. }
  7366. string df = GetPostString("DeductFee");
  7367. if (df == "")
  7368. {
  7369. df = "0";
  7370. }
  7371. string rf = GetPostString("RefundFee");
  7372. if (rf == "")
  7373. {
  7374. rf = "0";
  7375. }
  7376. string pm = GetPostString("AfterSalePayment");
  7377. if (pm == "")
  7378. {
  7379. pm = "0";
  7380. }
  7381. entity.AfterSalePayment = Convert.ToDouble(pm);
  7382. entity.DeductFee = Convert.ToDouble(df);
  7383. entity.RefundFee = Convert.ToDouble(rf);
  7384. entity.UpdateTime = DateTime.Now;
  7385. entity.Update();
  7386. string toState = GetPostString("ToState");
  7387. string original = GetPostString("isOriginal");
  7388. ApiVo apiVo = new ApiVo();
  7389. apiVo.orderNumber = entity.ctid;
  7390. apiVo.actionName = "afterDesign";
  7391. apiVo.orderRemarks = entity.AfterSaleMethod;
  7392. apiVo.reasonRemarks = entity.AfterSaleReason;
  7393. apiVo.isDesign = isDesign;
  7394. apiVo.designFree = designFree;
  7395. apiVo.responsibleId = responsibleId;
  7396. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7397. if (toState == "设计师")
  7398. {
  7399. apiVo.isOriginal = Convert.ToBoolean(original);
  7400. }
  7401. designHelper.API_WorkCore(apiVo);//afterDesign
  7402. CeErpMethod methodSql = new CeErpMethod();
  7403. methodSql.con = entity.AfterSaleMethod;
  7404. methodSql.addTime = DateTime.Now;
  7405. methodSql.Create();
  7406. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7407. CeErpMethod.ExecuteNonQuery(delsql);
  7408. if (isCompale)
  7409. {
  7410. aftersale_data_change(entity.ctid);
  7411. }
  7412. returnSuccessMsg("操作成功!");
  7413. return;
  7414. }
  7415. returnErrorMsg("找不到订单记录");
  7416. }
  7417. }
  7418. public void ins_erp_toresponsible()
  7419. {
  7420. if (UrlPostParmsCheck("ctid"))
  7421. {
  7422. string eid = GetPostString("ctid");
  7423. CeErpTradeCell entity = null;
  7424. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7425. if (entity != null)
  7426. {
  7427. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7428. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7429. {
  7430. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7431. return;
  7432. }
  7433. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7434. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7435. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7436. if (entity.AfterSalePreTime == null)
  7437. {
  7438. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7439. {
  7440. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7441. }
  7442. }
  7443. entity.AfterSalePreTime = DateTime.Now;
  7444. //预完成给售后主管审核客户问题直接完成
  7445. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7446. {
  7447. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7448. {
  7449. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7450. }
  7451. }
  7452. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7453. ceErpTradeAfterSaleExtend.Update();
  7454. entity.AfterSaleUserId = CurrentUser.UserID;
  7455. entity.AfterSaleState = 2;
  7456. entity.UpdateTime = DateTime.Now;
  7457. entity.Update();
  7458. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7459. aftersale_data_change(entity.ctid);
  7460. returnSuccessMsg("操作成功!");
  7461. return;
  7462. }
  7463. returnErrorMsg("找不到订单记录");
  7464. }
  7465. }
  7466. public void cancel_erp_aftersaleanddelnew()
  7467. {
  7468. if (UrlPostParmsCheck("ctid"))
  7469. {
  7470. string eid = GetPostString("ctid");
  7471. CeErpTradeCell entity = null;
  7472. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7473. if (entity != null)
  7474. {
  7475. entity.AfterSaleState = 0;
  7476. entity.AfterSaleReason = "";
  7477. entity.AfterSaleMethod = "";
  7478. entity.AfterSaleMemo = "";
  7479. entity.AfterSaleResponsible = "";
  7480. entity.ResponsibleUserId = "";
  7481. entity.DeductFee = 0;
  7482. entity.RefundFee = 0;
  7483. entity.IsArbitrate = 0;
  7484. CeErpTradeResponsible.DelByTid(eid, -1);
  7485. entity.Update();
  7486. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7487. if (after != null)
  7488. {
  7489. if (after.OrderState < 5)
  7490. CeErpTradeCell.DelByCtid("S_" + eid);
  7491. }
  7492. returnSuccessMsg("操作成功!");
  7493. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7494. return;
  7495. }
  7496. returnErrorMsg("找不到订单记录");
  7497. }
  7498. }
  7499. public void get_erp_aftersale_pregather()
  7500. {
  7501. List<string> lw = new List<string>();
  7502. int st = GetInt("st");
  7503. string tid = GetPostString("ctid");
  7504. if (tid.Length > 0)
  7505. {
  7506. string select_tid = getTidByCtid(tid);
  7507. lw.Add(string.Format("tid='{0}'", select_tid));
  7508. }
  7509. string shopname = GetPostString("shopname");
  7510. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7511. string buyernick = GetPostString("buyer_nick");
  7512. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7513. string sellermemo = GetPostString("seller_memo");
  7514. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7515. string orderState = GetPostString("orderState");
  7516. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7517. string reason = GetPostString("reason");
  7518. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7519. string method = GetPostString("method");
  7520. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7521. string handler = GetPostString("handler");
  7522. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7523. string handledate1 = GetPostString("handledate1");
  7524. string handledate2 = GetPostString("handledate2");
  7525. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7526. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7527. string supplier = GetPostString("supplier");
  7528. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7529. string responsible = GetPostString("responsibleman");
  7530. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7531. string customer = GetPostString("customer");
  7532. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7533. string design = GetPostString("design");
  7534. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7535. string afterMemoType = GetPostString("aftermemotype");
  7536. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7537. string afterSaleMemo = GetPostString("afterSaleMemo");
  7538. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7539. string afterresult = GetPostString("afterresult");
  7540. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7541. string poscode = CurrentUser.UserPost.Post.Code;
  7542. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7543. {
  7544. string shopid = CurrentUser.User.pemShop;
  7545. lw.Add(string.Format("shopId in ({0})", shopid));
  7546. }
  7547. var mainwhere = string.Join(" and ", lw.ToArray());
  7548. string ro_json = "";
  7549. string type = GetPostString("gather_type");
  7550. int number = 0;
  7551. if (poscode == "AfterSale")
  7552. {
  7553. //处理中
  7554. if (type == "Handling")
  7555. {
  7556. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7557. DataTable dt = null;
  7558. try
  7559. {
  7560. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7561. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7562. }
  7563. catch (Exception e)
  7564. {
  7565. dt = new DataTable();
  7566. }
  7567. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7568. return;
  7569. }
  7570. if (type == "Wait")
  7571. {
  7572. //待处理
  7573. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7574. DataTable dt1 = null;
  7575. try
  7576. {
  7577. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7578. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7579. }
  7580. catch (Exception e)
  7581. {
  7582. dt1 = new DataTable();
  7583. }
  7584. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7585. return;
  7586. }
  7587. if (type == "back")
  7588. {
  7589. //打回
  7590. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7591. DataTable dt2 = null;
  7592. try
  7593. {
  7594. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7595. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7596. }
  7597. catch (Exception e)
  7598. {
  7599. dt2 = new DataTable();
  7600. }
  7601. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7602. return;
  7603. }
  7604. if (type == "preCompletion")
  7605. {
  7606. //预完成
  7607. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7608. DataTable dt3 = null;
  7609. try
  7610. {
  7611. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7612. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7613. }
  7614. catch (Exception e)
  7615. {
  7616. dt3 = new DataTable();
  7617. }
  7618. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7619. return;
  7620. }
  7621. if (type == "documentary")
  7622. {
  7623. //跟单中
  7624. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate > 2 and HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSalSend = 0 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7625. DataTable dt4 = null;
  7626. try
  7627. {
  7628. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7629. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7630. }
  7631. catch (Exception e)
  7632. {
  7633. dt4 = new DataTable();
  7634. }
  7635. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7636. return;
  7637. }
  7638. if (type == "reBack")
  7639. {
  7640. //被打回
  7641. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7642. DataTable dt1 = null;
  7643. try
  7644. {
  7645. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7646. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7647. }
  7648. catch (Exception e)
  7649. {
  7650. dt1 = new DataTable();
  7651. }
  7652. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7653. return;
  7654. }
  7655. }
  7656. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7657. {
  7658. if (type == "puBack")
  7659. {
  7660. //退回
  7661. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7662. DataTable dt = null;
  7663. try
  7664. {
  7665. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7666. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7667. }
  7668. catch (Exception e)
  7669. {
  7670. dt = new DataTable();
  7671. }
  7672. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7673. return;
  7674. }
  7675. if (type == "reBack")
  7676. {
  7677. //打回
  7678. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7679. DataTable dt1 = null;
  7680. try
  7681. {
  7682. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7683. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7684. }
  7685. catch (Exception e)
  7686. {
  7687. dt1 = new DataTable();
  7688. }
  7689. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7690. return;
  7691. }
  7692. if (type == "examEd")
  7693. {
  7694. //已审核
  7695. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7696. DataTable dt2 = null;
  7697. try
  7698. {
  7699. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7700. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7701. }
  7702. catch (Exception e)
  7703. {
  7704. dt2 = new DataTable();
  7705. }
  7706. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7707. return;
  7708. }
  7709. if (type == "waitExam")
  7710. {
  7711. //待审核
  7712. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7713. DataTable dt3 = null;
  7714. try
  7715. {
  7716. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7717. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7718. }
  7719. catch (Exception e)
  7720. {
  7721. dt3 = new DataTable();
  7722. }
  7723. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7724. return;
  7725. }
  7726. if (type == "Handling")
  7727. {
  7728. //处理中
  7729. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7730. DataTable dt4 = null;
  7731. try
  7732. {
  7733. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7734. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7735. }
  7736. catch (Exception e)
  7737. {
  7738. dt4 = new DataTable();
  7739. }
  7740. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7741. return;
  7742. }
  7743. if (type == "Wait")
  7744. {
  7745. //待处理
  7746. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7747. DataTable dt5 = null;
  7748. try
  7749. {
  7750. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7751. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7752. }
  7753. catch (Exception e)
  7754. {
  7755. dt5 = new DataTable();
  7756. }
  7757. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7758. return;
  7759. }
  7760. if (type == "documentary")
  7761. {
  7762. //跟单中
  7763. string sql6 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate > 2 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSalSend = 0 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7764. DataTable dt6 = null;
  7765. try
  7766. {
  7767. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7768. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7769. }
  7770. catch (Exception e)
  7771. {
  7772. dt6 = new DataTable();
  7773. }
  7774. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7775. return;
  7776. }
  7777. }
  7778. returnSuccess(ro_json);
  7779. }
  7780. public void end_erp_aftersale()
  7781. {
  7782. if (UrlPostParmsCheck("ctid"))
  7783. {
  7784. string eid = GetPostString("ctid");
  7785. CeErpTradeCell entity = null;
  7786. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7787. if (entity != null)
  7788. {
  7789. string stype = GetPostString("stype");
  7790. string typeStr = stype;
  7791. entity.AfterSaleState = 4;
  7792. entity.FinishAfterSaleTime = DateTime.Now;
  7793. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7794. entity.Update();
  7795. ApiVo apiVo = new ApiVo();
  7796. apiVo.orderNumber = entity.ctid;
  7797. apiVo.actionName = "afterOver";
  7798. designHelper.API_WorkCore(apiVo); //afterOver
  7799. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7800. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7801. CeErpSukuraData.createInfo(entity.ctid, 8);
  7802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7803. returnSuccessMsg("操作成功!");
  7804. return;
  7805. }
  7806. returnErrorMsg("找不到订单记录");
  7807. }
  7808. }
  7809. public void ins_erp_finishaftersale()
  7810. {
  7811. if (UrlPostParmsCheck("id"))
  7812. {
  7813. string eid = GetPostString("id");
  7814. CeErpTradeResponsible entity = null;
  7815. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7816. if (entity != null)
  7817. {
  7818. entity.VerifyState = 1;
  7819. entity.VerifyTime = DateTime.Now;
  7820. entity.Update();
  7821. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7822. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7823. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7824. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7825. if (dt.Rows.Count <= 0)
  7826. {
  7827. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7828. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7829. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7830. CeErpSukuraData.createInfo(entity.tid, 8);
  7831. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7832. {
  7833. CeErpDesignerBill.Del(entity.tid);
  7834. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7835. }
  7836. }
  7837. returnSuccessMsg("操作成功!");
  7838. return;
  7839. }
  7840. returnErrorMsg("找不到订单记录");
  7841. }
  7842. }
  7843. public void upd_erp_arbitrateaftersale()
  7844. {
  7845. if (UrlPostParmsCheck("id"))
  7846. {
  7847. string eid = GetPostString("id");
  7848. CeErpTradeResponsible entity = null;
  7849. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7850. if (entity != null)
  7851. {
  7852. entity.IsArbitrate = 1;
  7853. entity.ArbitradeMemo = GetPostString("reason");
  7854. entity.VerifyState = 2;
  7855. entity.Update();
  7856. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7857. if (tradecell != null)
  7858. {
  7859. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7860. tradecell.IsArbitrate = 1;
  7861. tradecell.Update();
  7862. }
  7863. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7864. returnSuccessMsg("操作成功!");
  7865. return;
  7866. }
  7867. returnErrorMsg("找不到订单记录");
  7868. }
  7869. }
  7870. public void upd_erp_backaftersale()
  7871. {
  7872. if (UrlPostParmsCheck("tid"))
  7873. {
  7874. string eid = GetPostString("tid");
  7875. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7876. int backNum = 0;
  7877. if (number != null)
  7878. {
  7879. backNum = number.BackNum;
  7880. }
  7881. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7882. CeErpTradeCell entity = null;
  7883. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7884. if (entity != null)
  7885. {
  7886. entity.AfterSaleBackReason = GetPostString("backreason");
  7887. entity.AfterSaleState = 1;
  7888. entity.AfterSaleSupplierState = 0;
  7889. entity.UpdateTime = DateTime.Now;
  7890. entity.Update();
  7891. returnSuccessMsg("操作成功!");
  7892. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7893. return;
  7894. }
  7895. returnErrorMsg("找不到订单记录");
  7896. }
  7897. }
  7898. public void get_erp_supplieraftersalelist()
  7899. {
  7900. DataStruct dStruct = GetPostStruct();
  7901. List<string> lw = new List<string>();
  7902. string tid = GetPostString("ctid");
  7903. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7904. string shopname = GetPostString("shopname");
  7905. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7906. string buyernick = GetPostString("buyer_nick");
  7907. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7908. string sellermemo = GetPostString("seller_memo");
  7909. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7910. string orderState = GetPostString("orderState");
  7911. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7912. string afterState = GetPostString("afterstate");
  7913. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7914. string date1 = GetPostString("date1");
  7915. string date2 = GetPostString("date2");
  7916. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7917. if (dw.Length > 0) lw.Add(dw);
  7918. string price1 = GetPostString("price1");
  7919. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7920. string price2 = GetPostString("price2");
  7921. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7922. string reason = GetPostString("reason");
  7923. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7924. string method = GetPostString("method");
  7925. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7926. string handledate1 = GetPostString("handledate1");
  7927. string handledate2 = GetPostString("handledate2");
  7928. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7929. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7930. string handler = GetPostString("handler");
  7931. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7932. string afterdate1 = GetPostString("afterdate1");
  7933. string afterdate2 = GetPostString("afterdate2");
  7934. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7935. if (afterDate.Length > 0) lw.Add(afterDate);
  7936. string customer = GetPostString("customer");
  7937. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7938. string design = GetPostString("design");
  7939. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7940. string afterMemoType = GetPostString("aftermemotype");
  7941. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7942. string vstate = GetPostString("vstate");
  7943. if (vstate.Length > 0)
  7944. {
  7945. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7946. }
  7947. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7948. string supplier = GetPostString("supplier");
  7949. int supid = commonHelper.getSupplierIDByName(supplier);
  7950. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7951. string posCode = CurrentUser.UserPost.Post.Code;
  7952. if (posCode == "Supplier")
  7953. {
  7954. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7955. }
  7956. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7957. {
  7958. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7959. }
  7960. else
  7961. {
  7962. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7963. }
  7964. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7965. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7967. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7968. writeGridDataTableJson(dStruct.TotalCount, dt);
  7969. }
  7970. public void upd_erp_supverifyaftersale()
  7971. {
  7972. if (UrlPostParmsCheck("id"))
  7973. {
  7974. string id = GetPostString("id");
  7975. int st = GetPostInt("afterstate");
  7976. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7977. CeErpTradeCell entity = null;
  7978. if (ceErpTradeResponsible != null)
  7979. {
  7980. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7981. }
  7982. string afmemo = GetPostString("supmemo");
  7983. string image = GetPostString("image");
  7984. if (entity != null)
  7985. {
  7986. entity.AfterSaleSupplierState = st;
  7987. entity.AfterSaleSupplierMemo = afmemo;
  7988. if (st == 1)
  7989. {
  7990. ceErpTradeResponsible.VerifyState = 1;
  7991. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7992. ceErpTradeResponsible.Update();
  7993. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7994. if (isAll)
  7995. {
  7996. entity.AfterSaleState = 4;
  7997. entity.FinishAfterSaleTime = DateTime.Now;
  7998. }
  7999. }
  8000. else
  8001. {
  8002. CeErpTradeResponsible.dateByTid(entity.ctid);
  8003. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  8004. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  8005. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  8006. if (num < 1)
  8007. {
  8008. entity.AfterSaleState = 1;
  8009. }
  8010. else
  8011. {
  8012. entity.AfterSaleState = 5;
  8013. }
  8014. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  8015. if (ceErpTradeAfterSaleExtend != null)
  8016. {
  8017. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8018. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  8019. ceErpTradeAfterSaleExtend.Update();
  8020. }
  8021. else
  8022. {
  8023. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8024. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8025. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8026. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  8027. ceErpTradeAfterSaleExtend.Create();
  8028. }
  8029. }
  8030. if (entity.AfterSaleState == 4)
  8031. {
  8032. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  8033. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  8034. {
  8035. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  8036. }
  8037. ApiVo apiVo = new ApiVo();
  8038. apiVo.orderNumber = entity.ctid;
  8039. apiVo.actionName = "afterOver";
  8040. designHelper.API_WorkCore(apiVo); //afterOver
  8041. }
  8042. entity.UpdateTime = DateTime.Now;
  8043. entity.Update();
  8044. returnSuccessMsg("操作成功!");
  8045. CeErpSukuraData.createInfo(entity.ctid, 8);
  8046. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8047. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8048. return;
  8049. }
  8050. returnErrorMsg("找不到订单记录");
  8051. }
  8052. }
  8053. public void upd_erp_masteraftersale()
  8054. {
  8055. if (UrlPostParmsCheck("id"))
  8056. {
  8057. string id = GetPostString("id");
  8058. int st = GetPostInt("afterstate");
  8059. string afmemo = GetPostString("supmemo");
  8060. string image = GetPostString("image");
  8061. string textResult = GetPostString("textResult");
  8062. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  8063. if (ceErpTradeResponsible != null)
  8064. {
  8065. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  8066. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  8067. ceErpTradeResponsible.Update();
  8068. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  8069. if (entity != null)
  8070. {
  8071. entity.AfterSaleSupplierState = st;
  8072. entity.AfterSaleSupplierMemo = afmemo;
  8073. if (st == 1)
  8074. {
  8075. }
  8076. else
  8077. {
  8078. CeErpTradeResponsible.dateByTid(entity.ctid);
  8079. //退回到售后
  8080. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  8081. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  8082. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  8083. if (num <= 1)
  8084. {
  8085. entity.AfterSaleState = 1;
  8086. }
  8087. else
  8088. {
  8089. entity.AfterSaleState = 5;
  8090. }
  8091. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  8092. if (ceErpTradeAfterSaleExtend != null)
  8093. {
  8094. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8095. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  8096. ceErpTradeAfterSaleExtend.Update();
  8097. }
  8098. else
  8099. {
  8100. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8101. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8102. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8103. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  8104. ceErpTradeAfterSaleExtend.Create();
  8105. }
  8106. }
  8107. entity.UpdateTime = DateTime.Now;
  8108. entity.Update();
  8109. returnSuccessMsg("操作成功!");
  8110. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8111. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8112. return;
  8113. }
  8114. }
  8115. returnErrorMsg("找不到订单记录");
  8116. }
  8117. }
  8118. public void upd_erp_personaftersale()
  8119. {
  8120. if (UrlPostParmsCheck("id"))
  8121. {
  8122. //林小连
  8123. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  8124. {
  8125. upd_erp_masteraftersale();
  8126. return;
  8127. }
  8128. string id = GetPostString("id");
  8129. int st = GetPostInt("afterstate");
  8130. string afmemo = GetPostString("supmemo");
  8131. string image = GetPostString("image");
  8132. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  8133. if (ceErpTradeResponsible != null)
  8134. {
  8135. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  8136. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  8137. ceErpTradeResponsible.Update();
  8138. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  8139. if (entity != null)
  8140. {
  8141. entity.AfterSaleSupplierMemo = afmemo;
  8142. entity.AfterSaleSupplierState = st;
  8143. if (st == 1)
  8144. {
  8145. bool isAll = commonHelper.tradeResponsibleAll(entity);
  8146. if (isAll)
  8147. {
  8148. entity.AfterSaleState = 4;
  8149. entity.FinishAfterSaleTime = DateTime.Now;
  8150. }
  8151. }
  8152. else
  8153. {
  8154. CeErpTradeResponsible.dateByTid(entity.ctid);
  8155. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  8156. if (ceErpTradeAfterSaleExtend != null)
  8157. {
  8158. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8159. ceErpTradeAfterSaleExtend.Update();
  8160. }
  8161. else
  8162. {
  8163. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8164. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8165. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8166. ceErpTradeAfterSaleExtend.Create();
  8167. }
  8168. //退回到主管
  8169. //entity.AfterSaleState = 2;
  8170. }
  8171. if (entity.AfterSaleState == 4)
  8172. {
  8173. ApiVo apiVo = new ApiVo();
  8174. apiVo.orderNumber = entity.ctid;
  8175. apiVo.actionName = "afterOver";
  8176. designHelper.API_WorkCore(apiVo); //afterOver
  8177. }
  8178. entity.UpdateTime = DateTime.Now;
  8179. entity.Update();
  8180. returnSuccessMsg("操作成功!");
  8181. CeErpSukuraData.createInfo(entity.ctid, 8);
  8182. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8183. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8184. return;
  8185. }
  8186. }
  8187. returnErrorMsg("找不到订单记录");
  8188. }
  8189. }
  8190. public void set_erp_supplierrefundtag()
  8191. {
  8192. if (UrlPostParmsCheck("ctid"))
  8193. {
  8194. string eid = GetPostString("ctid");
  8195. CeErpTradeCell entity = null;
  8196. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8197. if (entity != null)
  8198. {
  8199. entity.IsSupplierRefund = GetPostInt("tag");
  8200. entity.Update();
  8201. returnSuccessMsg("操作成功!");
  8202. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  8203. return;
  8204. }
  8205. returnErrorMsg("找不到订单记录");
  8206. }
  8207. }
  8208. public void get_erp_refundlist()
  8209. {
  8210. DataStruct dStruct = GetPostStruct();
  8211. List<string> lw = new List<string>();
  8212. string tid = GetPostString("tid");
  8213. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8214. //string rid = GetPostString("refund_id");
  8215. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  8216. string shopname = GetPostString("shopname");
  8217. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8218. string buyernick = GetPostString("buyer_nick");
  8219. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8220. string customer = GetPostString("customer");
  8221. if (customer.Length > 0) lw.Add(string.Format("CustomerUserName = '{0}'", customer));
  8222. string design = GetPostString("design");
  8223. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8224. string sellermemo = GetPostString("seller_memo");
  8225. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8226. //string date1 = GetPostString("date1");
  8227. //string date2 = GetPostString("date2");
  8228. //string dateType = GetPostString("dateType");
  8229. //if (dateType.Length > 0)
  8230. //{
  8231. // if (dateType == "1001") dateType = "0";
  8232. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8233. // if (searchDT.Count == 2)
  8234. // {
  8235. // date1 = searchDT[0].ToString();
  8236. // date2 = searchDT[1].ToString();
  8237. // }
  8238. //}
  8239. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8240. //if (dw.Length > 0) lw.Add(dw);
  8241. string redate1 = GetPostString("refunddate1");
  8242. string redate2 = GetPostString("refunddate2");
  8243. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8244. if (dwdate.Length > 0) lw.Add(dwdate);
  8245. string price1 = GetPostString("price1");
  8246. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8247. string price2 = GetPostString("price2");
  8248. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8249. string ispartrefund = GetPostString("ispartrefund");
  8250. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8251. string refundState = GetPostString("refundvstate");
  8252. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8253. int st = GetInt("st");
  8254. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8255. {
  8256. string responsible = GetPostString("responsibleman");
  8257. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8258. lw.Add(string.Format("RefundState>={0}", st));
  8259. string code = CurrentUser.UserPost.Post.Code;
  8260. if (code == "CustomerService")
  8261. {
  8262. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8263. }
  8264. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8265. {
  8266. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8267. }
  8268. else if (code == "Place" || code == "PlaceMr")
  8269. {
  8270. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8271. }
  8272. dStruct.Order = "RefundState asc,created desc";
  8273. }
  8274. else if (st == 10)
  8275. {
  8276. string responsible = GetPostString("responsibleman");
  8277. if (responsible == "空白")
  8278. {
  8279. lw.Add(string.Format("ResponsibleUserName = ''"));
  8280. }
  8281. else if (responsible.Length > 0)
  8282. {
  8283. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8284. }
  8285. lw.Add(string.Format("RefundState>=0"));
  8286. dStruct.Order = "created desc";
  8287. }
  8288. else
  8289. {
  8290. string responsible = GetPostString("responsibleman");
  8291. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8292. lw.Add(string.Format("RefundState={0}", st));
  8293. dStruct.Order = "created desc";
  8294. }
  8295. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8296. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8297. if (dt != null)
  8298. {
  8299. dt.Columns.Add("refund_fees");
  8300. foreach (DataRow dr in dt.Rows)
  8301. {
  8302. String status = dr["status"].ToString();
  8303. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8304. {
  8305. dr["refund_fees"] = dr["refund_fee"];
  8306. }
  8307. else
  8308. {
  8309. dr["refund_fees"] = "0.0";
  8310. }
  8311. }
  8312. }
  8313. writeGridDataTableJson(dStruct.TotalCount, dt);
  8314. }
  8315. public void get_erp_refunddesignlist()
  8316. {
  8317. DataStruct dStruct = GetPostStruct();
  8318. List<string> lw = new List<string>();
  8319. string tid = GetPostString("tid");
  8320. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8321. string shopname = GetPostString("shopname");
  8322. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8323. string buyernick = GetPostString("buyer_nick");
  8324. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8325. string customer = GetPostString("customer");
  8326. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8327. string design = GetPostString("design");
  8328. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8329. string sellermemo = GetPostString("seller_memo");
  8330. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8331. string redate1 = GetPostString("refunddate1");
  8332. string redate2 = GetPostString("refunddate2");
  8333. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8334. if (dwdate.Length > 0) lw.Add(dwdate);
  8335. string price1 = GetPostString("price1");
  8336. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8337. string price2 = GetPostString("price2");
  8338. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8339. string ispartrefund = GetPostString("ispartrefund");
  8340. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8341. string designerorg = GetPostString("designerorg");
  8342. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8343. string refundState = GetPostString("refundState");
  8344. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8345. int myOrgid = CurrentUser.UserPost.OrgID;
  8346. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8347. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8348. {
  8349. if (CurrentUser.User.TeamIds.Length > 0)
  8350. {
  8351. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8352. }
  8353. else
  8354. {
  8355. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8356. }
  8357. }
  8358. else if ("SysAdmin".Equals(myOrgCode))
  8359. {
  8360. }
  8361. else
  8362. {
  8363. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8364. {
  8365. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8366. }
  8367. else
  8368. {
  8369. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8370. }
  8371. }
  8372. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8373. dStruct.Order = "created desc";
  8374. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8375. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8376. dt.Columns.Add("refund_fees");
  8377. foreach (DataRow dr in dt.Rows)
  8378. {
  8379. String status = dr["status"].ToString();
  8380. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8381. {
  8382. dr["refund_fees"] = dr["refund_fee"];
  8383. }
  8384. else
  8385. {
  8386. dr["refund_fees"] = "0.0";
  8387. }
  8388. }
  8389. writeGridDataTableJson(dStruct.TotalCount, dt);
  8390. }
  8391. public void handle_erp_refundtag()
  8392. {
  8393. if (UrlPostParmsCheck("refund_id"))
  8394. {
  8395. string eid = GetPostString("refund_id");
  8396. string respMan = GetPostString("ResponsibleName");
  8397. if (respMan.Length <= 0)
  8398. {
  8399. returnErrorMsg("责任人不能为空");
  8400. return;
  8401. }
  8402. CeErpTradeRefund entity = null;
  8403. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8404. if (entity != null)
  8405. {
  8406. entity.ResponsibleUserName = respMan;
  8407. string userid = GetPostString("ResponsibleUserId");
  8408. if (userid.Length > 0)
  8409. {
  8410. entity.ResponsibleUserId = userid;
  8411. }
  8412. entity.Memo = GetPostString("Memo");
  8413. if (respMan.IndexOf("客服") != -1 ||
  8414. respMan.IndexOf("设计师") != -1 ||
  8415. respMan.IndexOf("下单员") != -1)
  8416. {
  8417. entity.RefundState = 2;
  8418. }
  8419. else
  8420. {
  8421. entity.RefundState = 3;
  8422. }
  8423. entity.modified = DateTime.Now;
  8424. entity.Update();
  8425. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8426. returnSuccessMsg("操作成功!");
  8427. return;
  8428. }
  8429. returnErrorMsg("找不到订单记录");
  8430. }
  8431. }
  8432. public void handle_erp_designrefundtag()
  8433. {
  8434. if (UrlPostParmsCheck("refund_id"))
  8435. {
  8436. string eid = GetPostString("refund_id");
  8437. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8438. if (ceErpTradeCellExtend == null)
  8439. {
  8440. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8441. ceErpTradeCellExtend.ctid = eid;
  8442. }
  8443. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8444. if (ceErpTradeCellExtend.ID > 0)
  8445. {
  8446. ceErpTradeCellExtend.Update();
  8447. }
  8448. else
  8449. {
  8450. ceErpTradeCellExtend.Create();
  8451. }
  8452. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8453. returnSuccessMsg("操作成功!");
  8454. return;
  8455. }
  8456. returnErrorMsg("找不到订单记录");
  8457. }
  8458. public void upd_erp_refundverify()
  8459. {
  8460. if (UrlPostParmsCheck("refund_id"))
  8461. {
  8462. string eid = GetPostString("refund_id");
  8463. CeErpTradeRefund entity = null;
  8464. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8465. if (entity != null)
  8466. {
  8467. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8468. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8469. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8470. {
  8471. entity.RefundState = 2;
  8472. }
  8473. else
  8474. {
  8475. entity.RefundState = 3;
  8476. }
  8477. entity.Update();
  8478. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8479. returnSuccessMsg("操作成功!");
  8480. return;
  8481. }
  8482. returnErrorMsg("找不到订单记录");
  8483. }
  8484. }
  8485. public void upd_erp_refundapprove()
  8486. {
  8487. if (UrlPostParmsCheck("refund_id"))
  8488. {
  8489. string eid = GetPostString("refund_id");
  8490. CeErpTradeRefund entity = null;
  8491. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8492. if (entity != null)
  8493. {
  8494. int apr = GetPostInt("approve");
  8495. if (apr == 0)
  8496. {
  8497. entity.RefundState = 1;
  8498. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8499. }
  8500. else if (apr == 1)
  8501. {
  8502. entity.RefundState = 3;
  8503. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8504. }
  8505. entity.modified = DateTime.Now;
  8506. entity.Update();
  8507. returnSuccessMsg("操作成功!");
  8508. return;
  8509. }
  8510. returnErrorMsg("找不到订单记录");
  8511. }
  8512. }
  8513. public void get_erp_billlist()
  8514. {
  8515. DataStruct dStruct = GetPostStruct();
  8516. List<string> lw = new List<string>();
  8517. string title = GetPostString("title");
  8518. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8519. string tid = GetPostString("tid");
  8520. string tids = GetPostString("tids");
  8521. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8522. if (tids.Length > 0)
  8523. {
  8524. tids = "'" + tids + "'";
  8525. tids = tids.Replace(",", "','");
  8526. lw.Add(string.Format("tid in ({0})", tids));
  8527. }
  8528. string shopname = GetPostString("shopname");
  8529. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8530. string buyernick = GetPostString("buyer_nick");
  8531. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8532. string customer = GetPostString("customer");
  8533. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8534. string date1 = GetPostString("date1");
  8535. string date2 = GetPostString("date2");
  8536. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8537. if (dw.Length > 0) lw.Add(dw);
  8538. string price1 = GetPostString("price1");
  8539. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8540. string price2 = GetPostString("price2");
  8541. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8542. string returndate1 = GetPostString("returndate1");
  8543. string returndate2 = GetPostString("returndate2");
  8544. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8545. if (dw1.Length > 0) lw.Add(dw1);
  8546. string billtype = GetPostString("billtype");
  8547. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8548. string billstate = GetPostString("billstate");
  8549. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8550. string usershop = CurrentUser.User.pemShop;
  8551. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8552. dStruct.Order = "createTime desc";
  8553. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8554. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8555. //foreach (DataRow dr in dt.Rows)
  8556. //{
  8557. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8558. //}
  8559. writeGridDataTableJson(dStruct.TotalCount, dt);
  8560. }
  8561. public void modify_erp_billinfo()
  8562. {
  8563. if (UrlPostParmsCheck("ID"))
  8564. {
  8565. string eid = GetPostString("ID");
  8566. CeErpBill bill_entity = null;
  8567. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8568. if (bill_entity != null)
  8569. {
  8570. bill_entity.tid = GetPostString("tid");
  8571. bill_entity.title = GetPostString("title");
  8572. bill_entity.tax = GetPostString("tax");
  8573. bill_entity.bank = GetPostString("bank");
  8574. bill_entity.bankac = GetPostString("bankac");
  8575. bill_entity.address = GetPostString("address");
  8576. bill_entity.phone = GetPostString("phone");
  8577. bill_entity.price = GetPostString("price");
  8578. bill_entity.productId = GetPostInt("ProductName");
  8579. bill_entity.num = GetPostInt("num");
  8580. bill_entity.unit = GetPostString("unit");
  8581. bill_entity.type = GetPostString("type");
  8582. bill_entity.sendType = GetPostString("SendType");
  8583. bill_entity.email = GetPostString("email");
  8584. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8585. bill_entity.shopName = GetPostString("ShopName");
  8586. bill_entity.applymemo = GetPostString("applymemo");
  8587. bill_entity.modifyTime = DateTime.Now;
  8588. bill_entity.createTime = DateTime.Now;
  8589. bill_entity.state = 0;
  8590. bill_entity.Update();
  8591. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8592. returnSuccessMsg("发票修改成功!");
  8593. return;
  8594. }
  8595. returnErrorMsg("找不到对应记录");
  8596. }
  8597. }
  8598. public void set_erp_invoicing()
  8599. {
  8600. if (UrlPostParmsCheck("id"))
  8601. {
  8602. try
  8603. {
  8604. string eid = GetPostString("id");
  8605. CeErpBill bill_entity = null;
  8606. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8607. if (bill_entity != null)
  8608. {
  8609. int ComId = GetPostInt("ComId");
  8610. //string memo = GetPostString("Memo");
  8611. int allInfo = GetPostInt("allinfo");
  8612. string clert = CurrentUser.User.Name;
  8613. //string detailValue = GetPostString("detailvalue");
  8614. string billId = bill_entity.billOrderId;
  8615. string[] billIdList = billId.Split(',');
  8616. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8617. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8618. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8619. {
  8620. billCount += 1;
  8621. }
  8622. if (billId.Length <= 0 || billIdList.Length != billCount)
  8623. {
  8624. bill_entity.billOrderId = "";
  8625. string prebill = "ltb";
  8626. for (int idx = 1; idx <= billCount; idx++)
  8627. {
  8628. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8629. string billoid = prebill + idx + dtstr;
  8630. bill_entity.billOrderId += billoid;
  8631. if (idx < billCount)
  8632. {
  8633. bill_entity.billOrderId += ",";
  8634. }
  8635. }
  8636. }
  8637. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8638. if (bill_entity.state == 5)
  8639. {
  8640. string errMsg = bill_entity.failerror;
  8641. string[] errlist = errMsg.Split('|');
  8642. string[] errTags = new string[errlist.Length];
  8643. for (int itag = 0; itag < errlist.Length; itag++)
  8644. {
  8645. if (errlist[itag].Length <= 0) continue;
  8646. errTags[itag] = errlist[itag].Split('&')[0];
  8647. }
  8648. for (int iii = 0; iii < errTags.Length; iii++)
  8649. {
  8650. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8651. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8652. if (billOrderList.Length >= erroBillOrderTag)
  8653. {
  8654. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8655. if (needModifyBillId.Length <= 19)
  8656. {
  8657. needModifyBillId = needModifyBillId + "1";
  8658. }
  8659. else
  8660. {
  8661. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8662. last = last + 1;
  8663. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8664. }
  8665. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8666. }
  8667. }
  8668. }
  8669. bool isHaveBillSucces = false;
  8670. string totalRes = "";
  8671. bill_entity.failerror = "";
  8672. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8673. {
  8674. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8675. totalRes += res;
  8676. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8677. {
  8678. isHaveBillSucces = true;
  8679. bill_entity.comId = ComId;
  8680. bill_entity.state = 1;
  8681. bill_entity.executeTime = DateTime.Now;
  8682. bill_entity.executeUser = clert;
  8683. }
  8684. else
  8685. {
  8686. bill_entity.state = 5;
  8687. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8688. }
  8689. }
  8690. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8691. bill_entity.Update();
  8692. if (isHaveBillSucces)
  8693. {
  8694. StringBuilder sql = new StringBuilder();
  8695. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8696. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8697. }
  8698. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8699. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8700. {
  8701. returnErrorMsg("开票失败");
  8702. }
  8703. else
  8704. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8705. return;
  8706. }
  8707. returnErrorMsg("找不到对应记录");
  8708. }
  8709. catch (Exception ex)
  8710. {
  8711. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8712. returnErrorMsg("操作失败");
  8713. }
  8714. }
  8715. }
  8716. public void get_erp_invoicing_back()
  8717. {
  8718. if (UrlPostParmsCheck("id"))
  8719. {
  8720. try
  8721. {
  8722. string id = GetPostString("id");
  8723. CeErpBill entiy = CeErpBill.Get(id);
  8724. if (entiy != null)
  8725. {
  8726. if (entiy.state == 0)
  8727. {
  8728. returnErrorMsg("发票还未开具");
  8729. return;
  8730. }
  8731. string[] billOrderList = entiy.billOrderId.Split(',');
  8732. int iTag = 0;
  8733. entiy.fplsh = "";
  8734. entiy.fpdm = "";
  8735. entiy.fphm = "";
  8736. foreach (string billOrderId in billOrderList)
  8737. {
  8738. iTag++;
  8739. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8740. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8741. {
  8742. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8743. try
  8744. {
  8745. Invoicing_get_response_Obj iObj = null;
  8746. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8747. if (iObj != null)
  8748. {
  8749. entiy.state = 2;
  8750. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8751. entiy.fpdm += iObj.list[0].c_fpdm;
  8752. entiy.fphm += iObj.list[0].c_fphm;
  8753. if (iTag < billOrderList.Length)
  8754. {
  8755. entiy.fplsh += ",";
  8756. entiy.fpdm += ",";
  8757. entiy.fphm += ",";
  8758. }
  8759. entiy.Update();
  8760. }
  8761. StringBuilder sql = new StringBuilder();
  8762. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8763. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8764. returnSuccessMsg("开票成功");
  8765. }
  8766. catch (Exception ex)
  8767. {
  8768. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8769. }
  8770. return;
  8771. }
  8772. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8773. {
  8774. var res_obj = new
  8775. {
  8776. data = "开票中"
  8777. };
  8778. string ro_json = JsonConvert.SerializeObject(res_obj);
  8779. returnSuccess(ro_json);
  8780. return;
  8781. }
  8782. else
  8783. {
  8784. int eidx = res.IndexOf("c_resultmsg");
  8785. int lidx = res.IndexOf("c_status");
  8786. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8787. entiy.state = 5;
  8788. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8789. entiy.Update();
  8790. returnErrorMsg("开票失败");
  8791. return;
  8792. }
  8793. }
  8794. }
  8795. }
  8796. catch (Exception ex)
  8797. {
  8798. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8799. }
  8800. return;
  8801. }
  8802. }
  8803. public void get_erp_invoicing()
  8804. {
  8805. if (UrlPostParmsCheck("id"))
  8806. {
  8807. try
  8808. {
  8809. string id = GetPostString("id");
  8810. CeErpBill entiy = CeErpBill.Get(id);
  8811. if (entiy != null)
  8812. {
  8813. if (entiy.state == 0)
  8814. {
  8815. returnErrorMsg("发票还未开具");
  8816. return;
  8817. }
  8818. if (entiy.sendType == "纸质发票")
  8819. {
  8820. if (entiy.img.Length <= 0)
  8821. {
  8822. returnErrorMsg("查无纸质发票");
  8823. return;
  8824. }
  8825. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8826. returnSuccess(returnres);
  8827. return;
  8828. }
  8829. string[] billOrderList = entiy.billOrderId.Split(',');
  8830. int iTag = 0;
  8831. string fpUrl = "";
  8832. entiy.fplsh = "";
  8833. entiy.fpdm = "";
  8834. entiy.fphm = "";
  8835. foreach (string billOrderId in billOrderList)
  8836. {
  8837. iTag++;
  8838. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8839. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8840. {
  8841. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8842. Invoicing_get_response_Obj iObj = null;
  8843. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8844. if (iObj != null)
  8845. {
  8846. //entiy.state = 2;
  8847. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8848. entiy.fpdm += iObj.list[0].c_fpdm;
  8849. entiy.fphm += iObj.list[0].c_fphm;
  8850. if (iTag < billOrderList.Length)
  8851. {
  8852. entiy.fplsh += ",";
  8853. entiy.fpdm += ",";
  8854. entiy.fphm += ",";
  8855. }
  8856. entiy.Update();
  8857. fpUrl += iObj.list[0].c_url + ",";
  8858. }
  8859. //returnSuccess(res);
  8860. StringBuilder sql = new StringBuilder();
  8861. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8862. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8863. }
  8864. else
  8865. {
  8866. int eidx = res.IndexOf("c_resultmsg");
  8867. //int lidx = res.IndexOf("c_status");
  8868. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8869. //开票失败
  8870. entiy.state = 5;
  8871. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8872. entiy.Update();
  8873. returnErrorMsg("开票失败");
  8874. return;
  8875. }
  8876. }
  8877. var returnObj = new
  8878. {
  8879. data = fpUrl
  8880. };
  8881. string ro_json = JsonConvert.SerializeObject(returnObj);
  8882. returnSuccess(ro_json);
  8883. }
  8884. }
  8885. catch (Exception ex)
  8886. {
  8887. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8888. }
  8889. return;
  8890. }
  8891. }
  8892. public void save_erp_billimg()
  8893. {
  8894. if (UrlPostParmsCheck("id"))
  8895. {
  8896. string eid = GetPostString("id");
  8897. CeErpBill bill_entity = null;
  8898. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8899. if (bill_entity != null)
  8900. {
  8901. bill_entity.img = GetPostString("img");
  8902. bill_entity.executeTime = DateTime.Now;
  8903. bill_entity.state = 2;
  8904. bill_entity.Update();
  8905. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8906. returnSuccessMsg("保存成功");
  8907. }
  8908. return;
  8909. }
  8910. }
  8911. public void upd_erp_billreturnback()
  8912. {
  8913. if (UrlPostParmsCheck("id"))
  8914. {
  8915. int eid = GetPostInt("id");
  8916. CeErpBill bill_entity = null;
  8917. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8918. if (bill_entity != null)
  8919. {
  8920. bill_entity.state = 3;
  8921. bill_entity.returnReason = GetPostString("reason");
  8922. bill_entity.Update();
  8923. returnSuccessMsg("驳回成功!");
  8924. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8925. }
  8926. return;
  8927. }
  8928. }
  8929. public void cancel_erp_bill()
  8930. {
  8931. if (UrlPostParmsCheck("id"))
  8932. {
  8933. int eid = GetPostInt("id");
  8934. int detailValue = GetPostInt("detailvalue");
  8935. CeErpBill bill_entity = null;
  8936. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8937. string cres = "";
  8938. string gres = "";
  8939. if (bill_entity != null)
  8940. {
  8941. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8942. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8943. {
  8944. int iTag = 0;
  8945. bill_entity.fplsh = "";
  8946. bill_entity.fpdm = "";
  8947. bill_entity.fphm = "";
  8948. foreach (string billOrderId in billOrderList)
  8949. {
  8950. iTag++;
  8951. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8952. if (gres.IndexOf("success") != -1)
  8953. {
  8954. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8955. Invoicing_get_response_Obj iObj = null;
  8956. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8957. if (iObj != null)
  8958. {
  8959. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8960. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8961. bill_entity.fphm += iObj.list[0].c_fphm;
  8962. if (iTag < billOrderList.Length)
  8963. {
  8964. bill_entity.fplsh += ",";
  8965. bill_entity.fpdm += ",";
  8966. bill_entity.fphm += ",";
  8967. }
  8968. bill_entity.Update();
  8969. }
  8970. }
  8971. else
  8972. {
  8973. returnErrorMsg(gres);
  8974. return;
  8975. }
  8976. }
  8977. }
  8978. if (bill_entity.sendType == "纸质发票")
  8979. {
  8980. //作废
  8981. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8982. //if (DateTime.Now.Month == extime.Month)
  8983. //{
  8984. //cres = taobaoHelper.cancel_invoicing(eid);
  8985. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8986. //{
  8987. bill_entity.state = 4;//已作废
  8988. bill_entity.Update();
  8989. returnSuccessMsg("发票已作废");
  8990. return;
  8991. //}
  8992. //else
  8993. //{
  8994. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8995. // bill_entity.Update();
  8996. // returnErrorMsg(cres);
  8997. // return;
  8998. //}
  8999. //}
  9000. //else
  9001. //{
  9002. // returnErrorMsg("纸质发票只能作废本月的发票");
  9003. // return;
  9004. //}
  9005. }
  9006. //红冲
  9007. int redTag = 0;
  9008. string[] fpdmList = bill_entity.fpdm.Split(',');
  9009. string[] fphmList = bill_entity.fphm.Split(',');
  9010. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  9011. {
  9012. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  9013. return;
  9014. }
  9015. foreach (string billOrderId in billOrderList)
  9016. {
  9017. redTag++;
  9018. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  9019. cres += onecres;
  9020. cres += ",";
  9021. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  9022. {
  9023. bill_entity.state = 4;//已作废
  9024. //bill_entity.Update();
  9025. //returnSuccessMsg("发票已红冲");
  9026. }
  9027. else if (onecres.IndexOf("重复冲红") != -1)
  9028. {
  9029. bill_entity.state = 4;//已作废
  9030. //bill_entity.Update();
  9031. //returnSuccessMsg("发票已红冲");
  9032. }
  9033. else
  9034. {
  9035. string errmsg = commonHelper.KeepChinese(onecres);
  9036. bill_entity.failerror += redTag + "&" + errmsg + "|";
  9037. }
  9038. }
  9039. bill_entity.Update();
  9040. if (cres.IndexOf("失败") != -1)
  9041. returnErrorMsg("红冲失败");
  9042. else
  9043. returnSuccessMsg("发票已红冲");
  9044. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  9045. return;
  9046. }
  9047. return;
  9048. }
  9049. }
  9050. public void del_erp_billorder()
  9051. {
  9052. if (UrlPostParmsCheck("id"))
  9053. {
  9054. string eid = GetPostString("id");
  9055. CeErpBill.Del(eid);
  9056. CeErpBill bill = CeErpBill.Get(eid);
  9057. if (bill != null)
  9058. {
  9059. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  9060. }
  9061. returnSuccessMsg("删除成功");
  9062. }
  9063. }
  9064. public void finish_erp_bill()
  9065. {
  9066. if (UrlPostParmsCheck("ids"))
  9067. {
  9068. string eids = GetPostString("ids");
  9069. string[] list = eids.Split(',');
  9070. foreach (string eid in list)
  9071. {
  9072. CeErpBill bill = CeErpBill.Get(eid);
  9073. if (bill != null)
  9074. {
  9075. bill.state = 2;
  9076. bill.Update();
  9077. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  9078. }
  9079. }
  9080. returnSuccessMsg("操作成功");
  9081. }
  9082. }
  9083. public void get_erp_returncash()
  9084. {
  9085. DataStruct dStruct = GetPostStruct();
  9086. List<string> lw = new List<string>();
  9087. string tid = GetPostString("tid");
  9088. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9089. string shopname = GetPostString("shopname");
  9090. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9091. string buyernick = GetPostString("buyer_nick");
  9092. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9093. string customer = GetPostString("customer");
  9094. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9095. string returndate1 = GetPostString("returndate1");
  9096. string returndate2 = GetPostString("returndate2");
  9097. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9098. if (dw.Length > 0) lw.Add(dw);
  9099. string finishDate1 = GetPostString("finishdate1");
  9100. string finishDate2 = GetPostString("finishdate2");
  9101. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9102. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9103. string returntype = GetPostString("returntype");
  9104. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  9105. string returnvstate = GetPostString("returnvstate");
  9106. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  9107. dStruct.Order = "created desc";
  9108. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9109. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  9110. writeGridDataTableJson(dStruct.TotalCount, dt);
  9111. }
  9112. public void get_erp_staygoods()
  9113. {
  9114. DataStruct dStruct = GetPostStruct();
  9115. List<string> lw = new List<string>();
  9116. string tid = GetPostString("tid");
  9117. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9118. string shopname = GetPostString("shopname");
  9119. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  9120. string wangwang = GetPostString("wangwang");
  9121. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  9122. string customer = GetPostString("customer");
  9123. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  9124. string returndate1 = GetPostString("returndate1");
  9125. string returndate2 = GetPostString("returndate2");
  9126. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  9127. if (dw.Length > 0) lw.Add(dw);
  9128. string finishDate1 = GetPostString("finishdate1");
  9129. string finishDate2 = GetPostString("finishdate2");
  9130. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  9131. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9132. string returnvstate = GetPostString("returnvstate");
  9133. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  9134. string persuadetype = GetPostString("persuadetype");
  9135. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  9136. string customerOrg = GetPostString("customerOrg");
  9137. if (customerOrg.Length > 0)
  9138. {
  9139. lw.Add(string.Format("OrgID = {0}", customerOrg));
  9140. }
  9141. string designerorg = GetPostString("designerorg");
  9142. if (designerorg.Length > 0)
  9143. {
  9144. lw.Add(string.Format("OrgID = {0}", designerorg));
  9145. }
  9146. dStruct.Order = "creata_time desc";
  9147. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9148. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  9149. writeGridDataTableJson(dStruct.TotalCount, dt);
  9150. }
  9151. public void upd_erp_staygoods()
  9152. {
  9153. if (UrlPostParmsCheck("id"))
  9154. {
  9155. int eid = GetPostInt("id");
  9156. CeErpStayGoods entity = null;
  9157. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9158. if (entity != null)
  9159. {
  9160. entity.audit_type = 1;
  9161. entity.audit_time = DateTime.Now;
  9162. entity.audit_u_id = CurrentUser.UserID;
  9163. entity.audit_u_name = CurrentUser.UserName;
  9164. entity.Update();
  9165. returnSuccessMsg("审核成功!");
  9166. return;
  9167. }
  9168. returnErrorMsg("找不到订单记录");
  9169. }
  9170. }
  9171. public void upd_erp_stayGoodsback()
  9172. {
  9173. if (UrlPostParmsCheck("id"))
  9174. {
  9175. int eid = GetPostInt("id");
  9176. CeErpStayGoods entity = null;
  9177. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9178. if (entity != null)
  9179. {
  9180. entity.audit_text = GetPostString("reason");
  9181. entity.audit_type = 2;
  9182. entity.audit_time = DateTime.Now;
  9183. entity.audit_u_id = CurrentUser.UserID;
  9184. entity.audit_u_name = CurrentUser.UserName;
  9185. entity.Update();
  9186. returnSuccessMsg("退回成功!");
  9187. return;
  9188. }
  9189. returnErrorMsg("找不到订单记录");
  9190. }
  9191. }
  9192. public void upd_erp_returncashverify()
  9193. {
  9194. if (UrlPostParmsCheck("ID"))
  9195. {
  9196. int eid = GetPostInt("ID");
  9197. CeErpReturnCash entity = null;
  9198. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9199. if (entity != null)
  9200. {
  9201. entity.cashstate = 1;
  9202. entity.verifytime = DateTime.Now;
  9203. entity.verifyuserid = CurrentUser.UserID;
  9204. entity.Update();
  9205. returnSuccessMsg("审核成功!");
  9206. return;
  9207. }
  9208. returnErrorMsg("找不到订单记录");
  9209. }
  9210. }
  9211. public void upd_all_erp_returncashverify()
  9212. {
  9213. if (UrlPostParmsCheck("ID"))
  9214. {
  9215. String[] list = GetPostString("ID").Split(',');
  9216. CeErpReturnCash entity = null;
  9217. for (int i = 0; i < list.Length; i++)
  9218. {
  9219. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9220. if (entity != null)
  9221. {
  9222. if (entity.cashstate == 1)
  9223. {
  9224. returnErrorMsg("已审核过的订单不需要在审核!");
  9225. return;
  9226. }
  9227. entity.cashstate = 1;
  9228. entity.verifytime = DateTime.Now;
  9229. entity.verifyuserid = CurrentUser.UserID;
  9230. entity.Update();
  9231. }
  9232. }
  9233. returnSuccessMsg("审核成功!");
  9234. return;
  9235. }
  9236. }
  9237. public void upd_erp_returncashback()
  9238. {
  9239. if (UrlPostParmsCheck("ID"))
  9240. {
  9241. int eid = GetPostInt("ID");
  9242. CeErpReturnCash entity = null;
  9243. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9244. if (entity != null)
  9245. {
  9246. entity.backreason = GetPostString("reason");
  9247. entity.cashstate = 2;
  9248. entity.verifytime = DateTime.Now;
  9249. entity.verifyuserid = CurrentUser.UserID;
  9250. entity.Update();
  9251. returnSuccessMsg("退回成功!");
  9252. return;
  9253. }
  9254. returnErrorMsg("找不到订单记录");
  9255. }
  9256. }
  9257. public void upd_erp_returnprice()
  9258. {
  9259. if (UrlPostParmsCheck("ID"))
  9260. {
  9261. int eid = GetPostInt("ID");
  9262. CeErpReturnCash entity = null;
  9263. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9264. if (entity != null)
  9265. {
  9266. if (entity.cashstate == 1)
  9267. {
  9268. returnErrorMsg("审核通过了不能改");
  9269. return;
  9270. }
  9271. entity.returnprice = GetPostDouble("returnprice");
  9272. entity.Update();
  9273. returnSuccessMsg("修改成功!");
  9274. return;
  9275. }
  9276. returnErrorMsg("找不到订单记录");
  9277. }
  9278. }
  9279. public void del_erp_returncash()
  9280. {
  9281. if (UrlPostParmsCheck("ID"))
  9282. {
  9283. int eid = GetPostInt("ID");
  9284. CeErpReturnCash.Del(eid);
  9285. returnSuccessMsg("操作成功");
  9286. return;
  9287. }
  9288. }
  9289. public void test_for_do_sql()
  9290. {
  9291. string sql = GetPostString("sqlstr");
  9292. if (sql.Length > 0)
  9293. {
  9294. try
  9295. {
  9296. DbHelper.DbConn.ExecuteNonQuery(sql);
  9297. var res_obj = new
  9298. {
  9299. data = "成功",
  9300. };
  9301. string ro_json = JsonConvert.SerializeObject(res_obj);
  9302. returnSuccess(ro_json);
  9303. }
  9304. catch (Exception ex)
  9305. {
  9306. var res_obj = new
  9307. {
  9308. data = ex.Message,
  9309. };
  9310. string ro_json = JsonConvert.SerializeObject(res_obj);
  9311. returnSuccess(ro_json);
  9312. }
  9313. }
  9314. }
  9315. public void get_user_info()
  9316. {
  9317. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9318. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9319. }
  9320. public void get_total_data()
  9321. {
  9322. int userId = CurrentUser.UserID;
  9323. string sql = "";
  9324. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9325. {
  9326. 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);
  9327. }
  9328. else
  9329. {
  9330. 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 " +
  9331. "(select ID from CE_ErpUser where ID = {0}) d " +
  9332. "left join " +
  9333. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9334. ") a on d.ID = a.id left join " +
  9335. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9336. ") b on a.id = b.id1 left join" +
  9337. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9338. ") c on a.id = c.id2;", userId);
  9339. }
  9340. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9341. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9342. }
  9343. public void get_date_area_total_data2()
  9344. {
  9345. int userId = CurrentUser.UserID;
  9346. string date_type = GetPostString("timetype");
  9347. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9348. string sql = "";
  9349. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9350. {
  9351. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9352. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9353. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9354. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9355. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9356. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9357. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9358. ") a on e.ID = a.id left join " +
  9359. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9360. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9361. ") b on a.id = b.id1 " +
  9362. "left join " +
  9363. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9364. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9365. ") c on a.id = c.id2 " +
  9366. "left join " +
  9367. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9368. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9369. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9370. }
  9371. else
  9372. {
  9373. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9374. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9375. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9376. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9377. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9378. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9379. ") a on e.ID = a.id left join " +
  9380. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9381. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9382. ") c on a.id = c.id2 " +
  9383. "left join " +
  9384. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9385. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9386. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9387. }
  9388. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9389. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9390. }
  9391. public void get_date_area_total_data()
  9392. {
  9393. int userId = CurrentUser.UserID;
  9394. string date_type = GetPostString("timetype");
  9395. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9396. string date1 = searchDT[0].ToString();
  9397. string date2 = searchDT[1].ToString();
  9398. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9399. {
  9400. SqlParameter[] sqlParameter ={
  9401. new SqlParameter("@userId", SqlDbType.Int,4),
  9402. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9403. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9404. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9405. };
  9406. sqlParameter[0].Value = userId;
  9407. sqlParameter[1].Value = date1;
  9408. sqlParameter[2].Value = date2;
  9409. sqlParameter[3].Direction = ParameterDirection.Output;
  9410. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9411. string res = sqlParameter[3].Value.ToString();
  9412. var res_obj = new
  9413. {
  9414. data = res
  9415. };
  9416. string ro_json = JsonConvert.SerializeObject(res_obj);
  9417. returnSuccess(ro_json);
  9418. }
  9419. else
  9420. {
  9421. SqlParameter[] sqlParameter ={
  9422. new SqlParameter("@userId", SqlDbType.Int,4),
  9423. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9424. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9425. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9426. };
  9427. sqlParameter[0].Value = userId;
  9428. sqlParameter[1].Value = date1;
  9429. sqlParameter[2].Value = date2;
  9430. sqlParameter[3].Direction = ParameterDirection.Output;
  9431. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9432. string res = sqlParameter[3].Value.ToString();
  9433. var res_obj = new
  9434. {
  9435. data = res
  9436. };
  9437. string ro_json = JsonConvert.SerializeObject(res_obj);
  9438. returnSuccess(ro_json);
  9439. }
  9440. //writeGridDataViewJson(dt.Rows.Count, dv);
  9441. }
  9442. public void get_order_list()
  9443. {
  9444. string strFields = GetPostString("paraFields");
  9445. string strOrder = GetPostString("paraOrder");
  9446. string strWhere = GetPostString("paraWhere");
  9447. string strPageSize = GetPostString("paraPageSize");
  9448. DataStruct dStruct = GetPostStruct();
  9449. dStruct.PageSize = int.Parse(strPageSize);
  9450. dStruct.Fileds = strFields;
  9451. dStruct.Order = strOrder;
  9452. dStruct.MainWhere = strWhere;
  9453. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9454. writeGridDataTableJson(dStruct.TotalCount, dt);
  9455. }
  9456. ////获取待开始订单列表
  9457. //public void get_wait_design_order_list()
  9458. //{
  9459. // string date_type = GetPostString("date_type");
  9460. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9461. // DataStruct dStruct = GetPostStruct();
  9462. // dStruct.PageSize = 1000;
  9463. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9464. // List<string> lw = new List<string>();
  9465. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9466. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9467. // dStruct.Order = "WaitDesignTime asc";
  9468. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9469. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9470. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9471. //}
  9472. //获取完成单量排名
  9473. public void get_finish_order_count_ranking()
  9474. {
  9475. /* string date_type = GetPostString("date_type");
  9476. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9477. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9478. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9479. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9480. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9481. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9482. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9483. writeGridDataTableJson(0, new DataTable());
  9484. }
  9485. public void get_finish_order_amount_ranking()
  9486. {
  9487. /*string date_type = GetPostString("date_type");
  9488. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9489. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9490. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9491. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9492. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9493. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9494. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9495. writeGridDataTableJson(0, new DataTable());
  9496. }
  9497. public void get_finish_refund_count_ranking()
  9498. {
  9499. string date_type = GetPostString("date_type");
  9500. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9501. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9502. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9503. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9504. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9505. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9506. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9507. writeGridDataTableJson(dt.Rows.Count, dt);
  9508. }
  9509. public void get_finish_refund_amount_ranking()
  9510. {
  9511. string date_type = GetPostString("date_type");
  9512. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9513. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9514. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9515. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9516. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9517. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9518. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9519. writeGridDataTableJson(dt.Rows.Count, dt);
  9520. }
  9521. public void set_erp_finishorder_director()
  9522. {
  9523. if (UrlPostParmsCheck("ctid"))
  9524. {
  9525. string eid = GetPostString("ctid");
  9526. CeErpTradeCell entity = null;
  9527. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9528. if (entity != null)
  9529. {
  9530. entity.OrderState = 8;
  9531. entity.Update();
  9532. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9533. returnSuccessMsg("操作成功!");
  9534. return;
  9535. }
  9536. returnErrorMsg("找不到记录");
  9537. }
  9538. }
  9539. public void get_erp_placeregistlist()
  9540. {
  9541. DataStruct dStruct = GetPostStruct();
  9542. List<string> lw = new List<string>();
  9543. string outsid = GetPostString("outsid");
  9544. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9545. string memo = GetPostString("memo");
  9546. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9547. string filename = GetPostString("filename");
  9548. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9549. string islate = GetPostString("islate");
  9550. if (islate.Length > 0)
  9551. {
  9552. if (islate == "1")
  9553. lw.Add(string.Format("OutLate>0"));
  9554. else
  9555. lw.Add(string.Format("OutLate=0"));
  9556. }
  9557. string placedate1 = GetPostString("placedate1");
  9558. string placedate2 = GetPostString("placedate2");
  9559. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9560. if (dw.Length > 0) lw.Add(dw);
  9561. string deliveryDate1 = GetPostString("deliverydate1");
  9562. string deliveryDate2 = GetPostString("deliverydate2");
  9563. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9564. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9565. dStruct.Order = "ID desc";
  9566. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9567. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9568. writeGridDataTableJson(dStruct.TotalCount, dt);
  9569. }
  9570. public void ins_erp_placeregist()
  9571. {
  9572. if (UrlPostParmsCheck("id"))
  9573. {
  9574. string eid = GetPostString("id");
  9575. CeErpPlaceRegister entity = null;
  9576. if (eid == "0")//新增
  9577. {
  9578. entity = new CeErpPlaceRegister();
  9579. string xdTime = GetPostString("placeTime");
  9580. if (xdTime.Length > 0)
  9581. {
  9582. entity.PlactTime = Convert.ToDateTime(xdTime);
  9583. }
  9584. string fhTime = GetPostString("deliveryTime");
  9585. if (fhTime.Length > 0)
  9586. {
  9587. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9588. }
  9589. string preTime = GetPostString("preOutTime");
  9590. if (preTime.Length > 0)
  9591. {
  9592. entity.PreOutTime = Convert.ToDateTime(preTime);
  9593. }
  9594. entity.DeliveryCount = GetPostInt("deliveryCount");
  9595. entity.ReceiveCount = GetPostInt("receiveCount");
  9596. entity.OutSid = GetPostString("outSid");
  9597. entity.FileName = GetPostString("fileName");
  9598. entity.Memo = GetPostString("memo");
  9599. entity.AddUserId = CurrentUser.UserID;
  9600. entity.CreateTime = DateTime.Now;
  9601. entity.Img = GetPostString("img");
  9602. entity.Supplier = GetPostInt("supplier");
  9603. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9604. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9605. {
  9606. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9607. DateTime dt2 = (DateTime)entity.PreOutTime;
  9608. TimeSpan span = dt1.Subtract(dt2);
  9609. if (span.Days > 0)
  9610. {
  9611. entity.OutLate = span.Days;
  9612. }
  9613. }
  9614. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9615. entity.Create();
  9616. returnSuccessMsg("添加成功!");
  9617. return;
  9618. }
  9619. else //修改
  9620. {
  9621. entity = CeErpPlaceRegister.Get(eid);
  9622. if (entity != null)
  9623. {
  9624. string xdTime = GetPostString("placeTime");
  9625. if (xdTime.Length > 0)
  9626. {
  9627. entity.PlactTime = Convert.ToDateTime(xdTime);
  9628. }
  9629. string fhTime = GetPostString("deliveryTime");
  9630. if (fhTime.Length > 0)
  9631. {
  9632. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9633. }
  9634. string preTime = GetPostString("preOutTime");
  9635. if (preTime.Length > 0)
  9636. {
  9637. entity.PreOutTime = Convert.ToDateTime(preTime);
  9638. }
  9639. entity.DeliveryCount = GetPostInt("deliveryCount");
  9640. entity.ReceiveCount = GetPostInt("receiveCount");
  9641. if (entity.DeliveryCount == entity.ReceiveCount)
  9642. {
  9643. entity.CurState = "已完成";
  9644. }
  9645. else
  9646. {
  9647. entity.CurState = "未完成";
  9648. }
  9649. entity.OutSid = GetPostString("outSid");
  9650. entity.FileName = GetPostString("fileName");
  9651. entity.Memo = GetPostString("memo");
  9652. entity.Img = GetPostString("img");
  9653. entity.Supplier = GetPostInt("supplier");
  9654. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9655. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9656. {
  9657. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9658. DateTime dt2 = (DateTime)entity.PreOutTime;
  9659. TimeSpan span = dt1.Subtract(dt2);
  9660. if (span.Days > 0)
  9661. {
  9662. entity.OutLate = span.Days;
  9663. }
  9664. }
  9665. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9666. entity.Update();
  9667. returnSuccessMsg("修改成功");
  9668. return;
  9669. }
  9670. returnErrorMsg("找不到对应的记录");
  9671. return;
  9672. }
  9673. }
  9674. returnErrorMsg("缺少必要参数");
  9675. }
  9676. public void del_erp_placeregist()
  9677. {
  9678. string eid = GetPostString("id");
  9679. CeErpPlaceRegister.Del(eid);
  9680. returnSuccessMsg("删除成功!");
  9681. return;
  9682. }
  9683. public void ins_erp_placeregistbyorder()
  9684. {
  9685. string ctid = GetPostString("ctid");
  9686. if (ctid.Length > 0)
  9687. {
  9688. StringBuilder sql = new StringBuilder();
  9689. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9690. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9691. if (dt.Rows.Count > 0)
  9692. {
  9693. foreach (DataRow dr in dt.Rows)
  9694. {
  9695. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9696. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9697. entity.AddUserId = CurrentUser.UserID;
  9698. entity.tid = dr["tid"].ToString();
  9699. entity.Did = Convert.ToString(dr["ctid"]);
  9700. entity.splitTag = dr["SplitTag"].ToString();
  9701. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9702. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9703. if (pre_ctid.Length > 0)
  9704. {
  9705. sellmemo = sellmemo.Replace(pre_ctid, "");
  9706. }
  9707. sellmemo = sellmemo.Replace("[", "");
  9708. sellmemo = sellmemo.Replace("]", "");
  9709. entity.FileName = sellmemo;
  9710. string count = dr["ProductCount"].ToString();
  9711. int usecount = commonHelper.getIntCountFromString(count);
  9712. entity.DeliveryCount = usecount;
  9713. entity.CurState = "未完成";
  9714. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9715. {
  9716. entity.Supplier = 24;//dl手提袋定制
  9717. }
  9718. else
  9719. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9720. entity.CreateTime = DateTime.Now;
  9721. entity.Create();
  9722. }
  9723. returnSuccessMsg("操作成功");
  9724. return;
  9725. }
  9726. returnErrorMsg("没有找到对应订单");
  9727. return;
  9728. }
  9729. returnErrorMsg("缺少订单编号");
  9730. return;
  9731. }
  9732. public void get_erp_persuadelist()
  9733. {
  9734. DataStruct dStruct = GetPostStruct();
  9735. List<string> lw = new List<string>();
  9736. string ctid = GetPostString("ctid");
  9737. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9738. string shopname = GetPostString("shopname");
  9739. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9740. string buyernick = GetPostString("buyer_nick");
  9741. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9742. string customer = GetPostString("customer");
  9743. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9744. string returndate1 = GetPostString("returndate1");
  9745. string returndate2 = GetPostString("returndate2");
  9746. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9747. if (dw.Length > 0) lw.Add(dw);
  9748. string finishDate1 = GetPostString("finishdate1");
  9749. string finishDate2 = GetPostString("finishdate2");
  9750. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9751. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9752. string persuadetype = GetPostString("persuadetype");
  9753. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9754. string returnvstate = GetPostString("returnvstate");
  9755. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9756. dStruct.Order = "created desc";
  9757. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9758. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9759. writeGridDataTableJson(dStruct.TotalCount, dt);
  9760. }
  9761. public void upd_erp_returnpersuadeback()
  9762. {
  9763. if (UrlPostParmsCheck("ID"))
  9764. {
  9765. int eid = GetPostInt("ID");
  9766. CeErpPersuade entity = null;
  9767. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9768. if (entity != null)
  9769. {
  9770. entity.backreason = GetPostString("reason");
  9771. entity.pstate = 2;
  9772. entity.verifytime = DateTime.Now;
  9773. entity.verifyuserid = CurrentUser.UserID;
  9774. entity.Update();
  9775. returnSuccessMsg("退回成功!");
  9776. return;
  9777. }
  9778. returnErrorMsg("找不到订单记录");
  9779. }
  9780. }
  9781. public void upd_erp_returnpersuadeverify()
  9782. {
  9783. if (UrlPostParmsCheck("ID"))
  9784. {
  9785. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9786. {
  9787. returnErrorMsg("暂无权限审核");
  9788. return;
  9789. }
  9790. int eid = GetPostInt("ID");
  9791. CeErpPersuade entity = null;
  9792. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9793. if (entity != null)
  9794. {
  9795. entity.pstate = 1;
  9796. entity.verifytime = DateTime.Now;
  9797. entity.verifyuserid = CurrentUser.UserID;
  9798. entity.Update();
  9799. returnSuccessMsg("审核成功!");
  9800. return;
  9801. }
  9802. returnErrorMsg("找不到订单记录");
  9803. }
  9804. }
  9805. public void del_erp_persuade()
  9806. {
  9807. if (UrlPostParmsCheck("ID"))
  9808. {
  9809. int eid = GetPostInt("ID");
  9810. CeErpPersuade.Del(eid);
  9811. returnSuccessMsg("操作成功");
  9812. return;
  9813. }
  9814. }
  9815. public void get_erp_oldcustoupload()
  9816. {
  9817. DataStruct dStruct = GetPostStruct();
  9818. List<string> lw = new List<string>();
  9819. string buyernick = GetPostString("buyer_nick");
  9820. if (buyernick.Length > 0)
  9821. {
  9822. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9823. }
  9824. else
  9825. return;
  9826. dStruct.Order = "pay_time desc";
  9827. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9828. DataTable dt = null;
  9829. dt = WebCache.GetData("view_erptradecell", dStruct);
  9830. writeGridDataTableJson(dStruct.TotalCount, dt);
  9831. }
  9832. public void get_erp_checkorderlist()
  9833. {
  9834. DataStruct dStruct = GetPostStruct();
  9835. List<string> lw = new List<string>();
  9836. string tid = GetPostString("ctid");
  9837. if (tid.Length > 0)
  9838. {
  9839. string select_tid = getTidByCtid(tid);
  9840. lw.Add(string.Format("tid='{0}'", select_tid));
  9841. }
  9842. string shopname = GetPostString("shopname");
  9843. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9844. string buyernick = GetPostString("buyer_nick");
  9845. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9846. string customer = GetPostString("customer");
  9847. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9848. string design = GetPostString("design");
  9849. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9850. string orderState = GetPostString("orderState");
  9851. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9852. string address = GetPostString("address");
  9853. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9854. string sellermemo = GetPostString("seller_memo");
  9855. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9856. string supplier = GetPostString("supplier");
  9857. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9858. {
  9859. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9860. }
  9861. else
  9862. {
  9863. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9864. }
  9865. string date1 = GetPostString("date1");
  9866. string date2 = GetPostString("date2");
  9867. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9868. if (dw.Length > 0) lw.Add(dw);
  9869. string placedate1 = GetPostString("placedate1");
  9870. string placedate2 = GetPostString("placedate2");
  9871. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9872. if (fdw.Length > 0) lw.Add(fdw);
  9873. string price1 = GetPostString("price1");
  9874. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9875. string price2 = GetPostString("price2");
  9876. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9877. string checkst = GetPostString("checkstate");
  9878. if (checkst.Length > 0 && "10".Equals(checkst))
  9879. {
  9880. lw.Add(string.Format("CheckOut>0"));
  9881. }
  9882. else
  9883. {
  9884. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9885. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9886. }
  9887. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9888. {
  9889. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9890. }
  9891. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9892. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9893. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9894. writeGridDataTableJson(dStruct.TotalCount, dt);
  9895. }
  9896. public void ins_erp_startCheck()
  9897. {
  9898. if (UrlPostParmsCheck("ctid"))
  9899. {
  9900. string eid = GetPostString("ctid");
  9901. CeErpTradeCell entity = null;
  9902. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9903. if (entity != null)
  9904. {
  9905. entity.MemoOpt = 4;
  9906. entity.UpdateTime = DateTime.Now;
  9907. entity.Update();
  9908. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9909. CeErpSukuraData.createInfo(entity.ctid, 6);
  9910. returnSuccessMsg("操作成功!");
  9911. return;
  9912. }
  9913. returnErrorMsg("找不到记录");
  9914. }
  9915. }
  9916. public void upd_erp_sendXlw()
  9917. {
  9918. if (UrlPostParmsCheck("ctid"))
  9919. {
  9920. string eid = GetPostString("ctid");
  9921. CeErpTradeCell entity = null;
  9922. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9923. if (entity != null)
  9924. {
  9925. if (entity.IsSendGift == 1)
  9926. {
  9927. returnErrorMsg("请勿重复标记");
  9928. return;
  9929. }
  9930. entity.IsSendGift = 1;
  9931. entity.Update();
  9932. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9933. returnSuccessMsg("操作成功!");
  9934. return;
  9935. }
  9936. returnErrorMsg("找不到记录");
  9937. }
  9938. }
  9939. public void cancel_sendXlw()
  9940. {
  9941. if (UrlPostParmsCheck("ctid"))
  9942. {
  9943. string eid = GetPostString("ctid");
  9944. CeErpTradeCell entity = null;
  9945. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9946. if (entity != null)
  9947. {
  9948. if (entity.IsSendGift == 0)
  9949. {
  9950. returnErrorMsg("未标记小礼物");
  9951. return;
  9952. }
  9953. entity.IsSendGift = 0;
  9954. entity.Update();
  9955. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9956. returnSuccessMsg("操作成功!");
  9957. return;
  9958. }
  9959. returnErrorMsg("找不到记录");
  9960. }
  9961. }
  9962. public void get_erp_designbill()
  9963. {
  9964. DataStruct dStruct = GetPostStruct();
  9965. List<string> lw = new List<string>();
  9966. int isMy = GetInt("my");
  9967. if (isMy == 1)
  9968. {
  9969. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9970. }
  9971. string tid = GetPostString("tid");
  9972. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9973. string userName = GetPostString("design");
  9974. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9975. string price1 = GetPostString("price1");
  9976. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9977. string price2 = GetPostString("price2");
  9978. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9979. string rePrice1 = GetPostString("rePrice1");
  9980. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9981. string rePrice2 = GetPostString("rePrice2");
  9982. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9983. string designerType = GetPostString("designerType");
  9984. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9985. string orderState = GetPostString("orderState");
  9986. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9987. string endTime1 = GetPostString("endTime1");
  9988. string endTime2 = GetPostString("endTime2");
  9989. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9990. if (dw.Length > 0) lw.Add(dw);
  9991. string isDk = GetPostString("isDk");
  9992. if (isDk == "1")
  9993. {
  9994. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9995. }
  9996. else if (isDk == "0")
  9997. {
  9998. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9999. }
  10000. dStruct.Order = "oid, create_time desc";
  10001. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10002. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  10003. writeGridDataTableJson(dStruct.TotalCount, dt);
  10004. }
  10005. public void upd_erp_designerbill()
  10006. {
  10007. if (UrlPostParmsCheck("ID"))
  10008. {
  10009. string eid = GetPostString("ID");
  10010. CeErpDesignerBill entity = null;
  10011. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  10012. if (entity != null)
  10013. {
  10014. if (GetPostDouble("designerpirce") > 0)
  10015. {
  10016. entity.realPrice = GetPostDouble("designerpirce");
  10017. entity.update_time = DateTime.Now;
  10018. entity.update_u_id = CurrentUser.UserID;
  10019. entity.update_u_name = CurrentUser.UserName;
  10020. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  10021. entity.Update();
  10022. returnSuccessMsg("操作成功!");
  10023. return;
  10024. }
  10025. else
  10026. {
  10027. entity.price = GetPostDouble("price");
  10028. entity.update_time = DateTime.Now;
  10029. entity.update_u_id = CurrentUser.UserID;
  10030. entity.update_u_name = CurrentUser.UserName;
  10031. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  10032. entity.Update();
  10033. returnSuccessMsg("操作成功!");
  10034. return;
  10035. }
  10036. }
  10037. returnErrorMsg("找不到记录");
  10038. }
  10039. }
  10040. public void audit_erp_designerbill()
  10041. {
  10042. if (UrlPostParmsCheck("ID"))
  10043. {
  10044. string eid = GetPostString("ID");
  10045. CeErpDesignerBill entity = null;
  10046. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  10047. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  10048. if (entity != null)
  10049. {
  10050. entity.realPrice = GetPostDouble("designerpirce");
  10051. entity.update_time = DateTime.Now;
  10052. entity.update_u_id = CurrentUser.UserID;
  10053. entity.update_u_name = CurrentUser.UserName;
  10054. entity.isAudit = 1;
  10055. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  10056. entity.Update();
  10057. if (orderEntity != null)
  10058. {
  10059. orderEntity.IsReadTag = 3;
  10060. orderEntity.Update();
  10061. }
  10062. returnSuccessMsg("操作成功!");
  10063. return;
  10064. }
  10065. returnErrorMsg("找不到记录");
  10066. }
  10067. }
  10068. public void all_audit_erp_designerbill()
  10069. {
  10070. if (UrlPostParmsCheck("idList"))
  10071. {
  10072. string[] list = GetPostString("idList").Split(',');
  10073. CeErpDesignerBill entity = null;
  10074. for (int i = 0; i < list.Length; i++)
  10075. {
  10076. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  10077. if (entity == null) return;
  10078. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  10079. if (orderEntity == null) return;
  10080. if (entity.realPrice == 0) entity.realPrice = entity.price;
  10081. entity.update_time = DateTime.Now;
  10082. entity.update_u_id = CurrentUser.UserID;
  10083. entity.update_u_name = CurrentUser.UserName;
  10084. entity.isAudit = 1;
  10085. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  10086. entity.Update();
  10087. orderEntity.IsReadTag = 3;
  10088. orderEntity.Update();
  10089. }
  10090. returnSuccessMsg("操作成功!");
  10091. return;
  10092. }
  10093. }
  10094. public void get_erp_sameorders()
  10095. {
  10096. if (UrlPostParmsCheck("ctid"))
  10097. {
  10098. string eid = GetPostString("ctid");
  10099. CeErpTradeCell entity = null;
  10100. entity = CeErpTradeCell.GetByCtid(eid);
  10101. if (entity != null)
  10102. {
  10103. StringBuilder sql = new StringBuilder();
  10104. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  10105. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10106. var res = new
  10107. {
  10108. data = dt.Rows.Count
  10109. };
  10110. string ro_jsond = JsonConvert.SerializeObject(res);
  10111. returnSuccess(ro_jsond);
  10112. return;
  10113. }
  10114. returnErrorMsg("未找到订单");
  10115. return;
  10116. }
  10117. returnErrorMsg("缺少必要的参数");
  10118. }
  10119. public void get_erp_islasthavesameorder()
  10120. {
  10121. if (UrlPostParmsCheck("ctid"))
  10122. {
  10123. string eid = GetPostString("ctid");
  10124. string[] ctidList = eid.Split(',');
  10125. StringBuilder sql = new StringBuilder();
  10126. string tisCtid = "";
  10127. foreach (string ctid in ctidList)
  10128. {
  10129. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  10130. if (entity != null)
  10131. {
  10132. sql = new StringBuilder();
  10133. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  10134. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10135. if (dth.Rows.Count > 0)
  10136. {
  10137. tisCtid += entity.ctid;
  10138. tisCtid += ",";
  10139. }
  10140. }
  10141. }
  10142. if (tisCtid.Length > 0)
  10143. {
  10144. var res = new
  10145. {
  10146. data = tisCtid
  10147. };
  10148. string ro_jsond = JsonConvert.SerializeObject(res);
  10149. returnSuccess(ro_jsond);
  10150. }
  10151. else
  10152. {
  10153. var res = new
  10154. {
  10155. data = ""
  10156. };
  10157. string ro_jsond = JsonConvert.SerializeObject(res);
  10158. returnSuccess(ro_jsond);
  10159. }
  10160. return;
  10161. }
  10162. returnErrorMsg("缺少必要的参数");
  10163. }
  10164. public void file_client_down_url()
  10165. {
  10166. if (!UrlPostParmsCheck("userId"))
  10167. {
  10168. returnErrorMsg("缺少必要的参数");
  10169. }
  10170. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  10171. }
  10172. public void checkout_form_data()
  10173. {
  10174. if (!UrlPostParmsCheck("tid"))
  10175. {
  10176. returnErrorMsg("缺少必要的参数");
  10177. }
  10178. string tid = GetPostString("tid");
  10179. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  10180. if (ceErpOrderFormData != null)
  10181. {
  10182. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  10183. returnSuccess(ro_jsond);
  10184. return;
  10185. }
  10186. returnErrorMsg("尚未有文件!");
  10187. }
  10188. public void back_supplier_audit()
  10189. {
  10190. int userId = CurrentUser.UserID;
  10191. StringBuilder sql = new StringBuilder();
  10192. 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);
  10193. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10194. if (dt.Rows.Count > 0)
  10195. {
  10196. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10197. }
  10198. else
  10199. {
  10200. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10201. }
  10202. }
  10203. public void back_supplier_query()
  10204. {
  10205. string eid = GetPostString("ctid");
  10206. if (eid != "")
  10207. {
  10208. StringBuilder sql = new StringBuilder();
  10209. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  10210. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10211. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10212. }
  10213. else
  10214. {
  10215. returnErrorMsg("找不到订单记录");
  10216. return;
  10217. }
  10218. }
  10219. public void verified_to_order()
  10220. {
  10221. int userId = CurrentUser.UserID;
  10222. StringBuilder sql = new StringBuilder();
  10223. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10224. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10225. if (dt.Rows.Count > 0)
  10226. {
  10227. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10228. }
  10229. else
  10230. {
  10231. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10232. }
  10233. }
  10234. public void upd_supplier_audit()
  10235. {
  10236. if (UrlPostParmsCheck("ctid"))
  10237. {
  10238. string eid = GetPostString("ctid");
  10239. string reason = GetPostString("returnreason");
  10240. CeErpTradeCell entity = null;
  10241. CeWithdraw withdraw = null;
  10242. withdraw = CeWithdraw.GetByTid(eid);
  10243. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10244. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10245. {
  10246. if (withdraw != null)
  10247. {
  10248. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10249. {
  10250. returnSuccessMsg("您没有权限操作!");
  10251. return;
  10252. }
  10253. else
  10254. {
  10255. if (reason.Equals("1"))
  10256. {
  10257. if (entity.OrderState == -1)
  10258. {
  10259. if (entity.FinishPlaceTime == null)
  10260. {
  10261. entity.OrderState = 2;
  10262. }
  10263. else
  10264. {
  10265. entity.OrderState = 6;
  10266. }
  10267. //配件单直接到下单部
  10268. if (entity.IsSample == 4)
  10269. {
  10270. entity.OrderState = 5;
  10271. }
  10272. }
  10273. entity.Update();
  10274. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10275. if (withdraw != null)
  10276. {
  10277. withdraw.status = int.Parse(reason);
  10278. withdraw.Update();
  10279. }
  10280. returnSuccessMsg("操作成功!");
  10281. return;
  10282. }
  10283. else
  10284. {
  10285. withdraw.status = int.Parse(reason);
  10286. withdraw.acknowledgingtime = DateTime.Now;
  10287. withdraw.Update();
  10288. returnSuccessMsg("查看详细请点击线下订单查询");
  10289. return;
  10290. }
  10291. }
  10292. }
  10293. // 第一个字符是 'N'
  10294. }
  10295. if (eid[0] != 'N')
  10296. {
  10297. }
  10298. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10299. {
  10300. entity.IsVerifyToSupplier = false;
  10301. entity.IsReturn = 1;
  10302. entity.ReturnTime = DateTime.Now;
  10303. entity.ReturnReason = reason;
  10304. if (entity.OrderState == 6)
  10305. {
  10306. entity.OrderState = 5;
  10307. }
  10308. entity.Update();
  10309. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10310. if (withdraw != null)
  10311. {
  10312. withdraw.status = int.Parse(reason);
  10313. withdraw.Update();
  10314. }
  10315. returnSuccessMsg("操作成功!");
  10316. return;
  10317. }
  10318. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10319. {
  10320. ;
  10321. if (withdraw != null)
  10322. {
  10323. withdraw.status = int.Parse(reason);
  10324. withdraw.acknowledgingtime = DateTime.Now;
  10325. withdraw.Update();
  10326. returnSuccessMsg("供应商取消撤回!");
  10327. return;
  10328. }
  10329. }
  10330. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10331. {
  10332. if (entity.OrderState == -1)
  10333. {
  10334. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10335. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10336. /*if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10337. {
  10338. returnErrorMsg("台湾客户需填写身份证!");
  10339. return;
  10340. }*/
  10341. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10342. {
  10343. returnErrorMsg("偏远地区需要填写物流费!");
  10344. return;
  10345. }
  10346. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10347. {
  10348. returnErrorMsg("订单spu没有确认无法通过审核!");
  10349. return;
  10350. }
  10351. if (entity.FinishPlaceTime == null)
  10352. {
  10353. entity.OrderState = 2;
  10354. }
  10355. else
  10356. {
  10357. entity.OrderState = 3;
  10358. }
  10359. commonHelper.getCytPrice(entity);
  10360. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10361. {
  10362. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10363. }
  10364. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10365. {
  10366. entity.OrderState = 6;
  10367. }
  10368. if (entity.IsSample == 4)
  10369. {
  10370. entity.OrderState = 5;
  10371. }
  10372. }
  10373. entity.Update();
  10374. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10375. if (withdraw != null)
  10376. {
  10377. withdraw.status = int.Parse(reason);
  10378. withdraw.Update();
  10379. }
  10380. returnSuccessMsg("操作成功!");
  10381. return;
  10382. }
  10383. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10384. {
  10385. if (withdraw == null)
  10386. {
  10387. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10388. return;
  10389. }
  10390. }
  10391. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10392. {
  10393. if (withdraw != null)
  10394. {
  10395. withdraw.status = int.Parse(reason);
  10396. withdraw.acknowledgingtime = DateTime.Now;
  10397. withdraw.Update();
  10398. returnSuccessMsg("查看详细请点击线下订单查询");
  10399. return;
  10400. }
  10401. }
  10402. return;
  10403. }
  10404. }
  10405. //校验报价
  10406. public void refund_order_tip()
  10407. {
  10408. int userid = CurrentUser.UserID;
  10409. int sectionId = CurrentUser.UserPost.OrgID;
  10410. StringBuilder sql = new StringBuilder();
  10411. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10412. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10413. List<string> ids = new List<string>();
  10414. if (dth.Rows.Count > 0)
  10415. {
  10416. foreach (DataRow dr in dth.Rows)
  10417. {
  10418. ids.Add(dr["ID"].ToString());
  10419. }
  10420. try
  10421. {
  10422. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10423. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10424. }
  10425. catch (Exception ex)
  10426. {
  10427. }
  10428. }
  10429. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10430. }
  10431. public void refund_order_Design()
  10432. {
  10433. int userid = CurrentUser.UserID;
  10434. int sectionId = CurrentUser.UserPost.OrgID;
  10435. StringBuilder sql = new StringBuilder();
  10436. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10437. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10438. List<string> ids = new List<string>();
  10439. if (dth.Rows.Count > 0)
  10440. {
  10441. foreach (DataRow dr in dth.Rows)
  10442. {
  10443. ids.Add(dr["ID"].ToString());
  10444. }
  10445. try
  10446. {
  10447. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10448. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10449. }
  10450. catch (Exception ex)
  10451. {
  10452. }
  10453. }
  10454. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10455. }
  10456. public void change_order_info()
  10457. {
  10458. int userid = CurrentUser.UserID;
  10459. StringBuilder sql = new StringBuilder();
  10460. 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);
  10461. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10462. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10463. }
  10464. public void size_order_tip()
  10465. {
  10466. int userid = CurrentUser.UserID;
  10467. StringBuilder sql = new StringBuilder();
  10468. sql.AppendFormat("select top 1 * from CE_ErpMessageTip c where (c.userId = '{0}' ) and c.isVisit = 0 and c.type in (3,4);", userid);
  10469. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10470. List<string> ids = new List<string>();
  10471. if (dth.Rows.Count > 0)
  10472. {
  10473. foreach (DataRow dr in dth.Rows)
  10474. {
  10475. ids.Add(dr["ID"].ToString());
  10476. }
  10477. try
  10478. {
  10479. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10480. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10481. }
  10482. catch (Exception ex)
  10483. {
  10484. }
  10485. }
  10486. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10487. }
  10488. public void change_win_mome()
  10489. {
  10490. if (UrlPostParmsCheck("id,ctid"))
  10491. {
  10492. string id = GetPostString("id");
  10493. string ctid = GetPostString("ctid");
  10494. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10495. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10496. if (ce == null || ceErpMessageTip == null)
  10497. {
  10498. returnSuccessMsg("未找到对应的订单!");
  10499. return;
  10500. }
  10501. if (ce.OrderState >= 5)
  10502. {
  10503. ceErpMessageTip.isVisit = true;
  10504. ceErpMessageTip.Update();
  10505. returnSuccessMsg("已上传文件无法修改!");
  10506. return;
  10507. }
  10508. int type = GetPostInt("type");
  10509. string content = GetPostString("content");
  10510. if (type == 0)
  10511. {
  10512. content = content.Replace("(", "(");
  10513. content = content.Replace(")", ")");
  10514. string check = MidStrEx(content, "(", ")").Trim();
  10515. if (string.IsNullOrEmpty(check))
  10516. {
  10517. returnSuccessMsg("文件名格式不正确");
  10518. return;
  10519. }
  10520. }
  10521. ce.seller_memo = content;
  10522. ce.Update();
  10523. ceErpMessageTip.isVisit = true;
  10524. ceErpMessageTip.Update();
  10525. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10526. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10527. ApiVo apiVo = new ApiVo();
  10528. apiVo.orderNumber = ce.ctid;
  10529. apiVo.actionName = "demandDesign";
  10530. apiVo.orderRemarks = content;
  10531. apiVo.demandExamine = type + 1;
  10532. designHelper.API_WorkCore(apiVo);//demandDesign
  10533. returnSuccessMsg("修改成功!");
  10534. }
  10535. }
  10536. public static string MidStrEx(string sourse, string startstr, string endstr)
  10537. {
  10538. string result = string.Empty;
  10539. int startindex, endindex;
  10540. try
  10541. {
  10542. startindex = sourse.IndexOf(startstr);
  10543. if (startindex == -1)
  10544. return result;
  10545. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10546. endindex = tmpstr.IndexOf(endstr);
  10547. if (endindex == -1)
  10548. return result;
  10549. result = tmpstr.Remove(endindex);
  10550. }
  10551. catch (Exception ex)
  10552. {
  10553. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10554. }
  10555. return result;
  10556. }
  10557. public void refund_order_list()
  10558. {
  10559. int userid = CurrentUser.UserID;
  10560. int sectionId = CurrentUser.UserPost.OrgID;
  10561. StringBuilder sql = new StringBuilder();
  10562. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10563. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10564. DataStruct dStruct = GetPostStruct();
  10565. DataTable dt = null;
  10566. List<string> ids = new List<string>();
  10567. List<string> tids = new List<string>();
  10568. if (dth.Rows.Count > 0)
  10569. {
  10570. foreach (DataRow dr in dth.Rows)
  10571. {
  10572. tids.Add("'" + dr["tid"].ToString() + "'");
  10573. ids.Add(dr["id"].ToString());
  10574. }
  10575. try
  10576. {
  10577. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10578. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10579. List<string> lw = new List<string>();
  10580. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10581. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10582. dt = WebCache.GetData("view_orderlist", dStruct);
  10583. }
  10584. catch (Exception ex)
  10585. {
  10586. }
  10587. }
  10588. writeGridDataTableJson(dStruct.TotalCount, dt);
  10589. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10590. }
  10591. //新增
  10592. public void order_batch_downloads()
  10593. {
  10594. string ceid = GetPostString("tid");
  10595. String[] tid = ceid.Split(',');
  10596. order_batch_caiyingtong(tid);
  10597. /* (string success, string errors) = UploadFiles(tid);
  10598. returnSuccessMsg(success + errors);*/
  10599. return;
  10600. }
  10601. //报价接口
  10602. public void Get_To_Quote()
  10603. {
  10604. string ceid = GetPostString("ctid");
  10605. if (ceid != null)
  10606. {
  10607. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10608. if (entity != null)
  10609. {
  10610. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10611. {
  10612. return;
  10613. }
  10614. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10615. double price = 0;
  10616. if (cp == null)
  10617. {
  10618. JObject jsonObject12 = new JObject
  10619. {
  10620. { "UserId", "77886" },
  10621. { "Pwd", "lt666888" },
  10622. { "Filename", entity.seller_memo }
  10623. };
  10624. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10625. JObject jsonObjects1 = JObject.Parse(response1);
  10626. string ms1g = (string)jsonObjects1["msg"];
  10627. if (ms1g == "报价成功")
  10628. {
  10629. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10630. string data = (string)jsonObject1["price"];
  10631. 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 + "');";
  10632. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10633. returnSuccessMsg("获取报价成功:" + data);
  10634. price = Convert.ToDouble(data);
  10635. }
  10636. else
  10637. {
  10638. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10639. return;
  10640. }
  10641. }
  10642. String[] beizhu = entity.seller_memo.Split('-');
  10643. String chanp = "";
  10644. if (beizhu.Length > 0)
  10645. {
  10646. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10647. }
  10648. else
  10649. {
  10650. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10651. }
  10652. JObject jsonObject = new JObject
  10653. {
  10654. { "UserId", "77886" },
  10655. { "Pwd", "lt666888" },
  10656. { "Filename", chanp }
  10657. };
  10658. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10659. JObject jsonObjects = JObject.Parse(response);
  10660. string msg = (string)jsonObjects["msg"];
  10661. if (msg == "报价成功")
  10662. {
  10663. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10664. string data = (string)jsonObject1["price"];
  10665. 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 + "');";
  10666. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10667. returnSuccessMsg("获取报价成功:" + data);
  10668. price = Convert.ToDouble(data);
  10669. }
  10670. else
  10671. {
  10672. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10673. return;
  10674. }
  10675. if (price > 0)
  10676. {
  10677. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10678. if (ceErpTradeCellExtend == null)
  10679. {
  10680. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10681. ceErpTradeCellExtend.ctid = entity.ctid;
  10682. ceErpTradeCellExtend.payment_cyt = price;
  10683. ceErpTradeCellExtend.Create();
  10684. }
  10685. else
  10686. {
  10687. ceErpTradeCellExtend.payment_cyt = price;
  10688. ceErpTradeCellExtend.Update();
  10689. }
  10690. }
  10691. return;
  10692. }
  10693. }
  10694. else
  10695. {
  10696. returnErrorMsg("请至少选择一条数据");
  10697. return;
  10698. }
  10699. }
  10700. //新增
  10701. public void order_To_Supplier()
  10702. {
  10703. string ceid = GetPostString("tid");
  10704. String[] tid = ceid.Split(',');
  10705. if (tid.Length > 0)
  10706. {
  10707. try
  10708. {
  10709. for (int i = 0; i < tid.Length; i++)
  10710. {
  10711. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10712. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10713. entity.SupplierId = suid;
  10714. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10715. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10716. entity.Update();
  10717. }
  10718. }
  10719. catch (Exception ex)
  10720. {
  10721. returnErrorMsg("自动匹配供应商失败");
  10722. return;
  10723. }
  10724. }
  10725. else
  10726. {
  10727. returnErrorMsg("请至少选择一条数据");
  10728. return;
  10729. }
  10730. returnSuccessMsg("自动匹配供应商成功");
  10731. return;
  10732. }
  10733. public (string, string) UploadFiles(string[] urls)
  10734. {
  10735. string success = "";
  10736. string errors = "";
  10737. int userid = CurrentUser.UserID;
  10738. foreach (string url in urls)
  10739. {
  10740. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10741. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10742. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10743. {
  10744. JObject jsonObject = new JObject
  10745. {
  10746. { "Userid", "77886" },
  10747. { "pwd", "cyt86435015" },
  10748. { "content", base64FileContent },
  10749. { "ext", Path.GetExtension(fileName) }
  10750. };
  10751. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10752. JObject jsonObjects = JObject.Parse(response);
  10753. string msg = (string)jsonObjects["msg"];
  10754. if (msg.Equals("上传成功"))
  10755. {
  10756. success += url + " 上传成功";
  10757. }
  10758. else
  10759. {
  10760. errors += url + " 上传失败";
  10761. }
  10762. }
  10763. else
  10764. {
  10765. errors += url + " 格式出现问题";
  10766. }
  10767. }
  10768. if (urls.Length == 0)
  10769. {
  10770. return (success, errors);
  10771. }
  10772. return (success, errors);
  10773. }
  10774. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10775. {
  10776. return true; //总是接受
  10777. }
  10778. public static string HttpPost(string url, string param = null)
  10779. {
  10780. HttpWebRequest request;
  10781. //如果是发送HTTPS请求
  10782. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10783. {
  10784. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10785. request = WebRequest.Create(url) as HttpWebRequest;
  10786. request.ProtocolVersion = HttpVersion.Version10;
  10787. }
  10788. else
  10789. {
  10790. request = WebRequest.Create(url) as HttpWebRequest;
  10791. }
  10792. request.Method = "POST";
  10793. request.ContentType = "application/json";
  10794. request.Accept = "*/*";
  10795. request.Timeout = 120000;
  10796. request.AllowAutoRedirect = false;
  10797. StreamWriter requestStream = null;
  10798. WebResponse response = null;
  10799. string responseStr = null;
  10800. try
  10801. {
  10802. requestStream = new StreamWriter(request.GetRequestStream());
  10803. requestStream.Write(param);
  10804. requestStream.Close();
  10805. response = request.GetResponse();
  10806. if (response != null)
  10807. {
  10808. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10809. responseStr = reader.ReadToEnd();
  10810. reader.Close();
  10811. }
  10812. }
  10813. catch (Exception ex)
  10814. {
  10815. return ex.Message;
  10816. }
  10817. finally
  10818. {
  10819. request = null;
  10820. requestStream = null;
  10821. response = null;
  10822. }
  10823. return responseStr;
  10824. }
  10825. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10826. {
  10827. string base64FileContent;
  10828. string fileName;
  10829. using (WebClient webClient = new WebClient())
  10830. {
  10831. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10832. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10833. {
  10834. using (Stream stream = response.GetResponseStream())
  10835. {
  10836. using (MemoryStream memoryStream = new MemoryStream())
  10837. {
  10838. stream.CopyTo(memoryStream);
  10839. byte[] fileBytes = memoryStream.ToArray();
  10840. base64FileContent = Convert.ToBase64String(fileBytes);
  10841. fileName = response.Headers["Content-Disposition"];
  10842. if (!string.IsNullOrEmpty(fileName))
  10843. {
  10844. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10845. if (index >= 0)
  10846. {
  10847. fileName = fileName.Substring(index + 9).Trim('\"');
  10848. }
  10849. }
  10850. else
  10851. {
  10852. fileName = Path.GetFileName(downloadUrl);
  10853. }
  10854. }
  10855. }
  10856. }
  10857. }
  10858. return (fileName, base64FileContent);
  10859. }
  10860. //新增
  10861. public void order_batch_caiyingtong(string[] downloadUrls)
  10862. {
  10863. try
  10864. {
  10865. //遍历文件
  10866. DataStruct dStruct = GetPostStruct();
  10867. DataTable dt = null;
  10868. int userid = CurrentUser.UserID;
  10869. List<string> ids = new List<string>();//失败组
  10870. List<string> tids = new List<string>();
  10871. using (WebClient webClient = new WebClient())
  10872. {
  10873. foreach (var url in downloadUrls)
  10874. {
  10875. try
  10876. {
  10877. tids.Add("'" + url + "'");
  10878. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10879. if (entity != null)
  10880. {
  10881. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10882. if (cp == null)
  10883. {
  10884. JObject jsonObject = new JObject
  10885. {
  10886. { "Userid", "77886" },
  10887. { "pwd", "lt666888" },
  10888. { "Filename",entity.seller_memo }
  10889. };
  10890. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10891. JObject jsonObjects = JObject.Parse(response);
  10892. string msg = (string)jsonObjects["msg"];
  10893. if (msg == "报价成功")
  10894. {
  10895. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10896. DownloadAndConvertToBase64(url1);
  10897. }
  10898. else
  10899. {
  10900. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10901. }
  10902. }
  10903. else
  10904. {
  10905. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10906. JObject jsonObject = new JObject
  10907. {
  10908. { "Userid", "77886" },
  10909. { "pwd", "lt666888" },
  10910. { "Filename",chanp }
  10911. };
  10912. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10913. JObject jsonObjects = JObject.Parse(response);
  10914. string msg = (string)jsonObjects["msg"];
  10915. if (msg == "报价成功")
  10916. {
  10917. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10918. DownloadAndConvertToBase64(url1);
  10919. }
  10920. else
  10921. {
  10922. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10923. }
  10924. }
  10925. }
  10926. // 上传文件到FTP
  10927. }
  10928. catch (Exception ex)
  10929. {
  10930. Console.WriteLine($"An error occurred: {ex.Message}");
  10931. }
  10932. }
  10933. List<string> lw = new List<string>();
  10934. lw.Add(string.Format("( OrderState < 6 )"));
  10935. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10936. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10937. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10938. if (dt.Rows.Count > 0)
  10939. {
  10940. foreach (DataRow dr in dt.Rows)
  10941. {
  10942. ids.Add(dr["ctid"].ToString());
  10943. }
  10944. }
  10945. String ErrorMsgs = "";
  10946. foreach (String id in ids)
  10947. {
  10948. ErrorMsgs += id + ",";
  10949. }
  10950. if (ErrorMsgs.Length > 1)
  10951. {
  10952. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10953. }
  10954. if (ErrorMsgs.Length < 1)
  10955. {
  10956. ErrorMsgs = "上传成功";
  10957. returnSuccessMsg(ErrorMsgs);
  10958. }
  10959. else
  10960. {
  10961. returnErrorMsg("以下订单" + ErrorMsgs);
  10962. }
  10963. }
  10964. // 删除文件夹及其内容
  10965. /* Directory.Delete(localDirectory, true);*/
  10966. }
  10967. catch { }
  10968. }
  10969. public void get_center_data()
  10970. {
  10971. int userId = CurrentUser.UserID;
  10972. string postCode = CurrentUser.UserPost.Post.Code;
  10973. List<string> lw = new List<string>();
  10974. List<string> ww = new List<string>();
  10975. DateTime currentTime = DateTime.Now;
  10976. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10977. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10978. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10979. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10980. string sql = " SELECT ";
  10981. string startTime = "2023-10-01 11:22:31";
  10982. //设计
  10983. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10984. {
  10985. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10986. 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));
  10987. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10988. 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));
  10989. }
  10990. //客服
  10991. else if (postCode == "CustomerService" || postCode == "Director")
  10992. {
  10993. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10994. 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));
  10995. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10996. 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));
  10997. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10998. 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));
  10999. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  11000. 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));
  11001. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  11002. 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));
  11003. }
  11004. //售后
  11005. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  11006. {
  11007. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  11008. 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));
  11009. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  11010. 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));
  11011. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  11012. 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));
  11013. }
  11014. //下单部
  11015. else if (postCode == "Place" || postCode == "PlaceMr")
  11016. {
  11017. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  11018. 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));
  11019. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  11020. 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));
  11021. }
  11022. //车间
  11023. else if (postCode == "Supplier")
  11024. {
  11025. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  11026. 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));
  11027. }
  11028. DataTable dt = new DataTable();
  11029. if (lw.Count > 0)
  11030. {
  11031. sql += string.Join(" , ", lw);
  11032. sql += " FROM ";
  11033. sql += string.Join(" , ", ww);
  11034. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11035. }
  11036. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  11037. }
  11038. public void get_center_data_list()
  11039. {
  11040. int userId = CurrentUser.UserID;
  11041. string postCode = CurrentUser.UserPost.Post.Code;
  11042. string shopIds = CurrentUser.User.pemShop;
  11043. DataStruct dStruct = GetPostStruct();
  11044. List<string> lw = new List<string>();
  11045. DateTime currentTime = DateTime.Now;
  11046. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  11047. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  11048. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  11049. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  11050. string startTime = "2023-10-01 11:22:31";
  11051. int order_type = GetPostInt("order_type");
  11052. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  11053. {
  11054. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  11055. if (order_type == 0)
  11056. {
  11057. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  11058. }
  11059. else if (order_type == 3)
  11060. {
  11061. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  11062. }
  11063. else
  11064. {
  11065. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  11066. }
  11067. }
  11068. //客服
  11069. if (postCode == "CustomerService" || postCode == "Director")
  11070. {
  11071. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  11072. if (order_type == 0)
  11073. {
  11074. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  11075. }
  11076. else if (order_type == 1)
  11077. {
  11078. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  11079. }
  11080. else if (order_type == 2)
  11081. {
  11082. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  11083. }
  11084. else if (order_type == 3)
  11085. {
  11086. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  11087. }
  11088. else if (order_type == 4)
  11089. {
  11090. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  11091. }
  11092. else
  11093. {
  11094. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  11095. }
  11096. }
  11097. //售后
  11098. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  11099. {
  11100. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  11101. if (shopIds != "")
  11102. {
  11103. lw.Add(string.Format("ShopId in ({0})", shopIds));
  11104. }
  11105. if (order_type == 2)
  11106. {
  11107. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  11108. }
  11109. else if (order_type == 4)
  11110. {
  11111. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  11112. }
  11113. else if (order_type == 5)
  11114. {
  11115. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  11116. }
  11117. else
  11118. {
  11119. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  11120. }
  11121. }
  11122. //下单部
  11123. if (postCode == "Place" || postCode == "PlaceMr")
  11124. {
  11125. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  11126. if (shopIds != "")
  11127. {
  11128. lw.Add(string.Format("ShopId in ({0})", shopIds));
  11129. }
  11130. else if (order_type == 1)
  11131. {
  11132. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  11133. }
  11134. else if (order_type == 2)
  11135. {
  11136. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  11137. }
  11138. else
  11139. {
  11140. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  11141. }
  11142. }
  11143. //车间
  11144. if (postCode == "Supplier")
  11145. {
  11146. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  11147. if (order_type == 5)
  11148. {
  11149. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  11150. }
  11151. else
  11152. {
  11153. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  11154. }
  11155. }
  11156. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11157. dStruct.Fileds = "tid,ctid";
  11158. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  11159. writeGridDataTableJson(dStruct.TotalCount, dt);
  11160. }
  11161. public void aftersale_audit_master()
  11162. {
  11163. if (UrlPostParmsCheck("ctid"))
  11164. {
  11165. string ctid = GetPostString("ctid");
  11166. if (ctid.Length > 0)
  11167. {
  11168. bool result = aftersale_data_change(ctid);
  11169. if (result)
  11170. {
  11171. returnSuccessMsg("修改成功!");
  11172. return;
  11173. }
  11174. }
  11175. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11176. }
  11177. }
  11178. public void aftersale_documentary_finish()
  11179. {
  11180. if (UrlPostParmsCheck("ctid"))
  11181. {
  11182. string ctid = GetPostString("ctid");
  11183. if (ctid.Length > 0)
  11184. {
  11185. List<string> list = new List<string>();
  11186. string[] ctid_list = ctid.Split(',');
  11187. foreach (var item in ctid_list)
  11188. {
  11189. try
  11190. {
  11191. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(item);
  11192. if (ceErpTradeAfterSaleExtend == null)
  11193. {
  11194. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11195. ceErpTradeAfterSaleExtend.tid = item;
  11196. }
  11197. ceErpTradeAfterSaleExtend.AfterSalSend = 1;
  11198. if (ceErpTradeAfterSaleExtend.ID > 0)
  11199. {
  11200. ceErpTradeAfterSaleExtend.Update();
  11201. }
  11202. else
  11203. {
  11204. ceErpTradeAfterSaleExtend.Create();
  11205. }
  11206. LogHelper.addLog(item, CurrentUser.UserID, "跟单完成", 6, 4);
  11207. }
  11208. catch (Exception ex)
  11209. {
  11210. list.Add(item);
  11211. }
  11212. }
  11213. if (list.Count > 0)
  11214. {
  11215. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11216. return;
  11217. }
  11218. returnSuccessMsg("修改成功!");
  11219. return;
  11220. }
  11221. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11222. }
  11223. }
  11224. public void aftersale_batch_audit_master()
  11225. {
  11226. if (UrlPostParmsCheck("ctids"))
  11227. {
  11228. string ctids = GetPostString("ctids");
  11229. if (ctids.Length > 0)
  11230. {
  11231. List<string> list = new List<string>();
  11232. string[] ctid_list = ctids.Split(',');
  11233. foreach (var item in ctid_list)
  11234. {
  11235. bool result = aftersale_data_change(item);
  11236. if (!result)
  11237. {
  11238. list.Add(item);
  11239. }
  11240. }
  11241. if (list.Count > 0)
  11242. {
  11243. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11244. return;
  11245. }
  11246. returnSuccessMsg("修改成功!");
  11247. return;
  11248. }
  11249. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11250. }
  11251. }
  11252. public bool aftersale_data_change(string ctid)
  11253. {
  11254. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11255. if (ceErpTradeCell != null)
  11256. {
  11257. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  11258. ceErpTradeCell.AfterSaleSupplierState = 0;
  11259. StringBuilder sql = new StringBuilder();
  11260. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  11261. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11262. CeErpTradeResponsible.DelByTid(ctid, 0);
  11263. 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 == "不理赔")
  11264. {
  11265. CeErpTradeResponsible.DelByTid(ctid, -1);
  11266. ceErpTradeCell.AfterSaleSupplierState = 1;
  11267. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11268. ceErpTradeCell.AfterSaleState = 4;
  11269. }
  11270. else
  11271. {
  11272. ceErpTradeCell.AfterSaleState = 3;
  11273. }
  11274. bool needCyt = false;
  11275. if (dt != null)
  11276. {
  11277. if (dt.Rows.Count == 1)
  11278. {
  11279. bool isEnd = false;
  11280. foreach (DataRow dr in dt.Rows)
  11281. {
  11282. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11283. {
  11284. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11285. isEnd = true;
  11286. }
  11287. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  11288. {
  11289. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11290. isEnd = true;
  11291. }
  11292. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11293. {
  11294. needCyt = true;
  11295. }
  11296. }
  11297. if (isEnd)
  11298. {
  11299. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11300. ceErpTradeCell.AfterSaleState = 4;
  11301. ceErpTradeCell.AfterSaleSupplierState = 1;
  11302. }
  11303. }
  11304. else
  11305. {
  11306. bool isAll = true;
  11307. foreach (DataRow dr in dt.Rows)
  11308. {
  11309. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11310. {
  11311. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11312. continue;
  11313. }
  11314. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11315. {
  11316. string path = "";
  11317. int OrgID = 0;
  11318. if (!Convert.IsDBNull(dr["OrgPath"]))
  11319. {
  11320. path = dr["OrgPath"].ToString();
  11321. }
  11322. if (!Convert.IsDBNull(dr["OrgID"]))
  11323. {
  11324. OrgID = Convert.ToInt32(dr["OrgID"]);
  11325. }
  11326. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11327. {
  11328. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11329. continue;
  11330. }
  11331. }
  11332. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11333. {
  11334. needCyt = true;
  11335. }
  11336. isAll = false;
  11337. }
  11338. if (isAll)
  11339. {
  11340. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11341. ceErpTradeCell.AfterSaleState = 4;
  11342. ceErpTradeCell.AfterSaleSupplierState = 1;
  11343. }
  11344. }
  11345. }
  11346. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11347. {
  11348. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11349. }
  11350. if (ceErpTradeCell.AfterSaleState == 4)
  11351. {
  11352. ApiVo apiVo = new ApiVo();
  11353. apiVo.orderNumber = ceErpTradeCell.ctid;
  11354. apiVo.actionName = "afterOver";
  11355. designHelper.API_WorkCore(apiVo); //afterOver
  11356. }
  11357. ceErpTradeCell.Update();
  11358. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11359. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11360. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11361. return true;
  11362. }
  11363. return false;
  11364. }
  11365. public void get_erp_wechatorder()
  11366. {
  11367. DataStruct dStruct = GetPostStruct();
  11368. List<string> lw = new List<string>();
  11369. string tid = GetPostString("tid");
  11370. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11371. string shopname = GetPostString("shopname");
  11372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11373. string buyernick = GetPostString("buyer_nick");
  11374. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11375. string customer = GetPostString("customer");
  11376. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11377. string returndate1 = GetPostString("returndate1");
  11378. string returndate2 = GetPostString("returndate2");
  11379. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11380. if (dw.Length > 0) lw.Add(dw);
  11381. string finishDate1 = GetPostString("finishdate1");
  11382. string finishDate2 = GetPostString("finishdate2");
  11383. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11384. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11385. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11386. dStruct.Order = "created desc";
  11387. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11388. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11389. writeGridDataTableJson(dStruct.TotalCount, dt);
  11390. }
  11391. public void get_erp_wechatlist_sumprice()
  11392. {
  11393. DataStruct dStruct = GetPostStruct();
  11394. List<string> lw = new List<string>();
  11395. string tid = GetPostString("tid");
  11396. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11397. string shopname = GetPostString("shopname");
  11398. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11399. string buyernick = GetPostString("buyer_nick");
  11400. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11401. string customer = GetPostString("customer");
  11402. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11403. string returndate1 = GetPostString("returndate1");
  11404. string returndate2 = GetPostString("returndate2");
  11405. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11406. if (dw.Length > 0) lw.Add(dw);
  11407. string finishDate1 = GetPostString("finishdate1");
  11408. string finishDate2 = GetPostString("finishdate2");
  11409. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11410. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11411. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11412. string mainWhere = string.Join(" and ", lw.ToArray());
  11413. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11414. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11415. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11416. decimal total = 0;
  11417. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11418. {
  11419. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11420. }
  11421. var res = new
  11422. {
  11423. data = total
  11424. };
  11425. string ro_jsond = JsonConvert.SerializeObject(res);
  11426. returnSuccess(ro_jsond);
  11427. return;
  11428. }
  11429. public void get_erp_qr_waitdeliverylist()
  11430. {
  11431. DataStruct dStruct = GetPostStruct();
  11432. List<string> lw = new List<string>();
  11433. string tid = GetPostString("ctid");
  11434. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11435. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11436. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11437. var res_objz = new
  11438. {
  11439. restype = 1,
  11440. data = dt
  11441. };
  11442. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11443. returnSuccess(ro_jsonz);
  11444. }
  11445. public void get_erp_yield_list()
  11446. {
  11447. DataStruct dStruct = GetPostStruct();
  11448. List<string> lw = new List<string>();
  11449. string tid = GetPostString("ctid");
  11450. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11451. string shopname = GetPostString("shopname");
  11452. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11453. string buyernick = GetPostString("buyer_nick");
  11454. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11455. //if (tid.Length == 0 && buyernick.Length == 0)
  11456. //{
  11457. // lw.Add(string.Format("IsRefund<={0}", 1));
  11458. //}
  11459. string customer = GetPostString("customer");
  11460. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11461. string design = GetPostString("design");
  11462. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11463. string orderState = GetPostString("orderState");
  11464. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11465. string address = GetPostString("address");
  11466. 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));
  11467. string sellermemo = GetPostString("seller_memo");
  11468. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11469. string supplier = GetPostString("supplier");
  11470. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11471. string OrderArea = GetPostString("order_area");
  11472. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11473. string placedate1 = GetPostString("placedate1");
  11474. string placedate2 = GetPostString("placedate2");
  11475. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11476. if (fdw.Length > 0) lw.Add(fdw);
  11477. string price1 = GetPostString("price1");
  11478. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11479. string price2 = GetPostString("price2");
  11480. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11481. string unusualCon = GetPostString("unusualcon");
  11482. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11483. string posTag = CurrentUser.UserPost.Post.Code;
  11484. if (posTag == "Supplier")
  11485. {
  11486. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11487. }
  11488. lw.Add(string.Format("OrderState = 6 "));
  11489. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11490. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11491. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11492. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11493. writeGridDataTableJson(dStruct.TotalCount, dt);
  11494. }
  11495. public void change_erp_sup_state()
  11496. {
  11497. if (UrlPostParmsCheck("ctid"))
  11498. {
  11499. string ctid = GetPostString("ctid");
  11500. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11501. if (ceErpTradeCell != null)
  11502. {
  11503. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11504. if (ceErpTradeCellExtend == null)
  11505. {
  11506. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11507. ceErpTradeCellExtend.ctid = ctid;
  11508. ceErpTradeCellExtend.SupState = 1;
  11509. ceErpTradeCellExtend.Create();
  11510. }
  11511. else
  11512. {
  11513. ceErpTradeCellExtend.SupState = 1;
  11514. ceErpTradeCellExtend.Update();
  11515. }
  11516. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11517. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11518. return;
  11519. }
  11520. returnErrorMsg("找不到订单");
  11521. }
  11522. }
  11523. public void supplier_all_downs()
  11524. {
  11525. if (UrlPostParmsCheck("tids"))
  11526. {
  11527. string tids = GetPostString("tids");
  11528. if (tids != null && tids.Length > 0)
  11529. {
  11530. StringBuilder sql = new StringBuilder();
  11531. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11532. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11533. sql = new StringBuilder();
  11534. 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, "下载设计文件");
  11535. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11536. string[] list = tids.Split(',');
  11537. foreach (string ctid in list)
  11538. {
  11539. CeErpSukuraData.createInfo(ctid, 3);
  11540. }
  11541. designHelper.api_approveDesign(tids); //approveDesign
  11542. returnSuccessMsg("下载成功!");
  11543. return;
  11544. }
  11545. returnErrorMsg("下载订单更新失败");
  11546. }
  11547. }
  11548. public void uploaderFileSuccess()
  11549. {
  11550. if (UrlPostParmsCheck("fileName"))
  11551. {
  11552. string fileName = GetPostString("fileName");
  11553. ApiVo apiVo = new ApiVo();
  11554. apiVo.orderNumber = fileName;
  11555. apiVo.actionName = "finishDesign";
  11556. designHelper.API_WorkCore(apiVo);//finishDesign
  11557. returnSuccessMsg("");
  11558. }
  11559. }
  11560. public void get_sample2_order()
  11561. {
  11562. if (UrlPostParmsCheck("ctid"))
  11563. {
  11564. string ctid = GetPostString("ctid");
  11565. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11566. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11567. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11568. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11569. double total = 0.0;
  11570. double order_price = 0.0;
  11571. if (dt_bu.Rows.Count > 0)
  11572. {
  11573. foreach (DataRow dr in dt_bu.Rows)
  11574. {
  11575. total += Convert.ToDouble(dr["payment"]);
  11576. }
  11577. }
  11578. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11579. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11580. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11581. string tid = ctid.Replace("S_", "");
  11582. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11583. double paymant = 0.0;
  11584. if (entity != null)
  11585. {
  11586. paymant = entity.payment;
  11587. }
  11588. string return_reason = "";
  11589. if (dt_after != null && dt_after.Rows.Count > 0)
  11590. {
  11591. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11592. }
  11593. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11594. }
  11595. }
  11596. public void get_erp_design_status()
  11597. {
  11598. string designName = GetPostString("designName");
  11599. DataStruct dStruct = GetPostStruct();
  11600. if (designName.Length > 0)
  11601. {
  11602. 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";
  11603. sql_user += " and Name like '%" + designName + "%'";
  11604. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11605. List<string> ids_list = new List<string>();
  11606. if (user_table.Rows.Count > 0)
  11607. {
  11608. foreach (DataRow item in user_table.Rows)
  11609. {
  11610. ids_list.Add(item["id"].ToString());
  11611. string ids_s = item["TeamIds"].ToString();
  11612. if (ids_s.Length > 0)
  11613. {
  11614. ids_list.AddRange(ids_s.Split(','));
  11615. }
  11616. }
  11617. }
  11618. HashSet<string> set = new HashSet<string>(ids_list);
  11619. ids_list = set.ToList();
  11620. if (ids_list.Count > 0)
  11621. {
  11622. 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));
  11623. dStruct.MainWhere = sql;
  11624. DataTable dt = null;
  11625. dt = WebCache.GetData("view_ErpUser", dStruct);
  11626. writeGridDataTableJson(dStruct.TotalCount, dt);
  11627. }
  11628. }
  11629. }
  11630. public void change_erp_order_price()
  11631. {
  11632. string ctid = GetPostString("ctid");
  11633. double price = GetPostDouble("price");
  11634. if (ctid.Length > 0)
  11635. {
  11636. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11637. if (ceErpTradeCellExtend == null)
  11638. {
  11639. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11640. ceErpTradeCellExtend.ctid = ctid;
  11641. ceErpTradeCellExtend.payment_cyt = price;
  11642. ceErpTradeCellExtend.Create();
  11643. }
  11644. else
  11645. {
  11646. ceErpTradeCellExtend.payment_cyt = price;
  11647. ceErpTradeCellExtend.Update();
  11648. }
  11649. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11650. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11651. {
  11652. ceErpDataSendOrderInfo.isSync = false;
  11653. ceErpDataSendOrderInfo.Update();
  11654. }
  11655. if (ceErpDataSendOrderInfo == null)
  11656. {
  11657. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11658. ceErpDataSendOrderInfo.isSync = false;
  11659. ceErpDataSendOrderInfo.ctid = ctid;
  11660. ceErpDataSendOrderInfo.Create();
  11661. }
  11662. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11663. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11664. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11665. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11666. {
  11667. dataSendOrderBean dataSendOrderBean = null;
  11668. foreach (DataRow item in dth.Rows)
  11669. {
  11670. try
  11671. {
  11672. dataSendOrderBean = new dataSendOrderBean();
  11673. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11674. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11675. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11676. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11677. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11678. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11679. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11680. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11681. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11682. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11683. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11684. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11685. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11686. if (result != null)
  11687. {
  11688. if ("0".Equals(result.errcode))
  11689. {
  11690. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11691. }
  11692. else
  11693. {
  11694. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11695. }
  11696. }
  11697. }
  11698. catch (Exception ex)
  11699. {
  11700. }
  11701. }
  11702. }
  11703. returnSuccessMsg("修改成功!");
  11704. return;
  11705. }
  11706. returnErrorMsg("找不到订单");
  11707. }
  11708. public void find_he_together()
  11709. {
  11710. string ctid = GetPostString("ctid");
  11711. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11712. List<string> list = new List<string>();
  11713. if (ceErpTradeCell != null)
  11714. {
  11715. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11716. {
  11717. 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);
  11718. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11719. if (table != null && table.Rows.Count > 0)
  11720. {
  11721. foreach (TableRow row in table.Rows)
  11722. {
  11723. }
  11724. }
  11725. }
  11726. }
  11727. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11728. }
  11729. //不统计
  11730. List<int> no_suppliers = new List<int>()
  11731. {
  11732. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11733. };
  11734. List<int> no_shop = new List<int>()
  11735. {
  11736. 136,114,34,96
  11737. };
  11738. public void get_place_order_data()
  11739. {
  11740. string date1 = GetPostString("date1");
  11741. string date2 = GetPostString("date2");
  11742. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11743. DateTime start = DateTime.Parse(starttime);
  11744. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11745. DateTime end = DateTime.Parse(endtime);
  11746. if (date1 != null && date1.Length > 0)
  11747. {
  11748. DateTime dateTime = DateTime.Parse(date1);
  11749. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11750. start = DateTime.Parse(starttime);
  11751. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11752. end = DateTime.Parse(endtime);
  11753. }
  11754. if (date2 != null && date2.Length > 0)
  11755. {
  11756. DateTime dateTime = DateTime.Parse(date2);
  11757. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11758. end = DateTime.Parse(endtime);
  11759. }
  11760. string startMonthDate = commonHelper.FirstDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 00:00:00");
  11761. string endMonthDate = commonHelper.LastDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 23:59:59");
  11762. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime,AfterSaleState=0,AfterSaleReason = '',delivery=0,shopId,UnusualTag from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierId > 0 ", starttime, endtime);
  11763. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11764. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState,AfterSaleReason,delivery=0,shopId,UnusualTag FROM view_ErpTradeCell WHERE ( HandleTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime IS NOT NULL", startMonthDate, endMonthDate);
  11765. DataTable afterSaleData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11766. data.Merge(afterSaleData);
  11767. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState=0,AfterSaleReason = '',delivery=1,shopId,UnusualTag FROM view_ErpTradeCell WHERE orderstate = 6 AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime > '2025-11-01 00:00:31.000' AND IsRefund <= 1 AND LEN( ProductName ) > 0 AND SupplierId not in (86,10,105,86)", startMonthDate, endMonthDate);
  11768. DataTable deliveryData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11769. data.Merge(deliveryData);
  11770. //不干胶-----1,卡片-----29
  11771. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11772. foreach (DataRow row in data.Rows)
  11773. {
  11774. int productId = Convert.ToInt32(row["ProductId"]);
  11775. int shopId = Convert.ToInt32(row["shopId"]);
  11776. string ProductName = row["ProductName"].ToString();
  11777. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11778. if (no_suppliers.Contains(supplierId))
  11779. {
  11780. continue;
  11781. }
  11782. string seller_memo = row["seller_memo"].ToString();
  11783. bool ispj = commonHelper.placeDataIsPeijian(seller_memo);//是否配件单
  11784. if (ispj)
  11785. {
  11786. continue;
  11787. }
  11788. seller_memo = seller_memo.Replace("UV", "uv");
  11789. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11790. //吊牌归到卡片
  11791. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11792. seller_memo = seller_memo.Replace("卡套", "卡片");
  11793. seller_memo = seller_memo.Replace("封套", "卡片");
  11794. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11795. seller_memo = seller_memo.Replace("腰封", "卡片");
  11796. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11797. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11798. seller_memo = seller_memo.Replace("横幅", "条幅");
  11799. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11800. string map_key = commonHelper.placeDataGetMapKey(seller_memo, supplierId);
  11801. string type = commonHelper.placeDataGetMapKey(seller_memo, supplierId);
  11802. if (map_key == "")
  11803. {
  11804. type = ProductName;
  11805. map_key = ProductName;
  11806. }
  11807. if ("其他".Equals(map_key) && commonHelper.suppliers.ContainsKey(supplierId))
  11808. {
  11809. map_key = commonHelper.suppliers[supplierId];
  11810. }
  11811. map_key += "_" + row["SupplierName"].ToString();
  11812. Dictionary<string, int> map = null;
  11813. if (other_map.ContainsKey(map_key))
  11814. {
  11815. other_map.TryGetValue(map_key, out map);
  11816. }
  11817. else
  11818. {
  11819. map = new Dictionary<string, int>();
  11820. map.Add("dayDev", 0);//当天出货
  11821. map.Add("dayTotal", 0);//下单总数
  11822. map.Add("payTotal", 0);//500以上
  11823. map.Add("today", 0);//当天出货数量
  11824. map.Add("unusua", 0);//异常数
  11825. map.Add("aftersale", 0);//异常数
  11826. map.Add("deliveryNum", 0);//待发货数
  11827. other_map.Add(map_key, map);
  11828. other_map.TryGetValue(map_key, out map);
  11829. }
  11830. int afterSaleState = Convert.ToInt32(row["AfterSaleState"]);
  11831. int delivery = Convert.ToInt32(row["delivery"]);
  11832. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11833. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11834. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11835. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11836. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11837. //GD-CYT-----64
  11838. bool istoday = commonHelper.placeDataIsToday(row, type);
  11839. if (afterSaleState == 0 && delivery == 0)
  11840. {
  11841. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11842. {
  11843. map["dayTotal"]++;
  11844. }
  11845. if (Convert.ToDecimal(row["payment"]) >= 500)
  11846. {
  11847. map["payTotal"]++;
  11848. }
  11849. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11850. {
  11851. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11852. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11853. {
  11854. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11855. {
  11856. map["today"]++;
  11857. }
  11858. }
  11859. else
  11860. {
  11861. if (supplierId == 80 || supplierId == 126)
  11862. {
  11863. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11864. {
  11865. map["today"]++;
  11866. }
  11867. }
  11868. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11869. {
  11870. map["today"]++;
  11871. }
  11872. }
  11873. }
  11874. if (istoday)
  11875. {
  11876. map["dayDev"]++;
  11877. }
  11878. }
  11879. else if (delivery == 0)
  11880. {
  11881. if (row["AfterSaleReason"].ToString().Contains("车间责任"))
  11882. {
  11883. map["aftersale"]++;
  11884. }
  11885. }
  11886. else
  11887. {
  11888. map["deliveryNum"]++;
  11889. if (no_shop.Contains(shopId))
  11890. {
  11891. continue;
  11892. }
  11893. if (!Convert.IsDBNull(row["UnusualTag"]) && Convert.ToInt32(row["UnusualTag"]) == 5)
  11894. {
  11895. map["unusua"]++;
  11896. }
  11897. continue;
  11898. }
  11899. }
  11900. DataTable dt = new DataTable();
  11901. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11902. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11903. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11904. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11905. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11906. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11907. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11908. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11909. dt.Columns.Add(new DataColumn("aftersale", typeof(string)));
  11910. dt.Columns.Add(new DataColumn("deliveryNum", typeof(string)));
  11911. other_map.Keys.ForEach(key =>
  11912. {
  11913. DataRow dr = dt.NewRow();
  11914. Dictionary<string, int> map = other_map[key];
  11915. string[] key_list = key.Split('_');
  11916. dr[0] = key_list[0];
  11917. dr[1] = key_list[1];
  11918. if (key_list.Length > 2)
  11919. {
  11920. dr[1] += "(" + key_list[2] + ")";
  11921. }
  11922. dr[2] = map["dayTotal"];
  11923. dr[3] = map["payTotal"];
  11924. dr[4] = map["today"];
  11925. dr[5] = map["unusua"];
  11926. dr[6] = map["dayDev"];
  11927. double rate = 0.00;
  11928. if (map["dayDev"] > 0)
  11929. {
  11930. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11931. }
  11932. dr[7] = rate.ToString();
  11933. dr[8] = map["aftersale"];
  11934. dr[9] = map["deliveryNum"];
  11935. dt.Rows.Add(dr);
  11936. });
  11937. DataView dv = new DataView(dt);
  11938. dv.Sort = "SupplierName";
  11939. //dv.Sort = "ProductName desc";
  11940. DataTable dtNew = dv.ToTable();
  11941. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11942. }
  11943. public void get_place_all_order_data()
  11944. {
  11945. string date1 = GetPostString("date1");
  11946. string date2 = GetPostString("date2");
  11947. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11948. DateTime start = DateTime.Parse(starttime);
  11949. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11950. DateTime end = DateTime.Parse(endtime);
  11951. if (date1 != null && date1.Length > 0)
  11952. {
  11953. DateTime dateTime = DateTime.Parse(date1);
  11954. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11955. start = DateTime.Parse(starttime);
  11956. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11957. end = DateTime.Parse(endtime);
  11958. }
  11959. if (date2 != null && date2.Length > 0)
  11960. {
  11961. DateTime dateTime = DateTime.Parse(date2);
  11962. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11963. end = DateTime.Parse(endtime);
  11964. }
  11965. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11966. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,FinishPlaceTime,OrderState,FinishDeliveryTime from view_ErpTradeCell where ( FinishDeliveryTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 and SupplierId > 0 ", starttime, endtime);
  11967. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11968. string timer_sql = string.Format("select * from CE_ErpSupplierProductTime");
  11969. DataTable timer_data = DbHelper.DbConn.ExecuteDataset(timer_sql).Tables[0];
  11970. Dictionary<int, List<CeErpSupplierProductTime>> timer_map = new Dictionary<int, List<CeErpSupplierProductTime>>();
  11971. foreach (DataRow datarow in timer_data.Rows)
  11972. {
  11973. List<CeErpSupplierProductTime> list = null;
  11974. int supplierId = Convert.ToInt32(datarow["SupplierId"]);
  11975. if (timer_map.ContainsKey(supplierId))
  11976. {
  11977. timer_map.TryGetValue(supplierId, out list);
  11978. }
  11979. else
  11980. {
  11981. list = new List<CeErpSupplierProductTime>();
  11982. timer_map.Add(supplierId, list);
  11983. timer_map.TryGetValue(supplierId, out list);
  11984. }
  11985. CeErpSupplierProductTime ceErpSupplierProductTime = new CeErpSupplierProductTime();
  11986. ceErpSupplierProductTime.quantity = Convert.ToInt32(datarow["quantity"]);
  11987. ceErpSupplierProductTime.dayDeadLine = datarow["dayDeadLine"].ToString();
  11988. ceErpSupplierProductTime.deadLine = datarow["deadLine"].ToString();
  11989. ceErpSupplierProductTime.productId = datarow["productId"].ToString();
  11990. ceErpSupplierProductTime.craft = datarow["craft"].ToString();
  11991. ceErpSupplierProductTime.sendDay = Convert.ToInt32(datarow["sendDay"]);
  11992. list.Add(ceErpSupplierProductTime);
  11993. }
  11994. foreach (DataRow row in data.Rows)
  11995. {
  11996. //存储数据
  11997. int productId = Convert.ToInt32(row["ProductId"]);
  11998. string ProductName = row["ProductName"].ToString();
  11999. int supplierId = Convert.ToInt32(row["SupplierId"]);
  12000. if (no_suppliers.Contains(supplierId))
  12001. {
  12002. continue;
  12003. }
  12004. string seller_memo = row["seller_memo"].ToString();
  12005. bool ispj = commonHelper.placeDataIsPeijian(seller_memo);//是否配件单
  12006. if (ispj)
  12007. {
  12008. continue;
  12009. }
  12010. seller_memo = seller_memo.Replace("UV", "uv");
  12011. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  12012. //吊牌归到卡片
  12013. seller_memo = seller_memo.Replace("吊牌", "卡片");
  12014. seller_memo = seller_memo.Replace("卡套", "卡片");
  12015. seller_memo = seller_memo.Replace("封套", "卡片");
  12016. seller_memo = seller_memo.Replace("吸管套", "卡片");
  12017. seller_memo = seller_memo.Replace("腰封", "卡片");
  12018. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  12019. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  12020. seller_memo = seller_memo.Replace("横幅", "条幅");
  12021. seller_memo = seller_memo.Replace("锦旗", "条幅");
  12022. string map_key = commonHelper.placeDataGetMapKey(seller_memo, supplierId);
  12023. string type = commonHelper.placeDataGetMapKey(seller_memo, supplierId);
  12024. if (map_key == "")
  12025. {
  12026. type = ProductName;
  12027. map_key = ProductName;
  12028. }
  12029. if ("其他".Equals(map_key) && commonHelper.suppliers.ContainsKey(supplierId))
  12030. {
  12031. map_key = commonHelper.suppliers[supplierId];
  12032. }
  12033. map_key += "_" + row["SupplierName"].ToString();
  12034. Dictionary<string, int> map = null;
  12035. if (other_map.ContainsKey(map_key))
  12036. {
  12037. other_map.TryGetValue(map_key, out map);
  12038. }
  12039. else
  12040. {
  12041. map = new Dictionary<string, int>();
  12042. map.Add("all", 0);//全部
  12043. map.Add("unusua", 0);//异常数
  12044. map.Add("normal", 0);//正常数
  12045. map.Add("noMatch", 0);//未匹配
  12046. other_map.Add(map_key, map);
  12047. other_map.TryGetValue(map_key, out map);
  12048. }
  12049. //处理是否超时
  12050. string finishPlaceTime = row["FinishPlaceTime"].ToString();
  12051. string sellmer_mome = row["seller_memo"].ToString();
  12052. string txtCount = row["ProductCount"].ToString();
  12053. string FinishDeliveryTime = row["FinishDeliveryTime"].ToString();
  12054. map["all"]++;
  12055. if (string.IsNullOrEmpty(finishPlaceTime))
  12056. {
  12057. map["noMatch"]++;
  12058. continue;
  12059. }
  12060. if (string.IsNullOrEmpty(FinishDeliveryTime))
  12061. {
  12062. map["noMatch"]++;
  12063. continue;
  12064. }
  12065. if (!timer_map.ContainsKey(supplierId))
  12066. {
  12067. map["noMatch"]++;
  12068. continue;
  12069. }
  12070. List<CeErpSupplierProductTime> lists = timer_map[supplierId];
  12071. if (lists.Count > 0)
  12072. {
  12073. bool isComplate = false;
  12074. string[] productIds = null;
  12075. foreach (CeErpSupplierProductTime ceErpSupplierProductTime in lists)
  12076. {
  12077. string[] crafts = { };
  12078. if (string.IsNullOrEmpty(ceErpSupplierProductTime.productId))
  12079. {
  12080. continue;
  12081. }
  12082. if (ceErpSupplierProductTime.quantity > 0)
  12083. {
  12084. int quantity = commonHelper.handleProductCount(txtCount, true);
  12085. //订单数量大于写入的数量则跳过
  12086. if (quantity > ceErpSupplierProductTime.quantity)
  12087. {
  12088. continue;
  12089. }
  12090. }
  12091. productIds = ceErpSupplierProductTime.productId.Split(',');
  12092. if (productIds.Contains(productId.ToString()))
  12093. {
  12094. string textCraft = ceErpSupplierProductTime.craft;
  12095. textCraft = textCraft.Replace(",", ",");//统一格式
  12096. if (!string.IsNullOrEmpty(textCraft))
  12097. {
  12098. crafts = textCraft.Split(',');
  12099. }
  12100. if (crafts.Length > 0)
  12101. {
  12102. bool isinCraft = false;
  12103. for (int i = 0; i < crafts.Length; i++)
  12104. {
  12105. if (sellmer_mome.IndexOf(crafts[i]) >= 0)
  12106. {
  12107. isinCraft = true;
  12108. break;
  12109. }
  12110. }
  12111. //有写工艺并且备注中没匹配中则跳过
  12112. if (!isinCraft)
  12113. {
  12114. continue;
  12115. }
  12116. }
  12117. DateTime deadLine = DateTime.Parse(ceErpSupplierProductTime.deadLine);
  12118. DateTime dayDeadLine = DateTime.Parse(ceErpSupplierProductTime.dayDeadLine);
  12119. int sendDay = ceErpSupplierProductTime.sendDay;
  12120. //订单发货时间
  12121. DateTime placeTime = DateTime.Parse(finishPlaceTime);
  12122. DateTime sendtime = DateTime.Now;//预计发货时间
  12123. DateTime dateTime = DateTime.Parse(FinishDeliveryTime);//实际发货时间
  12124. //下单时间小于当日发货时间则不用判断
  12125. //当日发货必须发货
  12126. if (dayDeadLine.Hour > 0 && dayDeadLine.Hour > placeTime.Hour)
  12127. {
  12128. sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59"));
  12129. }
  12130. else if (deadLine.Hour > 0 && deadLine.Hour > placeTime.Hour)
  12131. {
  12132. //在截稿时间之前下单的可以减去一天时间
  12133. sendDay = Math.Max(1, sendDay - 1);
  12134. sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 00:00:00")).AddDays(sendDay);
  12135. }
  12136. else
  12137. {
  12138. sendDay = Math.Max(1, sendDay - 1);
  12139. sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59")).AddDays(sendDay);
  12140. }
  12141. isComplate = true;
  12142. //判断有没有到发货日期大于0还没到发货时间
  12143. if (DateTime.Compare(sendtime.Date, dateTime.Date) < 0)
  12144. {
  12145. //匹配到就不要继续匹配了
  12146. map["unusua"]++;
  12147. break;
  12148. }
  12149. else
  12150. {
  12151. map["normal"]++;
  12152. break;
  12153. }
  12154. }
  12155. }
  12156. if (!isComplate)
  12157. {
  12158. map["noMatch"]++;
  12159. continue;
  12160. }
  12161. }
  12162. else
  12163. {
  12164. map["noMatch"]++;
  12165. }
  12166. }
  12167. DataTable dt = new DataTable();
  12168. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  12169. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  12170. dt.Columns.Add(new DataColumn("all", typeof(string)));
  12171. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  12172. dt.Columns.Add(new DataColumn("normal", typeof(string)));
  12173. dt.Columns.Add(new DataColumn("noMatch", typeof(string)));
  12174. dt.Columns.Add(new DataColumn("shipmentRate", typeof(string)));
  12175. other_map.Keys.ForEach(key =>
  12176. {
  12177. DataRow dr = dt.NewRow();
  12178. Dictionary<string, int> map = other_map[key];
  12179. string[] key_list = key.Split('_');
  12180. dr[0] = key_list[0];
  12181. dr[1] = key_list[1];
  12182. if (key_list.Length > 2)
  12183. {
  12184. dr[1] += "(" + key_list[2] + ")";
  12185. }
  12186. dr[2] = map["all"];
  12187. dr[3] = map["unusua"];
  12188. dr[4] = map["normal"];
  12189. dr[5] = map["noMatch"];
  12190. double rate = 0.00;
  12191. if (map["all"] > 0)
  12192. {
  12193. rate = Math.Round(((Convert.ToDouble(map["normal"]) + Convert.ToDouble(map["noMatch"])) / Convert.ToDouble(map["all"])), 2) * 100;
  12194. }
  12195. dr[6] = rate.ToString();
  12196. dt.Rows.Add(dr);
  12197. });
  12198. DataView dv = new DataView(dt);
  12199. dv.Sort = "SupplierName";
  12200. //dv.Sort = "ProductName desc";
  12201. DataTable dtNew = dv.ToTable();
  12202. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  12203. }
  12204. public void check_order_desing_info()
  12205. {
  12206. string ctid = GetPostString("ctid");
  12207. if (!string.IsNullOrEmpty(ctid))
  12208. {
  12209. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12210. if (ceErpTradeCell != null)
  12211. {
  12212. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  12213. returnSuccess(JsonConvert.SerializeObject(new { response }));
  12214. return;
  12215. }
  12216. returnErrorMsg("找不到订单");
  12217. return;
  12218. }
  12219. returnErrorMsg("找不到订单");
  12220. }
  12221. public void get_timeout_detail()
  12222. {
  12223. string poscode = CurrentUser.UserPost.Post.Code;
  12224. DataStruct dStruct = GetPostStruct();
  12225. List<string> lw = new List<string>();
  12226. string id = GetPostString("id");
  12227. string pay_date1 = GetPostString("pay_date1");
  12228. string pay_date2 = GetPostString("pay_date2");
  12229. int type = GetPostInt("type");
  12230. if (type == 0)
  12231. {
  12232. if (pay_date1.Length > 0)
  12233. {
  12234. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  12235. }
  12236. if (pay_date2.Length > 0)
  12237. {
  12238. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  12239. }
  12240. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  12241. }
  12242. if (type == 1)
  12243. {
  12244. if (pay_date1.Length > 0)
  12245. {
  12246. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  12247. }
  12248. if (pay_date2.Length > 0)
  12249. {
  12250. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  12251. }
  12252. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  12253. }
  12254. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12255. DataTable dt = null;
  12256. dt = WebCache.GetData("view_orderlist", dStruct);
  12257. writeGridDataTableJson(dStruct.TotalCount, dt);
  12258. }
  12259. public void saveUrgentChargePrice()
  12260. {
  12261. string ctid = GetPostString("ctid");
  12262. if (!string.IsNullOrEmpty(ctid))
  12263. {
  12264. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12265. if (ceErpTradeCell != null)
  12266. {
  12267. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  12268. if (prices <= 100)
  12269. {
  12270. returnErrorMsg("此订单金额不足100元,无法加急。");
  12271. return;
  12272. }
  12273. double price = GetPostDouble("price");
  12274. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  12275. if (ceErpTradeCellExtend == null)
  12276. {
  12277. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12278. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  12279. }
  12280. ceErpTradeCellExtend.urgentCharge = price;
  12281. if (ceErpTradeCellExtend.ID > 0)
  12282. {
  12283. ceErpTradeCellExtend.Update();
  12284. }
  12285. else
  12286. {
  12287. ceErpTradeCellExtend.Save();
  12288. }
  12289. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  12290. returnSuccessMsg("修改成功!");
  12291. return;
  12292. }
  12293. returnErrorMsg("找不到订单");
  12294. return;
  12295. }
  12296. returnErrorMsg("找不到订单");
  12297. }
  12298. public void finish_erp_order()
  12299. {
  12300. string ctid = GetPostString("ctid");
  12301. if (!string.IsNullOrEmpty(ctid))
  12302. {
  12303. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  12304. {
  12305. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12306. if (ceErpTradeCell != null)
  12307. {
  12308. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  12309. ceErpTradeCell.Update();
  12310. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  12311. returnSuccessMsg("修改成功!");
  12312. return;
  12313. }
  12314. }
  12315. }
  12316. returnErrorMsg("找不到订单");
  12317. }
  12318. public void get_trade_order_list()
  12319. {
  12320. string tid = GetPostString("tid");
  12321. if (!string.IsNullOrEmpty(tid))
  12322. {
  12323. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  12324. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12325. writeGridDataTableJson(data.Rows.Count, data);
  12326. return;
  12327. }
  12328. returnErrorMsg("找不到订单");
  12329. }
  12330. public void save_cell_spu()
  12331. {
  12332. string ctid = GetPostString("ctid");
  12333. string spu_id = GetPostString("spu_id");
  12334. if (!string.IsNullOrEmpty(ctid))
  12335. {
  12336. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12337. if (ceErpTradeCellExtend == null)
  12338. {
  12339. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12340. ceErpTradeCellExtend.ctid = ctid;
  12341. }
  12342. ceErpTradeCellExtend.spu_id = spu_id;
  12343. if (!string.IsNullOrEmpty(spu_id))
  12344. {
  12345. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12346. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  12347. }
  12348. if (ceErpTradeCellExtend.ID == 0)
  12349. {
  12350. ceErpTradeCellExtend.Create();
  12351. }
  12352. else
  12353. {
  12354. ceErpTradeCellExtend.Update();
  12355. }
  12356. returnSuccessMsg("修改成功!");
  12357. return;
  12358. }
  12359. returnErrorMsg("找不到订单");
  12360. }
  12361. public void change_express_info()
  12362. {
  12363. string ctid = GetPostString("ctid");
  12364. string transNo = GetPostString("transNo");
  12365. string transCom = GetPostString("transCom");
  12366. if (!string.IsNullOrEmpty(ctid))
  12367. {
  12368. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12369. if (ceErpTradeCellExtend == null)
  12370. {
  12371. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12372. ceErpTradeCellExtend.ctid = ctid;
  12373. }
  12374. ceErpTradeCellExtend.modExpressNo = transNo;
  12375. ceErpTradeCellExtend.modExpressCom = transCom;
  12376. ceErpTradeCellExtend.readMod = 2;
  12377. if (ceErpTradeCellExtend.ID == 0)
  12378. {
  12379. ceErpTradeCellExtend.Create();
  12380. }
  12381. else
  12382. {
  12383. ceErpTradeCellExtend.Update();
  12384. }
  12385. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  12386. returnSuccessMsg("修改成功!");
  12387. return;
  12388. }
  12389. returnErrorMsg("找不到订单");
  12390. }
  12391. public void get_change_express_list()
  12392. {
  12393. DataStruct dStruct = GetPostStruct();
  12394. List<string> lw = new List<string>();
  12395. int st = 2;
  12396. string tid = GetPostString("ctid");
  12397. if (tid.Length > 0)
  12398. {
  12399. string select_tid = getTidByCtid(tid);
  12400. lw.Add(string.Format("tid='{0}'", select_tid));
  12401. }
  12402. string shopname = GetPostString("shopname");
  12403. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12404. string buyernick = GetPostString("buyer_nick");
  12405. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12406. string sellermemo = GetPostString("seller_memo");
  12407. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12408. string supplier = GetPostString("supplier");
  12409. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12410. string customer = GetPostString("customer");
  12411. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12412. string design = GetPostString("design");
  12413. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12414. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12415. string poscode = CurrentUser.UserPost.Post.Code;
  12416. if (poscode != "SysAdmin")
  12417. {
  12418. string shopid = CurrentUser.User.pemShop;
  12419. lw.Add(string.Format("shopId in ({0})", shopid));
  12420. }
  12421. lw.Add("readMod = 2");
  12422. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12423. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  12424. writeGridDataTableJson(dStruct.TotalCount, dt);
  12425. }
  12426. public void deal_express_complete()
  12427. {
  12428. string ctid = GetPostString("ctid");
  12429. if (!string.IsNullOrEmpty(ctid))
  12430. {
  12431. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12432. if (ceErpTradeCellExtend == null)
  12433. {
  12434. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12435. ceErpTradeCellExtend.ctid = ctid;
  12436. }
  12437. ceErpTradeCellExtend.readMod = 1;
  12438. if (ceErpTradeCellExtend.ID == 0)
  12439. {
  12440. ceErpTradeCellExtend.Create();
  12441. }
  12442. else
  12443. {
  12444. ceErpTradeCellExtend.Update();
  12445. }
  12446. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12447. returnSuccessMsg("修改成功!");
  12448. return;
  12449. }
  12450. returnErrorMsg("找不到订单");
  12451. }
  12452. public void aftersale_return_visit()
  12453. {
  12454. string ctid = GetPostString("ctid");
  12455. if (!string.IsNullOrEmpty(ctid))
  12456. {
  12457. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12458. if (ceErpTradeCellExtend == null)
  12459. {
  12460. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12461. ceErpTradeCellExtend.ctid = ctid;
  12462. }
  12463. ceErpTradeCellExtend.returnVisit = 1;
  12464. if (ceErpTradeCellExtend.ID == 0)
  12465. {
  12466. ceErpTradeCellExtend.Create();
  12467. }
  12468. else
  12469. {
  12470. ceErpTradeCellExtend.Update();
  12471. }
  12472. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12473. if (ceErpTradeAfterSaleExtend != null)
  12474. {
  12475. ceErpTradeAfterSaleExtend.TextResult = "";
  12476. ceErpTradeAfterSaleExtend.Update();
  12477. }
  12478. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12479. returnSuccessMsg("修改成功!");
  12480. return;
  12481. }
  12482. returnErrorMsg("找不到订单");
  12483. }
  12484. public void orderPlaceInfo()
  12485. {
  12486. string ctids = GetPostString("ctids");
  12487. string[] list = ctids.Split(',');
  12488. foreach (string ctid in list)
  12489. {
  12490. CeErpSukuraData.createInfo(ctid, 3);
  12491. }
  12492. StringBuilder sql = new StringBuilder();
  12493. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12494. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12495. designHelper.api_approveDesign(ctids); //approveDesign
  12496. returnSuccessMsg("");
  12497. }
  12498. public void get_issue_list()
  12499. {
  12500. DataStruct dStruct = GetPostStruct();
  12501. List<string> lw = new List<string>();
  12502. int st = 2;
  12503. string tid = GetPostString("ctid");
  12504. if (tid.Length > 0)
  12505. {
  12506. string select_tid = getTidByCtid(tid);
  12507. lw.Add(string.Format("tid='{0}'", select_tid));
  12508. }
  12509. string shopname = GetPostString("shopname");
  12510. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12511. string buyernick = GetPostString("buyer_nick");
  12512. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12513. string sellermemo = GetPostString("seller_memo");
  12514. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12515. string supplier = GetPostString("supplier");
  12516. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12517. string customer = GetPostString("customer");
  12518. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12519. string design = GetPostString("design");
  12520. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12521. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12522. string poscode = CurrentUser.UserPost.Post.Code;
  12523. if (poscode != "SysAdmin")
  12524. {
  12525. string shopid = CurrentUser.User.pemShop;
  12526. lw.Add(string.Format("shopId in ({0})", shopid));
  12527. }
  12528. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12529. {
  12530. lw.Add("IssueState = 1");
  12531. }
  12532. else
  12533. {
  12534. string iisstate = GetPostString("iisstate");
  12535. if ("1".Equals(iisstate))
  12536. {
  12537. lw.Add("IssueState =1");
  12538. }
  12539. else if ("2".Equals(iisstate))
  12540. {
  12541. lw.Add("IssueState = 2");
  12542. }
  12543. else
  12544. {
  12545. lw.Add("IssueState > 0");
  12546. }
  12547. }
  12548. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12549. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12550. writeGridDataTableJson(dStruct.TotalCount, dt);
  12551. }
  12552. public void saveIssueContent()
  12553. {
  12554. string ctid = GetPostString("ctid");
  12555. if (!string.IsNullOrEmpty(ctid))
  12556. {
  12557. string content = GetPostString("content");
  12558. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12559. if (ceErpTradeAfterSaleExtend == null)
  12560. {
  12561. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12562. ceErpTradeAfterSaleExtend.tid = ctid;
  12563. }
  12564. ceErpTradeAfterSaleExtend.IssueContent = content;
  12565. ceErpTradeAfterSaleExtend.IssueState = 1;
  12566. if (ceErpTradeAfterSaleExtend.ID > 0)
  12567. {
  12568. ceErpTradeAfterSaleExtend.Update();
  12569. }
  12570. else
  12571. {
  12572. ceErpTradeAfterSaleExtend.Create();
  12573. }
  12574. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12575. returnSuccessMsg("添加成功!");
  12576. return;
  12577. }
  12578. returnErrorMsg("找不到订单");
  12579. }
  12580. public void dealIssueContent()
  12581. {
  12582. string ctid = GetPostString("ctid");
  12583. if (!string.IsNullOrEmpty(ctid))
  12584. {
  12585. string content = GetPostString("content");
  12586. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12587. if (ceErpTradeAfterSaleExtend != null)
  12588. {
  12589. ceErpTradeAfterSaleExtend.IssueState = 2;
  12590. ceErpTradeAfterSaleExtend.Update();
  12591. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12592. returnSuccessMsg("修改完成!");
  12593. return;
  12594. }
  12595. }
  12596. returnErrorMsg("找不到订单");
  12597. }
  12598. public void set_tid_attachments()
  12599. {
  12600. string tid = GetPostString("tid");
  12601. string atta = GetPostString("atta");
  12602. if (!string.IsNullOrEmpty(tid))
  12603. {
  12604. if (string.IsNullOrEmpty(atta))
  12605. {
  12606. returnErrorMsg("文件地址为空");
  12607. return;
  12608. }
  12609. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12610. if (ceErpTradeCell != null)
  12611. {
  12612. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12613. if (ceErpTrade == null)
  12614. {
  12615. returnErrorMsg("找不到订单");
  12616. return;
  12617. }
  12618. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12619. bool isSend = false;
  12620. if (dt != null && dt.Rows.Count > 0)
  12621. {
  12622. foreach (DataRow row in dt.Rows)
  12623. {
  12624. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12625. {
  12626. isSend = true;
  12627. }
  12628. }
  12629. if (isSend)
  12630. {
  12631. returnErrorMsg("已发货无法修改");
  12632. return;
  12633. }
  12634. ceErpTrade.Attachments = atta;
  12635. ceErpTrade.Update();
  12636. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12637. returnSuccessMsg("上传成功!");
  12638. return;
  12639. }
  12640. }
  12641. }
  12642. returnErrorMsg("找不到订单");
  12643. }
  12644. public void get_tid_attachments()
  12645. {
  12646. string tid = GetPostString("tid");
  12647. if (!string.IsNullOrEmpty(tid))
  12648. {
  12649. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12650. if (ceErpTradeCell != null)
  12651. {
  12652. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12653. if (ceErpTrade == null)
  12654. {
  12655. returnErrorMsg("找不到订单");
  12656. return;
  12657. }
  12658. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12659. return;
  12660. }
  12661. }
  12662. returnErrorMsg("找不到订单");
  12663. }
  12664. public void check_erp_sameorders()
  12665. {
  12666. if (UrlPostParmsCheck("ctid"))
  12667. {
  12668. string eid = GetPostString("ctid");
  12669. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12670. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12671. if (entity != null && ceErpTrade != null)
  12672. {
  12673. if (entity.OrderState > 6)
  12674. {
  12675. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12676. return;
  12677. }
  12678. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12679. List<string> ids = new List<string>();
  12680. if (dt != null && dt.Rows.Count > 1)
  12681. {
  12682. bool needhe = true;
  12683. foreach (DataRow dr in dt.Rows)
  12684. {
  12685. ids.Add("'" + dr["ctid"] + "'");
  12686. /* //备注有合包
  12687. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12688. {
  12689. needhe = true;
  12690. }
  12691. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12692. {
  12693. needhe = true;
  12694. }
  12695. //顺丰快递
  12696. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12697. {
  12698. needhe = true;
  12699. }*/
  12700. }
  12701. if (!needhe)
  12702. {
  12703. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12704. return;
  12705. }
  12706. StringBuilder sql = new StringBuilder();
  12707. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12708. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12709. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12710. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12711. foreach (DataRow dr in dt.Rows)
  12712. {
  12713. dr["dstate"] = 0;
  12714. dr["dnumber"] = 0;
  12715. foreach (DataRow row in dt1.Rows)
  12716. {
  12717. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12718. {
  12719. dr["dstate"] = 2;
  12720. dr["default"] = 1;
  12721. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12722. }
  12723. }
  12724. if (eid.Equals(dr["ctid"].ToString()))
  12725. {
  12726. dr["dstate"] = 1;
  12727. dr["default"] = 1;
  12728. }
  12729. }
  12730. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12731. return;
  12732. }
  12733. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12734. return;
  12735. }
  12736. returnErrorMsg("未找到订单");
  12737. return;
  12738. }
  12739. returnErrorMsg("缺少必要的参数");
  12740. }
  12741. public void get_mark_number()
  12742. {
  12743. string eid = GetPostString("ctid");
  12744. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12745. if (entity != null)
  12746. {
  12747. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12748. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12749. int current = 1;
  12750. if (ceErpDeliverMark == null)
  12751. {
  12752. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12753. List<string> ids = new List<string>();
  12754. if (dt != null && dt.Rows.Count > 1)
  12755. {
  12756. foreach (DataRow dr in dt.Rows)
  12757. {
  12758. ids.Add("'" + dr["ctid"] + "'");
  12759. }
  12760. //查询已有的编号
  12761. StringBuilder sql = new StringBuilder();
  12762. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12763. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12764. if (dt1 == null || dt1.Rows.Count == 0)
  12765. {
  12766. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12767. List<int> list_number = new List<int>();
  12768. foreach (DataRow row in numbers.Rows)
  12769. {
  12770. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12771. }
  12772. //查询空余编号
  12773. for (int i = 0; i < list_number.Count + 2; i++)
  12774. {
  12775. if (!list_number.Contains(current))
  12776. {
  12777. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12778. //防止查询过程中有新数据生成
  12779. if (ceErpDeliverMark1 == null)
  12780. {
  12781. break;
  12782. }
  12783. }
  12784. current++;
  12785. }
  12786. }
  12787. else
  12788. {
  12789. foreach (DataRow row in dt1.Rows)
  12790. {
  12791. current = Convert.ToInt32(row["markNumber"]);
  12792. }
  12793. }
  12794. ceErpDeliverMark = new CeErpDeliverMark();
  12795. ceErpDeliverMark.ctid = eid;
  12796. ceErpDeliverMark.createtime = DateTime.Now;
  12797. if (ceErpTrade != null)
  12798. {
  12799. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12800. }
  12801. ceErpDeliverMark.markNumber = current;
  12802. ceErpDeliverMark.Create();
  12803. }
  12804. }
  12805. else
  12806. {
  12807. current = ceErpDeliverMark.markNumber;
  12808. }
  12809. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12810. return;
  12811. }
  12812. }
  12813. public void aftersaleCytSend()
  12814. {
  12815. string ctid = GetPostString("ctid");
  12816. if (!string.IsNullOrEmpty(ctid))
  12817. {
  12818. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12819. if (ceErpTradeCell != null)
  12820. {
  12821. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12822. }
  12823. returnSuccessMsg("推送成功");
  12824. return;
  12825. }
  12826. returnErrorMsg("缺少必要的参数");
  12827. }
  12828. public void packOrderInfo()
  12829. {
  12830. string ctids = GetPostString("ctids");
  12831. if (!string.IsNullOrEmpty(ctids))
  12832. {
  12833. string[] ctid_list = ctids.Split(',');
  12834. if (ctid_list.Length > 100)
  12835. {
  12836. returnErrorMsg("单次下载次数不能超过100个");
  12837. return;
  12838. }
  12839. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12840. StringBuilder sql = new StringBuilder();
  12841. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12842. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12843. int supplierId = 0;
  12844. StringBuilder insterSql = new StringBuilder();
  12845. for (int i = 0; i < dt.Rows.Count; i++)
  12846. {
  12847. DataRow row = dt.Rows[i];
  12848. if (i == 0)
  12849. {
  12850. supplierId = Convert.ToInt32(row["SupplierId"]);
  12851. }
  12852. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12853. {
  12854. returnErrorMsg("同车间的订单才能一起打包");
  12855. return;
  12856. }
  12857. int orderState = Convert.ToInt32(row["OrderState"]);
  12858. if (orderState != 5)
  12859. {
  12860. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12861. return;
  12862. }
  12863. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12864. }
  12865. CeErpPackData ceErpPackData = new CeErpPackData();
  12866. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12867. ceErpPackData.supplierId = supplierId;
  12868. ceErpPackData.createtime = DateTime.Now;
  12869. ceErpPackData.createBy = CurrentUser.UserID;
  12870. ceErpPackData.createName = CurrentUser.UserName;
  12871. ceErpPackData.Create();
  12872. if (ceErpPackData.ID > 0)
  12873. {
  12874. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12875. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12876. }
  12877. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12878. returnSuccessMsg("打包成功");
  12879. return;
  12880. }
  12881. returnErrorMsg("缺少必要的参数");
  12882. }
  12883. public void rePackOrderInfo()
  12884. {
  12885. string id = GetPostString("id");
  12886. if (!string.IsNullOrEmpty(id))
  12887. {
  12888. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12889. if (ceErpPackData == null)
  12890. {
  12891. returnSuccessMsg("查无数据");
  12892. return;
  12893. }
  12894. ceErpPackData.upStatus = 0;
  12895. ceErpPackData.message = "";
  12896. ceErpPackData.Update();
  12897. returnSuccessMsg("打包成功");
  12898. return;
  12899. }
  12900. returnErrorMsg("缺少必要的参数");
  12901. }
  12902. public void backPackOrderInfo()
  12903. {
  12904. string id = GetPostString("id");
  12905. if (!string.IsNullOrEmpty(id))
  12906. {
  12907. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12908. if (ceErpPackData == null)
  12909. {
  12910. returnSuccessMsg("查无数据");
  12911. return;
  12912. }
  12913. ceErpPackData.upStatus = 4;
  12914. ceErpPackData.Update();
  12915. List<string> list = new List<string>();
  12916. StringBuilder sql = new StringBuilder();
  12917. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12918. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12919. for (int i = 0; i < dt.Rows.Count; i++)
  12920. {
  12921. DataRow row = dt.Rows[i];
  12922. list.Add("'" + row["ctid"].ToString() + "'");
  12923. }
  12924. string textCtids = string.Join(",", list);
  12925. 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));
  12926. 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, "无法打包退回"));
  12927. returnSuccessMsg("退回成功");
  12928. return;
  12929. }
  12930. returnErrorMsg("缺少必要的参数");
  12931. }
  12932. public void addPackDownNum()
  12933. {
  12934. string id = GetPostString("id");
  12935. if (!string.IsNullOrEmpty(id))
  12936. {
  12937. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12938. returnSuccessMsg("下载成功");
  12939. return;
  12940. }
  12941. returnErrorMsg("缺少必要的参数");
  12942. }
  12943. public void get_pack_list()
  12944. {
  12945. DataStruct dStruct = GetPostStruct();
  12946. List<string> lw = new List<string>();
  12947. string supplier = GetPostString("supplier");
  12948. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12949. string posTag = CurrentUser.UserPost.Post.Code;
  12950. if (posTag == "Supplier")
  12951. {
  12952. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12953. }
  12954. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12955. dStruct.Order = "createtime desc";
  12956. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12957. writeGridDataTableJson(dStruct.TotalCount, dt);
  12958. }
  12959. public void get_pack_order_list()
  12960. {
  12961. string packId = GetPostString("packId");
  12962. if (string.IsNullOrEmpty(packId))
  12963. {
  12964. returnErrorMsg("缺少必要的参数");
  12965. return;
  12966. }
  12967. StringBuilder sql = new StringBuilder();
  12968. 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);
  12969. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12970. if (dt == null || dt.Rows.Count == 0)
  12971. {
  12972. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12973. return;
  12974. }
  12975. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12976. return;
  12977. }
  12978. public void get_supplier_product_time_list()
  12979. {
  12980. DataStruct dStruct = GetPostStruct();
  12981. List<string> lw = new List<string>();
  12982. string txtKey = GetPostString("txtKey");
  12983. if (txtKey.Length > 0)
  12984. {
  12985. lw.Add(string.Format("(supplierName = '{0}' or productName like '%{0}%')", txtKey));
  12986. }
  12987. string posTag = CurrentUser.UserPost.Post.Code;
  12988. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12989. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12990. writeGridDataTableJson(dStruct.TotalCount, dt);
  12991. }
  12992. public void saveSupplierProductTime()
  12993. {
  12994. string productId = GetPostString("productId");
  12995. if (string.IsNullOrEmpty(productId))
  12996. {
  12997. returnErrorMsg("缺少必要的参数");
  12998. return;
  12999. }
  13000. string productName = GetPostString("productName");
  13001. int supplierId = GetPostInt("supplierId");
  13002. if (supplierId == 0)
  13003. {
  13004. returnErrorMsg("缺少必要的参数");
  13005. return;
  13006. }
  13007. int quantity = GetPostInt("quantity");
  13008. int sendDay = GetPostInt("sendTime");
  13009. string supplierName = GetPostString("supplierName");
  13010. string craft = GetPostString("craft");
  13011. string deadLine = GetPostString("deadLine");
  13012. string dayDeadLine = GetPostString("dayDeadLine");
  13013. try
  13014. {
  13015. int eid = GetPostInt("eid");
  13016. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  13017. if (ceErpSupplierProductTime == null)
  13018. {
  13019. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  13020. }
  13021. ceErpSupplierProductTime.productId = productId;
  13022. ceErpSupplierProductTime.productName = productName;
  13023. ceErpSupplierProductTime.supplierId = supplierId;
  13024. ceErpSupplierProductTime.supplierName = supplierName;
  13025. ceErpSupplierProductTime.craft = craft;
  13026. ceErpSupplierProductTime.sendDay = sendDay;
  13027. ceErpSupplierProductTime.quantity = quantity;
  13028. if (!string.IsNullOrEmpty(deadLine))
  13029. {
  13030. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  13031. }
  13032. if (!string.IsNullOrEmpty(dayDeadLine))
  13033. {
  13034. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  13035. }
  13036. if (ceErpSupplierProductTime.ID == 0)
  13037. {
  13038. ceErpSupplierProductTime.Save();
  13039. }
  13040. else
  13041. {
  13042. ceErpSupplierProductTime.Update();
  13043. }
  13044. }
  13045. catch (Exception e)
  13046. {
  13047. }
  13048. returnSuccessMsg("保存成功");
  13049. return;
  13050. }
  13051. public void delSupplierProductTime()
  13052. {
  13053. int eid = GetPostInt("eid");
  13054. if (eid > 0)
  13055. {
  13056. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  13057. if (ceErpSupplierProductTime == null)
  13058. {
  13059. returnErrorMsg("查无数据");
  13060. return;
  13061. }
  13062. ceErpSupplierProductTime.Delete();
  13063. returnSuccessMsg("保存成功");
  13064. return;
  13065. }
  13066. returnErrorMsg("缺少必要的参数");
  13067. }
  13068. public void getExpressInfo()
  13069. {
  13070. string ctid = GetPostString("ctid");
  13071. if (!string.IsNullOrEmpty(ctid))
  13072. {
  13073. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13074. if (ceErpTradeCell != null)
  13075. {
  13076. string outSid = ceErpTradeCell.OutSid;
  13077. if (outSid.Length > 0)
  13078. {
  13079. 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);
  13080. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13081. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  13082. return;
  13083. }
  13084. }
  13085. returnErrorMsg("查无记录");
  13086. return;
  13087. }
  13088. returnErrorMsg("缺少必要的参数");
  13089. }
  13090. public void getExpressPostData()
  13091. {
  13092. string express = GetPostString("express");
  13093. if (!string.IsNullOrEmpty(express))
  13094. {
  13095. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  13096. if (ceErpExpressInfo != null)
  13097. {
  13098. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  13099. return;
  13100. }
  13101. }
  13102. returnErrorMsg("缺少必要的参数");
  13103. }
  13104. public void checkSupplierOrder()
  13105. {
  13106. string ctids = GetPostString("ctids");
  13107. if (ctids != null)
  13108. {
  13109. List<string> list = new List<string>();
  13110. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  13111. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13112. for (int i = 0; i < dt.Rows.Count; i++)
  13113. {
  13114. DataRow row = dt.Rows[i];
  13115. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  13116. {
  13117. continue;
  13118. }
  13119. list.Add(row["seller_memo"].ToString());
  13120. }
  13121. if (list.Count > 0)
  13122. {
  13123. 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, "点击下载按钮"));
  13124. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  13125. return;
  13126. }
  13127. }
  13128. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  13129. return;
  13130. }
  13131. public void addPersonId()
  13132. {
  13133. string tid = GetPostString("tid");
  13134. string personId = GetPostString("personId");
  13135. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  13136. if (ceErpTrade != null)
  13137. {
  13138. ceErpTrade.receiver_zip = personId;
  13139. ceErpTrade.Update();
  13140. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  13141. returnSuccessMsg("保存成功");
  13142. return;
  13143. }
  13144. returnErrorMsg("缺少必要的参数");
  13145. }
  13146. public void addDeliveryPaymant()
  13147. {
  13148. string tid = GetPostString("tid");
  13149. string paymant = GetPostString("paymant");
  13150. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  13151. if (ceErpTrade != null)
  13152. {
  13153. if (!string.IsNullOrEmpty(paymant))
  13154. {
  13155. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  13156. }
  13157. ceErpTrade.Update();
  13158. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  13159. returnSuccessMsg("保存成功");
  13160. return;
  13161. }
  13162. returnErrorMsg("缺少必要的参数");
  13163. }
  13164. public void saveCellFile()
  13165. {
  13166. string tid = GetPostString("tid");
  13167. string ctid = GetPostString("ctid");
  13168. string urls = GetPostString("urls");
  13169. string type = GetPostString("type");
  13170. string del = GetPostString("del");
  13171. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  13172. {
  13173. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  13174. {
  13175. ctid = tid;
  13176. }
  13177. if ("1".Equals(del))
  13178. {
  13179. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  13180. }
  13181. string[] list = urls.Split(',');
  13182. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  13183. {
  13184. foreach (string item in list)
  13185. {
  13186. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  13187. ceErpTradeCellFile.Create();
  13188. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  13189. }
  13190. }
  13191. returnSuccessMsg("保存成功");
  13192. return;
  13193. }
  13194. returnErrorMsg("缺少必要的参数");
  13195. }
  13196. public void getCellFile()
  13197. {
  13198. string tid = GetPostString("tid");
  13199. string ctid = GetPostString("ctid");
  13200. string type = GetPostString("type");
  13201. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  13202. {
  13203. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  13204. {
  13205. ctid = tid;
  13206. }
  13207. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  13208. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13209. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  13210. return;
  13211. }
  13212. returnErrorMsg("缺少必要的参数");
  13213. }
  13214. public void delCellFile()
  13215. {
  13216. string id = GetPostString("id");
  13217. if (string.IsNullOrEmpty(id))
  13218. {
  13219. returnErrorMsg("缺少必要的参数");
  13220. return;
  13221. }
  13222. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  13223. CeErpTradeCellFile.delByID(id);
  13224. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  13225. returnSuccessMsg("保存成功");
  13226. }
  13227. public void getInvoiceOrder()
  13228. {
  13229. string tid = GetPostString("tid");
  13230. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  13231. List<string> tids = new List<string>();
  13232. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  13233. {
  13234. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WHERE buyer_id = '{0}' AND seller_nick = '{1}' order by pay_time desc;", ceErpTrade.buyer_id, ceErpTrade.seller_nick);
  13235. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13236. foreach (DataRow dr in dt.Rows)
  13237. {
  13238. tids.Add("'" + dr["tid"].ToString() + "'");
  13239. }
  13240. }
  13241. else
  13242. {
  13243. tids.Add("'" + ceErpTrade.tid + "'");
  13244. }
  13245. DataTable cell_dt = new DataTable();
  13246. if (tids.Count > 0)
  13247. {
  13248. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  13249. }
  13250. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  13251. return;
  13252. }
  13253. public void getOrderLogInfo()
  13254. {
  13255. string ctid = GetPostString("ctid");
  13256. if (!string.IsNullOrEmpty(ctid))
  13257. {
  13258. StringBuilder sql = new StringBuilder();
  13259. sql.AppendFormat("select * from view_erptradelog where tid='{0}' order by id;", ctid);
  13260. DataSet ds = DbHelper.DbConn.ExecuteDataset(sql.ToString());
  13261. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(ds.Tables[0])) + "}");
  13262. return;
  13263. }
  13264. returnErrorMsg("缺少必要的参数");
  13265. }
  13266. public void setCellTeampId()
  13267. {
  13268. string ctid = GetPostString("ctid");
  13269. string tempId = GetPostString("tempId");
  13270. if (!string.IsNullOrEmpty(ctid))
  13271. {
  13272. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  13273. if (ceErpTradeCellExtend == null)
  13274. {
  13275. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  13276. ceErpTradeCellExtend.ctid = ctid;
  13277. }
  13278. ceErpTradeCellExtend.tempId = tempId;
  13279. if (ceErpTradeCellExtend.ID > 0)
  13280. {
  13281. ceErpTradeCellExtend.Update();
  13282. }
  13283. else
  13284. {
  13285. ceErpTradeCellExtend.Create();
  13286. }
  13287. designHelper.API_sendTempInfo(ctid, tempId);
  13288. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "修改模板id" + tempId, 6);
  13289. returnSuccessMsg("保存成功");
  13290. return;
  13291. }
  13292. returnErrorMsg("缺少必要的参数");
  13293. }
  13294. public void saveJointorder()
  13295. {
  13296. string ctid = GetPostString("ctid");
  13297. if (!string.IsNullOrEmpty(ctid))
  13298. {
  13299. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  13300. if (ceErpTradeCellExtend == null)
  13301. {
  13302. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  13303. ceErpTradeCellExtend.ctid = ctid;
  13304. }
  13305. if (ceErpTradeCellExtend.IsJoint == 1)
  13306. {
  13307. ceErpTradeCellExtend.IsJoint = 0;
  13308. }
  13309. else
  13310. {
  13311. ceErpTradeCellExtend.IsJoint = 1;
  13312. }
  13313. if (ceErpTradeCellExtend.ID > 0)
  13314. {
  13315. ceErpTradeCellExtend.Update();
  13316. }
  13317. else
  13318. {
  13319. ceErpTradeCellExtend.Create();
  13320. }
  13321. returnSuccessMsg("保存成功");
  13322. return;
  13323. }
  13324. returnErrorMsg("缺少必要的参数");
  13325. }
  13326. public void applyOrderBack()
  13327. {
  13328. string ctid = GetPostString("ctid");
  13329. string reason = GetPostString("reason");
  13330. if (!string.IsNullOrEmpty(ctid))
  13331. {
  13332. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13333. if (ceErpTradeCell == null)
  13334. {
  13335. returnErrorMsg("找不到订单");
  13336. return;
  13337. }
  13338. if (ceErpTradeCell.OrderState != 5 && ceErpTradeCell.OrderState != 6)
  13339. {
  13340. returnErrorMsg("待下单已下单才能申请");
  13341. return;
  13342. }
  13343. //下单后24小时后无法申请
  13344. if (ceErpTradeCell.OrderState == 6 && ceErpTradeCell.FinishPlaceTime != null)
  13345. {
  13346. DateTime now = DateTime.Now;
  13347. if (!string.IsNullOrEmpty(ceErpTradeCell.FinishPlaceTime.ToString()) && DateTime.Compare(DateTime.Parse(ceErpTradeCell.FinishPlaceTime.ToString()), now.AddHours(-24)) < 0)
  13348. {
  13349. returnErrorMsg("下单后24小时后无法申请");
  13350. return;
  13351. }
  13352. }
  13353. string sql = string.Format("select Con,UserId from CE_ErpTradeLog where tid = '{0}'", ceErpTradeCell.ctid);
  13354. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13355. if (dataTable != null && dataTable.Rows.Count > 0)
  13356. {
  13357. foreach (DataRow row in dataTable.Rows)
  13358. {
  13359. if (row["Con"].ToString().Contains("拒绝打回"))
  13360. {
  13361. returnErrorMsg("被拒绝过无法继续申请");
  13362. return;
  13363. }
  13364. }
  13365. }
  13366. ceErpTradeCell.IsReturn = 4;
  13367. ceErpTradeCell.Update();
  13368. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请打回:" + reason, ceErpTradeCell.OrderState);
  13369. returnSuccessMsg("保存成功");
  13370. return;
  13371. }
  13372. returnErrorMsg("缺少必要的参数");
  13373. }
  13374. public void cancelApplyOrderBack()
  13375. {
  13376. string ctid = GetPostString("ctid");
  13377. if (!string.IsNullOrEmpty(ctid))
  13378. {
  13379. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13380. if (ceErpTradeCell == null)
  13381. {
  13382. returnErrorMsg("找不到订单");
  13383. return;
  13384. }
  13385. if (ceErpTradeCell.IsReturn != 4)
  13386. {
  13387. returnErrorMsg("订单未在申请阶段");
  13388. return;
  13389. }
  13390. ceErpTradeCell.IsReturn = 0;
  13391. ceErpTradeCell.Update();
  13392. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "取消申请打回", ceErpTradeCell.OrderState);
  13393. returnSuccessMsg("保存成功");
  13394. return;
  13395. }
  13396. returnErrorMsg("缺少必要的参数");
  13397. }
  13398. public void get_erp_applybackorderlist()
  13399. {
  13400. DataStruct dStruct = GetPostStruct();
  13401. List<string> lw = new List<string>();
  13402. string tid = GetPostString("ctid");
  13403. if (tid.Length > 0)
  13404. {
  13405. string select_tid = getTidByCtid(tid);
  13406. lw.Add(string.Format("tid='{0}'", select_tid));
  13407. }
  13408. string shopname = GetPostString("shopname");
  13409. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  13410. string buyernick = GetPostString("buyer_nick");
  13411. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  13412. string customer = GetPostString("customer");
  13413. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  13414. string design = GetPostString("design");
  13415. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  13416. string orderState = GetPostString("orderState");
  13417. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  13418. string supplier = GetPostString("supplier");
  13419. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  13420. string sellermemo = GetPostString("seller_memo");
  13421. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  13422. string otherMemo = GetPostString("otherMemo");
  13423. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  13424. string address = GetPostString("address");
  13425. 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));
  13426. string date1 = GetPostString("date1");
  13427. string date2 = GetPostString("date2");
  13428. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  13429. if (dw.Length > 0) lw.Add(dw);
  13430. string price1 = GetPostString("price1");
  13431. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  13432. string price2 = GetPostString("price2");
  13433. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  13434. if (CurrentUser.UserPost.Post.Code == "Supplier")
  13435. {
  13436. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  13437. lw.Add(string.Format("OrderState = 6"));
  13438. }
  13439. else if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  13440. {
  13441. lw.Add("OrderState in (5,6) ");
  13442. }
  13443. lw.Add(string.Format("IsReturn = 4"));
  13444. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  13445. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  13446. string pagesize = GetPostString("pagesize");
  13447. if (pagesize != null)
  13448. {
  13449. dStruct.PageSize = 200;
  13450. }
  13451. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  13452. writeGridDataTableJson(dStruct.TotalCount, dt);
  13453. }
  13454. public void refuseBackOrder()
  13455. {
  13456. string ctid = GetPostString("ctid");
  13457. if (!string.IsNullOrEmpty(ctid))
  13458. {
  13459. string reason = GetPostString("returnreason");
  13460. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13461. if (ceErpTradeCell == null)
  13462. {
  13463. returnErrorMsg("找不到订单");
  13464. return;
  13465. }
  13466. string sql = string.Format("select Con,UserId from CE_ErpTradeLog where tid = '{0}' order by ID desc", ceErpTradeCell.ctid);
  13467. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13468. int userId = 0;
  13469. if (dataTable != null && dataTable.Rows.Count > 0)
  13470. {
  13471. foreach (DataRow row in dataTable.Rows)
  13472. {
  13473. if (row["Con"].ToString().Contains("申请打回:"))
  13474. {
  13475. userId = Convert.ToInt32(row["UserId"]);
  13476. }
  13477. }
  13478. }
  13479. if (userId > 0)
  13480. {
  13481. CeErpMessageTip ct = new CeErpMessageTip();
  13482. ct.tid = ceErpTradeCell.ctid;
  13483. ct.sectionId = 0;
  13484. ct.userId = userId;
  13485. ct.type = 4;
  13486. ct.isVisit = false;
  13487. ct.content = ceErpTradeCell.ctid + ",申请打回被拒绝:" + reason;
  13488. ct.Create();
  13489. }
  13490. ceErpTradeCell.IsReturn = 0;
  13491. ceErpTradeCell.Update();
  13492. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "拒绝打回:" + reason, ceErpTradeCell.OrderState);
  13493. returnSuccessMsg("保存成功");
  13494. return;
  13495. }
  13496. returnErrorMsg("缺少必要的参数");
  13497. }
  13498. public void passApplyBack()
  13499. {
  13500. if (UrlPostParmsCheck("ctid"))
  13501. {
  13502. string eid = GetPostString("ctid");
  13503. CeErpTradeCell entity = null;
  13504. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  13505. string userpost = CurrentUser.UserPost.Post.Code;
  13506. if (entity != null)
  13507. {
  13508. string message = "操作成功!";
  13509. string isDown = "";
  13510. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  13511. {
  13512. message = eid + "订单有被点击下载。请注意沟通是否已下载完!";
  13513. isDown = "被点击下载";
  13514. }
  13515. bool isPlace = false;
  13516. if (entity.OrderState > 6)
  13517. {
  13518. returnErrorMsg("已发货无法打回!");
  13519. return;
  13520. }
  13521. if (entity.OrderState == 6)
  13522. {
  13523. isPlace = true;
  13524. }
  13525. bool isNeedUpdateCell2 = false;
  13526. if (entity.OrderState >= 6)
  13527. {
  13528. isNeedUpdateCell2 = true;
  13529. }
  13530. int returnTag = 2;
  13531. if (userpost == "Supplier")
  13532. {
  13533. returnTag = 1;
  13534. }
  13535. int toType = GetPostInt("totype");
  13536. string fromType = "3";
  13537. if (entity.OrderState < 5)
  13538. {
  13539. fromType = "3";
  13540. }
  13541. else
  13542. {
  13543. fromType = "4";
  13544. }
  13545. if (entity.IsXianHuo == 0)
  13546. {
  13547. if (returnTag == 2)
  13548. {
  13549. if (toType == 1)
  13550. {
  13551. entity.OrderState = 0;
  13552. entity.ReturnUserType = 1;
  13553. string clearman = GetPostString("clearman");
  13554. if (!string.IsNullOrEmpty(clearman))
  13555. {
  13556. entity.DesignUserId = 0;
  13557. }
  13558. }
  13559. else
  13560. {
  13561. entity.OrderState = 3;
  13562. entity.ReturnUserType = 2;
  13563. }
  13564. entity.IsReadTag = 1;
  13565. }
  13566. else if (returnTag == 1)
  13567. {
  13568. entity.OrderState = 5;
  13569. }
  13570. entity.IsVerifyToSupplier = false;
  13571. }
  13572. if (entity.IsXianHuo == 1)
  13573. {
  13574. entity.OrderState = 5;
  13575. }
  13576. entity.IsVerifyToSupplier = false;
  13577. entity.IsHaveNewOrder = 0;
  13578. entity.UnusualTag = 0;
  13579. entity.UnusualTime = null;
  13580. entity.UnusualCon = "";
  13581. entity.IsReturn = returnTag;
  13582. entity.ReturnTime = DateTime.Now;
  13583. entity.UpdateTime = DateTime.Now;
  13584. entity.ReturnReason = GetPostString("returnreason");
  13585. entity.Update();
  13586. if (entity.OrderState == 3)
  13587. {
  13588. ApiVo apiVo = new ApiVo();
  13589. apiVo.orderNumber = entity.ctid;
  13590. apiVo.actionName = "rebutDesign";
  13591. apiVo.orderRemarks = entity.ReturnReason;
  13592. designHelper.API_WorkCore(apiVo);//rebutDesign
  13593. }
  13594. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason + isDown, entity.OrderState);
  13595. if (isPlace)
  13596. {
  13597. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  13598. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  13599. if (dth != null && dth.Rows.Count > 0)
  13600. {
  13601. dataSendOrderBean dataSendOrderBean = null;
  13602. foreach (DataRow item in dth.Rows)
  13603. {
  13604. try
  13605. {
  13606. dataSendOrderBean = new dataSendOrderBean();
  13607. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  13608. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  13609. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  13610. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  13611. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  13612. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  13613. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  13614. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  13615. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  13616. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  13617. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  13618. dataSendOrderBean.Radio1723534706288 = "打回";
  13619. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  13620. if (result != null)
  13621. {
  13622. if ("0".Equals(result.errcode))
  13623. {
  13624. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  13625. }
  13626. else
  13627. {
  13628. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  13629. }
  13630. }
  13631. }
  13632. catch (Exception ex)
  13633. {
  13634. }
  13635. }
  13636. }
  13637. }
  13638. returnSuccessMsg(message);
  13639. return;
  13640. }
  13641. returnErrorMsg("找不到订单记录");
  13642. }
  13643. }
  13644. public void getApplyBackCount()
  13645. {
  13646. string sql = string.Format("SELECT top 1 ctid FROM [dbo].[CE_ErpTradeCell]");
  13647. List<string> lw = new List<string>();
  13648. lw.Add("IsReturn = 4");
  13649. if (CurrentUser.UserPost.Post.Code == "Supplier")
  13650. {
  13651. lw.Add("OrderState = 6");
  13652. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  13653. }
  13654. else if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  13655. {
  13656. lw.Add("OrderState = 5");
  13657. }
  13658. else
  13659. {
  13660. ReturnSuccess("{" + string.Format("\"data\":{0}", "0") + "}");
  13661. return;
  13662. }
  13663. sql += " where " + string.Join(" and ", lw.ToArray());
  13664. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  13665. List<string> list = new List<string>();
  13666. if (dataTable != null && dataTable.Rows.Count > 0)
  13667. {
  13668. foreach (DataRow row in dataTable.Rows)
  13669. {
  13670. list.Add(row["ctid"].ToString());
  13671. }
  13672. }
  13673. ReturnSuccess("{" + string.Format("\"data\":{0}", "\"" + string.Join(",", list) + "\"") + "}");
  13674. return;
  13675. }
  13676. public void getSysPrice()
  13677. {
  13678. string ctid = GetPostString("ctid");
  13679. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  13680. if (ceErpTradeCell.ProductId == 0)
  13681. {
  13682. returnSuccessMsg("没有产品id");
  13683. }
  13684. dataHelper.get_sys_price(ceErpTradeCell);
  13685. returnSuccessMsg("保存成功");
  13686. }
  13687. public void saveAssignLog(string reason, CeErpTradeCell ce)
  13688. {
  13689. if (ce != null)
  13690. {
  13691. CeErpAssignLog ceErpAssignLog = new CeErpAssignLog();
  13692. ceErpAssignLog.ctid = ce.ctid;
  13693. ceErpAssignLog.userid = CurrentUser.UserID;
  13694. ceErpAssignLog.seller_memo = ce.seller_memo;
  13695. ceErpAssignLog.reason = reason;
  13696. ceErpAssignLog.Save();
  13697. }
  13698. }
  13699. public void get_erp_assignLog()
  13700. {
  13701. DataStruct dStruct = GetPostStruct();
  13702. List<string> lw = new List<string>();
  13703. string tid = GetPostString("ctid");
  13704. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  13705. string apdate2 = GetPostString("apdate2");
  13706. string apdate1 = GetPostString("apdate1");
  13707. string dwap = GetDateMinuteWhere("createtime", apdate1, apdate2);
  13708. if (dwap.Length > 0) lw.Add(dwap);
  13709. dStruct.Order = " createtime desc";
  13710. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  13711. DataTable dt = WebCache.GetData("view_ErpAssignLog", dStruct);
  13712. writeGridDataTableJson(dStruct.TotalCount, dt);
  13713. }
  13714. public void change_upfile_status()
  13715. {
  13716. int id = GetPostInt("id");
  13717. CeErpUpFileSupplier ceErpUpFileSupplier = CeErpUpFileSupplier.Get(id);
  13718. if (ceErpUpFileSupplier != null)
  13719. {
  13720. ceErpUpFileSupplier.isOpen = !ceErpUpFileSupplier.isOpen;
  13721. ceErpUpFileSupplier.Update();
  13722. }
  13723. returnSuccessMsg("保存成功");
  13724. }
  13725. public void test_seller_memo_upfile()
  13726. {
  13727. string ctid = GetPostString("ctid");
  13728. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  13729. if (ce == null)
  13730. {
  13731. returnErrorMsg("查无订单");
  13732. return;
  13733. }
  13734. int supplierId = getsupplierId(ce);
  13735. if (supplierId > 0)
  13736. {
  13737. CeErpSupplier ceErpSupplier = CeErpSupplier.Get(supplierId);
  13738. if (ceErpSupplier != null)
  13739. {
  13740. returnSuccessMsg(ceErpSupplier.ComName);
  13741. return;
  13742. }
  13743. }
  13744. returnErrorMsg("未匹配到车间");
  13745. return;
  13746. }
  13747. private int getsupplierId(CeErpTradeCell entity)
  13748. {
  13749. int supplierId = 0;
  13750. StringBuilder sql = new StringBuilder();
  13751. sql.AppendFormat("select * from CE_ErpUpFileSupplier where isOpen = 1");
  13752. DataTable cellEx = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  13753. int num = getProductCount(entity.seller_memo);
  13754. foreach (DataRow row in cellEx.Rows)
  13755. {
  13756. bool isIn = true;
  13757. //判断材质工艺都要符合
  13758. if (!Convert.IsDBNull(row["seller_memo"]) && !string.IsNullOrEmpty(row["seller_memo"].ToString()))
  13759. {
  13760. string memo = row["seller_memo"].ToString();
  13761. string[] memolist = memo.Split('+');
  13762. for (int i = 0; i < memolist.Length; i++)
  13763. {
  13764. if (!Regex.IsMatch(entity.seller_memo, memolist[i].Replace("/", "|")))
  13765. {
  13766. isIn = false;
  13767. }
  13768. }
  13769. }
  13770. if (!isIn)
  13771. {
  13772. continue;
  13773. }
  13774. //判断金额符不符合
  13775. if (!Convert.IsDBNull(row["payment"]) && !string.IsNullOrEmpty(row["payment"].ToString()))
  13776. {
  13777. string payment = row["payment"].ToString();
  13778. string[] paymentList = payment.Split('-');
  13779. if (!string.IsNullOrEmpty(paymentList[0]))
  13780. {
  13781. if (entity.payment < Convert.ToDouble(paymentList[0]))
  13782. {
  13783. continue;
  13784. }
  13785. }
  13786. if (!string.IsNullOrEmpty(paymentList[1]))
  13787. {
  13788. if (entity.payment > Convert.ToDouble(paymentList[1]))
  13789. {
  13790. continue;
  13791. }
  13792. }
  13793. }
  13794. if (!Convert.IsDBNull(row["size"]) && !string.IsNullOrEmpty(row["size"].ToString()))
  13795. {
  13796. string pattern = @"\b(\d{1,5}[x\*]\d{1,5}(mm|cm))\b";
  13797. string memo = entity.seller_memo.Replace("MM", "mm").Replace("CM", "cm");
  13798. Regex reg = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Multiline, TimeSpan.FromSeconds(2));//2秒后超时
  13799. MatchCollection matches = reg.Matches(memo);//设定要查找的字符串
  13800. double width = 0;
  13801. double height = 0;
  13802. try
  13803. {
  13804. if (matches[0].Success)
  13805. {
  13806. string sizematches = matches[0].Groups[0].Value;
  13807. sizematches = sizematches.Replace("mm", "");
  13808. sizematches = sizematches.Replace("cm", "");
  13809. string[] size_list = sizematches.Split('x');
  13810. if (size_list.Length > 1)
  13811. {
  13812. width = Convert.ToDouble(size_list[0]);
  13813. height = Convert.ToDouble(size_list[1]);
  13814. }
  13815. }
  13816. }
  13817. catch (Exception ex)
  13818. {
  13819. }
  13820. string size = row["size"].ToString();
  13821. string[] sizeList = size.Split('-');
  13822. if (!string.IsNullOrEmpty(sizeList[0]))
  13823. {
  13824. string[] sizeItemList = sizeList[0].Split('x');
  13825. //第一个尺寸格式不正确
  13826. if (sizeItemList.Length < 2)
  13827. {
  13828. continue;
  13829. }
  13830. double sizeWidth = Convert.ToDouble(sizeItemList[0]);
  13831. double sizeheight = Convert.ToDouble(sizeItemList[1]);
  13832. //备注尺寸要大于第一个尺寸
  13833. if (!((width > sizeWidth && height > sizeheight) || (width > sizeheight && height > sizeWidth)))
  13834. {
  13835. continue;
  13836. }
  13837. }
  13838. if (!string.IsNullOrEmpty(sizeList[1]))
  13839. {
  13840. string[] sizeItemList = sizeList[1].Split('x');
  13841. //第二个尺寸格式不正确
  13842. if (sizeItemList.Length < 2)
  13843. {
  13844. continue;
  13845. }
  13846. double sizeWidth = Convert.ToDouble(sizeItemList[0]);
  13847. double sizeheight = Convert.ToDouble(sizeItemList[1]);
  13848. //备注尺寸要大于第二个尺寸
  13849. if (!((width < sizeWidth && height < sizeheight) || (width < sizeheight && height < sizeWidth)))
  13850. {
  13851. continue;
  13852. }
  13853. }
  13854. }
  13855. //判断数量是否符合
  13856. if (!Convert.IsDBNull(row["number"]) && !string.IsNullOrEmpty(row["number"].ToString()))
  13857. {
  13858. string numberText = row["number"].ToString();
  13859. string[] numberTextList = numberText.Split('-');
  13860. int number = 0;
  13861. if (!string.IsNullOrEmpty(numberTextList[0]))
  13862. {
  13863. number = Convert.ToInt32(numberTextList[0]);
  13864. if (number > num)
  13865. {
  13866. continue;
  13867. }
  13868. }
  13869. if (!string.IsNullOrEmpty(numberTextList[1]))
  13870. {
  13871. number = Convert.ToInt32(numberTextList[1]);
  13872. if (number < num)
  13873. {
  13874. continue;
  13875. }
  13876. }
  13877. }
  13878. //判断店铺符不符合
  13879. if (!Convert.IsDBNull(row["shopIds"]) && !string.IsNullOrEmpty(row["shopIds"].ToString()))
  13880. {
  13881. List<string> shopids = row["shopIds"].ToString().Split(',').ToList();
  13882. if (!shopids.Contains(entity.ShopId.ToString()))
  13883. {
  13884. continue;
  13885. }
  13886. }
  13887. //地区不符合
  13888. if (!Convert.IsDBNull(row["address"]) && !string.IsNullOrEmpty(row["address"].ToString()))
  13889. {
  13890. if (!Regex.IsMatch(entity.seller_memo, row["address"].ToString().Replace("、", "|")))
  13891. {
  13892. continue;
  13893. }
  13894. }
  13895. //限制条件
  13896. if (!Convert.IsDBNull(row["filterText"]) && !string.IsNullOrEmpty(row["filterText"].ToString()))
  13897. {
  13898. if (Regex.IsMatch(entity.seller_memo, row["filterText"].ToString().Replace("/", "|")))
  13899. {
  13900. continue;
  13901. }
  13902. }
  13903. supplierId = Convert.ToInt32(row["supplierId"]);
  13904. break;
  13905. }
  13906. return supplierId;
  13907. }
  13908. public static int getProductCount(string txt)
  13909. {
  13910. // 提取"个"或"张"前面的数字
  13911. int unit = 0;
  13912. try
  13913. {
  13914. string unitPattern = @"(\d+)(?=个|张|本|套|件|卷|劵|条|箱 )";
  13915. System.Text.RegularExpressions.Match unitMatch = Regex.Match(txt, unitPattern);
  13916. string unitNum = unitMatch.Success ? unitMatch.Groups[1].Value : "1";
  13917. if (!int.TryParse(unitNum, out unit))
  13918. {
  13919. return 0;
  13920. }
  13921. }
  13922. catch (Exception ex)
  13923. {
  13924. }
  13925. return unit;
  13926. }
  13927. public void setNegotiateInfo()
  13928. {
  13929. string ctid = GetPostString("ctid");
  13930. string negotiate = GetPostString("negotiate");
  13931. if (!string.IsNullOrEmpty(ctid))
  13932. {
  13933. CeErpTradeCellExtend ce = CeErpTradeCellExtend.getByTid(ctid);
  13934. if (ce == null)
  13935. {
  13936. ce = new CeErpTradeCellExtend();
  13937. ce.ctid = ctid;
  13938. }
  13939. ce.negotiate = negotiate + "-" + CurrentUser.UserName;
  13940. if (ce.ID > 0)
  13941. {
  13942. ce.Update();
  13943. }
  13944. else
  13945. {
  13946. ce.Create();
  13947. }
  13948. LogHelper.addLog(ce.ctid, CurrentUser.UserID, "协商内容:" + negotiate, 0, 1);
  13949. returnSuccessMsg("保存成功");
  13950. }
  13951. }
  13952. }
  13953. }