sync.order.cs 669 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301
  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. namespace SiteCore.Handler
  55. {
  56. public partial class sync
  57. {
  58. public void get_erp_orderlist()
  59. {
  60. string poscode = CurrentUser.UserPost.Post.Code;
  61. DataStruct dStruct = GetPostStruct();
  62. //commonHelper.setDeliveryUnusualOrder2();
  63. //string a = SecurityHelper.DecryptSymmetric("kncY+n90QZs=");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  66. //banniuApiHelper.sendLogisticsInfo(null);
  67. //commonHelper.autoDistributeToSupplier(CeErpTradeCell.GetByCode("260112211259328680"));
  68. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  69. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  70. //int sid = commonHelper.autoDistributeToSupplier(entity);
  71. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  72. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1767755073000,\"deliveryType\":\"NONE\",\"discountFee\":12.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1770347015000,\"lines\":[{\"mark2\":[],\"num\":53,\"outerId\":\"\",\"payment\":74.92,\"picUrl\":\"https://img.pddpic.com/garner-api-new/e8713e37e8de8dd2061900ac1bcf4bca.jpeg\",\"platServiceFee\":0.0,\"price\":1.64,\"refOlId\":\"2601071-211151798634092_1625548099674\",\"refSkuId\":\"1625548099674\",\"refSpuId\":\"543300089267\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":1.414,\"singleFee\":1.41,\"spuOuterId\":\"HK_1\",\"standards\":\"创意餐桌卡片【包邮免费排版】,极速发货\",\"status\":\"NOT_SHIPPED\",\"title\":\"婚礼餐盘卡定制婚礼席位卡高级手工高颜值结婚餐盘创意餐桌装饰品\",\"totalFee\":74.92,\"totalPrice\":86.92,\"totalSellPrice\":74.92}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1767755057000,\"openBuyerId\":\"***********\",\"orderSource\":\"SYNC\",\"orderTime\":1767755009000,\"payTime\":1767755014000,\"payment\":74.92,\"platServiceFee\":0.0,\"posCode\":\"jingshangtianhua\",\"posId\":650737,\"postFee\":0.0,\"props\":{},\"receivedPayment\":74.92,\"receiverCity\":\"普洱市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"澜沧拉祜族自治县\",\"receiverId\":\"ca16574d75e647aedf34fb28e61299c8$\",\"receiverState\":\"云南省\",\"receiverTown\":\"澜沧拉祜族自治县\",\"refOid\":\"2601071-211151798634092\",\"refType\":\"PDD\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"80x110mm-180张-卡片-300克铜板纸-双面印刷覆膜裁切-阿伟\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"sysTags\":[],\"totalFee\":74.92,\"totalPrice\":86.92,\"totalSellPrice\":74.92,\"type\":\"SALE\"}}");
  73. //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}}");
  74. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  75. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  76. //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}]}}");
  77. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  78. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  79. string tids = File.ReadAllText(path);
  80. List<string> list = tids.Split(',').ToList();
  81. int index = 0;
  82. foreach (string item in list)
  83. {
  84. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  85. try
  86. {
  87. 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);
  88. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  89. {
  90. 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);
  91. }
  92. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  93. List<string> tidList = new List<string>();
  94. if (dataTable != null && dataTable.Rows.Count > 0)
  95. {
  96. foreach (DataRow row in dataTable.Rows)
  97. {
  98. tidList.Add("'" + row["tid"].ToString() + "'");
  99. }
  100. }
  101. if (tidList.Count > 0)
  102. {
  103. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  104. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  105. if (dataTable != null && dataTable.Rows.Count > 0)
  106. {
  107. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  108. if (count > 0)
  109. {
  110. Debug.WriteLine(index++);
  111. continue;
  112. }
  113. }
  114. }
  115. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  116. }
  117. catch (Exception e)
  118. {
  119. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  120. }
  121. Debug.WriteLine(index++);
  122. }*/
  123. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  124. List<string> lw = new List<string>();
  125. string tid = GetPostString("ctid");
  126. string date1 = GetPostString("date1");
  127. //12-1 修改
  128. string urgent = GetPostString("urgent");
  129. string back = GetPostString("back");
  130. string offlineSearch = GetPostString("offlineSearch");
  131. int paramsCount = 0;
  132. if (!string.IsNullOrWhiteSpace(urgent))
  133. {
  134. if (urgent.Equals("true"))
  135. {
  136. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  137. }
  138. }
  139. if (!string.IsNullOrWhiteSpace(back))
  140. {
  141. if (back.Equals("true"))
  142. {
  143. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  144. }
  145. }
  146. if (!string.IsNullOrWhiteSpace(offlineSearch))
  147. {
  148. if (offlineSearch.Equals("true"))
  149. {
  150. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  151. }
  152. }
  153. //end
  154. string date2 = GetPostString("date2");
  155. string buyernick = GetPostString("buyer_nick");
  156. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  157. {
  158. if (tid.Length <= 0 && buyernick.Length <= 0)
  159. {
  160. return;
  161. }
  162. }
  163. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  164. {
  165. if (tid.Length > 0)
  166. {
  167. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  168. if (ceErpTradeCell != null)
  169. {
  170. tid = ceErpTradeCell.tid;
  171. }
  172. List<string> select_tid = getTidByCtidMore(tid);
  173. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  174. }
  175. if (buyernick.Length > 0)
  176. {
  177. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  178. }
  179. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  180. if (dw.Length > 0)
  181. {
  182. lw.Add(dw);
  183. }
  184. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  185. {
  186. string usershop = "0," + CurrentUser.User.pemShop;
  187. lw.Add(string.Format("ShopId in ({0})", usershop));
  188. }
  189. }
  190. else
  191. {
  192. if (ex_psize == 0)
  193. {
  194. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  195. }
  196. if (PKey != "admin" && poscode != "SysAdmin")
  197. {
  198. string usershop = "0," + CurrentUser.User.pemShop;
  199. lw.Add(string.Format("ShopId in ({0})", usershop));
  200. paramsCount++;
  201. }
  202. }
  203. string uploaddate1 = GetPostString("uploaddate1");
  204. string uploaddate2 = GetPostString("uploaddate2");
  205. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  206. if (update.Length > 0) lw.Add(update);
  207. string deliverydate1 = GetPostString("deliverydate1");
  208. string deliverydate2 = GetPostString("deliverydate2");
  209. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  210. if (deliverydate.Length > 0)
  211. {
  212. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  213. };
  214. string shopname = GetPostString("shopname");
  215. if (shopname.Length > 0)
  216. {
  217. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  218. if (ceErpShop != null)
  219. {
  220. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  221. }
  222. }
  223. string addwechat = GetPostString("addwechat");
  224. if (addwechat.Length > 0)
  225. {
  226. int addWt = Convert.ToInt32(addwechat);
  227. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  228. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  229. }
  230. string customer = GetPostString("customer");
  231. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  232. string design = GetPostString("design");
  233. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  234. string orderState = GetPostString("orderState");
  235. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  236. string address = GetPostString("address");
  237. 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));
  238. string sellermemo = GetPostString("seller_memo");
  239. if (sellermemo.Length > 0)
  240. {
  241. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  242. }
  243. string otherMemo = GetPostString("otherMemo");
  244. if (otherMemo.Length > 0)
  245. {
  246. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  247. }
  248. string backReason = GetPostString("backReason");
  249. if (backReason.Length > 0)
  250. {
  251. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  252. }
  253. string apdate1 = GetPostString("apdate1");
  254. string apdate2 = GetPostString("apdate2");
  255. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  256. if (dwap.Length > 0) lw.Add(dwap);
  257. string price1 = GetPostString("price1");
  258. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  259. string price2 = GetPostString("price2");
  260. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  261. string isoldcustomer = GetPostString("isoldcus");
  262. string buyer_id = GetPostString("buyer_id");
  263. if (buyer_id.Length > 0) lw.Add(string.Format("buyer_id = '{0}'", buyer_id));
  264. string spudata = GetPostString("spudata");
  265. if ("0".Equals(spudata))
  266. {
  267. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  268. }
  269. if ("1".Equals(spudata))
  270. {
  271. lw.Add(string.Format("spu_id <> ''"));
  272. }
  273. string finishdate1 = GetPostString("finishdate1");
  274. string finishdate2 = GetPostString("finishdate2");
  275. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  276. bool isFinish = false;
  277. if (finishdate.Length > 0)
  278. {
  279. lw.Add(finishdate);
  280. isFinish = true;
  281. paramsCount++;
  282. }
  283. if (isoldcustomer.Length > 0)
  284. {
  285. if ("2".Equals(isoldcustomer))
  286. {
  287. lw.Add(string.Format("VipCustomer=1"));
  288. }
  289. else
  290. {
  291. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  292. }
  293. }
  294. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  295. if (ex_psize > 0)
  296. {
  297. int UserID = CurrentUser.UserID;
  298. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  299. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  300. {
  301. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  302. }
  303. dStruct.Order = "pay_time desc";
  304. }
  305. string isNew = GetPostString("isNew");
  306. if (isNew == "true")
  307. {
  308. lw.Add(string.Format("IsNew = {0}", 1));
  309. }
  310. string overtime = GetPostString("overtime");
  311. if (overtime == "1")
  312. {
  313. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  314. }
  315. String usePost = CurrentUser.UserPost.Post.Code;
  316. if (usePost.Equals("Operation") == true)
  317. {
  318. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  319. }
  320. else
  321. {
  322. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  323. }
  324. //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";
  325. if (dStruct.PageSize == 100000)
  326. {
  327. dStruct.Order = "";
  328. }
  329. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  330. DataTable dt = null;
  331. string tablename = "view_orderlist";
  332. if (isFinish)
  333. {
  334. tablename = "view_orderlist_end";
  335. }
  336. dt = WebCache.GetData(tablename, dStruct);
  337. if (dt != null && dt.Rows.Count > 0)
  338. {
  339. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  340. foreach (DataRow dr in dt.Rows)
  341. {
  342. try
  343. {
  344. if (dr["refund_fees"] != null)
  345. {
  346. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  347. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  348. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  349. if (payment == refund_fees)
  350. {
  351. dr["refund_fees"] = Math.Round(refund_fees, 2);
  352. }
  353. else if (refund_fees == total_fee)
  354. {
  355. dr["refund_fees"] = payment;
  356. }
  357. else
  358. {
  359. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  360. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  361. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  362. }
  363. }
  364. // 对象操作
  365. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  366. ceErpTradeCell.ctid = dr["ctid"].ToString();
  367. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  368. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  369. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  370. if (dStruct.PageSize != 100000)
  371. {
  372. if (dr["DispatchSort"].ToString() == "2")
  373. {
  374. dr["gongchuang"] = 200;
  375. }
  376. else if ("外协".Equals(dr["ToType"].ToString()))
  377. {
  378. dr["gongchuang"] = 200;
  379. }
  380. else if ("内部".Equals(dr["ToType"].ToString()))
  381. {
  382. dr["gongchuang"] = -1;
  383. }
  384. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  385. {
  386. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  387. dr["gongchuang"] = response.code;
  388. }
  389. }
  390. }
  391. catch (NullReferenceException ex)
  392. {
  393. // 处理空引用异常
  394. dr["refund_fees"] = "0.00";
  395. }
  396. }
  397. }
  398. writeGridDataTableJson(dStruct.TotalCount, dt);
  399. }
  400. public void get_erp_orderlist_sumprice()
  401. {
  402. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  403. return;
  404. List<string> lw = new List<string>();
  405. string tid = GetPostString("ctid");
  406. string date1 = GetPostString("date1");
  407. string date2 = GetPostString("date2");
  408. if (tid.Length > 0 || date1.Length > 0)
  409. {
  410. lw.Add(string.Format("ctid like '%{0}%'", tid));
  411. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  412. if (dw.Length > 0) lw.Add(dw);
  413. }
  414. else
  415. {
  416. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  417. }
  418. string shopname = GetPostString("shopname");
  419. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  420. string buyernick = GetPostString("buyer_nick");
  421. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  422. string customer = GetPostString("customer");
  423. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  424. string design = GetPostString("design");
  425. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  426. string orderState = GetPostString("orderState");
  427. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  428. string address = GetPostString("address");
  429. 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));
  430. string sellermemo = GetPostString("seller_memo");
  431. if (sellermemo.Length > 0)
  432. {
  433. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  434. }
  435. string apdate1 = GetPostString("apdate1");
  436. string apdate2 = GetPostString("apdate2");
  437. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  438. if (dwap.Length > 0) lw.Add(dwap);
  439. string price1 = GetPostString("price1");
  440. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  441. string price2 = GetPostString("price2");
  442. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  443. string isoldcustomer = GetPostString("isoldcus");
  444. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  445. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  446. if (PKey != "admin")
  447. {
  448. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  449. lw.Add(string.Format("shopId in ({0})", usershop));
  450. }
  451. //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";
  452. string mainWhere = string.Join(" and ", lw.ToArray());
  453. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  454. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  455. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  456. decimal total = 0;
  457. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  458. {
  459. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  460. }
  461. var res = new
  462. {
  463. data = total
  464. };
  465. string ro_jsond = JsonConvert.SerializeObject(res);
  466. returnSuccess(ro_jsond);
  467. return;
  468. }
  469. public void get_erp_CustomerServiceGather()
  470. {
  471. string userWhere = "", orderWhere = "";
  472. List<string> lw = new List<string>();
  473. string customer = GetPostString("customer");
  474. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  475. string shopname = GetPostString("shopname");
  476. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  477. string date1 = GetPostString("date1");
  478. string date2 = GetPostString("date2");
  479. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  480. if (dw.Length > 0) lw.Add(dw);
  481. orderWhere = string.Join(" and ", lw.ToArray());
  482. 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 " +
  483. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  484. "left join " +
  485. "( " +
  486. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  487. ") as b on a.ID = b.CustomerUserId " +
  488. "left join " +
  489. "( " +
  490. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  491. ") as d on a.ID = d.CustomerUserId " +
  492. "left join " +
  493. "( " +
  494. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  495. ") as e on a.ID = e.CustomerUserId " +
  496. "left join " +
  497. "( " +
  498. " select CustomerUserId, RefundCount, RefundSum from " +
  499. " ( " +
  500. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  501. " from CE_ErpTradeRefund a " +
  502. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  503. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  504. " group by CustomerUserId " +
  505. " ) as a " +
  506. ") as f on a.ID = f.CustomerUserId " +
  507. "where a.PostCode = 'CustomerService'",
  508. userWhere, orderWhere);
  509. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  510. writeGridDataTableJson(dt.Rows.Count, dt);
  511. //writeGridDataTableJson(dt.Rows.Count, dt);
  512. }
  513. //设计汇总
  514. public void get_erp_DesignerGather()
  515. {
  516. string userWhere = "", orderWhere = "";
  517. List<string> lw = new List<string>();
  518. string Designer = GetPostString("designer");
  519. int org = GetPostInt("org");
  520. if (Designer.Length > 0)
  521. {
  522. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  523. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  524. }
  525. else if (org > 0)
  526. {
  527. userWhere = string.Format(" where OrgID ={0}", org);
  528. }
  529. string shopname = GetPostString("shopname");
  530. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  531. string state = GetPostString("state");
  532. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  533. string OrderArea = GetPostString("order_area");
  534. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  535. string date1 = GetPostString("date1");
  536. string date2 = GetPostString("date2");
  537. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  538. if (dw.Length > 0) lw.Add(dw);
  539. string UpDate1 = GetPostString("UpDate1");
  540. string UpDate2 = GetPostString("UpDate2");
  541. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  542. if (dw.Length > 0) lw.Add(dw);
  543. orderWhere = string.Join(" and ", lw.ToArray());
  544. 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 (" +
  545. "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 " +
  546. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  547. "left join " +
  548. "( " +
  549. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  550. ") as b on a.ID = b.DesignUserId " +
  551. "left join " +
  552. "( " +
  553. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  554. ") as d on a.ID = d.DesignUserId " +
  555. "left join " +
  556. "( " +
  557. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  558. ") as e on a.ID = e.DesignUserId " +
  559. "left join " +
  560. "( " +
  561. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  562. ") as g on a.ID = g.DesignUserId " +
  563. "left join " +
  564. "( " +
  565. " select CustomerUserId, RefundCount, RefundSum from " +
  566. " ( " +
  567. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  568. " from CE_ErpTradeRefund a " +
  569. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  570. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  571. " group by CustomerUserId " +
  572. " ) as a " +
  573. ") as f on a.ID = f.CustomerUserId " +
  574. "where a.PostCode = 'Designer') as z",
  575. userWhere, orderWhere);
  576. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  577. writeGridDataTableJson(dt.Rows.Count, dt);
  578. }
  579. //删除tradecell的订单
  580. public void del_erp_cellorder()
  581. {
  582. if (UrlPostParmsCheck("ctid"))
  583. {
  584. string eid = GetPostString("ctid");
  585. CeErpTradeCell.DelByCtid(eid);
  586. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  587. returnSuccessMsg("删除成功");
  588. }
  589. }
  590. public void clear_erp_refundstate()
  591. {
  592. if (UrlPostParmsCheck("ids"))
  593. {
  594. string eids = GetPostString("ids");
  595. string[] ctidList = eids.Split(',');
  596. foreach (string ctid in ctidList)
  597. {
  598. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  599. if (entity != null)
  600. {
  601. entity.IsRefund = 0;
  602. entity.Update();
  603. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  604. }
  605. else
  606. continue;
  607. }
  608. returnSuccessMsg("操作成功");
  609. return;
  610. }
  611. returnErrorMsg("缺少必要参数");
  612. }
  613. public void set_erp_urgency()
  614. {
  615. if (UrlPostParmsCheck("ctid"))
  616. {
  617. string eid = GetPostString("ctid");
  618. CeErpTradeCell entity = null;
  619. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  620. if (entity != null)
  621. {
  622. double prices = commonHelper.calculationPrice(entity);
  623. if (prices <= 100)
  624. {
  625. returnErrorMsg("此订单金额不足100元,无法加急。");
  626. return;
  627. }
  628. string utime = GetPostString("urgencytime");
  629. if (utime.Length > 0)
  630. {
  631. entity.UrgencyTime = Convert.ToDateTime(utime);
  632. }
  633. else
  634. {
  635. returnErrorMsg("请选择加急时间");
  636. return;
  637. }
  638. if (entity.OrderState <= 4)
  639. {
  640. //entity.seller_memo = entity.seller_memo + "-加急";
  641. string smemo = entity.seller_memo;
  642. int kindex = smemo.IndexOf(")");
  643. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  644. if (lastoneStr != "-")
  645. {
  646. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  647. }
  648. string prememo = smemo.Substring(0, kindex + 2);
  649. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  650. int lastkindex = lastmemo.IndexOf("(");
  651. DateTime urgtime = Convert.ToDateTime(utime);
  652. string newlastmemo = "";
  653. if (lastkindex == 0)
  654. {
  655. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  656. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  657. }
  658. else
  659. {
  660. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  661. }
  662. entity.seller_memo = prememo + newlastmemo;
  663. }
  664. entity.IsUrgency = true;
  665. entity.UpdateTime = DateTime.Now;
  666. entity.Update();
  667. ApiVo apiVo = new ApiVo();
  668. apiVo.orderNumber = entity.ctid;
  669. apiVo.actionName = "changeDesign";
  670. apiVo.orderRemarks = entity.seller_memo;
  671. apiVo.remarkSign = 3;
  672. designHelper.API_WorkCore(apiVo); //changeDesign
  673. CeErpSukuraData.createInfo(entity.ctid, 7);
  674. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  675. returnSuccessMsg("设置成功!");
  676. return;
  677. }
  678. returnErrorMsg("找不到记录");
  679. }
  680. }
  681. public void set_erp_reset()
  682. {
  683. if (UrlPostParmsCheck("ctid"))
  684. {
  685. string eid = GetPostString("ctid");
  686. CeErpTradeCell entity = null;
  687. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  688. if (entity != null)
  689. {
  690. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  691. {
  692. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  693. {
  694. returnErrorMsg("财务要求已下单已发货无法重置");
  695. return;
  696. }
  697. }
  698. entity.IsUrgency = false;
  699. entity.seller_memo = "";
  700. entity.OtherMemo = "";
  701. entity.OrderState = 0;
  702. entity.IsReturn = 0;
  703. //entity.IsRefund = 0;
  704. entity.MemoOpt = 0;
  705. entity.AfterSaleState = 0;
  706. entity.AfterSaleResponsible = "";
  707. entity.AfterSaleUserId = 0;
  708. entity.IsNeedBill = 0;
  709. entity.CustomerUserId = 0;
  710. entity.DesignUserId = 0;
  711. entity.SupplierId = 0;
  712. entity.PlaceUserId = 0;
  713. entity.ptid = "";
  714. entity.IsSample = 0;
  715. entity.IsXianHuo = 0;
  716. entity.isDianziOrder = 0;
  717. entity.DispatchSort = 0;
  718. entity.IsVerifyToSupplier = false;
  719. entity.FinishPlaceTime = null;
  720. entity.Update();
  721. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  722. if (trade != null)
  723. {
  724. trade.seller_memo = "";
  725. trade.Update();
  726. }
  727. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  728. returnSuccessMsg("重置成功!");
  729. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  730. if (desginBill != null)
  731. {
  732. desginBill.isDel = 1;
  733. desginBill.Update();
  734. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  735. }
  736. ApiVo apiVo = new ApiVo();
  737. apiVo.orderNumber = entity.ctid;
  738. apiVo.actionName = "resetDesign";
  739. designHelper.API_WorkCore(apiVo);//resetDesign
  740. return;
  741. }
  742. returnErrorMsg("找不到记录");
  743. }
  744. }
  745. public void save_erp_sellermemo()
  746. {
  747. if (UrlPostParmsCheck("ctid"))
  748. {
  749. string ctid = GetPostString("ctid");
  750. CeErpTradeCell entity = null;
  751. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  752. if (entity != null)
  753. {
  754. string memo = GetPostString("seller_memo");
  755. string qn_memo = GetPostString("qn_memo");
  756. memo = memo.Replace(" ", "");
  757. if (memo.Contains("补差"))
  758. {
  759. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  760. return;
  761. }
  762. List<string> bitList = new List<string>
  763. {
  764. "\\","/",":","*","?", "\"","<" ,">","|"
  765. };
  766. bool isIn = false;
  767. foreach (string bit in bitList)
  768. {
  769. if (memo.Contains(bit))
  770. {
  771. isIn = true;
  772. }
  773. }
  774. if (isIn)
  775. {
  776. returnErrorMsg("不能使用 一些符合作为文件名");
  777. return;
  778. }
  779. if (entity.seller_memo != memo)
  780. {
  781. if (entity.IsSample == 2)
  782. {
  783. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  784. return;
  785. }
  786. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  787. {
  788. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  789. {
  790. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  791. return;
  792. }
  793. /*if (CurrentUser.UserPost.Post.Code != "Place")
  794. {
  795. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  796. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  797. {
  798. returnErrorMsg("售前系统订单无法再此修改!");
  799. return;
  800. }
  801. }*/
  802. }
  803. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  804. }
  805. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  806. {
  807. if (entity.OrderState >= 5)
  808. {
  809. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  810. return;
  811. }
  812. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  813. if (string.IsNullOrEmpty(delMemo))
  814. {
  815. returnErrorMsg("备注不规范,无法识别");
  816. return;
  817. }
  818. memo = delMemo;
  819. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  820. }
  821. //commonHelper.getCytPrice(entity);
  822. int memoopt = GetPostInt("MemoOpt");
  823. Boolean ismemoopt = false;
  824. if (memoopt > 0)
  825. {
  826. string stropt = "";
  827. if (memoopt == 1)
  828. {
  829. stropt = "“改稿”";
  830. ismemoopt = true;
  831. }
  832. else if (memoopt == 2)
  833. {
  834. stropt = "“定稿”";
  835. }
  836. else if (memoopt == 3)
  837. {
  838. stropt = "“查货”";
  839. CeErpSukuraData.createInfo(entity.ctid, 6);
  840. }
  841. entity.MemoOpt = Convert.ToInt32(memoopt);
  842. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  843. }
  844. if (entity.OrderState < 5)
  845. {
  846. memo = memo.Replace("(", "(");
  847. memo = memo.Replace(")", ")");
  848. }
  849. /* if (entity.OrderState < 3)
  850. {
  851. entity.DispatchSort = 0;
  852. }*/
  853. entity.seller_memo = memo;
  854. entity.UpdateTime = DateTime.Now;
  855. entity.Update();
  856. ApiVo apiVo = new ApiVo();
  857. apiVo.orderNumber = entity.ctid;
  858. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  859. apiVo.orderRemarks = memo;
  860. apiVo.remarkSign = memoopt;
  861. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  862. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  863. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  864. {
  865. //dataHelper.api_orderBack(entity.ctid, "0", "");
  866. }
  867. if (entity.seller_memo.Contains("改稿"))
  868. {
  869. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  870. }
  871. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  872. returnSuccessMsg("保存成功!");
  873. return;
  874. }
  875. returnErrorMsg("找不到记录");
  876. }
  877. }
  878. public void ins_erp_checkorder()
  879. {
  880. if (UrlPostParmsCheck("ctid"))
  881. {
  882. string ctid = GetPostString("ctid");
  883. CeErpTradeCell entity = null;
  884. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  885. if (entity != null)
  886. {
  887. if (entity.OrderState < 6)
  888. {
  889. returnErrorMsg("下单完成后才可查货");
  890. return;
  891. }
  892. /*if (entity.OrderState > 6)
  893. {
  894. returnErrorMsg("订单已发货");
  895. return;
  896. }*/
  897. if (entity.FinishPlaceTime != null)
  898. {
  899. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  900. {
  901. returnErrorMsg("下单时间不足,无法查货");
  902. return;
  903. }
  904. }
  905. entity.MemoOpt = 3;
  906. entity.CheckOrderTime = DateTime.Now;
  907. entity.UpdateTime = DateTime.Now;
  908. entity.Update();
  909. CeErpSukuraData.createInfo(entity.ctid, 6);
  910. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  911. returnSuccessMsg("操作成功!");
  912. return;
  913. }
  914. returnErrorMsg("找不到记录");
  915. }
  916. }
  917. public void save_erp_othermemo()
  918. {
  919. if (UrlPostParmsCheck("ctid"))
  920. {
  921. string ctid = GetPostString("ctid");
  922. CeErpTradeCell entity = null;
  923. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  924. if (entity != null)
  925. {
  926. entity.OtherMemo = GetPostString("otherMemo");
  927. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  928. {
  929. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  930. StringBuilder sql = new StringBuilder();
  931. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  932. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  933. if (dt != null && dt.Rows.Count > 0)
  934. {
  935. foreach (DataRow dr in dt.Rows)
  936. {
  937. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  938. {
  939. //品类一直
  940. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  941. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  942. if (ceErpSampleCustomer == null)
  943. {
  944. ceErpSampleCustomer = new CeErpSampleCustomer();
  945. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  946. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  947. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  948. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  949. ceErpSampleCustomer.shopId = entity.ShopId;
  950. }
  951. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  952. ceErpSampleCustomer.lastTid = entity.tid;
  953. if (ceErpSampleCustomer.ID > 0)
  954. {
  955. ceErpSampleCustomer.Update();
  956. }
  957. else
  958. {
  959. ceErpSampleCustomer.Create();
  960. }
  961. }
  962. }
  963. }
  964. }
  965. //if (entity.IsOldCustomer == 1)
  966. //{
  967. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  968. //{
  969. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  970. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  971. //}
  972. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  973. //{
  974. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  975. // {
  976. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  977. // {
  978. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  979. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  980. // }
  981. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  982. // {
  983. // entity.OrderState = 2;
  984. // entity.DesignUserId = 0;
  985. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  986. // }
  987. // else
  988. // {
  989. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  990. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  991. // }
  992. // }
  993. //}
  994. //}
  995. entity.UpdateTime = DateTime.Now;
  996. entity.Update();
  997. returnSuccessMsg("保存成功!");
  998. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  999. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  1000. if (entity.OtherMemo.Contains("改稿"))
  1001. {
  1002. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1003. }
  1004. return;
  1005. }
  1006. returnErrorMsg("找不到记录");
  1007. }
  1008. }
  1009. public void save_erp_customermemo()
  1010. {
  1011. if (UrlPostParmsCheck("ctid"))
  1012. {
  1013. string ctid = GetPostString("ctid");
  1014. CeErpTradeCell entity = null;
  1015. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1016. if (entity != null)
  1017. {
  1018. entity.UpdateTime = DateTime.Now;
  1019. entity.CustomerMemo = GetPostString("CustomerMemo");
  1020. entity.Update();
  1021. ApiVo apiVo = new ApiVo();
  1022. apiVo.orderNumber = entity.ctid;
  1023. apiVo.actionName = "followRemarks";
  1024. apiVo.orderRemarks = entity.CustomerMemo;
  1025. designHelper.API_WorkCore(apiVo);//followRemarks
  1026. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1027. returnSuccessMsg("保存成功!");
  1028. return;
  1029. }
  1030. returnErrorMsg("找不到记录");
  1031. }
  1032. }
  1033. public void upd_erp_addmemotag()
  1034. {
  1035. if (UrlPostParmsCheck("ctid"))
  1036. {
  1037. ;
  1038. string eid = GetPostString("ctid");
  1039. string sfTagstr = GetPostString("memotag");
  1040. CeErpTradeCell entity = null;
  1041. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1042. if (entity != null)
  1043. {
  1044. ApiVo apiVo = new ApiVo();
  1045. if (entity.OrderState == 0)
  1046. {
  1047. returnErrorMsg("请先领单");
  1048. return;
  1049. }
  1050. //撤销顺丰
  1051. if (sfTagstr == "撤销顺丰")
  1052. {
  1053. entity.IsSF = 0;
  1054. string reMsg = "";
  1055. string oldmemo = entity.seller_memo;
  1056. if (entity.OrderState < 5)
  1057. {
  1058. oldmemo = oldmemo.Replace("顺丰到付", "");
  1059. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1060. entity.seller_memo = oldmemo;
  1061. }
  1062. else
  1063. {
  1064. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1065. {
  1066. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1067. }
  1068. }
  1069. entity.Update();
  1070. apiVo.orderNumber = entity.ctid;
  1071. apiVo.actionName = "orderRemarks";
  1072. apiVo.orderRemarks = entity.seller_memo;
  1073. apiVo.isSf = entity.IsSF.ToString();
  1074. designHelper.API_WorkCore(apiVo);//orderRemarks
  1075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1076. returnSuccessMsg("撤销成功!" + reMsg);
  1077. return;
  1078. }
  1079. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1080. {
  1081. //string oldmemo = entity.seller_memo;
  1082. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1083. string sfStr = GetPostString("memotag");
  1084. string smemo = entity.seller_memo;
  1085. int kindex = smemo.IndexOf(")");
  1086. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1087. if (lastoneStr != "-")
  1088. {
  1089. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1090. }
  1091. string prememo = smemo.Substring(0, kindex + 2);
  1092. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1093. int lastkindex = lastmemo.IndexOf("(");
  1094. string newlastmemo = "";
  1095. if (lastkindex == 0)
  1096. {
  1097. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1098. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1099. }
  1100. else
  1101. {
  1102. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1103. }
  1104. entity.seller_memo = prememo + newlastmemo;
  1105. }
  1106. string sfTagMSg = "";
  1107. if (sfTagstr == "顺丰寄付")
  1108. {
  1109. entity.IsSF = 1;
  1110. sfTagMSg = "顺丰寄付";
  1111. }
  1112. else if (sfTagstr == "顺丰到付")
  1113. {
  1114. entity.IsSF = 2;
  1115. sfTagMSg = "顺丰到付";
  1116. }
  1117. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1118. {
  1119. string deliveryWayName = "";
  1120. if (sfTagstr == "撤销顺丰")
  1121. {
  1122. sfTagstr = "普通快递";
  1123. }
  1124. if (sfTagstr == "顺丰寄付")
  1125. {
  1126. sfTagstr = "顺丰特快寄付";
  1127. }
  1128. if (sfTagstr == "顺丰到付")
  1129. {
  1130. sfTagstr = "顺丰特快到付";
  1131. }
  1132. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1133. if ("修改失败".Equals(result))
  1134. {
  1135. returnErrorMsg("修改失败");
  1136. return;
  1137. }
  1138. }
  1139. entity.Update();
  1140. apiVo = new ApiVo();
  1141. apiVo.orderNumber = entity.ctid;
  1142. apiVo.actionName = "orderRemarks";
  1143. apiVo.orderRemarks = entity.seller_memo;
  1144. apiVo.isSf = entity.IsSF.ToString();
  1145. designHelper.API_WorkCore(apiVo);//orderRemarks
  1146. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1147. returnSuccessMsg("标记成功!");
  1148. return;
  1149. }
  1150. returnErrorMsg("找不到记录");
  1151. }
  1152. }
  1153. public void upd_erp_ordertag()
  1154. {
  1155. if (UrlPostParmsCheck("ctid"))
  1156. {
  1157. string eid = GetPostString("ctid");
  1158. CeErpTradeCell entity = null;
  1159. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1160. if (entity != null)
  1161. {
  1162. int tag = GetPostInt("wechattag");
  1163. //if(tag==4 && entity.IsSample == 2)
  1164. //{
  1165. // returnErrorMsg("补差价单不能标记微信单");
  1166. // return;
  1167. //}
  1168. entity.wechatTag = tag;
  1169. entity.Update();
  1170. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1171. if (tag == 1)
  1172. {
  1173. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1174. if (cash == null)
  1175. {
  1176. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1177. cash = new CeErpReturnCash();
  1178. cash.tid = entity.tid;
  1179. cash.seller_nick = main.seller_nick;
  1180. cash.payment = trade.payment;
  1181. cash.buyer_nick = main.buyer_nick;
  1182. cash.cashstate = 0;
  1183. cash.rtype = "微信返现";
  1184. cash.returnprice = 0;
  1185. cash.created = DateTime.Now;
  1186. cash.con = "订单标记微信单";
  1187. cash.img = "";
  1188. cash.applyuserid = CurrentUser.UserID;
  1189. cash.Create();
  1190. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1191. }
  1192. else
  1193. {
  1194. cash.cashstate = 0;
  1195. cash.Update();
  1196. }
  1197. CeErpSukuraData.createInfo(entity.ctid, 9);
  1198. }
  1199. else if (tag == 2)
  1200. {
  1201. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1202. if (cash == null)
  1203. {
  1204. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1205. cash = new CeErpReturnCash();
  1206. cash.tid = entity.tid;
  1207. cash.seller_nick = main.seller_nick;
  1208. cash.payment = trade.payment;
  1209. cash.buyer_nick = main.buyer_nick;
  1210. cash.cashstate = 0;
  1211. cash.rtype = "推购返现";
  1212. cash.returnprice = 5;
  1213. cash.created = DateTime.Now;
  1214. cash.con = "订单标记推购单";
  1215. cash.img = "";
  1216. cash.applyuserid = CurrentUser.UserID;
  1217. cash.Create();
  1218. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1219. }
  1220. else
  1221. {
  1222. cash.cashstate = 0;
  1223. cash.Update();
  1224. }
  1225. CeErpSukuraData.createInfo(entity.ctid, 9);
  1226. }
  1227. else if (tag == 3)
  1228. {
  1229. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1230. if (pers == null)
  1231. {
  1232. pers = new CeErpPersuade();
  1233. pers.ctid = entity.ctid;
  1234. pers.pstate = 0;
  1235. pers.created = DateTime.Now;
  1236. pers.applyuserid = CurrentUser.UserID;
  1237. pers.Create();
  1238. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1239. }
  1240. else
  1241. {
  1242. pers.pstate = 0;
  1243. pers.Update();
  1244. }
  1245. }
  1246. else if (tag == 4 || tag == 5)
  1247. {
  1248. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1249. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1250. if (pers == null)
  1251. {
  1252. pers = CeErpStayGoods.GetByTid(entity.tid);
  1253. }
  1254. if (pers == null)
  1255. {
  1256. pers = new CeErpStayGoods();
  1257. pers.t_id = entity.tid;
  1258. pers.ctid = entity.ctid;
  1259. pers.status = "待审核";
  1260. pers.audit_type = 0;
  1261. if (tag == 4)
  1262. {
  1263. pers.stay_type = "微信推购";
  1264. }
  1265. else
  1266. {
  1267. pers.stay_type = "旺旺推购";
  1268. }
  1269. if (entity.IsXianHuo == 0)
  1270. {
  1271. pers.product_id = entity.ProductId;
  1272. }
  1273. pers.wangwang = main.buyer_nick;
  1274. pers.shop_name = main.seller_nick;
  1275. pers.creata_time = DateTime.Now;
  1276. pers.create_u_id = CurrentUser.UserID;
  1277. pers.create_u_name = CurrentUser.UserName;
  1278. pers.Create();
  1279. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1280. }
  1281. else
  1282. {
  1283. pers.ctid = entity.ctid;
  1284. pers.audit_type = 0;
  1285. pers.Update();
  1286. }
  1287. CeErpSukuraData.createInfo(entity.ctid, 10);
  1288. }
  1289. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1290. returnSuccessMsg("标记成功!");
  1291. return;
  1292. }
  1293. returnErrorMsg("找不到记录");
  1294. }
  1295. }
  1296. public void upd_erp_ordertag_cancel()
  1297. {
  1298. if (UrlPostParmsCheck("ctid"))
  1299. {
  1300. string eid = GetPostString("ctid");
  1301. CeErpTradeCell entity = null;
  1302. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1303. if (entity != null)
  1304. {
  1305. entity.wechatTag = 0;
  1306. entity.Update();
  1307. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1308. if (pers != null)
  1309. {
  1310. pers.status = "取消推购";
  1311. pers.audit_type = 3;
  1312. pers.Update();
  1313. }
  1314. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1315. returnSuccessMsg("标记成功!");
  1316. return;
  1317. }
  1318. returnErrorMsg("找不到记录");
  1319. }
  1320. }
  1321. public void upd_erp_addweichattag()
  1322. {
  1323. if (UrlPostParmsCheck("ctid"))
  1324. {
  1325. ;
  1326. string eid = GetPostString("ctid");
  1327. CeErpTradeCell entity = null;
  1328. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1329. if (entity != null)
  1330. {
  1331. if (entity.IsAddWechat > 0)
  1332. {
  1333. returnErrorMsg("此单已经标记过了");
  1334. return;
  1335. }
  1336. 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);
  1337. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1338. if (dt.Rows.Count > 0)
  1339. {
  1340. entity.IsAddWechat = 2;
  1341. }
  1342. else
  1343. {
  1344. entity.IsAddWechat = 1;
  1345. }
  1346. entity.Update();
  1347. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1348. returnSuccessMsg("标记成功!");
  1349. return;
  1350. }
  1351. returnErrorMsg("找不到记录");
  1352. }
  1353. }
  1354. public void upd_erp_getmyorder()
  1355. {
  1356. if (UrlPostParmsCheck("ctid"))
  1357. {
  1358. string eid = GetPostString("ctid");
  1359. CeErpTradeCell entity = null;
  1360. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1361. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1362. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1363. {
  1364. returnErrorMsg("台湾客户需填写身份证号!");
  1365. return;
  1366. }
  1367. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1368. {
  1369. returnErrorMsg("偏远地区需要填写物流费!");
  1370. return;
  1371. }
  1372. if (entity != null)
  1373. {
  1374. if (entity.ctid.IndexOf("C") != -1)
  1375. {
  1376. StringBuilder sql = new StringBuilder();
  1377. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1378. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1379. if (dt.Rows.Count > 0)
  1380. {
  1381. decimal total = 0;
  1382. foreach (DataRow dr in dt.Rows)
  1383. {
  1384. total += Convert.ToDecimal(dr["payment"]);
  1385. }
  1386. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1387. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1388. {
  1389. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1390. return;
  1391. }
  1392. }
  1393. }
  1394. if (entity.OrderState == -1)
  1395. {
  1396. returnErrorMsg("待审核订单无法领取!");
  1397. return;
  1398. }
  1399. entity.CustomerUserId = CurrentUser.UserID;
  1400. if (entity.OrderState < 2)
  1401. {
  1402. entity.OrderState = 2;
  1403. if (entity.ShopId != 0)
  1404. {
  1405. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1406. }
  1407. }
  1408. entity.UpdateTime = DateTime.Now;
  1409. entity.Update();
  1410. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1411. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1412. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1413. {
  1414. //dataHelper.api_orderBack(entity.ctid, "0", "");
  1415. }
  1416. returnSuccessMsg("领单成功!");
  1417. return;
  1418. }
  1419. returnErrorMsg("找不到记录");
  1420. }
  1421. }
  1422. public void getmyorder_from_init()
  1423. {
  1424. if (UrlPostParmsCheck("ctid"))
  1425. {
  1426. string eid = GetPostString("ctid");
  1427. CeErpTradeCell entity = null;
  1428. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1429. if (entity != null)
  1430. {
  1431. string sellerMemo = GetPostString("sellerMemo");
  1432. if (sellerMemo.Length > 0)
  1433. {
  1434. entity.seller_memo = sellerMemo;
  1435. }
  1436. string oterhMemo = GetPostString("otherMemo");
  1437. if (oterhMemo.Length > 0)
  1438. {
  1439. entity.OtherMemo = oterhMemo;
  1440. }
  1441. int urg = GetPostInt("urgency");
  1442. entity.IsUrgency = (urg == 1 ? true : false);
  1443. int wechat = GetPostInt("wechat");
  1444. int command = GetPostInt("command");
  1445. if (wechat == 1)
  1446. {
  1447. entity.wechatTag = 1;
  1448. }
  1449. if (command == 1)
  1450. {
  1451. entity.wechatTag = 2;
  1452. }
  1453. string pPro = GetPostString("pprofession");
  1454. if (pPro.Length > 0)
  1455. {
  1456. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1457. string spro = GetPostString("profession");
  1458. if (spro.Length > 0)
  1459. {
  1460. entity.ProfessionId = Convert.ToInt32(spro);
  1461. }
  1462. }
  1463. string proId = GetPostString("productId");
  1464. if (proId.Length > 0)
  1465. {
  1466. entity.ProductId = Convert.ToInt32(proId);
  1467. }
  1468. entity.Material = GetPostString("material");
  1469. entity.Craft = GetPostString("craft");
  1470. entity.CustomerUserId = CurrentUser.UserID;
  1471. if (entity.OrderState < 2)
  1472. {
  1473. entity.OrderState = 2;
  1474. if (entity.ShopId != 0)
  1475. {
  1476. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1477. }
  1478. }
  1479. entity.Update();
  1480. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1481. returnSuccessMsg("领单成功!");
  1482. return;
  1483. }
  1484. returnErrorMsg("找不到记录");
  1485. }
  1486. }
  1487. public void upd_erp_setrelationorder()
  1488. {
  1489. if (UrlPostParmsCheck("ctid"))
  1490. {
  1491. ;
  1492. string eid = GetPostString("ctid");
  1493. string ftid = GetPostString("ftid");
  1494. CeErpTradeCell entity = null;
  1495. CeErpTradeCell fentity = null;
  1496. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1497. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1498. if (fentity == null)
  1499. {
  1500. returnErrorMsg("找不到关联的主订单");
  1501. return;
  1502. }
  1503. if (entity != null)
  1504. {
  1505. if (entity.OrderState >= 5)
  1506. {
  1507. returnErrorMsg("本单已经设计完成无法关联");
  1508. return;
  1509. }
  1510. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1511. {
  1512. returnErrorMsg("线下单续审核后才能关联!");
  1513. return;
  1514. }
  1515. entity.ptid = ftid;
  1516. entity.OrderState = fentity.OrderState;
  1517. //entity.status = fentity.status;
  1518. entity.CustomerUserId = fentity.CustomerUserId;
  1519. entity.DesignUserId = fentity.DesignUserId;
  1520. entity.seller_memo = "补差价单:" + ftid;
  1521. entity.IsSample = 2;
  1522. entity.Update();
  1523. ApiVo apiVo = new ApiVo();
  1524. apiVo.orderNumber = ftid;
  1525. apiVo.payment = entity.payment;
  1526. apiVo.actionName = "repairDesign";
  1527. designHelper.API_WorkCore(apiVo);//repairDesign
  1528. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1529. returnSuccessMsg("关联成功!");
  1530. return;
  1531. }
  1532. else
  1533. returnErrorMsg("找不到记录");
  1534. }
  1535. }
  1536. public void download_erp_neworder()
  1537. {
  1538. string seller = GetPostString("seller_nick");
  1539. string tid = GetPostString("tid");
  1540. if (seller.Length <= 0 || tid.Length <= 0)
  1541. {
  1542. returnErrorMsg("数据错误");
  1543. }
  1544. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1545. //{
  1546. // returnErrorMsg("找不到店铺Sessionkey");
  1547. //}
  1548. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1549. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1550. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1551. if (res.IndexOf("refOid") == -1)
  1552. {
  1553. returnErrorMsg("下载订单数据失败");
  1554. return;
  1555. }
  1556. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1557. returnSuccessMsg("下载完成");
  1558. //tmcHelper.createNewOrder(res);
  1559. //CeErpTrade entr = null;
  1560. //entr = CeErpTrade.Get(tid);
  1561. //if (entr != null)
  1562. //{
  1563. // returnSuccess("下载成功");
  1564. // //下载成功之后,Cell表生成对应的订单;
  1565. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1566. //}
  1567. //else
  1568. //{
  1569. // returnErrorMsg("下载失败或者创建订单失败");
  1570. //}
  1571. }
  1572. public void set_erp_atersale()
  1573. {
  1574. if (UrlPostParmsCheck("ctid"))
  1575. {
  1576. string eid = GetPostString("ctid");
  1577. string reason = GetPostString("AfterSaleReason");
  1578. CeErpTradeCell entity = null;
  1579. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1580. if (entity != null)
  1581. {
  1582. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1583. {
  1584. returnErrorMsg("此订单已经在售后");
  1585. return;
  1586. }*/
  1587. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1588. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1589. entity.AfterSaleTime = DateTime.Now;
  1590. entity.HandleTime = null;
  1591. entity.Update();
  1592. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1593. returnSuccessMsg("转售后成功!");
  1594. return;
  1595. }
  1596. returnErrorMsg("找不到记录");
  1597. }
  1598. }
  1599. public void set_erp_withdraw()
  1600. {
  1601. if (UrlPostParmsCheck("ctid"))
  1602. {
  1603. try
  1604. {
  1605. string eid = GetPostString("ctid");//商品id
  1606. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1607. CeWithdraw ceWithdrawSelect = null;
  1608. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1609. if (ceWithdrawSelect != null)
  1610. {
  1611. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1612. {
  1613. ceWithdrawSelect.status = -1;
  1614. ceWithdrawSelect.Update();
  1615. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1616. returnSuccessMsg("重新发起审核成功");
  1617. return;
  1618. }
  1619. else
  1620. {
  1621. returnSuccessMsg("请勿重复申请!");
  1622. return;
  1623. }
  1624. }
  1625. else
  1626. {
  1627. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1628. if (string.IsNullOrEmpty(CustomerUserId))
  1629. {
  1630. CustomerUserId = "-1";
  1631. }
  1632. int Userid = CurrentUser.UserID;//用户id
  1633. CeWithdraw ceWithdraw = new CeWithdraw();
  1634. ceWithdraw.tid = eid;
  1635. ceWithdraw.userid = Userid;
  1636. ceWithdraw.providerid = CustomerUserId;
  1637. ceWithdraw.status = 3;
  1638. ceWithdraw.creationtime = DateTime.Now;
  1639. ceWithdraw.Create();
  1640. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1641. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1642. return;
  1643. }
  1644. }
  1645. catch
  1646. {
  1647. returnErrorMsg("申请撤回订单失败");
  1648. return;
  1649. }
  1650. }
  1651. }
  1652. public void ins_erp_billinfo()
  1653. {
  1654. if (UrlPostParmsCheck("ctid"))
  1655. {
  1656. string eid = GetPostString("ctid");
  1657. CeErpTradeCell entity = null;
  1658. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1659. if (entity != null)
  1660. {
  1661. CeErpBill bill = CeErpBill.GetByTid(eid);
  1662. bool isHave = false;
  1663. if (bill != null)
  1664. {
  1665. isHave = true;
  1666. if (bill.state != 4)
  1667. {
  1668. returnErrorMsg("此单已经申请过发票了");
  1669. return;
  1670. }
  1671. }
  1672. if (entity.IsNeedBill == 0)
  1673. {
  1674. entity.IsNeedBill = 1;
  1675. }
  1676. entity.Update();
  1677. string errjson = "";
  1678. try
  1679. {
  1680. CeErpBill bill_entity = new CeErpBill();
  1681. bill_entity.tid = entity.tid;
  1682. bill_entity.title = GetPostString("title");
  1683. string taxstr = GetPostString("tax");
  1684. taxstr = taxstr.Replace(" ", "");
  1685. bill_entity.tax = taxstr;
  1686. bill_entity.bank = GetPostString("bank");
  1687. string bankacstr = GetPostString("bankac");
  1688. bankacstr = bankacstr.Replace(" ", "");
  1689. bill_entity.bankac = bankacstr;
  1690. bill_entity.address = GetPostString("address");
  1691. bill_entity.phone = GetPostString("phone");
  1692. bill_entity.price = GetPostString("price");
  1693. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1694. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1695. {
  1696. billCount += 1;
  1697. }
  1698. string prebill = "ltb";
  1699. for (int idx = 1; idx <= 1; idx++)
  1700. {
  1701. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1702. string billoid = prebill + idx + dtstr;
  1703. bill_entity.billOrderId += billoid;
  1704. if (idx < billCount)
  1705. {
  1706. bill_entity.billOrderId += ",";
  1707. }
  1708. }
  1709. bill_entity.productId = GetPostInt("ProductName");
  1710. bill_entity.num = GetPostInt("num");
  1711. bill_entity.unit = GetPostString("unit");
  1712. bill_entity.type = GetPostString("type");
  1713. bill_entity.sendType = GetPostString("SendType");
  1714. bill_entity.email = GetPostString("email");
  1715. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1716. bill_entity.shopName = GetPostString("ShopName");
  1717. bill_entity.applymemo = GetPostString("applyMemo");
  1718. bill_entity.createTime = DateTime.Now;
  1719. bill_entity.state = 0;
  1720. bill_entity.userId = CurrentUser.UserID;
  1721. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1722. bill_entity.Create();
  1723. }
  1724. catch (Exception ex)
  1725. {
  1726. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1727. returnErrorMsg("创建发票出错!");
  1728. return;
  1729. }
  1730. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1731. returnSuccessMsg("发票申请成功!");
  1732. return;
  1733. }
  1734. returnErrorMsg("找不到记录");
  1735. }
  1736. }
  1737. public void ins_erp_neworder()
  1738. {
  1739. if (UrlPostParmsCheck("receiver_name"))
  1740. {
  1741. CeErpTrade entity = new CeErpTrade();
  1742. string plat_form = GetPostString("platform");
  1743. string preStr = "N_";
  1744. if (plat_form == "拼多多")
  1745. {
  1746. preStr = "P_";
  1747. }
  1748. else if (plat_form == "阿里巴巴")
  1749. {
  1750. preStr = "A_";
  1751. }
  1752. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1753. entity.seller_nick = GetPostString("seller_nick");
  1754. entity.buyer_nick = GetPostString("buyer_nick");
  1755. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1756. entity.total_fee = entity.payment;
  1757. entity.pay_time = DateTime.Now;
  1758. entity.status = "NOT_SHIPPED";
  1759. entity.receiver_name = GetPostString("receiver_name");
  1760. entity.receiver_mobile = GetPostString("receiver_mobile");
  1761. entity.receiver_state = GetPostString("receiver_state");
  1762. entity.receiver_city = GetPostString("receiver_city");
  1763. entity.receiver_district = GetPostString("receiver_district");
  1764. entity.receiver_address = GetPostString("receiver_address");
  1765. if (entity.receiver_state == "" || entity.receiver_city == "")
  1766. {
  1767. returnErrorMsg("收件地址不能为空");
  1768. return;
  1769. }
  1770. int shopId = 0;
  1771. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1772. if (nShop != null)
  1773. {
  1774. shopId = nShop.ID;
  1775. }
  1776. if (shopId != 34 && entity.payment == 0)
  1777. {
  1778. returnErrorMsg("公司自用的单金额才能为0");
  1779. return;
  1780. }
  1781. entity.Create();
  1782. CeErpTradeCell entitycell = new CeErpTradeCell();
  1783. entitycell.ctid = entity.tid;
  1784. entitycell.tid = entity.tid;
  1785. entitycell.ShopId = shopId;
  1786. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1787. entitycell.OrderState = 0;
  1788. entitycell.pay_time = entity.pay_time;
  1789. entitycell.IsOffLineOrder = 1;
  1790. entitycell.Create();
  1791. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1792. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1793. return;
  1794. }
  1795. }
  1796. public void ins_erp_neworder2()
  1797. {
  1798. if (UrlPostParmsCheck("receiver_name"))
  1799. {
  1800. //string plat_form = GetPostString("platform");
  1801. string preStr = "X_";
  1802. string memo = GetPostString("memo");
  1803. string productId = GetPostString("productId");
  1804. string primg = GetPostString("proofimg");
  1805. string sellerNick = GetPostString("seller_nick");
  1806. string addFrom = GetPostString("addfrom");
  1807. if (addFrom == "1")
  1808. {
  1809. preStr = "N_";
  1810. }
  1811. int shopId = 0;
  1812. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1813. if (nShop != null)
  1814. {
  1815. shopId = nShop.ID;
  1816. }
  1817. else
  1818. {
  1819. returnErrorMsg("找不到对应店铺");
  1820. return;
  1821. }
  1822. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1823. {
  1824. returnErrorMsg("必须上传付款凭证");
  1825. return;
  1826. }
  1827. CeErpTrade entity = new CeErpTrade();
  1828. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1829. entity.seller_nick = sellerNick;
  1830. entity.buyer_nick = GetPostString("buyer_nick");
  1831. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1832. entity.total_fee = entity.payment;
  1833. entity.pay_time = DateTime.Now;
  1834. entity.status = "NOT_SHIPPED";
  1835. entity.receiver_name = GetPostString("receiver_name");
  1836. entity.receiver_mobile = GetPostString("receiver_mobile");
  1837. entity.receiver_state = GetPostString("receiver_state");
  1838. entity.receiver_city = GetPostString("receiver_city");
  1839. entity.receiver_district = GetPostString("receiver_district");
  1840. entity.receiver_address = GetPostString("receiver_address");
  1841. entity.seller_memo = memo;
  1842. entity.orderFrom = 20;
  1843. entity.orderType = 15;
  1844. if (entity.receiver_state == "" || entity.receiver_city == "")
  1845. {
  1846. returnErrorMsg("收件地址不能为空");
  1847. return;
  1848. }
  1849. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1850. {
  1851. returnErrorMsg("公司自用的单金额才能为0");
  1852. return;
  1853. }
  1854. entity.Create();
  1855. string toWhere = GetPostString("towhere");
  1856. string oldOrder = GetPostString("oldOrder");
  1857. CeErpTradeCell entitycell = new CeErpTradeCell();
  1858. entitycell.ctid = entity.tid;
  1859. //唯一标识
  1860. entitycell.OrderSn = entity.tid;
  1861. string orderSn = commonHelper.generateDateTimeRandomNos();
  1862. if (orderSn != "")
  1863. {
  1864. entitycell.OrderSn = orderSn;
  1865. }
  1866. entitycell.tid = entity.tid;
  1867. //if (preStr == "X_")
  1868. //{
  1869. entitycell.IsOffLineOrder = 1;
  1870. if ("1".Equals(oldOrder))
  1871. {
  1872. entitycell.IsOldCustomer = 1;
  1873. }
  1874. //}
  1875. entitycell.CustomerUserId = CurrentUser.UserID;
  1876. entitycell.PayProofImg = primg;
  1877. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1878. entitycell.ProductId = Convert.ToInt32(productId);
  1879. entitycell.ShopId = shopId;
  1880. entitycell.UpdateTime = DateTime.Now;
  1881. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1882. if (entitycell.ProductId > 0)
  1883. {
  1884. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1885. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1886. {
  1887. entitycell.NewProduct = 1;
  1888. }
  1889. }
  1890. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1891. {
  1892. entitycell.IsXianHuo = 1;
  1893. }
  1894. entitycell.pay_time = entity.pay_time;
  1895. if (toWhere == "1")
  1896. {
  1897. entitycell.OrderState = 2;
  1898. }
  1899. else
  1900. {
  1901. entitycell.OrderState = 6;
  1902. entitycell.FinishPlaceTime = entitycell.pay_time;
  1903. }
  1904. if (shopId == 94)
  1905. {
  1906. entitycell.OrderState = 4;
  1907. entitycell.WaitDesignTime = entitycell.pay_time;
  1908. entitycell.StartDesignTime = entitycell.pay_time;
  1909. entitycell.DesignUserId = 218;
  1910. }
  1911. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114 && shopId != 158))
  1912. {
  1913. entitycell.OrderState = -1;//修改12-5
  1914. CeWithdraw ceWithdraw = new CeWithdraw();
  1915. ceWithdraw.tid = entity.tid;
  1916. ceWithdraw.providerid = "-1";
  1917. ceWithdraw.status = -1;
  1918. ceWithdraw.creationtime = DateTime.Now;
  1919. ceWithdraw.userid = 4634;
  1920. ceWithdraw.Create();
  1921. }
  1922. entitycell.Create();
  1923. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1924. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1925. {
  1926. addPlaceRegist(entitycell, CurrentUser.UserID);
  1927. }
  1928. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1929. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1930. return;
  1931. }
  1932. }
  1933. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1934. {
  1935. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1936. entity.PlactTime = tradecell.pay_time;
  1937. entity.AddUserId = userid;
  1938. entity.FileName = tradecell.seller_memo;
  1939. entity.Supplier = 24;
  1940. entity.CreateTime = DateTime.Now;
  1941. entity.Did = tradecell.ctid;
  1942. entity.tid = tradecell.tid;
  1943. entity.splitTag = tradecell.SplitTag;
  1944. entity.CurState = "未完成";
  1945. entity.Create();
  1946. }
  1947. public void get_erp_offlinelist()
  1948. {
  1949. DataStruct dStruct = GetPostStruct();
  1950. List<string> lw = new List<string>();
  1951. string tid = GetPostString("ctid");
  1952. string date1 = GetPostString("date1");
  1953. string date2 = GetPostString("date2");
  1954. if (tid.Length > 0 || date1.Length > 0)
  1955. {
  1956. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1957. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1958. if (dw.Length > 0) lw.Add(dw);
  1959. }
  1960. else
  1961. {
  1962. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1963. }
  1964. string shopname = GetPostString("shopname");
  1965. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1966. string buyernick = GetPostString("buyer_nick");
  1967. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1968. string customer = GetPostString("customer");
  1969. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1970. string design = GetPostString("design");
  1971. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1972. string orderState = GetPostString("orderState");
  1973. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1974. string address = GetPostString("address");
  1975. 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));
  1976. string sellermemo = GetPostString("seller_memo");
  1977. if (sellermemo.Length > 0)
  1978. {
  1979. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1980. }
  1981. string price1 = GetPostString("price1");
  1982. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1983. string price2 = GetPostString("price2");
  1984. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1985. //if (PKey != "admin")
  1986. //{
  1987. // string usershop = CurrentUser.User.pemShop;
  1988. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1989. //}
  1990. //if (ex_psize > 0)
  1991. //{
  1992. dStruct.Order = "pay_time desc";
  1993. //}
  1994. //else
  1995. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1996. lw.Add(string.Format("IsOffLineOrder=1"));
  1997. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1998. DataTable dt = null;
  1999. dt = WebCache.GetData("view_erptradecell", dStruct);
  2000. writeGridDataTableJson(dStruct.TotalCount, dt);
  2001. }
  2002. public void get_erp_returncashrecord()
  2003. {
  2004. DataStruct dStruct = GetPostStruct();
  2005. List<string> lw = new List<string>();
  2006. string tid = GetPostString("ctid");
  2007. if (tid.Length > 0)
  2008. {
  2009. lw.Add(string.Format("tid like '%{0}%'", tid));
  2010. dStruct.Order = "id desc";
  2011. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2012. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2013. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2014. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2015. return;
  2016. }
  2017. returnErrorMsg("id数据错误!");
  2018. }
  2019. public void ins_erp_returncashrecord()
  2020. {
  2021. if (UrlPostParmsCheck("tid"))
  2022. {
  2023. string tid = GetPostString("tid");
  2024. string retype = GetPostString("type");
  2025. StringBuilder sql = new StringBuilder();
  2026. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2027. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2028. if (dt.Rows.Count > 0)
  2029. {
  2030. returnErrorMsg("相同返现类型记录已存在");
  2031. return;
  2032. }
  2033. CeErpReturnCash entity = new CeErpReturnCash();
  2034. entity.tid = tid;
  2035. entity.seller_nick = GetPostString("seller_nick");
  2036. string pment = GetPostString("payment");
  2037. if (pment.Length > 0)
  2038. {
  2039. entity.payment = Convert.ToDouble(pment);
  2040. }
  2041. entity.buyer_nick = GetPostString("buyer_nick");
  2042. entity.cashstate = 0;
  2043. entity.rtype = retype;
  2044. string rPrice = GetPostString("returnprice");
  2045. if (rPrice.Length > 0)
  2046. {
  2047. entity.returnprice = Convert.ToDouble(rPrice);
  2048. }
  2049. entity.created = DateTime.Now;
  2050. entity.con = GetPostString("con");
  2051. entity.img = GetPostString("img");
  2052. entity.applyuserid = CurrentUser.UserID;
  2053. entity.Create();
  2054. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2055. returnSuccessMsg("操作成功!");
  2056. return;
  2057. }
  2058. }
  2059. public void set_erp_predelivery()
  2060. {
  2061. if (UrlPostParmsCheck("ctid"))
  2062. {
  2063. string eid = GetPostString("ctid");
  2064. CeErpTradeCell entity = null;
  2065. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2066. if (entity != null)
  2067. {
  2068. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2069. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2070. //{
  2071. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2072. // return;
  2073. //}
  2074. entity.IsPreDelivery = 1;
  2075. entity.Update();
  2076. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2077. returnSuccessMsg("预发货成功!");
  2078. return;
  2079. //string shop = GetPostString("seller_nick");
  2080. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2081. //string comName = GetPostString("comName");
  2082. //string comCode = GetPostString("comCode");
  2083. //string outSid = GetPostString("outSid");//运单号
  2084. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2085. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2086. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2087. //string apires = "";
  2088. //if (deliveryType == "虚拟发货")
  2089. //{
  2090. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2091. //}
  2092. //else
  2093. //{
  2094. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2095. //}
  2096. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2097. ////{
  2098. //if (apires.IndexOf("发货成功") != -1)
  2099. //{
  2100. // if (deliveryType != "虚拟发货")
  2101. // {
  2102. // //还要插入快递信息到 快递信息表
  2103. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2104. // exinfo.tid = eid;
  2105. // exinfo.out_sid = outSid;
  2106. // exinfo.company_code = comCode;
  2107. // exinfo.company_name = comName;
  2108. // exinfo.delivery_memo = deliveryMemo;
  2109. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2110. // exinfo.deliveryType = deliveryType;
  2111. // exinfo.Create();
  2112. // }
  2113. // returnSuccessMsg("发货成功!");
  2114. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2115. //}
  2116. //else
  2117. //{
  2118. // returnErrorMsg("淘宝发货失败!!");
  2119. //}
  2120. //return;
  2121. }
  2122. returnErrorMsg("找不到订单记录");
  2123. }
  2124. }
  2125. public void get_erp_unusuallist()
  2126. {
  2127. DataStruct dStruct = GetPostStruct();
  2128. List<string> lw = new List<string>();
  2129. string tid = GetPostString("ctid");
  2130. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2131. string shopname = GetPostString("shopname");
  2132. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2133. string buyernick = GetPostString("buyer_nick");
  2134. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2135. string ResponsibleMan = GetPostString("responsible");
  2136. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2137. string date1 = GetPostString("date1");
  2138. string date2 = GetPostString("date2");
  2139. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2140. if (dw.Length > 0) lw.Add(dw);
  2141. string price1 = GetPostString("price1");
  2142. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2143. string price2 = GetPostString("price2");
  2144. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2145. string orderState = GetPostString("orderState");
  2146. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2147. string sellermemo = GetPostString("seller_memo");
  2148. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2149. lw.Add(string.Format("UnusualTag > 0"));
  2150. lw.Add(string.Format("IsRefund<={0}", 1));
  2151. dStruct.Order = "pay_time desc";
  2152. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2153. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2154. writeGridDataTableJson(dStruct.TotalCount, dt);
  2155. }
  2156. public void set_erp_unusualtonomal()
  2157. {
  2158. if (UrlPostParmsCheck("ctid"))
  2159. {
  2160. string eid = GetPostString("ctid");
  2161. CeErpTradeCell entity = null;
  2162. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2163. if (entity != null)
  2164. {
  2165. entity.UnusualTag = -1;
  2166. entity.Update();
  2167. returnSuccessMsg("忽略成功!");
  2168. return;
  2169. }
  2170. returnErrorMsg("找不到记录");
  2171. }
  2172. }
  2173. public void ins_erp_unusualreason()
  2174. {
  2175. if (UrlPostParmsCheck("ctid"))
  2176. {
  2177. string eid = GetPostString("ctid");
  2178. CeErpTradeCell entity = null;
  2179. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2180. if (entity != null)
  2181. {
  2182. entity.MemoOpt = 4;
  2183. entity.UnusualCon = GetPostString("con");
  2184. entity.Update();
  2185. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2186. if (trade != null)
  2187. {
  2188. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2189. }
  2190. //查货是否超时
  2191. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2192. if (ceErpTradeCellExtend == null)
  2193. {
  2194. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2195. ceErpTradeCellExtend.ctid = entity.ctid;
  2196. }
  2197. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2198. {
  2199. ceErpTradeCellExtend.CheckOut += 1;
  2200. }
  2201. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2202. if (ceErpTradeCellExtend.ID > 0)
  2203. {
  2204. ceErpTradeCellExtend.Update();
  2205. }
  2206. else
  2207. {
  2208. ceErpTradeCellExtend.Create();
  2209. }
  2210. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2211. returnSuccessMsg("操作成功!");
  2212. return;
  2213. }
  2214. returnErrorMsg("找不到记录");
  2215. }
  2216. }
  2217. public void upd_erp_sampleorder()
  2218. {
  2219. if (UrlPostParmsCheck("ctid"))
  2220. {
  2221. string eid = GetPostString("ctid");
  2222. string[] eArr = eid.Split(',');
  2223. if (eArr.Length > 1)
  2224. {
  2225. List<string> eLst = new List<string>();
  2226. for (int i = 0; i < eArr.Length; i++)
  2227. {
  2228. eLst.Add("'" + eArr[i] + "'");
  2229. }
  2230. eid = string.Join(",", eLst.ToArray());
  2231. }
  2232. else
  2233. {
  2234. eid = "'" + eid + "'";
  2235. }
  2236. StringBuilder sql = new StringBuilder();
  2237. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2238. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2239. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2240. if (dt.Rows.Count > 0)
  2241. {
  2242. string errmsg = "";
  2243. foreach (DataRow dr in dt.Rows)
  2244. {
  2245. StringBuilder sqlsb = new StringBuilder();
  2246. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2247. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2248. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2249. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2250. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2251. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2252. {
  2253. continue;
  2254. }
  2255. else
  2256. {
  2257. string emsg = commonHelper.KeepChinese(apires);
  2258. errmsg += emsg;
  2259. }*/
  2260. }
  2261. if (errmsg.Length > 0)
  2262. {
  2263. returnErrorMsg(errmsg);
  2264. return;
  2265. }
  2266. returnSuccessMsg("操作成功");
  2267. return;
  2268. }
  2269. returnErrorMsg("找不到记录");
  2270. }
  2271. }
  2272. public void upd_erp_transcustomer()
  2273. {
  2274. if (UrlPostParmsCheck("ctid"))
  2275. {
  2276. string eid = GetPostString("ctid");
  2277. int userid = GetPostInt("CustomerUserId");
  2278. CeErpTradeCell entity = null;
  2279. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2280. if (entity != null)
  2281. {
  2282. //string[] mlist = entity.seller_memo.Split('-');
  2283. //string sql = "select * from view_erpuser where id=" + userid;
  2284. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2285. //if (dt != null && dt.Rows.Count > 0)
  2286. //{
  2287. // string nmemo = "";
  2288. // for(int i = 0; i < mlist.Length - 1; i++)
  2289. // {
  2290. // nmemo += mlist[i];
  2291. // nmemo += "-";
  2292. // }
  2293. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2294. // entity.seller_memo = nmemo;
  2295. //}
  2296. entity.CustomerUserId = userid;
  2297. entity.Update();
  2298. returnSuccessMsg("操作成功!");
  2299. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2300. return;
  2301. }
  2302. returnErrorMsg("找不到记录");
  2303. }
  2304. }
  2305. public void upd_erp_transdesigner()
  2306. {
  2307. if (UrlPostParmsCheck("ctid"))
  2308. {
  2309. string eids = GetPostString("ctid");
  2310. string[] ctidList = eids.Split(',');
  2311. int userid = GetPostInt("DesignUserId");
  2312. foreach (string ctid in ctidList)
  2313. {
  2314. CeErpTradeCell entity = null;
  2315. CeErpDesignerBill entitys = null;
  2316. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2317. entitys = CeErpDesignerBill.GetByTid(ctid);
  2318. if (entity != null)
  2319. {
  2320. if (entity.OrderState > 4)
  2321. {
  2322. continue;
  2323. }
  2324. //存在退款不能流转
  2325. if (entity.IsRefund > 0)
  2326. {
  2327. continue;
  2328. }
  2329. entity.DesignUserId = userid;
  2330. entity.WaitDesignTime = DateTime.Now;
  2331. entity.Update();
  2332. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2333. }
  2334. }
  2335. returnSuccessMsg("操作成功!");
  2336. }
  2337. }
  2338. public void upd_erp_distributedesigner()
  2339. {
  2340. if (UrlPostParmsCheck("ctid"))
  2341. {
  2342. string eid = GetPostString("ctid");
  2343. int userid = GetPostInt("DesignUserId");
  2344. string[] idlist = eid.Split(',');
  2345. if (idlist.Length <= 0)
  2346. {
  2347. returnErrorMsg("订单不能为空");
  2348. return;
  2349. }
  2350. foreach (string ctid in idlist)
  2351. {
  2352. CeErpTradeCell entity = null;
  2353. CeErpDesignerBill entitys = null;
  2354. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2355. else continue;
  2356. if (entity != null)
  2357. {
  2358. if (userid == 2125 || userid == 3542)
  2359. { }
  2360. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2361. {
  2362. returnErrorMsg("金额错误的订单无法指派");
  2363. return;
  2364. }
  2365. if (entity.OrderState >= 5)
  2366. {
  2367. returnErrorMsg("已经设计完成无法指派");
  2368. return;
  2369. }
  2370. if (entity.OrderState == -1)
  2371. {
  2372. returnErrorMsg("审核中的订单无法指派");
  2373. return;
  2374. }
  2375. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2376. {
  2377. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2378. return;
  2379. }
  2380. //157赖橙帆 159林晨 73 静之颖
  2381. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
  2382. {
  2383. returnErrorMsg("指派设计共创无法再次指派!");
  2384. return;
  2385. }
  2386. entity.OrderState = 3;
  2387. if (entity.SupplierId == 0)
  2388. {
  2389. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2390. entity.SupplierId = suid;
  2391. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2392. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2393. }
  2394. if (userid == 2125 && entity.seller_memo != "")
  2395. {
  2396. //apiDesign.API_GetPrintData_CreateOrder(entity);
  2397. }
  2398. 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 };
  2399. if (userid == 3542 && entity.seller_memo != "")
  2400. {
  2401. string userPost = CurrentUser.UserPost.Post.Code;
  2402. if (CurrentUser.UserID == 4516 || CurrentUser.UserID == 73 || shopIds.Contains(entity.ShopId))
  2403. {
  2404. userPost = "SysAdmin";
  2405. }
  2406. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2407. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2408. if (response.msg != "设计共创:成功")
  2409. {
  2410. returnErrorMsg(response.msg);
  2411. return;
  2412. }
  2413. entity.DispatchSort = 2;
  2414. }
  2415. else
  2416. {
  2417. if (entity.DispatchSort == 2)
  2418. {
  2419. ApiVo apiVo = new ApiVo();
  2420. apiVo.actionName = "closeDesign";
  2421. apiVo.orderNumber = entity.ctid;
  2422. designHelper.API_WorkCore(apiVo);//closeDesign
  2423. }
  2424. entity.DispatchSort = 0;
  2425. }
  2426. entity.DesignUserId = userid;
  2427. entity.WaitDesignTime = DateTime.Now;
  2428. entity.UpdateTime = DateTime.Now;
  2429. entity.Update();
  2430. string name = commonHelper.getUserNameById(userid);
  2431. commonHelper.UpdateRelationOrder(entity.ctid);
  2432. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2433. }
  2434. }
  2435. returnSuccessMsg("操作成功!");
  2436. return;
  2437. }
  2438. }
  2439. public string getTidByCtid(string ctid)
  2440. {
  2441. string tid = "";
  2442. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2443. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2444. if (dataTable != null && dataTable.Rows.Count > 0)
  2445. {
  2446. tid = dataTable.Rows[0]["tid"].ToString();
  2447. }
  2448. return tid;
  2449. }
  2450. public List<string> getTidByCtidMore(string ctid)
  2451. {
  2452. 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);
  2453. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2454. List<string> list = new List<string>();
  2455. if (dataTable != null && dataTable.Rows.Count > 0)
  2456. {
  2457. foreach (DataRow item in dataTable.Rows)
  2458. {
  2459. list.Add("'" + item["tid"].ToString() + "'");
  2460. }
  2461. }
  2462. return list;
  2463. }
  2464. public List<string> getTidByCtidLike(string ctid)
  2465. {
  2466. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2467. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2468. List<string> list = new List<string>();
  2469. if (dataTable != null && dataTable.Rows.Count > 0)
  2470. {
  2471. foreach (DataRow item in dataTable.Rows)
  2472. {
  2473. list.Add("'" + item["tid"].ToString() + "'");
  2474. }
  2475. }
  2476. return list;
  2477. }
  2478. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2479. {
  2480. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2481. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2482. List<string> list = new List<string>();
  2483. if (dataTable != null && dataTable.Rows.Count > 0)
  2484. {
  2485. foreach (DataRow item in dataTable.Rows)
  2486. {
  2487. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2488. {
  2489. continue;
  2490. }
  2491. list.Add("'" + item["receiverId"].ToString() + "'");
  2492. }
  2493. }
  2494. return list;
  2495. }
  2496. public void get_erp_myorderlist()
  2497. {
  2498. DataStruct dStruct = GetPostStruct();
  2499. List<string> lw = new List<string>();
  2500. string tid = GetPostString("ctid");
  2501. if (tid.Length > 0)
  2502. {
  2503. string select_tid = getTidByCtid(tid);
  2504. lw.Add(string.Format("tid='{0}'", select_tid));
  2505. }
  2506. else
  2507. {
  2508. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2509. }
  2510. //12-1 修改
  2511. string urgent = GetPostString("urgent");
  2512. string back = GetPostString("back");
  2513. string offlineSearch = GetPostString("offlineSearch");
  2514. if (!string.IsNullOrWhiteSpace(urgent))
  2515. {
  2516. if (urgent.Equals("true"))
  2517. {
  2518. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2519. }
  2520. }
  2521. if (!string.IsNullOrWhiteSpace(back))
  2522. {
  2523. if (back.Equals("true"))
  2524. {
  2525. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2526. }
  2527. }
  2528. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2529. {
  2530. if (offlineSearch.Equals("true"))
  2531. {
  2532. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2533. }
  2534. }
  2535. //end
  2536. string shopname = GetPostString("shopname");
  2537. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2538. string buyernick = GetPostString("buyer_nick");
  2539. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2540. string design = GetPostString("design");
  2541. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2542. string orderState = GetPostString("orderState");
  2543. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2544. string sellermemo = GetPostString("seller_memo");
  2545. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2546. string date1 = GetPostString("date1");
  2547. string date2 = GetPostString("date2");
  2548. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2549. if (dw.Length > 0) lw.Add(dw);
  2550. string price1 = GetPostString("price1");
  2551. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2552. string price2 = GetPostString("price2");
  2553. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2554. string urgency = GetPostString("urgency");
  2555. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2556. string after = GetPostString("after");
  2557. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2558. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2559. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2560. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2562. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2563. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2564. if (dt != null && dt.Rows.Count > 0)
  2565. {
  2566. foreach (DataRow dr in dt.Rows)
  2567. {
  2568. try
  2569. {
  2570. // 对象操作
  2571. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2572. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2573. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2574. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2575. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2576. if (dStruct.PageSize != 100000)
  2577. {
  2578. if (dr["DispatchSort"].ToString() == "2")
  2579. {
  2580. dr["gongchuang"] = 200;
  2581. }
  2582. else if ("外协".Equals(dr["ToType"].ToString()))
  2583. {
  2584. dr["gongchuang"] = 200;
  2585. }
  2586. else if ("内部".Equals(dr["ToType"].ToString()))
  2587. {
  2588. dr["gongchuang"] = -1;
  2589. }
  2590. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2591. {
  2592. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2593. dr["gongchuang"] = response.code;
  2594. }
  2595. }
  2596. }
  2597. catch (NullReferenceException ex)
  2598. {
  2599. }
  2600. }
  2601. }
  2602. writeGridDataTableJson(dStruct.TotalCount, dt);
  2603. }
  2604. public void get_erp_myreturnorderlist()
  2605. {
  2606. DataStruct dStruct = GetPostStruct();
  2607. List<string> lw = new List<string>();
  2608. string tid = GetPostString("ctid");
  2609. if (tid.Length > 0)
  2610. {
  2611. string select_tid = getTidByCtid(tid);
  2612. lw.Add(string.Format("tid='{0}'", select_tid));
  2613. }
  2614. else
  2615. {
  2616. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2617. }
  2618. string shopname = GetPostString("shopname");
  2619. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2620. string buyernick = GetPostString("buyer_nick");
  2621. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2622. string design = GetPostString("design");
  2623. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2624. string orderState = GetPostString("orderState");
  2625. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2626. string sellermemo = GetPostString("seller_memo");
  2627. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2628. string date1 = GetPostString("date1");
  2629. string date2 = GetPostString("date2");
  2630. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2631. if (dw.Length > 0) lw.Add(dw);
  2632. string price1 = GetPostString("price1");
  2633. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2634. string price2 = GetPostString("price2");
  2635. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2636. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2637. {
  2638. lw.Add(string.Format("CusOrgID = 94"));
  2639. }
  2640. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2641. {
  2642. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2643. }
  2644. else
  2645. {
  2646. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2647. }
  2648. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2649. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2650. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2651. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2652. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2653. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2654. if (dt != null && dt.Rows.Count > 0)
  2655. {
  2656. foreach (DataRow dr in dt.Rows)
  2657. {
  2658. try
  2659. {
  2660. // 对象操作
  2661. if (dStruct.PageSize != 100000)
  2662. {
  2663. if (dr["DispatchSort"].ToString() == "2")
  2664. {
  2665. dr["gongchuang"] = 200;
  2666. }
  2667. else if ("外协".Equals(dr["ToType"].ToString()))
  2668. {
  2669. dr["gongchuang"] = 200;
  2670. }
  2671. else if ("内部".Equals(dr["ToType"].ToString()))
  2672. {
  2673. dr["gongchuang"] = -1;
  2674. }
  2675. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2676. {
  2677. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2678. dr["gongchuang"] = response.code;
  2679. }
  2680. }
  2681. }
  2682. catch (NullReferenceException ex)
  2683. {
  2684. // 处理空引用异常
  2685. }
  2686. }
  2687. }
  2688. writeGridDataTableJson(dStruct.TotalCount, dt);
  2689. }
  2690. public void get_erp_myorderlist_pregather()
  2691. {
  2692. string date1 = GetPostString("date1");
  2693. string date2 = GetPostString("date2");
  2694. int userId = CurrentUser.UserID; //客服id
  2695. string orderWhere = "";
  2696. List<string> lw = new List<string>();
  2697. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2698. if (dw.Length > 0) lw.Add(dw);
  2699. lw.Add(string.Format("CustomerUserId={0}", userId));
  2700. lw.Add(string.Format("OrderState<9"));
  2701. orderWhere = string.Join(" and ", lw.ToArray());
  2702. string orderWhere2 = "";
  2703. List<string> lw2 = new List<string>();
  2704. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2705. if (dw2.Length > 0) lw2.Add(dw2);
  2706. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2707. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2708. string sql = string.Format("select *" +
  2709. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2710. "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 " +
  2711. "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 " +
  2712. "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");
  2713. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2714. //writeGridDataTableJson(dt.Rows.Count, dt);
  2715. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2716. }
  2717. public void upd_erp_publishorder()
  2718. {
  2719. if (UrlPostParmsCheck("ctid"))
  2720. {
  2721. string eid = GetPostString("ctid");
  2722. CeErpTradeCell entity = null;
  2723. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2724. if (entity != null)
  2725. {
  2726. entity.OrderState = 0; //发布后,变为待抢单
  2727. entity.Update();
  2728. commonHelper.UpdateRelationOrder(entity.ctid);
  2729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2730. returnSuccessMsg("发布成功!");
  2731. return;
  2732. }
  2733. returnErrorMsg("找不到记录");
  2734. }
  2735. }
  2736. public void get_erp_my_tiporder()
  2737. {
  2738. StringBuilder sql = new StringBuilder();
  2739. int userId = 0;
  2740. if (CurrentUser != null) userId = CurrentUser.UserID;
  2741. string posCode = CurrentUser.UserPost.Post.Code;
  2742. string isTipedAfterSaleVerify = GetPostString("af");
  2743. DataTable dt = new DataTable();
  2744. if (posCode != "Supplier")
  2745. {
  2746. if (posCode == "CustomerService" || posCode == "Director")
  2747. {
  2748. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2749. }
  2750. else if (posCode == "Place" || posCode == "PlaceMr")
  2751. {
  2752. }
  2753. else
  2754. {
  2755. string teamIds = CurrentUser.User.TeamIds;
  2756. if (teamIds == "")
  2757. {
  2758. teamIds = "0";
  2759. }
  2760. 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);
  2761. }
  2762. if (sql.Length > 0)
  2763. {
  2764. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2765. }
  2766. }
  2767. if (dt.Rows.Count <= 0)
  2768. {
  2769. string key = "aftersale_order_" + userId;
  2770. if (RedisHelper.HasKey(key))
  2771. {
  2772. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2773. dt.Columns.Add("ctid", typeof(string));
  2774. dt.Columns.Add("IsReadTag", typeof(int));
  2775. foreach (var i in list)
  2776. {
  2777. DataRow data = dt.NewRow();
  2778. data["ctid"] = i;
  2779. data["IsReadTag"] = 4;
  2780. dt.Rows.Add(data);
  2781. }
  2782. RedisHelper.StringDelete(key);
  2783. }
  2784. }
  2785. if (dt.Rows.Count <= 0)
  2786. {
  2787. sql = new StringBuilder();
  2788. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2789. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2790. }
  2791. if (posCode == "Supplier")
  2792. {
  2793. string ids = CurrentUser.User.pemVend;
  2794. if (ids != null && ids.Length > 0)
  2795. {
  2796. string[] ids_list = ids.Split(',');
  2797. foreach (var item in ids_list)
  2798. {
  2799. string key = "return_order_" + item;
  2800. if (RedisHelper.HasKey(key))
  2801. {
  2802. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2803. dt.Columns.Add("ctid", typeof(string));
  2804. dt.Columns.Add("IsReadTag", typeof(int));
  2805. foreach (var i in list)
  2806. {
  2807. DataRow data = dt.NewRow();
  2808. data["ctid"] = i;
  2809. data["IsReadTag"] = 1;
  2810. dt.Rows.Add(data);
  2811. }
  2812. RedisHelper.StringDelete(key);
  2813. }
  2814. }
  2815. }
  2816. if (dt.Rows.Count <= 0)
  2817. {
  2818. sql = new StringBuilder();
  2819. 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);
  2820. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2821. }
  2822. }
  2823. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2824. }
  2825. public void reset_erp_tiporder()
  2826. {
  2827. string ids = GetPostString("ids");
  2828. string[] ctidList = ids.Split(',');
  2829. foreach (string ctid in ctidList)
  2830. {
  2831. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2832. if (enty != null)
  2833. {
  2834. enty.IsReadTag = 0;
  2835. enty.Update();
  2836. }
  2837. }
  2838. returnSuccessMsg("成功!");
  2839. return;
  2840. }
  2841. public void get_erp_designlist()
  2842. {
  2843. DataStruct dStruct = GetPostStruct();
  2844. List<string> lw = new List<string>();
  2845. string tid = GetPostString("ctid");
  2846. if (tid.Length > 0)
  2847. {
  2848. string select_tid = getTidByCtid(tid);
  2849. lw.Add(string.Format("tid='{0}'", select_tid));
  2850. }
  2851. string shopname = GetPostString("shopname");
  2852. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2853. string buyernick = GetPostString("buyer_nick");
  2854. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2855. string customer = GetPostString("customer");
  2856. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2857. string design = GetPostString("design");
  2858. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2859. string orderState = GetPostString("orderState");
  2860. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2861. lw.Add(string.Format("OrderState<6"));
  2862. string address = GetPostString("address");
  2863. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2864. string sellermemo = GetPostString("seller_memo");
  2865. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2866. string date1 = GetPostString("date1");
  2867. string date2 = GetPostString("date2");
  2868. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2869. if (dw.Length > 0) lw.Add(dw);
  2870. string apdate1 = GetPostString("apdate1");
  2871. string apdate2 = GetPostString("apdate2");
  2872. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2873. if (dwap.Length > 0) lw.Add(dwap);
  2874. string price1 = GetPostString("price1");
  2875. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2876. string price2 = GetPostString("price2");
  2877. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2878. string designTime = GetPostString("designtime");
  2879. if (designTime.Length > 0)
  2880. {
  2881. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2882. }
  2883. string usershop = CurrentUser.User.pemShop;
  2884. if (usershop.Length > 0)
  2885. {
  2886. lw.Add(string.Format("shopId in ({0})", usershop));
  2887. }
  2888. int myOrgid = CurrentUser.UserPost.OrgID;
  2889. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2890. if (myOrgCode.IndexOf("Designer") != -1)
  2891. {
  2892. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2893. {
  2894. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2895. }
  2896. else
  2897. {
  2898. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2899. }
  2900. }
  2901. else
  2902. {
  2903. string orgId = GetPostString("designerhd");
  2904. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2905. }
  2906. if (tid.Length > 0 || buyernick.Length > 0)
  2907. {
  2908. lw.Add(string.Format("OrderState >= 3"));
  2909. }
  2910. else
  2911. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2912. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2913. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2914. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2915. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2916. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2917. if (dt != null && dt.Rows.Count > 0)
  2918. {
  2919. foreach (DataRow dr in dt.Rows)
  2920. {
  2921. try
  2922. {
  2923. // 对象操作
  2924. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2925. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2926. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2927. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2928. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2929. if (dStruct.PageSize != 100000)
  2930. {
  2931. if (dr["DispatchSort"].ToString() == "2")
  2932. {
  2933. dr["gongchuang"] = 200;
  2934. }
  2935. else if ("外协".Equals(dr["ToType"].ToString()))
  2936. {
  2937. dr["gongchuang"] = 200;
  2938. }
  2939. else if ("内部".Equals(dr["ToType"].ToString()))
  2940. {
  2941. dr["gongchuang"] = -1;
  2942. }
  2943. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2944. {
  2945. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2946. dr["gongchuang"] = response.code;
  2947. }
  2948. }
  2949. }
  2950. catch (NullReferenceException ex)
  2951. {
  2952. }
  2953. }
  2954. }
  2955. writeGridDataTableJson(dStruct.TotalCount, dt);
  2956. }
  2957. public void get_erp_mydesignlist()
  2958. {
  2959. DataStruct dStruct = GetPostStruct();
  2960. List<string> lw = new List<string>();
  2961. string tid = GetPostString("ctid");
  2962. if (tid.Length > 0)
  2963. {
  2964. string select_tid = getTidByCtid(tid);
  2965. lw.Add(string.Format("tid='{0}'", select_tid));
  2966. }
  2967. string shopname = GetPostString("shopname");
  2968. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2969. string buyernick = GetPostString("buyer_nick");
  2970. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2971. string customer = GetPostString("customer");
  2972. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2973. string orderState = GetPostString("orderState");
  2974. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2975. //lw.Add(string.Format("OrderState<6"));
  2976. string date1 = GetPostString("date1");
  2977. string date2 = GetPostString("date2");
  2978. string dw = GetDateWhere("pay_time", date1, date2);
  2979. if (dw.Length > 0) lw.Add(dw);
  2980. string apdate1 = GetPostString("apdate1");
  2981. string apdate2 = GetPostString("apdate2");
  2982. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2983. if (dwap.Length > 0) lw.Add(dwap);
  2984. string price1 = GetPostString("price1");
  2985. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2986. string price2 = GetPostString("price2");
  2987. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2988. string olddownload = GetPostString("olddown");
  2989. if (olddownload == "1")
  2990. {
  2991. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2992. }
  2993. else if (olddownload == "2")
  2994. {
  2995. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2996. }
  2997. string sellermemo = GetPostString("seller_memo");
  2998. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2999. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  3000. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  3001. {
  3002. if (CurrentUser.User.TeamIds.Length > 0)
  3003. {
  3004. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  3005. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3006. else
  3007. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3008. }
  3009. else
  3010. {
  3011. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3012. }
  3013. }
  3014. if (tid.Length <= 0)
  3015. {
  3016. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3017. }
  3018. lw.Add(string.Format("IsReturn!=3"));
  3019. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3020. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3021. string teamids = CurrentUser.User.TeamIds.ToString();
  3022. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3023. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3024. if (dt != null && dt.Rows.Count > 0)
  3025. {
  3026. foreach (DataRow dr in dt.Rows)
  3027. {
  3028. try
  3029. {
  3030. // 对象操作
  3031. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3032. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3033. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3034. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3035. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3036. if (dStruct.PageSize != 100000)
  3037. {
  3038. if (dr["DispatchSort"].ToString() == "2")
  3039. {
  3040. dr["gongchuang"] = 200;
  3041. }
  3042. else if ("外协".Equals(dr["ToType"].ToString()))
  3043. {
  3044. dr["gongchuang"] = 200;
  3045. }
  3046. else if ("内部".Equals(dr["ToType"].ToString()))
  3047. {
  3048. dr["gongchuang"] = -1;
  3049. }
  3050. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3051. {
  3052. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3053. dr["gongchuang"] = response.code;
  3054. }
  3055. }
  3056. }
  3057. catch (NullReferenceException ex)
  3058. {
  3059. }
  3060. }
  3061. }
  3062. writeGridDataTableJson(dStruct.TotalCount, dt);
  3063. }
  3064. public void set_erp_startdesign()
  3065. {
  3066. if (UrlPostParmsCheck("ctid"))
  3067. {
  3068. string eid = GetPostString("ctid");
  3069. CeErpTradeCell entity = null;
  3070. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3071. if (entity != null)
  3072. {
  3073. if (entity.OrderState != 3)
  3074. {
  3075. returnErrorMsg("请刷新,订单已经设计了");
  3076. return;
  3077. }
  3078. entity.StartDesignTime = DateTime.Now;
  3079. entity.OrderState = 4;
  3080. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3081. {
  3082. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3083. entity.SupplierId = suid;
  3084. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3085. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3086. }
  3087. entity.UpdateTime = DateTime.Now;
  3088. //entity.MakeSupplier = suname;
  3089. entity.Update();
  3090. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3091. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3092. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3093. commonHelper.getCytPrice(entity);
  3094. returnSuccessMsg("操作成功!");
  3095. return;
  3096. }
  3097. returnErrorMsg("找不到记录");
  3098. }
  3099. }
  3100. public void ins_erp_designselfmemo()
  3101. {
  3102. if (UrlPostParmsCheck("ctid"))
  3103. {
  3104. string eid = GetPostString("ctid");
  3105. string con = GetPostString("con");
  3106. CeErpTradeCell entity = null;
  3107. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3108. if (entity != null)
  3109. {
  3110. entity.DesignSelfMemo = con;
  3111. entity.Update();
  3112. returnSuccessMsg("操作成功!");
  3113. return;
  3114. }
  3115. returnErrorMsg("找不到记录");
  3116. }
  3117. }
  3118. public void ins_erp_designprice()
  3119. {
  3120. if (UrlPostParmsCheck("ctid"))
  3121. {
  3122. string eid = GetPostString("ctid");
  3123. int uid = CurrentUser.UserID;
  3124. string userName = CurrentUser.UserName;
  3125. CeErpTradeCell entity = null;
  3126. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3127. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3128. if (entitys == null)
  3129. {
  3130. entitys = new CeErpDesignerBill();
  3131. }
  3132. if (entity != null)
  3133. {
  3134. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3135. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3136. entity.StartDesignTime = DateTime.Now;
  3137. entity.OrderState = 4;
  3138. string suname = "";
  3139. if (entity.SupplierId == 0)
  3140. {
  3141. int sid = commonHelper.autoDistributeToSupplier(entity);
  3142. entity.SupplierId = sid;
  3143. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3144. }
  3145. entity.Update();
  3146. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3147. if (ceErpUserPost != null)
  3148. {
  3149. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3150. if (ceErpPost != null)
  3151. {
  3152. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3153. {
  3154. entitys.tid = entity.ctid;
  3155. entitys.oid = entity.tid;
  3156. entitys.uid = uid;
  3157. entitys.userName = userName;
  3158. entitys.designerType = 1;
  3159. entitys.designerTypeText = "内部设计师";
  3160. entitys.price = Convert.ToDouble(GetPostString("price"));
  3161. entitys.designNum = GetPostInt("designNum");
  3162. entitys.modifyNum = GetPostInt("modifyNum");
  3163. entitys.designSize = GetPostString("designSize");
  3164. entitys.modifySize = GetPostString("modifySize");
  3165. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3166. {
  3167. entitys.create_time = DateTime.Now;
  3168. entitys.create_u_id = uid;
  3169. entitys.create_u_name = userName;
  3170. entitys.Save();
  3171. }
  3172. else
  3173. {
  3174. entitys.update_time = DateTime.Now;
  3175. entitys.update_u_id = uid;
  3176. entitys.update_u_name = userName;
  3177. entitys.Update();
  3178. }
  3179. }
  3180. }
  3181. }
  3182. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3184. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3185. if (suname != "")
  3186. {
  3187. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3188. }
  3189. commonHelper.getCytPrice(entity);
  3190. returnSuccessMsg("操作成功!");
  3191. return;
  3192. }
  3193. returnErrorMsg("找不到记录");
  3194. }
  3195. }
  3196. public void upload_erp_filecomplete()
  3197. {
  3198. if (UrlPostParmsCheck("ctid"))
  3199. {
  3200. string eid = GetPostString("ctid");
  3201. CeErpTradeCell entity = null;
  3202. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3203. if (entity != null)
  3204. {
  3205. entity.OrderState = 5; //设计完成
  3206. entity.Update();
  3207. returnSuccessMsg(eid + "上传成功,设计完成!");
  3208. return;
  3209. }
  3210. returnErrorMsg("找不到订单记录");
  3211. }
  3212. }
  3213. public void get_erp_designovertimelist()
  3214. {
  3215. DataStruct dStruct = GetPostStruct();
  3216. List<string> lw = new List<string>();
  3217. string tid = GetPostString("ctid");
  3218. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3219. string shopname = GetPostString("shopname");
  3220. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3221. string buyernick = GetPostString("buyer_nick");
  3222. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3223. string ResponsibleMan = GetPostString("responsible");
  3224. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3225. string date1 = GetPostString("date1");
  3226. string date2 = GetPostString("date2");
  3227. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3228. if (dw.Length > 0) lw.Add(dw);
  3229. string price1 = GetPostString("price1");
  3230. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3231. string price2 = GetPostString("price2");
  3232. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3233. string orderState = GetPostString("orderState");
  3234. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3235. string sellermemo = GetPostString("seller_memo");
  3236. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3237. lw.Add(string.Format("UnusualTag=3"));
  3238. lw.Add(string.Format("IsRefund<={0}", 1));
  3239. dStruct.Order = "WaitDesignTime desc";
  3240. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3241. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3242. writeGridDataTableJson(dStruct.TotalCount, dt);
  3243. }
  3244. //设计管理 获取抢单大厅列表
  3245. public void get_erp_grabinglist()
  3246. {
  3247. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3248. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3249. bool oldOrder = false;
  3250. if (org != null)
  3251. {
  3252. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3253. }
  3254. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3255. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3256. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3257. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3258. //先处理订单数据
  3259. if (dt.Rows.Count > 0)
  3260. {
  3261. Dictionary<string, int> design = null;
  3262. int count = 0;
  3263. foreach (DataRow row in dt.Rows)
  3264. {
  3265. if (map.ContainsKey(row["ShopId"].ToString()))
  3266. {
  3267. map.TryGetValue(row["ShopId"].ToString(), out design);
  3268. }
  3269. else
  3270. {
  3271. design = new Dictionary<string, int>();
  3272. }
  3273. if (design.ContainsKey(row["ProductId"].ToString()))
  3274. {
  3275. design.TryGetValue(row["ProductId"].ToString(), out count);
  3276. }
  3277. count++;
  3278. design[row["ProductId"].ToString()] = count;
  3279. map[row["ShopId"].ToString()] = design;
  3280. }
  3281. }
  3282. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3283. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3284. //把店铺排序和技能排序分类
  3285. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3286. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3287. if (design_dt.Rows.Count > 0)
  3288. {
  3289. Dictionary<string, string> design = null;
  3290. List<string> shopIds = null;
  3291. foreach (DataRow row in design_dt.Rows)
  3292. {
  3293. if ("0".Equals(row["designId"].ToString()))
  3294. {
  3295. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3296. {
  3297. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3298. }
  3299. else
  3300. {
  3301. shopIds = new List<string>();
  3302. }
  3303. shopIds.Add(row["shopId"].ToString());
  3304. shop_orders[row["orders"].ToString()] = shopIds;
  3305. }
  3306. else
  3307. {
  3308. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3309. {
  3310. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3311. }
  3312. else
  3313. {
  3314. design = new Dictionary<string, string>();
  3315. }
  3316. design[row["orders"].ToString()] = row["designId"].ToString();
  3317. design_orders[row["shopId"].ToString()] = design;
  3318. }
  3319. }
  3320. //处理成key value后根据key排序
  3321. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3322. foreach (List<string> val in shop_orders.Values)
  3323. {
  3324. if (val != null)
  3325. {
  3326. foreach (string key in val)
  3327. {
  3328. if (design_orders.ContainsKey(key.ToString()))
  3329. {
  3330. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3331. }
  3332. }
  3333. }
  3334. }
  3335. }
  3336. //校验哪个优先级有订单
  3337. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3338. foreach (string key in shop_orders.Keys)
  3339. {
  3340. List<string> ids = null;
  3341. shop_orders.TryGetValue(key, out ids);
  3342. //id为shopid
  3343. foreach (string id in ids)
  3344. {
  3345. Dictionary<string, int> list = null;
  3346. Dictionary<string, string> desing = null;
  3347. map.TryGetValue(id, out list);
  3348. design_orders.TryGetValue(id, out desing);
  3349. if (list != null && desing != null)
  3350. {
  3351. foreach (var item in desing)
  3352. {
  3353. int count = 0;
  3354. if (list.ContainsKey(item.Value))
  3355. {
  3356. list.TryGetValue(item.Value, out count);
  3357. if (count > 0)
  3358. {
  3359. designIds[id] = item.Value;
  3360. break;
  3361. }
  3362. }
  3363. }
  3364. }
  3365. }
  3366. if (designIds.Count > 0)
  3367. {
  3368. break;
  3369. }
  3370. }
  3371. DataTable table = new DataTable();
  3372. table.Columns.Add("tid", typeof(string));
  3373. table.Columns.Add("ctid", typeof(string));
  3374. table.Columns.Add("seller_nick", typeof(string));
  3375. table.Columns.Add("productName", typeof(string));
  3376. table.Columns.Add("pay_time", typeof(string));
  3377. table.Columns.Add("seller_memo", typeof(string));
  3378. if (designIds.Count > 0)
  3379. {
  3380. string shopId = "";
  3381. string productId = "";
  3382. foreach (var designInfo in designIds)
  3383. {
  3384. shopId = designInfo.Key;
  3385. productId = designInfo.Value;
  3386. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3387. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3388. if (dt.Rows.Count > 0)
  3389. {
  3390. foreach (DataRow row in dt.Rows)
  3391. {
  3392. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3393. {
  3394. DataRow data = table.NewRow();
  3395. data["ctid"] = row["ctid"].ToString();
  3396. data["tid"] = row["tid"].ToString();
  3397. data["seller_nick"] = ceErpShop.ShopName;
  3398. data["pay_time"] = row["pay_time"].ToString();
  3399. data["seller_memo"] = row["seller_memo"].ToString();
  3400. data["productName"] = ceErpProduct.PType;
  3401. table.Rows.Add(data);
  3402. }
  3403. }
  3404. }
  3405. }
  3406. }
  3407. writeGridDataTableJson(table.Rows.Count, table);
  3408. }
  3409. private object rushLockObject = new object();
  3410. public void set_erp_grabingorder()
  3411. {
  3412. if (UrlPostParmsCheck("ctid"))
  3413. {
  3414. int total = CurrentUser.User.Person.Total;
  3415. int userId = CurrentUser.User.ID;
  3416. int noFinish = CurrentUser.User.Person.NoFinish;
  3417. int finalization = CurrentUser.User.Person.Finalization;
  3418. string eids = GetPostString("ctid");
  3419. string key = "RushKey_" + userId;
  3420. int count = 0;
  3421. if (erpRedis.RedisHelper.KeyExists(key))
  3422. {
  3423. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3424. if (redisCount != null)
  3425. {
  3426. count = Convert.ToInt32(redisCount);
  3427. }
  3428. }
  3429. if (count >= total)
  3430. {
  3431. returnErrorMsg("半小时内已经抢" + total + "单");
  3432. return;
  3433. }
  3434. string[] ctidlist = eids.Split(',');
  3435. if (count + ctidlist.Length > total)
  3436. {
  3437. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3438. return;
  3439. }
  3440. int itag = 0;
  3441. lock (rushLockObject)
  3442. {
  3443. if (ctidlist.Length > 0)
  3444. {
  3445. string[] dtList = new string[ctidlist.Length];
  3446. for (int i = 0; i < ctidlist.Length; i++)
  3447. {
  3448. dtList[i] = "'" + ctidlist[i] + "'";
  3449. }
  3450. 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"));
  3451. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3452. if (dt_user.Rows.Count > 0)
  3453. {
  3454. int doing = 0;//未定稿
  3455. int finish = 0;//已完成
  3456. foreach (DataRow dr in dt_user.Rows)
  3457. {
  3458. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3459. {
  3460. doing++;
  3461. }
  3462. else
  3463. {
  3464. finish++;
  3465. }
  3466. }
  3467. if (doing >= noFinish)
  3468. {
  3469. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3470. return;
  3471. }
  3472. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3473. {
  3474. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3475. return;
  3476. }
  3477. }
  3478. //校验选择单子状态
  3479. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3480. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3481. if (dt.Rows.Count > 0)
  3482. {
  3483. List<string> list = new List<string>();
  3484. foreach (DataRow dr in dt.Rows)
  3485. {
  3486. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3487. {
  3488. list.Add(dr["ctid"].ToString());
  3489. }
  3490. }
  3491. if (list.Count > 0)
  3492. {
  3493. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3494. return;
  3495. }
  3496. }
  3497. foreach (string ctid in ctidlist)
  3498. {
  3499. CeErpTradeCell entity = null;
  3500. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3501. if (entity != null)
  3502. {
  3503. entity.OrderState = 3;
  3504. entity.DesignUserId = CurrentUser.UserID;
  3505. entity.WaitDesignTime = DateTime.Now;
  3506. entity.StartDesignTime = DateTime.Now;
  3507. entity.Update();
  3508. commonHelper.UpdateRelationOrder(entity.ctid);
  3509. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3510. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3511. itag++;
  3512. }
  3513. }
  3514. }
  3515. }
  3516. count += ctidlist.Length;
  3517. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3518. if (itag == 0)
  3519. returnErrorMsg("没有找到相关订单");
  3520. else
  3521. returnSuccessMsg("抢单成功!");
  3522. return;
  3523. }
  3524. }
  3525. public void get_erp_waitorderlist()
  3526. {
  3527. DataStruct dStruct = GetPostStruct();
  3528. List<string> lw = new List<string>();
  3529. string tid = GetPostString("ctid");
  3530. if (tid.Length > 0)
  3531. {
  3532. string select_tid = getTidByCtid(tid);
  3533. lw.Add(string.Format("tid='{0}'", select_tid));
  3534. }
  3535. string shopname = GetPostString("shopname");
  3536. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3537. string buyernick = GetPostString("buyer_nick");
  3538. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3539. string customer = GetPostString("customer");
  3540. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3541. string design = GetPostString("design");
  3542. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3543. string orderState = GetPostString("orderState");
  3544. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3545. string supplier = GetPostString("supplier");
  3546. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3547. string sellermemo = GetPostString("seller_memo");
  3548. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3549. string otherMemo = GetPostString("otherMemo");
  3550. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3551. string address = GetPostString("address");
  3552. 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));
  3553. string date1 = GetPostString("date1");
  3554. string date2 = GetPostString("date2");
  3555. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3556. if (dw.Length > 0) lw.Add(dw);
  3557. string price1 = GetPostString("price1");
  3558. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3559. string price2 = GetPostString("price2");
  3560. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3561. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3562. lw.Add(string.Format("IsSample != 2 "));
  3563. lw.Add(string.Format("OrderState = 5 "));
  3564. lw.Add(string.Format("IsRefund<={0}", 1));
  3565. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3566. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3567. string pagesize = GetPostString("pagesize");
  3568. if (pagesize != null)
  3569. {
  3570. dStruct.PageSize = 200;
  3571. }
  3572. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3573. List<string> tids = new List<string>();
  3574. if (dt != null)
  3575. {
  3576. dt.Columns.Add("compenPrice", typeof(double));
  3577. foreach (DataRow dr in dt.Rows)
  3578. {
  3579. if (Convert.IsDBNull(dr["compenPrice"]))
  3580. {
  3581. dr["compenPrice"] = 0;
  3582. }
  3583. tids.Add("'" + dr["tid"].ToString() + "'");
  3584. 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();
  3585. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3586. {
  3587. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3588. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3589. entity.SupplierId = suid;
  3590. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3591. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3592. entity.Update();
  3593. }
  3594. }
  3595. }
  3596. if (tids.Count > 0)
  3597. {
  3598. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3599. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3600. if (dt_price != null && dt_price.Rows.Count > 0)
  3601. {
  3602. foreach (DataRow dr in dt_price.Rows)
  3603. {
  3604. foreach (DataRow row in dt.Rows)
  3605. {
  3606. if (row["tid"].Equals(dr["ptid"]))
  3607. {
  3608. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3609. break;
  3610. }
  3611. }
  3612. }
  3613. }
  3614. }
  3615. writeGridDataTableJson(dStruct.TotalCount, dt);
  3616. }
  3617. public void get_erp_supplierwaitorderlist()
  3618. {
  3619. DataStruct dStruct = GetPostStruct();
  3620. List<string> lw = new List<string>();
  3621. string tid = GetPostString("ctid");
  3622. if (tid.Length > 0)
  3623. {
  3624. string select_tid = getTidByCtid(tid);
  3625. lw.Add(string.Format("tid='{0}'", select_tid));
  3626. }
  3627. string shopname = GetPostString("shopname");
  3628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3629. string sellermemo = GetPostString("seller_memo");
  3630. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3631. string date1 = GetPostString("date1");
  3632. string date2 = GetPostString("date2");
  3633. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3634. if (dw.Length > 0) lw.Add(dw);
  3635. lw.Add(string.Format("OrderState = 5 "));
  3636. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3637. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3638. {
  3639. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3640. }
  3641. string supplier = GetPostString("supplier");
  3642. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3643. {
  3644. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3645. }
  3646. lw.Add(string.Format("IsRefund<={0}", 1));
  3647. dStruct.Order = "FinishDesignTime desc";
  3648. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3649. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3650. if (dt != null)
  3651. {
  3652. foreach (DataRow dr in dt.Rows)
  3653. {
  3654. 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();
  3655. }
  3656. }
  3657. writeGridDataTableJson(dStruct.TotalCount, dt);
  3658. }
  3659. public void upd_erp_verifytosupplier()
  3660. {
  3661. if (UrlPostParmsCheck("ctid"))
  3662. {
  3663. string eids = GetPostString("ctid");
  3664. CeErpTradeCell entity = null;
  3665. string[] eidsList = eids.Split(',');
  3666. if (eidsList.Length <= 0)
  3667. {
  3668. returnErrorMsg("订单号不能空");
  3669. return;
  3670. }
  3671. List<string> tLst = new List<string>();
  3672. foreach (string ctidstr in eidsList)
  3673. {
  3674. tLst.Add("'" + ctidstr + "'");
  3675. CeErpDataSendOrderInfo.createObject(ctidstr);
  3676. }
  3677. string needtids = string.Join(",", tLst.ToArray());
  3678. StringBuilder sql = new StringBuilder();
  3679. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3680. 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);
  3681. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3682. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3683. returnSuccessMsg("操作成功!");
  3684. return;
  3685. /**foreach (string ctidstr in eidsList)
  3686. {
  3687. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3688. if (entity != null)
  3689. {
  3690. if (entity.SupplierId == 0)
  3691. {
  3692. continue;
  3693. }
  3694. entity.IsVerifyToSupplier = true;
  3695. if (entity.IsReturn == 1) //1是供应商打回
  3696. {
  3697. entity.IsReturn = 0;
  3698. }
  3699. entity.FinishPlaceTime = DateTime.Now;
  3700. entity.PlaceUserId = CurrentUser.UserID;
  3701. entity.Update();
  3702. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3703. }
  3704. }
  3705. returnSuccessMsg("操作成功!");
  3706. return;**/
  3707. }
  3708. }
  3709. public void upd_erp_supplierback()
  3710. {
  3711. if (UrlPostParmsCheck("ctid"))
  3712. {
  3713. string eid = GetPostString("ctid");
  3714. string reason = GetPostString("returnreason");
  3715. CeErpTradeCell entity = null;
  3716. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3717. if (entity != null)
  3718. {
  3719. string message = "操作成功!";
  3720. string isDown = "";
  3721. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3722. {
  3723. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3724. isDown = "被点击下载";
  3725. }
  3726. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3727. {
  3728. string key = "return_order_" + entity.SupplierId;
  3729. List<string> list = new List<string>();
  3730. if (RedisHelper.HasKey(key))
  3731. {
  3732. object data = RedisHelper.StringGet(key);
  3733. list = Convert.ToString(data).Split(',').ToList();
  3734. }
  3735. list.Add(eid);
  3736. RedisHelper.StringSet(key, string.Join(",", list));
  3737. }
  3738. entity.IsVerifyToSupplier = false;
  3739. entity.IsReturn = 1;
  3740. entity.IsHaveNewOrder = 0;
  3741. entity.ReturnTime = DateTime.Now;
  3742. entity.ReturnReason = reason;
  3743. if (entity.OrderState == 6)
  3744. {
  3745. entity.OrderState = 5;
  3746. }
  3747. entity.Update();
  3748. CeErpSukuraData.createInfo(entity.ctid, 5);
  3749. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3750. returnSuccessMsg(message);
  3751. return;
  3752. }
  3753. returnErrorMsg("找不到订单记录");
  3754. }
  3755. }
  3756. public void upd_erp_toaftersaleorder()
  3757. {
  3758. if (UrlPostParmsCheck("ctid"))
  3759. {
  3760. string eid = GetPostString("ctid");
  3761. string reason = GetPostString("returnreason");
  3762. CeErpTradeCell entity = null;
  3763. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3764. if (entity != null)
  3765. {
  3766. if (entity.isAfterSaleOrder != 1)
  3767. {
  3768. returnErrorMsg("带S的售后单才能打回给售后");
  3769. return;
  3770. }
  3771. if (entity.OrderState >= 5)
  3772. {
  3773. returnErrorMsg("已经设计完成了不能打回给售后");
  3774. return;
  3775. }
  3776. entity.OrderState = 0;
  3777. entity.IsReturn = 3;
  3778. entity.ReturnTime = DateTime.Now;
  3779. entity.UpdateTime = DateTime.Now;
  3780. entity.ReturnReason = reason;
  3781. entity.Update();
  3782. CeErpSukuraData.createInfo(entity.ctid, 5);
  3783. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3784. returnSuccessMsg("操作成功!");
  3785. return;
  3786. }
  3787. returnErrorMsg("找不到订单记录");
  3788. }
  3789. }
  3790. public void upd_erp_aftersaletodesign()
  3791. {
  3792. if (UrlPostParmsCheck("ctid"))
  3793. {
  3794. string eid = GetPostString("ctid");
  3795. CeErpTradeCell entity = null;
  3796. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3797. if (entity != null)
  3798. {
  3799. entity.OrderState = 3;
  3800. entity.IsReturn = 0;
  3801. entity.UpdateTime = DateTime.Now;
  3802. entity.Update();
  3803. CeErpSukuraData.createInfo(entity.ctid, 5);
  3804. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3805. returnSuccessMsg("操作成功!");
  3806. return;
  3807. }
  3808. returnErrorMsg("找不到订单记录");
  3809. }
  3810. }
  3811. public void assign_erp_supplier()
  3812. {
  3813. if (UrlPostParmsCheck("ctid"))
  3814. {
  3815. string eids = GetPostString("ctid");
  3816. int sid = GetPostInt("SupplierName");
  3817. string fromTag = GetPostString("tag");
  3818. string[] eidList = eids.Split(',');
  3819. if (eidList.Length <= 0)
  3820. {
  3821. returnErrorMsg("指派不能为空");
  3822. return;
  3823. }
  3824. string errMsg = "";
  3825. string suname = commonHelper.getSupplierNameById(sid);
  3826. foreach (string ctid in eidList)
  3827. {
  3828. CeErpTradeCell entity = null;
  3829. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3830. if (entity != null)
  3831. {
  3832. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3833. {
  3834. errMsg += (ctid + "指派失败!!!");
  3835. continue;
  3836. }
  3837. entity.SupplierId = sid;
  3838. entity.Update();
  3839. commonHelper.UpdateRelationOrder(entity.ctid);
  3840. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3841. if (entity.OrderState >= 6)
  3842. {
  3843. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3844. //{
  3845. // string msl = entity.MakeSupplier;
  3846. // string[] mslist = msl.Split(',');
  3847. // 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);
  3848. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3849. //}
  3850. //else
  3851. //{
  3852. StringBuilder sql = new StringBuilder();
  3853. 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);
  3854. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3855. //}
  3856. }
  3857. }
  3858. else
  3859. {
  3860. continue;
  3861. }
  3862. }
  3863. if (errMsg.Length > 0)
  3864. {
  3865. returnErrorMsg(errMsg);
  3866. return;
  3867. }
  3868. returnSuccessMsg("操作成功!");
  3869. return;
  3870. }
  3871. }
  3872. public void assign_erp_makesupplier()
  3873. {
  3874. if (UrlPostParmsCheck("ctid"))
  3875. {
  3876. string eids = GetPostString("ctid");
  3877. string sname = GetPostString("SupplierName");
  3878. string[] eidList = eids.Split(',');
  3879. if (eidList.Length <= 0)
  3880. {
  3881. returnErrorMsg("指派不能为空");
  3882. return;
  3883. }
  3884. List<string> tLst = new List<string>();
  3885. foreach (string ctid in eidList)
  3886. {
  3887. CeErpTradeCell entity = null;
  3888. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3889. if (entity != null)
  3890. {
  3891. entity.MakeSupplier = sname;
  3892. entity.Update();
  3893. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3894. tLst.Add("'" + ctid + "'");
  3895. }
  3896. else
  3897. {
  3898. continue;
  3899. }
  3900. }
  3901. string ctids = string.Join(",", tLst.ToArray());
  3902. StringBuilder sql2 = new StringBuilder();
  3903. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3904. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3905. returnSuccessMsg("操作成功!");
  3906. return;
  3907. }
  3908. }
  3909. public void ins_erp_returnreason()
  3910. {
  3911. if (UrlPostParmsCheck("ctid"))
  3912. {
  3913. string eid = GetPostString("ctid");
  3914. CeErpTradeCell entity = null;
  3915. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3916. string userpost = CurrentUser.UserPost.Post.Code;
  3917. if (entity != null)
  3918. {
  3919. bool isPlace = false;
  3920. if (entity.OrderState > 6)
  3921. {
  3922. returnErrorMsg("已发货无法打回!");
  3923. return;
  3924. }
  3925. if (entity.OrderState == 6)
  3926. {
  3927. isPlace = true;
  3928. }
  3929. bool isNeedUpdateCell2 = false;
  3930. if (entity.OrderState >= 6)
  3931. {
  3932. isNeedUpdateCell2 = true;
  3933. }
  3934. int returnTag = 2;
  3935. if (userpost == "Supplier")
  3936. {
  3937. returnTag = 1;
  3938. }
  3939. int toType = GetPostInt("totype");
  3940. string fromType = "3";
  3941. if (entity.OrderState < 5)
  3942. {
  3943. fromType = "3";
  3944. }
  3945. else
  3946. {
  3947. fromType = "4";
  3948. }
  3949. if (entity.IsXianHuo == 0)
  3950. {
  3951. if (returnTag == 2)
  3952. {
  3953. if (toType == 1)
  3954. {
  3955. entity.OrderState = 0;
  3956. entity.ReturnUserType = 1;
  3957. string clearman = GetPostString("clearman");
  3958. if (!string.IsNullOrEmpty(clearman))
  3959. {
  3960. entity.DesignUserId = 0;
  3961. }
  3962. }
  3963. else
  3964. {
  3965. entity.OrderState = 3;
  3966. entity.ReturnUserType = 2;
  3967. }
  3968. entity.IsReadTag = 1;
  3969. }
  3970. else if (returnTag == 1)
  3971. {
  3972. entity.OrderState = 5;
  3973. }
  3974. entity.IsVerifyToSupplier = false;
  3975. }
  3976. if (entity.IsXianHuo == 1)
  3977. {
  3978. entity.OrderState = 5;
  3979. }
  3980. entity.UnusualTag = 0;
  3981. entity.UnusualTime = null;
  3982. entity.UnusualCon = "";
  3983. entity.IsReturn = returnTag;
  3984. entity.ReturnTime = DateTime.Now;
  3985. entity.UpdateTime = DateTime.Now;
  3986. entity.ReturnReason = GetPostString("returnreason");
  3987. entity.Update();
  3988. if (entity.OrderState == 3)
  3989. {
  3990. ApiVo apiVo = new ApiVo();
  3991. apiVo.orderNumber = entity.ctid;
  3992. apiVo.actionName = "rebutDesign";
  3993. apiVo.orderRemarks = entity.ReturnReason;
  3994. designHelper.API_WorkCore(apiVo);//rebutDesign
  3995. }
  3996. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3997. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3998. {
  3999. //dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  4000. }
  4001. //CeErpSukuraData.createInfo(entity.ctid, 5);
  4002. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4004. if (isPlace)
  4005. {
  4006. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4007. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4008. if (dth != null && dth.Rows.Count > 0)
  4009. {
  4010. dataSendOrderBean dataSendOrderBean = null;
  4011. foreach (DataRow item in dth.Rows)
  4012. {
  4013. try
  4014. {
  4015. dataSendOrderBean = new dataSendOrderBean();
  4016. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4017. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4018. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4019. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4020. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4021. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4022. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4023. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4024. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4025. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4026. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4027. dataSendOrderBean.Radio1723534706288 = "打回";
  4028. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4029. if (result != null)
  4030. {
  4031. if ("0".Equals(result.errcode))
  4032. {
  4033. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4034. }
  4035. else
  4036. {
  4037. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4038. }
  4039. }
  4040. }
  4041. catch (Exception ex)
  4042. {
  4043. }
  4044. }
  4045. }
  4046. }
  4047. /*if (isNeedUpdateCell2)
  4048. {
  4049. if (entity.MakeSupplier.IndexOf(",") != -1)
  4050. {
  4051. StringBuilder sql2 = new StringBuilder();
  4052. 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);
  4053. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4054. }
  4055. else
  4056. {
  4057. StringBuilder sql2 = new StringBuilder();
  4058. 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);
  4059. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4060. }
  4061. }*/
  4062. returnSuccessMsg("操作成功!");
  4063. return;
  4064. }
  4065. returnErrorMsg("找不到订单记录");
  4066. }
  4067. }
  4068. public void cyt_erp_returnreason()
  4069. {
  4070. if (UrlPostParmsCheck("ctid"))
  4071. {
  4072. string eid = GetPostString("ctid");
  4073. CeErpTradeCell entity = null;
  4074. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4075. string userpost = CurrentUser.UserPost.Post.Code;
  4076. if (entity != null)
  4077. {
  4078. if (entity.OrderState > 6)
  4079. {
  4080. returnErrorMsg("已发货无法打回!");
  4081. return;
  4082. }
  4083. JObject jsonObject = new JObject
  4084. {
  4085. { "Userid", "77886" },
  4086. { "Pwd", "lt666888" },
  4087. { "LTOrderId",eid }
  4088. };
  4089. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4090. JObject jsonObjects = JObject.Parse(response);
  4091. string msg = (string)jsonObjects["msg"];
  4092. if (msg != "取消成功")
  4093. {
  4094. returnErrorMsg(msg);
  4095. return;
  4096. }
  4097. bool isNeedUpdateCell2 = false;
  4098. if (entity.OrderState >= 6)
  4099. {
  4100. isNeedUpdateCell2 = true;
  4101. }
  4102. int returnTag = 2;
  4103. if (userpost == "Supplier")
  4104. {
  4105. returnTag = 1;
  4106. }
  4107. if (entity.IsXianHuo == 0)
  4108. {
  4109. if (returnTag == 2)
  4110. {
  4111. int toType = GetPostInt("totype");
  4112. if (toType == 1)
  4113. {
  4114. entity.OrderState = 0;
  4115. entity.ReturnUserType = 1;
  4116. }
  4117. else
  4118. {
  4119. entity.OrderState = 4;
  4120. entity.ReturnUserType = 2;
  4121. }
  4122. entity.IsReadTag = 1;
  4123. }
  4124. else if (returnTag == 1)
  4125. {
  4126. entity.OrderState = 5;
  4127. }
  4128. entity.IsVerifyToSupplier = false;
  4129. }
  4130. entity.UnusualTag = 0;
  4131. entity.UnusualTime = null;
  4132. entity.UnusualCon = "";
  4133. entity.IsReturn = returnTag;
  4134. entity.ReturnTime = DateTime.Now;
  4135. entity.ReturnReason = GetPostString("returnreason");
  4136. entity.Update();
  4137. if (entity.OrderState == 4)
  4138. {
  4139. ApiVo apiVo = new ApiVo();
  4140. apiVo.orderNumber = entity.ctid;
  4141. apiVo.actionName = "rebutDesign";
  4142. apiVo.orderRemarks = entity.ReturnReason;
  4143. designHelper.API_WorkCore(apiVo);//rebutDesign
  4144. }
  4145. CeErpSukuraData.createInfo(entity.ctid, 5);
  4146. //apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4147. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4148. if (isNeedUpdateCell2)
  4149. {
  4150. if (entity.MakeSupplier.IndexOf(",") != -1)
  4151. {
  4152. StringBuilder sql2 = new StringBuilder();
  4153. 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);
  4154. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4155. }
  4156. else
  4157. {
  4158. StringBuilder sql2 = new StringBuilder();
  4159. 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);
  4160. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4161. }
  4162. }
  4163. returnSuccessMsg("操作成功!");
  4164. return;
  4165. }
  4166. returnErrorMsg("找不到订单记录");
  4167. }
  4168. }
  4169. public void upd_erp_xianhuoreturntag()
  4170. {
  4171. if (UrlPostParmsCheck("ctid"))
  4172. {
  4173. string eids = GetPostString("ctid");
  4174. string[] ctids = eids.Split(',');
  4175. foreach (string ctid in ctids)
  4176. {
  4177. CeErpTradeCell entity = null;
  4178. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4179. if (entity != null)
  4180. {
  4181. entity.IsReturn = 0;
  4182. entity.Update();
  4183. CeErpSukuraData.createInfo(entity.ctid, 5);
  4184. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4185. }
  4186. }
  4187. returnSuccessMsg("操作成功!");
  4188. return;
  4189. }
  4190. }
  4191. public void get_erp_waitdeliverylist()
  4192. {
  4193. DataStruct dStruct = GetPostStruct();
  4194. List<string> lw = new List<string>();
  4195. string tid = GetPostString("ctid");
  4196. if (tid.Length > 0)
  4197. {
  4198. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4199. if (tid.Length > 5)
  4200. {
  4201. List<string> tids = getTidByCtidLike(tid);
  4202. if (tids.Count > 0 && tids.Count < 10)
  4203. {
  4204. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4205. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4206. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4207. {
  4208. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4209. }*/
  4210. }
  4211. }
  4212. lw.Add(tid_sql);
  4213. }
  4214. string shopname = GetPostString("shopname");
  4215. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4216. string buyernick = GetPostString("buyer_nick");
  4217. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4218. //if (tid.Length == 0 && buyernick.Length == 0)
  4219. //{
  4220. // lw.Add(string.Format("IsRefund<={0}", 1));
  4221. //}
  4222. string customer = GetPostString("customer");
  4223. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4224. string design = GetPostString("design");
  4225. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4226. string orderState = GetPostString("orderState");
  4227. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4228. string address = GetPostString("address");
  4229. 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));
  4230. string sellermemo = GetPostString("seller_memo");
  4231. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4232. string supplier = GetPostString("supplier");
  4233. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4234. string OrderArea = GetPostString("order_area");
  4235. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4236. string placedate1 = GetPostString("placedate1");
  4237. string placedate2 = GetPostString("placedate2");
  4238. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4239. if (fdw.Length > 0) lw.Add(fdw);
  4240. string price1 = GetPostString("price1");
  4241. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4242. string price2 = GetPostString("price2");
  4243. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4244. string unusualCon = GetPostString("unusualcon");
  4245. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4246. string otherMemo = GetPostString("otherMemo");
  4247. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4248. string posTag = CurrentUser.UserPost.Post.Code;
  4249. if (posTag == "Supplier")
  4250. {
  4251. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4252. }
  4253. else
  4254. {
  4255. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4256. {
  4257. string usershop = CurrentUser.User.pemShop;
  4258. lw.Add(string.Format("ShopId in ({0})", usershop));
  4259. }
  4260. }
  4261. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4262. lw.Add(string.Format("type != 'PDD' "));
  4263. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4264. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4265. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4266. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4267. writeGridDataTableJson(dStruct.TotalCount, dt);
  4268. }
  4269. public void get_erp_changedeliverylist()
  4270. {
  4271. DataStruct dStruct = GetPostStruct();
  4272. List<string> lw = new List<string>();
  4273. string tid = GetPostString("ctid");
  4274. if (tid.Length > 0)
  4275. {
  4276. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4277. if (tid.Length > 5)
  4278. {
  4279. List<string> tids = getTidByCtidLike(tid);
  4280. if (tids.Count > 0 && tids.Count < 10)
  4281. {
  4282. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4283. }
  4284. }
  4285. lw.Add(tid_sql);
  4286. }
  4287. string shopname = GetPostString("shopname");
  4288. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4289. string buyernick = GetPostString("buyer_nick");
  4290. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4291. //if (tid.Length == 0 && buyernick.Length == 0)
  4292. //{
  4293. // lw.Add(string.Format("IsRefund<={0}", 1));
  4294. //}
  4295. string customer = GetPostString("customer");
  4296. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4297. string design = GetPostString("design");
  4298. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4299. string orderState = GetPostString("orderState");
  4300. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4301. string address = GetPostString("address");
  4302. 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));
  4303. string sellermemo = GetPostString("seller_memo");
  4304. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4305. string supplier = GetPostString("supplier");
  4306. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4307. string OrderArea = GetPostString("order_area");
  4308. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4309. string placedate1 = GetPostString("placedate1");
  4310. string placedate2 = GetPostString("placedate2");
  4311. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4312. if (fdw.Length > 0) lw.Add(fdw);
  4313. string price1 = GetPostString("price1");
  4314. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4315. string price2 = GetPostString("price2");
  4316. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4317. string unusualCon = GetPostString("unusualcon");
  4318. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4319. string otherMemo = GetPostString("otherMemo");
  4320. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4321. string posTag = CurrentUser.UserPost.Post.Code;
  4322. if (posTag == "Supplier")
  4323. {
  4324. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4325. }
  4326. else
  4327. {
  4328. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4329. {
  4330. string usershop = CurrentUser.User.pemShop;
  4331. lw.Add(string.Format("ShopId in ({0})", usershop));
  4332. }
  4333. }
  4334. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4335. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4336. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4337. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4338. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4339. /*if (tid.Length > 0)
  4340. {
  4341. List<string> tids = new List<string>();
  4342. if (dt != null && dt.Rows.Count > 0)
  4343. {
  4344. foreach (DataRow item in dt.Rows)
  4345. {
  4346. tids.Add("'" + item["tid"] + "'");
  4347. }
  4348. }
  4349. if (tids.Count > 0)
  4350. {
  4351. lw.RemoveAt(0);
  4352. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4353. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4354. dt = WebCache.GetData("view_erptradecell", dStruct);
  4355. }
  4356. }*/
  4357. writeGridDataTableJson(dStruct.TotalCount, dt);
  4358. }
  4359. public void get_erp_pddderiving()
  4360. {
  4361. DataStruct dStruct = GetPostStruct();
  4362. List<string> lw = new List<string>();
  4363. string tid = GetPostString("ctid");
  4364. if (tid.Length > 0)
  4365. {
  4366. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4367. if (tid.Length > 5)
  4368. {
  4369. List<string> tids = getTidByCtidLike(tid);
  4370. if (tids.Count > 0 && tids.Count < 10)
  4371. {
  4372. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4373. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4374. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4375. {
  4376. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4377. }*/
  4378. }
  4379. }
  4380. lw.Add(tid_sql);
  4381. }
  4382. string shopname = GetPostString("shopname");
  4383. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4384. string buyernick = GetPostString("buyer_nick");
  4385. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4386. //if (tid.Length == 0 && buyernick.Length == 0)
  4387. //{
  4388. // lw.Add(string.Format("IsRefund<={0}", 1));
  4389. //}
  4390. string customer = GetPostString("customer");
  4391. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4392. string design = GetPostString("design");
  4393. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4394. string orderState = GetPostString("orderState");
  4395. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4396. string address = GetPostString("address");
  4397. 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));
  4398. string sellermemo = GetPostString("seller_memo");
  4399. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4400. string supplier = GetPostString("supplier");
  4401. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4402. string OrderArea = GetPostString("order_area");
  4403. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4404. string placedate1 = GetPostString("placedate1");
  4405. string placedate2 = GetPostString("placedate2");
  4406. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4407. if (fdw.Length > 0) lw.Add(fdw);
  4408. string price1 = GetPostString("price1");
  4409. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4410. string price2 = GetPostString("price2");
  4411. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4412. string unusualCon = GetPostString("unusualcon");
  4413. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4414. string posTag = CurrentUser.UserPost.Post.Code;
  4415. if (posTag == "Supplier")
  4416. {
  4417. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4418. }
  4419. else
  4420. {
  4421. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4422. {
  4423. string usershop = CurrentUser.User.pemShop;
  4424. lw.Add(string.Format("ShopId in ({0})", usershop));
  4425. }
  4426. }
  4427. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4428. lw.Add(string.Format("type = 'PDD' "));
  4429. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4430. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4431. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4432. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4433. /*if (tid.Length > 0)
  4434. {
  4435. List<string> tids = new List<string>();
  4436. if (dt != null && dt.Rows.Count > 0)
  4437. {
  4438. foreach (DataRow item in dt.Rows)
  4439. {
  4440. tids.Add("'" + item["tid"] + "'");
  4441. }
  4442. }
  4443. if (tids.Count > 0)
  4444. {
  4445. lw.RemoveAt(0);
  4446. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4447. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4448. dt = WebCache.GetData("view_erptradecell", dStruct);
  4449. }
  4450. }*/
  4451. writeGridDataTableJson(dStruct.TotalCount, dt);
  4452. }
  4453. public void get_erp_jdderiving()
  4454. {
  4455. DataStruct dStruct = GetPostStruct();
  4456. List<string> lw = new List<string>();
  4457. string tid = GetPostString("ctid");
  4458. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4459. string shopname = GetPostString("shopname");
  4460. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4461. string buyernick = GetPostString("buyer_nick");
  4462. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4463. //if (tid.Length == 0 && buyernick.Length == 0)
  4464. //{
  4465. // lw.Add(string.Format("IsRefund<={0}", 1));
  4466. //}
  4467. string customer = GetPostString("customer");
  4468. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4469. string design = GetPostString("design");
  4470. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4471. string orderState = GetPostString("orderState");
  4472. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4473. string address = GetPostString("address");
  4474. 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));
  4475. string sellermemo = GetPostString("seller_memo");
  4476. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4477. string supplier = GetPostString("supplier");
  4478. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4479. string OrderArea = GetPostString("order_area");
  4480. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4481. string placedate1 = GetPostString("placedate1");
  4482. string placedate2 = GetPostString("placedate2");
  4483. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4484. if (fdw.Length > 0) lw.Add(fdw);
  4485. string price1 = GetPostString("price1");
  4486. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4487. string price2 = GetPostString("price2");
  4488. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4489. string unusualCon = GetPostString("unusualcon");
  4490. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4491. string posTag = CurrentUser.UserPost.Post.Code;
  4492. if (posTag == "Supplier")
  4493. {
  4494. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4495. }
  4496. lw.Add(string.Format("OrderState = 6 "));
  4497. lw.Add(string.Format("type = 'JD' "));
  4498. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4499. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4500. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4501. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4502. writeGridDataTableJson(dStruct.TotalCount, dt);
  4503. }
  4504. public void get_erp_demoorderlist()
  4505. {
  4506. DataStruct dStruct = GetPostStruct();
  4507. List<string> lw = new List<string>();
  4508. string tid = GetPostString("ctid");
  4509. if (tid.Length > 0)
  4510. {
  4511. string select_tid = getTidByCtid(tid);
  4512. lw.Add(string.Format("tid='{0}'", select_tid));
  4513. }
  4514. string shopname = GetPostString("shopname");
  4515. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4516. string buyernick = GetPostString("buyer_nick");
  4517. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4518. string customer = GetPostString("customer");
  4519. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4520. string design = GetPostString("design");
  4521. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4522. string orderState = GetPostString("orderState");
  4523. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4524. string address = GetPostString("address");
  4525. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4526. string sellermemo = GetPostString("seller_memo");
  4527. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4528. string supplier = GetPostString("supplier");
  4529. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4530. string OrderArea = GetPostString("order_area");
  4531. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4532. string date1 = GetPostString("date1");
  4533. string date2 = GetPostString("date2");
  4534. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4535. if (dw.Length > 0) lw.Add(dw);
  4536. string price1 = GetPostString("price1");
  4537. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4538. string price2 = GetPostString("price2");
  4539. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4540. string posTag = CurrentUser.UserPost.Post.Code;
  4541. if (posTag == "Supplier")
  4542. {
  4543. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4544. }
  4545. //lw.Add(string.Format("OrderState = 6 "));
  4546. lw.Add(string.Format("IsSample={0}", 3));
  4547. lw.Add(string.Format("IsRefund<={0}", 1));
  4548. dStruct.Order = "pay_time desc";
  4549. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4550. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4551. writeGridDataTableJson(dStruct.TotalCount, dt);
  4552. }
  4553. public void save_erp_checkmemo()
  4554. {
  4555. if (UrlPostParmsCheck("ctid"))
  4556. {
  4557. string ctid = GetPostString("ctid");
  4558. CeErpTradeCell entity = null;
  4559. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4560. if (entity != null)
  4561. {
  4562. entity.CheckMemo = GetPostString("CheckMemo");
  4563. entity.Update();
  4564. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4565. if (trade != null)
  4566. {
  4567. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4568. }
  4569. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4570. returnSuccessMsg("保存成功!");
  4571. return;
  4572. }
  4573. returnErrorMsg("找不到记录");
  4574. }
  4575. }
  4576. public void get_erp_returnlist()
  4577. {
  4578. DataStruct dStruct = GetPostStruct();
  4579. List<string> lw = new List<string>();
  4580. string tid = GetPostString("ctid");
  4581. if (tid.Length > 0)
  4582. {
  4583. string select_tid = getTidByCtid(tid);
  4584. lw.Add(string.Format("tid='{0}'", select_tid));
  4585. }
  4586. string shopname = GetPostString("shopname");
  4587. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4588. string buyernick = GetPostString("buyer_nick");
  4589. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4590. string customer = GetPostString("customer");
  4591. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4592. string design = GetPostString("design");
  4593. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4594. string orderState = GetPostString("orderState");
  4595. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4596. string address = GetPostString("address");
  4597. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4598. string sellermemo = GetPostString("seller_memo");
  4599. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4600. string supplier = GetPostString("supplier");
  4601. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4602. string date1 = GetPostString("date1");
  4603. string date2 = GetPostString("date2");
  4604. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4605. if (dw.Length > 0) lw.Add(dw);
  4606. string bdate1 = GetPostString("backdate1");
  4607. string bdate2 = GetPostString("backdate2");
  4608. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4609. if (dw_back.Length > 0) lw.Add(dw_back);
  4610. string price1 = GetPostString("price1");
  4611. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4612. string price2 = GetPostString("price2");
  4613. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4614. lw.Add(string.Format("IsReturn>0"));
  4615. lw.Add(string.Format("IsXianHuo=0"));
  4616. lw.Add(string.Format("IsReturn!=3"));
  4617. string backtype = GetPostString("backtype");
  4618. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4619. dStruct.Order = "FinishDesignTime desc";
  4620. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4621. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4622. writeGridDataTableJson(dStruct.TotalCount, dt);
  4623. }
  4624. public void get_erp_today_sumreturn()
  4625. {
  4626. DataStruct dStruct = GetPostStruct();
  4627. List<string> lw = new List<string>();
  4628. string bdate1 = GetPostString("returnTimeS");
  4629. string bdate2 = GetPostString("returnTimeE");
  4630. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4631. if (dw_back.Length > 0) lw.Add(dw_back);
  4632. lw.Add(string.Format("IsReturn=0"));
  4633. lw.Add(string.Format("IsXianHuo=0"));
  4634. string mainWhere = string.Join(" and ", lw.ToArray());
  4635. string sql = "";
  4636. if (dw_back.Length > 0)
  4637. {
  4638. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4639. }
  4640. else
  4641. {
  4642. 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 + "'";
  4643. }
  4644. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4645. decimal total = 0, today_finish = 0;
  4646. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4647. {
  4648. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4649. }
  4650. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4651. {
  4652. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4653. }
  4654. var res = new
  4655. {
  4656. data = total,
  4657. data1 = today_finish,
  4658. };
  4659. string ro_jsond = JsonConvert.SerializeObject(res);
  4660. returnSuccess(ro_jsond);
  4661. return;
  4662. }
  4663. public void get_erp_allreturnlist()
  4664. {
  4665. DataStruct dStruct = GetPostStruct();
  4666. List<string> lw = new List<string>();
  4667. string tid = GetPostString("ctid");
  4668. if (tid.Length > 0)
  4669. {
  4670. string select_tid = getTidByCtid(tid);
  4671. lw.Add(string.Format("tid='{0}'", select_tid));
  4672. }
  4673. string shopname = GetPostString("shopname");
  4674. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4675. string buyernick = GetPostString("buyer_nick");
  4676. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4677. string customer = GetPostString("customer");
  4678. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4679. string design = GetPostString("design");
  4680. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4681. string orderState = GetPostString("orderState");
  4682. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4683. string address = GetPostString("address");
  4684. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4685. string sellermemo = GetPostString("seller_memo");
  4686. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4687. string supplier = GetPostString("supplier");
  4688. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4689. string date1 = GetPostString("date1");
  4690. string date2 = GetPostString("date2");
  4691. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4692. if (dw.Length > 0) lw.Add(dw);
  4693. string bdate1 = GetPostString("backdate1");
  4694. string bdate2 = GetPostString("backdate2");
  4695. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4696. if (dw_back.Length > 0) lw.Add(dw_back);
  4697. string price1 = GetPostString("price1");
  4698. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4699. string price2 = GetPostString("price2");
  4700. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4701. string backreason = GetPostString("backreason");
  4702. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4703. lw.Add(string.Format("IsXianHuo=0"));
  4704. lw.Add(string.Format("ReturnTime != ''"));
  4705. string backtype = GetPostString("backtype");
  4706. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4707. string posTag = CurrentUser.UserPost.Post.Code;
  4708. if (posTag == "Supplier")
  4709. {
  4710. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4711. }
  4712. else
  4713. {
  4714. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4715. {
  4716. string usershop = CurrentUser.User.pemShop;
  4717. lw.Add(string.Format("ShopId in ({0})", usershop));
  4718. }
  4719. }
  4720. dStruct.Order = "FinishDesignTime desc";
  4721. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4722. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4723. writeGridDataTableJson(dStruct.TotalCount, dt);
  4724. }
  4725. public void get_erp_aftersalereturnlist()
  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=3"));
  4764. string backtype = GetPostString("backtype");
  4765. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4766. string backreason = GetPostString("backreason");
  4767. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4768. dStruct.Order = "ReturnTime 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_xianhuoreturnlist()
  4774. {
  4775. DataStruct dStruct = GetPostStruct();
  4776. List<string> lw = new List<string>();
  4777. string tid = GetPostString("ctid");
  4778. if (tid.Length > 0)
  4779. {
  4780. string select_tid = getTidByCtid(tid);
  4781. lw.Add(string.Format("tid='{0}'", select_tid));
  4782. }
  4783. string shopname = GetPostString("shopname");
  4784. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4785. string buyernick = GetPostString("buyer_nick");
  4786. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4787. string customer = GetPostString("customer");
  4788. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4789. string design = GetPostString("design");
  4790. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4791. string orderState = GetPostString("orderState");
  4792. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4793. string address = GetPostString("address");
  4794. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4795. string sellermemo = GetPostString("seller_memo");
  4796. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4797. string supplier = GetPostString("supplier");
  4798. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4799. string OrderArea = GetPostString("order_area");
  4800. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4801. string date1 = GetPostString("date1");
  4802. string date2 = GetPostString("date2");
  4803. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4804. if (dw.Length > 0) lw.Add(dw);
  4805. string price1 = GetPostString("price1");
  4806. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4807. string price2 = GetPostString("price2");
  4808. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4809. string posTag = CurrentUser.UserPost.Post.Code;
  4810. if (posTag == "Supplier")
  4811. {
  4812. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4813. }
  4814. lw.Add(string.Format("OrderState=6 "));
  4815. lw.Add(string.Format("IsXianHuo=1 "));
  4816. lw.Add(string.Format("IsReturn>0 "));
  4817. lw.Add(string.Format("IsReturn!=3"));
  4818. lw.Add(string.Format("IsRefund<={0}", 1));
  4819. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4820. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4821. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4822. writeGridDataTableJson(dStruct.TotalCount, dt);
  4823. }
  4824. public void set_erp_orderdelivery()
  4825. {
  4826. if (UrlPostParmsCheck("ctid"))
  4827. {
  4828. string eid = GetPostString("ctid");
  4829. CeErpTradeCell entity = null;
  4830. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4831. if (entity != null)
  4832. {
  4833. if (entity.OrderState >= 7)
  4834. {
  4835. returnErrorMsg("此单已发货,无需重复发货");
  4836. return;
  4837. }
  4838. if (entity.OrderState != 6)
  4839. {
  4840. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4841. return;
  4842. }
  4843. string shop = GetPostString("seller_nick");
  4844. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4845. string comName = GetPostString("comName");
  4846. string comCode = GetPostString("comCode");
  4847. string outSid = GetPostString("outSid");
  4848. string deliveryType = GetPostString("deliveryType");
  4849. string deliveryMemo = GetPostString("deliveryMemo");
  4850. outSid = outSid.Trim();
  4851. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4852. if (mainEn == null)
  4853. {
  4854. returnErrorMsg("找不到原始订单记录");
  4855. return;
  4856. }
  4857. bool isInitOrderDeliv = false;
  4858. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4859. {
  4860. isInitOrderDeliv = true;
  4861. }
  4862. string apires = "";
  4863. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4864. 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)
  4865. {
  4866. apires = "发货成功true";
  4867. }
  4868. else
  4869. {
  4870. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4871. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid, entity.ctid);
  4872. }
  4873. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4874. {
  4875. entity.OrderState = 7;//发货后订单已发货
  4876. entity.OutSid = outSid;
  4877. entity.MemoOpt = 0;
  4878. entity.UpdateTime = DateTime.Now;
  4879. entity.FinishDeliveryTime = DateTime.Now;
  4880. entity.Update();
  4881. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4882. commonHelper.UpdateRelationOrder(entity.ctid);
  4883. //还要插入快递信息到 快递信息表
  4884. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4885. exinfo.tid = eid;
  4886. exinfo.out_sid = outSid;
  4887. exinfo.company_code = comCode;
  4888. exinfo.company_name = comName;
  4889. exinfo.delivery_memo = deliveryMemo;
  4890. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4891. exinfo.deliveryType = deliveryType;
  4892. exinfo.printUser = CurrentUser.UserName;
  4893. exinfo.print_time = DateTime.Now;
  4894. exinfo.Create();
  4895. returnSuccessMsg("发货操作成功!");
  4896. commonHelper.UpdateRelationOrder(entity.ctid);
  4897. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4898. CeErpSukuraData.createInfo(entity.ctid, 4);
  4899. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4900. {
  4901. commonHelper.sendCytExpress(exinfo);
  4902. }
  4903. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4904. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4905. }
  4906. else
  4907. {
  4908. string errmsg = commonHelper.KeepChinese(apires);
  4909. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4910. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4911. }
  4912. return;
  4913. }
  4914. returnErrorMsg("找不到订单记录");
  4915. }
  4916. }
  4917. public void set_erp_multidelivery()
  4918. {
  4919. string eids = GetPostString("tids");
  4920. string[] eidList = eids.Split(',');
  4921. if (eidList.Length <= 0)
  4922. {
  4923. returnErrorMsg("发货不能为空");
  4924. return;
  4925. }
  4926. foreach (string ctid in eidList)
  4927. {
  4928. if (ctid.Length <= 0) continue;
  4929. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4930. if (expInfo != null)
  4931. {
  4932. StringBuilder sql = new StringBuilder();
  4933. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4934. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4935. if (dt.Rows.Count > 0)
  4936. {
  4937. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4938. {
  4939. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4940. expInfo.state = "异常";
  4941. expInfo.isMultiDelivery = 1;
  4942. expInfo.Update();
  4943. continue;
  4944. }
  4945. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4946. {
  4947. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4948. expInfo.state = "异常";
  4949. expInfo.Update();
  4950. continue;
  4951. }
  4952. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4953. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4954. bool isInitOrderDeliv = false;
  4955. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4956. {
  4957. isInitOrderDeliv = true;
  4958. expInfo.isMultiDelivery = 1;
  4959. }
  4960. if (ctid.IndexOf("N") != -1)
  4961. {
  4962. StringBuilder sqlbucha = new StringBuilder();
  4963. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4964. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4965. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4966. commonHelper.UpdateRelationOrder(ctid);
  4967. expInfo.delivery_memo = "发货成功";
  4968. expInfo.state = "发货成功";
  4969. expInfo.isMultiDelivery = 1;
  4970. expInfo.Update();
  4971. }
  4972. else
  4973. {
  4974. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4975. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid, ctid);
  4976. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4977. {
  4978. expInfo.delivery_memo = "发货成功";
  4979. expInfo.state = "发货成功";
  4980. expInfo.isMultiDelivery = 1;
  4981. expInfo.Update();
  4982. commonHelper.UpdateRelationOrder(ctid);
  4983. CeErpSukuraData.createInfo(ctid, 4);
  4984. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4985. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4986. }
  4987. else
  4988. {
  4989. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4990. expInfo.state = "异常";
  4991. expInfo.Update();
  4992. }
  4993. }
  4994. }
  4995. }
  4996. }
  4997. returnSuccessMsg("操作完成");
  4998. }
  4999. public void reset_erp_memoopt()
  5000. {
  5001. if (UrlPostParmsCheck("ctid"))
  5002. {
  5003. string eid = GetPostString("ctid");
  5004. CeErpTradeCell entity = null;
  5005. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5006. if (entity != null)
  5007. {
  5008. string stropt = "";
  5009. if (entity.MemoOpt == 1)
  5010. {
  5011. stropt = "“改稿”";
  5012. }
  5013. else if (entity.MemoOpt == 2)
  5014. {
  5015. stropt = "“定稿”";
  5016. }
  5017. else if (entity.MemoOpt == 3)
  5018. {
  5019. stropt = "“完成查货”";
  5020. CeErpSukuraData.createInfo(entity.ctid, 6);
  5021. }
  5022. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  5023. entity.UpdateTime = DateTime.Now;
  5024. entity.MemoOpt = 0;
  5025. entity.Update();
  5026. returnSuccessMsg("操作成功!");
  5027. return;
  5028. }
  5029. returnErrorMsg("找不到记录");
  5030. }
  5031. }
  5032. public void get_erp_deliveryunusual()
  5033. {
  5034. DataStruct dStruct = GetPostStruct();
  5035. List<string> lw = new List<string>();
  5036. string tid = GetPostString("ctid");
  5037. if (tid.Length > 0)
  5038. {
  5039. string select_tid = getTidByCtid(tid);
  5040. lw.Add(string.Format("tid='{0}'", select_tid));
  5041. }
  5042. string shopname = GetPostString("shopname");
  5043. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5044. string buyernick = GetPostString("buyer_nick");
  5045. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5046. string customer = GetPostString("customer");
  5047. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5048. string design = GetPostString("design");
  5049. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5050. string sellermemo = GetPostString("seller_memo");
  5051. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5052. string supplier = GetPostString("supplier");
  5053. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5054. string date1 = GetPostString("date1");
  5055. string date2 = GetPostString("date2");
  5056. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5057. if (dw.Length > 0) lw.Add(dw);
  5058. string placedate1 = GetPostString("placedate1");
  5059. string placedate2 = GetPostString("placedate2");
  5060. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5061. if (dw_place.Length > 0) lw.Add(dw_place);
  5062. string price1 = GetPostString("price1");
  5063. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5064. string price2 = GetPostString("price2");
  5065. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5066. string unusualCon = GetPostString("unusualcon");
  5067. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5068. string posTag = CurrentUser.UserPost.Post.Code;
  5069. if (posTag == "Supplier")
  5070. {
  5071. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5072. }
  5073. lw.Add(string.Format("OrderState = 6"));
  5074. lw.Add(string.Format("UnusualTag = 5"));
  5075. lw.Add(string.Format("IsRefund<={0}", 1));
  5076. dStruct.Order = "FinishPlaceTime desc";
  5077. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5078. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5079. writeGridDataTableJson(dStruct.TotalCount, dt);
  5080. }
  5081. public void get_erp_deliveryedlist()
  5082. {
  5083. DataStruct dStruct = GetPostStruct();
  5084. List<string> lw = new List<string>();
  5085. string tid = GetPostString("ctid");
  5086. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5087. string shopname = GetPostString("shopname");
  5088. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5089. string buyernick = GetPostString("buyer_nick");
  5090. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5091. string customer = GetPostString("customer");
  5092. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5093. string design = GetPostString("design");
  5094. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5095. string sellermemo = GetPostString("seller_memo");
  5096. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5097. string logistics = GetPostString("logistics");
  5098. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5099. string date1 = GetPostString("date1");
  5100. string date2 = GetPostString("date2");
  5101. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5102. //if (dw.Length > 0) lw.Add(dw);
  5103. string placedate1 = GetPostString("placedate1");
  5104. string placedate2 = GetPostString("placedate2");
  5105. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5106. if (fdw.Length > 0) lw.Add(fdw);
  5107. string devdate1 = GetPostString("deliverydate1");
  5108. string devdate2 = GetPostString("deliverydate2");
  5109. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5110. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5111. string price1 = GetPostString("price1");
  5112. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5113. string price2 = GetPostString("price2");
  5114. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5115. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5116. {
  5117. if (tid.Length > 0)
  5118. {
  5119. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5120. if (tid.Length > 5)
  5121. {
  5122. List<string> tids = getTidByCtidLike(tid);
  5123. if (tids.Count > 0 && tids.Count < 10)
  5124. {
  5125. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5126. }
  5127. }
  5128. lw.Add(tid_sql);
  5129. }
  5130. if (buyernick.Length > 0)
  5131. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5132. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5133. if (dw.Length > 0) lw.Add(dw);
  5134. }
  5135. else
  5136. {
  5137. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5138. }
  5139. string posTag = CurrentUser.UserPost.Post.Code;
  5140. if (posTag == "Supplier")
  5141. {
  5142. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5143. }
  5144. else
  5145. {
  5146. string supplier = GetPostString("supplier");
  5147. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5148. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5149. {
  5150. string usershop = CurrentUser.User.pemShop;
  5151. lw.Add(string.Format("ShopId in ({0})", usershop));
  5152. }
  5153. }
  5154. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5155. lw.Add(string.Format("type != 'PDD' "));
  5156. lw.Add(string.Format("IsRefund!={0}", 2));
  5157. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5158. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5159. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5160. /*if (tid.Length > 0)
  5161. {
  5162. List<string> tids = new List<string>();
  5163. if (dt != null && dt.Rows.Count > 0)
  5164. {
  5165. foreach (DataRow item in dt.Rows)
  5166. {
  5167. tids.Add("'" + item["tid"] + "'");
  5168. }
  5169. }
  5170. if (tids.Count > 0)
  5171. {
  5172. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5173. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5174. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5175. dt = WebCache.GetData("view_erptradecell", dStruct);
  5176. }
  5177. }*/
  5178. if (dt != null)
  5179. {
  5180. foreach (DataRow dr in dt.Rows)
  5181. {
  5182. 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();
  5183. }
  5184. }
  5185. writeGridDataTableJson(dStruct.TotalCount, dt);
  5186. }
  5187. public void get_erp_pdddeliveryed()
  5188. {
  5189. DataStruct dStruct = GetPostStruct();
  5190. List<string> lw = new List<string>();
  5191. string tid = GetPostString("ctid");
  5192. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5193. string shopname = GetPostString("shopname");
  5194. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5195. string buyernick = GetPostString("buyer_nick");
  5196. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5197. string customer = GetPostString("customer");
  5198. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5199. string design = GetPostString("design");
  5200. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5201. string sellermemo = GetPostString("seller_memo");
  5202. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5203. string logistics = GetPostString("logistics");
  5204. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5205. string date1 = GetPostString("date1");
  5206. string date2 = GetPostString("date2");
  5207. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5208. //if (dw.Length > 0) lw.Add(dw);
  5209. string placedate1 = GetPostString("placedate1");
  5210. string placedate2 = GetPostString("placedate2");
  5211. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5212. if (fdw.Length > 0) lw.Add(fdw);
  5213. string devdate1 = GetPostString("deliverydate1");
  5214. string devdate2 = GetPostString("deliverydate2");
  5215. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5216. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5217. string price1 = GetPostString("price1");
  5218. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5219. string price2 = GetPostString("price2");
  5220. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5221. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5222. {
  5223. if (tid.Length > 0)
  5224. {
  5225. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5226. if (tid.Length > 5)
  5227. {
  5228. List<string> tids = getTidByCtidLike(tid);
  5229. if (tids.Count > 0 && tids.Count < 10)
  5230. {
  5231. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5232. }
  5233. }
  5234. lw.Add(tid_sql);
  5235. }
  5236. if (buyernick.Length > 0)
  5237. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5238. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5239. if (dw.Length > 0) lw.Add(dw);
  5240. }
  5241. else
  5242. {
  5243. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5244. }
  5245. string posTag = CurrentUser.UserPost.Post.Code;
  5246. if (posTag == "Supplier")
  5247. {
  5248. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5249. }
  5250. else
  5251. {
  5252. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5253. {
  5254. string usershop = CurrentUser.User.pemShop;
  5255. lw.Add(string.Format("ShopId in ({0})", usershop));
  5256. }
  5257. string supplier = GetPostString("supplier");
  5258. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5259. }
  5260. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5261. lw.Add(string.Format("type = 'PDD' "));
  5262. lw.Add(string.Format("IsRefund!={0}", 2));
  5263. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5264. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5265. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5266. /* if (tid.Length > 0)
  5267. {
  5268. List<string> tids = new List<string>();
  5269. if (dt != null && dt.Rows.Count > 0)
  5270. {
  5271. foreach (DataRow item in dt.Rows)
  5272. {
  5273. tids.Add("'" + item["tid"] + "'");
  5274. }
  5275. }
  5276. if (tids.Count > 0)
  5277. {
  5278. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5279. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5280. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5281. dt = WebCache.GetData("view_erptradecell", dStruct);
  5282. }
  5283. }*/
  5284. foreach (DataRow dr in dt.Rows)
  5285. {
  5286. 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();
  5287. }
  5288. writeGridDataTableJson(dStruct.TotalCount, dt);
  5289. }
  5290. public void get_erp_jddeliveryed()
  5291. {
  5292. DataStruct dStruct = GetPostStruct();
  5293. List<string> lw = new List<string>();
  5294. string tid = GetPostString("ctid");
  5295. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5296. string shopname = GetPostString("shopname");
  5297. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5298. string buyernick = GetPostString("buyer_nick");
  5299. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5300. string customer = GetPostString("customer");
  5301. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5302. string design = GetPostString("design");
  5303. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5304. string sellermemo = GetPostString("seller_memo");
  5305. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5306. string date1 = GetPostString("date1");
  5307. string date2 = GetPostString("date2");
  5308. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5309. //if (dw.Length > 0) lw.Add(dw);
  5310. string placedate1 = GetPostString("placedate1");
  5311. string placedate2 = GetPostString("placedate2");
  5312. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5313. if (fdw.Length > 0) lw.Add(fdw);
  5314. string devdate1 = GetPostString("deliverydate1");
  5315. string devdate2 = GetPostString("deliverydate2");
  5316. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5317. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5318. string price1 = GetPostString("price1");
  5319. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5320. string price2 = GetPostString("price2");
  5321. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5322. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5323. {
  5324. if (tid.Length > 0)
  5325. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5326. if (buyernick.Length > 0)
  5327. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5328. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5329. if (dw.Length > 0) lw.Add(dw);
  5330. }
  5331. else
  5332. {
  5333. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5334. }
  5335. string posTag = CurrentUser.UserPost.Post.Code;
  5336. if (posTag == "Supplier")
  5337. {
  5338. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5339. }
  5340. else
  5341. {
  5342. string supplier = GetPostString("supplier");
  5343. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5344. }
  5345. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5346. lw.Add(string.Format("type = 'JD' "));
  5347. lw.Add(string.Format("IsRefund!={0}", 2));
  5348. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5349. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5350. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5351. foreach (DataRow dr in dt.Rows)
  5352. {
  5353. 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();
  5354. }
  5355. writeGridDataTableJson(dStruct.TotalCount, dt);
  5356. }
  5357. public void get_erp_allplacelist()
  5358. {
  5359. DataStruct dStruct = GetPostStruct();
  5360. List<string> lw = new List<string>();
  5361. string tid = GetPostString("ctid");
  5362. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5363. string shopname = GetPostString("shopname");
  5364. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5365. string buyernick = GetPostString("buyer_nick");
  5366. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5367. string customer = GetPostString("customer");
  5368. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5369. string design = GetPostString("design");
  5370. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5371. string sellermemo = GetPostString("seller_memo");
  5372. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5373. string supplier = GetPostString("supplier");
  5374. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5375. string date1 = GetPostString("date1");
  5376. string date2 = GetPostString("date2");
  5377. string pldate1 = GetPostString("placedate1");
  5378. string pldate2 = GetPostString("placedate2");
  5379. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5380. //if (dw.Length > 0) lw.Add(dw);
  5381. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5382. {
  5383. if (tid.Length > 0)
  5384. {
  5385. string select_tid = getTidByCtid(tid);
  5386. lw.Add(string.Format("tid='{0}'", select_tid));
  5387. }
  5388. if (buyernick.Length > 0)
  5389. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5390. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5391. if (dw.Length > 0) lw.Add(dw);
  5392. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5393. if (dw_place.Length > 0) lw.Add(dw_place);
  5394. }
  5395. else
  5396. {
  5397. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5398. {
  5399. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5400. }
  5401. }
  5402. string price1 = GetPostString("price1");
  5403. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5404. string price2 = GetPostString("price2");
  5405. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5406. string posTag = CurrentUser.UserPost.Post.Code;
  5407. if (posTag == "Supplier")
  5408. {
  5409. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5410. }
  5411. lw.Add(string.Format("OrderState >= 6"));
  5412. lw.Add(string.Format("IsSample != 2 "));
  5413. //lw.Add(string.Format("isDianziOrder = 0 "));
  5414. lw.Add(string.Format("SupplierId > 0 "));
  5415. //lw.Add(string.Format("IsRefund<={0}", 1));
  5416. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5417. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5418. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5419. foreach (DataRow dr in dt.Rows)
  5420. {
  5421. 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();
  5422. }
  5423. writeGridDataTableJson(dStruct.TotalCount, dt);
  5424. }
  5425. public void get_erp_financeallplacelist()
  5426. {
  5427. DataStruct dStruct = GetPostStruct();
  5428. List<string> lw = new List<string>();
  5429. string tid = GetPostString("ctid");
  5430. string shopname = GetPostString("shopname");
  5431. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5432. string buyernick = GetPostString("buyer_nick");
  5433. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5434. string customer = GetPostString("customer");
  5435. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5436. string design = GetPostString("design");
  5437. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5438. string sellermemo = GetPostString("seller_memo");
  5439. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5440. string supplier = GetPostString("supplier");
  5441. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5442. string date1 = GetPostString("date1");
  5443. string date2 = GetPostString("date2");
  5444. string pldate1 = GetPostString("placedate1");
  5445. string pldate2 = GetPostString("placedate2");
  5446. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5447. {
  5448. if (tid.Length > 0)
  5449. {
  5450. string select_tid = getTidByCtid(tid);
  5451. lw.Add(string.Format("tid='{0}'", select_tid));
  5452. }
  5453. if (buyernick.Length > 0)
  5454. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5455. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5456. if (dw.Length > 0) lw.Add(dw);
  5457. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5458. if (dw_place.Length > 0) lw.Add(dw_place);
  5459. }
  5460. else
  5461. {
  5462. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5463. {
  5464. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5465. }
  5466. }
  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. string posTag = CurrentUser.UserPost.Post.Code;
  5472. if (posTag == "Supplier")
  5473. {
  5474. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5475. }
  5476. //lw.Add(string.Format("OrderState >= 6"));
  5477. lw.Add(string.Format("IsSample != 2 "));
  5478. lw.Add(string.Format("isDianziOrder = 0 "));
  5479. //lw.Add(string.Format("IsRefund<={0}", 1));
  5480. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5481. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5482. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5483. foreach (DataRow dr in dt.Rows)
  5484. {
  5485. 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();
  5486. }
  5487. writeGridDataTableJson(dStruct.TotalCount, dt);
  5488. }
  5489. public void get_erp_expresslist()
  5490. {
  5491. int listtype = GetInt("ltype");
  5492. DataStruct dStruct = GetPostStruct();
  5493. List<string> lw = new List<string>();
  5494. string tid = GetPostString("tid");
  5495. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5496. string outsid = GetPostString("out_sid");
  5497. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5498. string importer = GetPostString("ImportUserName");
  5499. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5500. string file = GetPostString("import_file");
  5501. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5502. string printman = GetPostString("printman");
  5503. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5504. string date1 = GetPostString("date1");
  5505. string date2 = GetPostString("date2");
  5506. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5507. if (dw.Length > 0) lw.Add(dw);
  5508. string fdate1 = GetPostString("finishdate1");
  5509. string fdate2 = GetPostString("finishdate2");
  5510. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5511. if (fdw.Length > 0) lw.Add(fdw);
  5512. string supplierId = GetPostString("supplierId");
  5513. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5514. if (listtype == 1)
  5515. {
  5516. lw.Add(string.Format("importUserId !=0"));
  5517. }
  5518. string posTag = CurrentUser.UserPost.Post.Code;
  5519. if (posTag == "Supplier")
  5520. {
  5521. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5522. }
  5523. if (dStruct.PageSize != 100000)
  5524. {
  5525. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5526. }
  5527. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5528. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5529. writeGridDataTableJson(dStruct.TotalCount, dt);
  5530. }
  5531. public void set_erp_buchaorderdelivery()
  5532. {
  5533. if (UrlPostParmsCheck("ctid"))
  5534. {
  5535. string eid = GetPostString("ctid");
  5536. CeErpTradeCell entity = null;
  5537. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5538. if (entity != null)
  5539. {
  5540. if (entity.IsSample != 2)
  5541. {
  5542. returnErrorMsg("补差价单才能标记为已发货");
  5543. return;
  5544. }
  5545. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5546. entity.OrderState = 7;
  5547. entity.Update();
  5548. returnSuccessMsg("操作成功!");
  5549. return;
  5550. }
  5551. returnErrorMsg("找不到记录");
  5552. }
  5553. }
  5554. public void get_stdtemplates()
  5555. {
  5556. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5557. //string res = taobaoHelper.test();
  5558. string res = apiHelper.API_PrintTemplate();
  5559. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5560. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5561. {
  5562. int sidx = res.IndexOf("error_code");
  5563. int eidx = res.IndexOf("success");
  5564. string msg = res.Substring(sidx, eidx - sidx);
  5565. returnErrorMsg(msg);
  5566. return;
  5567. }
  5568. if (res.Length <= 0)
  5569. {
  5570. returnErrorMsg("模板数据为空!");
  5571. return;
  5572. }
  5573. ReturnSuccess(res);
  5574. }
  5575. public void cancel_print_order()
  5576. {
  5577. if (UrlPostParmsCheck("ctid"))
  5578. {
  5579. string ctid = GetPostString("ctid");
  5580. CeErpTradeCell entity = null;
  5581. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5582. if (entity != null)
  5583. {
  5584. string res = "";
  5585. string code = entity.LastBillWaybillCode;
  5586. if (code == "")
  5587. {
  5588. code = entity.OutSid;
  5589. }
  5590. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5591. XLog.SaveLog(0, "取消面单" + res);
  5592. }
  5593. }
  5594. }
  5595. public void set_erp_printwaybill()
  5596. {
  5597. if (UrlPostParmsCheck("ctid"))
  5598. {
  5599. string ctid = GetPostString("ctid");
  5600. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5601. string cpName = GetPostString("cpname");
  5602. string isTogether = GetPostString("together");
  5603. string printType = GetPostString("printType");
  5604. //var res_obj = new
  5605. //{
  5606. // restype = 1,
  5607. // 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\"}"
  5608. //};
  5609. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5610. //ReturnSuccess(ro_json);
  5611. //return;
  5612. bool isUseLastWayBillCode = false;
  5613. CeErpTradeCell entity = null;
  5614. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5615. if (entity != null)
  5616. {
  5617. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5618. {
  5619. isUseLastWayBillCode = true;
  5620. }
  5621. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5622. {
  5623. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5624. return;
  5625. }
  5626. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5627. {
  5628. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5629. return;
  5630. }
  5631. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5632. {
  5633. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5634. return;
  5635. }
  5636. }
  5637. string res = "";
  5638. Api_waybill_code_response_Obj fullObj = null;
  5639. string pData_str = "";
  5640. string curUseWayBillCode = "";
  5641. if (isUseLastWayBillCode == false)
  5642. {
  5643. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5644. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5645. if (res.IndexOf("failure") != -1)
  5646. {
  5647. //int idx = res.IndexOf("sub_message");
  5648. //int idx2 = res.IndexOf("flag");
  5649. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5650. string errMsgNeed = commonHelper.KeepChinese(res);
  5651. var res_objd = new
  5652. {
  5653. restype = 0,
  5654. data = "获取面单失败" + errMsgNeed
  5655. };
  5656. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5657. returnSuccess(ro_jsond);
  5658. if (res.IndexOf("停发") != -1)
  5659. {
  5660. entity.UnusualCon = "物流停发";
  5661. entity.Update();
  5662. }
  5663. //returnErrorMsg("获取面单失败,"+emsg);
  5664. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5665. return;
  5666. }
  5667. else if (res.IndexOf("errorMsg") != -1)
  5668. {
  5669. //int idx = res.IndexOf("errorMsg");
  5670. //int idx2 = res.IndexOf("}]}");
  5671. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5672. string errMsgNeed = commonHelper.KeepChinese(res);
  5673. var res_objf = new
  5674. {
  5675. restype = 0,
  5676. data = "获取面单失败2" + errMsgNeed
  5677. };
  5678. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5679. if (res.IndexOf("停发") != -1)
  5680. {
  5681. entity.UnusualCon = "物流停发";
  5682. entity.Update();
  5683. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5684. if (trade != null)
  5685. {
  5686. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5687. }
  5688. }
  5689. returnSuccess(ro_jsonf);
  5690. //returnErrorMsg("获取面单失败," + emsg);
  5691. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5692. return;
  5693. }
  5694. try
  5695. {
  5696. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5697. //res = res.Replace(" ", "");
  5698. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5699. }
  5700. catch (Exception ex)
  5701. {
  5702. XLog.SaveLog(0, "生成fullObj" + res);
  5703. var res_objf = new
  5704. {
  5705. restype = 0,
  5706. data = "生成fullObj发生错误" + ex.Message
  5707. };
  5708. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5709. returnSuccess(ro_jsonf);
  5710. return;
  5711. }
  5712. if (fullObj.response.data.content.Count > 0)
  5713. {
  5714. ContentItem codeObj = fullObj.response.data.content[0];
  5715. if (cpCode.IndexOf("SFFQ-") != -1)
  5716. {
  5717. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5718. }
  5719. else
  5720. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5721. curUseWayBillCode = codeObj.waybillCode;
  5722. }
  5723. else
  5724. {
  5725. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5726. var res_objf = new
  5727. {
  5728. restype = 0,
  5729. data = "生成fullObj找不到快递单号waybillCode"
  5730. };
  5731. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5732. returnSuccess(ro_jsonf);
  5733. return;
  5734. }
  5735. }
  5736. else
  5737. {
  5738. //使用上次打印的快递单号
  5739. if (cpCode == "SFFQ-LY")
  5740. {
  5741. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5742. }
  5743. else
  5744. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5745. curUseWayBillCode = entity.LastBillWaybillCode;
  5746. }
  5747. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5748. {
  5749. var res_obje = new
  5750. {
  5751. restype = 0,
  5752. data = "获取加密打印数据失败"
  5753. };
  5754. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5755. returnSuccess(ro_jsone);
  5756. entity.LastBillCpCode = cpCode;
  5757. entity.LastBillWaybillCode = curUseWayBillCode;
  5758. entity.Update();
  5759. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5760. //returnErrorMsg("获取加密打印数据失败");
  5761. return;
  5762. }
  5763. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5764. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5765. string btnType = "";
  5766. string errorMsg = "";
  5767. if (entity != null)
  5768. {
  5769. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5770. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5771. //cpcode是 YTO-CAINIAO
  5772. //string comCode = cpCode.Split('-')[0].ToString();
  5773. string apires = "";
  5774. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5775. //isTogether=2是新的合包弹窗
  5776. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5777. {
  5778. if (ctid.IndexOf("N") != -1)
  5779. {
  5780. apires = "发货成功";
  5781. }
  5782. else
  5783. {
  5784. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode, entity.ctid);
  5785. }
  5786. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5787. //打单后发货
  5788. StringBuilder sql = new StringBuilder();
  5789. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5790. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5791. {
  5792. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5793. }
  5794. else
  5795. {
  5796. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5797. }
  5798. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5799. foreach (DataRow row in dt.Rows)
  5800. {
  5801. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5802. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5803. {
  5804. try
  5805. {
  5806. btnType = "待发货";
  5807. entity.OutSid = curUseWayBillCode;
  5808. entity.OrderState = 7;
  5809. entity.IsUrgency = false;
  5810. entity.LastBillCpCode = "";
  5811. entity.LastBillWaybillCode = "";
  5812. entity.FinishDeliveryTime = DateTime.Now;
  5813. entity.IsReturn = 0;
  5814. entity.MemoOpt = 0;
  5815. entity.UpdateTime = DateTime.Now;
  5816. entity.Update();
  5817. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5818. //还要插入快递信息到 快递信息表
  5819. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5820. exinfo.tid = entity.ctid;
  5821. exinfo.out_sid = curUseWayBillCode;
  5822. exinfo.company_code = cpCode;
  5823. exinfo.company_name = cpName;
  5824. exinfo.supplierUserName = supplierName;
  5825. exinfo.deliveryType = "发货成功";
  5826. exinfo.print_time = DateTime.Now;
  5827. exinfo.printUser = CurrentUser.UserName;
  5828. exinfo.postData = pData_str;
  5829. exinfo.Create();
  5830. commonHelper.UpdateRelationOrder(entity.ctid);
  5831. CeErpSukuraData.createInfo(ctid, 4);
  5832. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5833. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5834. {
  5835. commonHelper.sendCytExpress(exinfo);
  5836. }
  5837. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5838. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5839. }
  5840. catch (Exception ex)
  5841. {
  5842. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5843. }
  5844. }
  5845. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5846. {
  5847. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5848. if (entity.OrderState == 6)
  5849. {
  5850. entity.OrderState = 7;
  5851. }
  5852. entity.UpdateTime = DateTime.Now;
  5853. entity.FinishDeliveryTime = DateTime.Now;
  5854. btnType = "已发货";
  5855. entity.Update();
  5856. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5857. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5858. exinfo.tid = entity.ctid;
  5859. exinfo.out_sid = curUseWayBillCode;
  5860. exinfo.company_code = cpCode;
  5861. exinfo.company_name = cpName;
  5862. exinfo.supplierUserName = supplierName;
  5863. exinfo.deliveryType = "发货成功";
  5864. exinfo.print_time = DateTime.Now;
  5865. exinfo.printUser = CurrentUser.UserName;
  5866. exinfo.postData = pData_str;
  5867. exinfo.Create();
  5868. commonHelper.UpdateRelationOrder(entity.ctid);
  5869. CeErpSukuraData.createInfo(entity.ctid, 4);
  5870. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5871. {
  5872. commonHelper.sendCytExpress(exinfo);
  5873. }
  5874. //不处理
  5875. }
  5876. else
  5877. {
  5878. entity.UpdateTime = DateTime.Now;
  5879. entity.LastBillCpCode = cpCode;
  5880. entity.LastBillWaybillCode = curUseWayBillCode;
  5881. entity.Update();
  5882. string errmsg = commonHelper.KeepChinese(apires);
  5883. var res_objz = new
  5884. {
  5885. restype = 0,
  5886. data = "打单后发货失败"
  5887. };
  5888. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5889. returnSuccess(ro_jsonz);
  5890. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5891. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5892. return;
  5893. }
  5894. }
  5895. }
  5896. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5897. {
  5898. string ctids = GetPostString("ctids");
  5899. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5900. List<string> list = new List<string>();
  5901. List<string> send_list = new List<string>();
  5902. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5903. CeErpTrade ceErpTrade = new CeErpTrade();
  5904. //可合包的合并一起发货
  5905. if (dt == null && string.IsNullOrEmpty(ctids))
  5906. {
  5907. var res_objz = new
  5908. {
  5909. restype = 0,
  5910. data = "打单后发货失败"
  5911. };
  5912. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5913. returnSuccess(ro_jsonz);
  5914. return;
  5915. }
  5916. if (!string.IsNullOrEmpty(ctids))
  5917. {
  5918. StringBuilder sql = new StringBuilder();
  5919. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5920. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5921. }
  5922. foreach (DataRow row in dt.Rows)
  5923. {
  5924. list.Add("'" + row["ctid"] + "'");
  5925. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5926. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5927. if (ctid.IndexOf("N") != -1)
  5928. {
  5929. apires = "发货成功";
  5930. }
  5931. else
  5932. {
  5933. if (!send_list.Contains(ceErpTrade.tid))
  5934. {
  5935. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode, ctid);
  5936. }
  5937. else
  5938. {
  5939. apires = "发货成功";
  5940. }
  5941. }
  5942. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5943. {
  5944. send_list.Add(ceErpTrade.tid);
  5945. try
  5946. {
  5947. btnType = "待发货";
  5948. ceErpTradeCell.OutSid = curUseWayBillCode;
  5949. ceErpTradeCell.OrderState = 7;
  5950. ceErpTradeCell.IsUrgency = false;
  5951. ceErpTradeCell.LastBillCpCode = "";
  5952. ceErpTradeCell.LastBillWaybillCode = "";
  5953. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5954. ceErpTradeCell.IsReturn = 0;
  5955. ceErpTradeCell.MemoOpt = 0;
  5956. ceErpTradeCell.UpdateTime = DateTime.Now;
  5957. ceErpTradeCell.Update();
  5958. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5959. //还要插入快递信息到 快递信息表
  5960. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5961. exinfo.tid = ceErpTradeCell.ctid;
  5962. exinfo.out_sid = curUseWayBillCode;
  5963. exinfo.company_code = cpCode;
  5964. exinfo.company_name = cpName;
  5965. exinfo.supplierUserName = supplierName;
  5966. exinfo.deliveryType = "发货成功";
  5967. exinfo.print_time = DateTime.Now;
  5968. exinfo.printUser = CurrentUser.UserName;
  5969. exinfo.postData = pData_str;
  5970. exinfo.Create();
  5971. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5972. CeErpSukuraData.createInfo(ctid, 4);
  5973. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5974. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5975. {
  5976. commonHelper.sendCytExpress(exinfo);
  5977. }
  5978. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5979. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5980. }
  5981. catch (Exception ex)
  5982. {
  5983. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5984. }
  5985. }
  5986. else
  5987. {
  5988. ceErpTradeCell.UpdateTime = DateTime.Now;
  5989. ceErpTradeCell.LastBillCpCode = cpCode;
  5990. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5991. ceErpTradeCell.Update();
  5992. string errmsg = commonHelper.KeepChinese(apires);
  5993. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5994. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5995. }
  5996. }
  5997. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5998. }
  5999. }
  6000. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  6001. var res_obj = new
  6002. {
  6003. restype = 1,
  6004. data = pData_str,
  6005. errorMsg
  6006. };
  6007. string ro_json = JsonConvert.SerializeObject(res_obj);
  6008. ReturnSuccess(ro_json);
  6009. return;
  6010. }
  6011. }
  6012. private string GetUTF8String(byte[] vs)
  6013. {
  6014. throw new NotImplementedException();
  6015. }
  6016. public void set_erp_printwaybill_cn()
  6017. {
  6018. if (UrlPostParmsCheck("ctid"))
  6019. {
  6020. string ctid = GetPostString("ctid");
  6021. string cpCode = GetPostString("cpcode");
  6022. string cpName = GetPostString("cpname");
  6023. string tempUrl = GetPostString("tempurl");
  6024. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6025. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  6026. //string res = taobaoHelper.test();
  6027. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6028. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  6029. {
  6030. int sidx = res.IndexOf("errorMsg");
  6031. int eidx = res.IndexOf("}");
  6032. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  6033. var res_objzxx = new
  6034. {
  6035. restype = 0,
  6036. data = msg
  6037. };
  6038. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  6039. returnSuccess(ro_jsonzxx);
  6040. //returnErrorMsg(msg);
  6041. return;
  6042. }
  6043. int idx = res.IndexOf("waybillCode");
  6044. int idx2 = res.IndexOf("printData");
  6045. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  6046. string eid = GetPostString("ctid");
  6047. CeErpTradeCell entity = null;
  6048. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6049. if (entity != null)
  6050. {
  6051. string osid = entity.OutSid;
  6052. entity.OutSid = osid + "," + outsid;
  6053. entity.FinishDeliveryTime = DateTime.Now;
  6054. entity.OrderState = 7;
  6055. entity.UpdateTime = DateTime.Now;
  6056. entity.IsReturn = 0;
  6057. entity.Update();
  6058. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6059. exinfo.tid = entity.ctid;
  6060. exinfo.out_sid = outsid;
  6061. exinfo.company_code = cpCode;
  6062. exinfo.company_name = cpName;
  6063. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6064. exinfo.deliveryType = "发货成功";
  6065. exinfo.print_time = DateTime.Now;
  6066. exinfo.printUser = CurrentUser.UserName;
  6067. exinfo.Create();
  6068. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6069. {
  6070. commonHelper.sendCytExpress(exinfo);
  6071. }
  6072. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6073. }
  6074. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6075. var res_objz = new
  6076. {
  6077. restype = 1,
  6078. data = res
  6079. };
  6080. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6081. returnSuccess(ro_jsonz);
  6082. //ReturnSuccess(res);
  6083. }
  6084. }
  6085. ////打单,打印面单 获取面单号
  6086. //public void set_erp_printwaybill()
  6087. //{
  6088. // if (UrlPostParmsCheck("ctid"))
  6089. // {
  6090. // string ctid = GetPostString("ctid");
  6091. // string cpCode = GetPostString("cpcode");
  6092. // string tempUrl = GetPostString("tempurl");
  6093. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6094. // //string res = taobaoHelper.test();
  6095. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6096. // if (res.IndexOf("error_response") != -1)
  6097. // {
  6098. // int sidx = res.IndexOf("sub_msg");
  6099. // int eidx = res.IndexOf("request_id");
  6100. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6101. // returnErrorMsg(msg);
  6102. // return;
  6103. // }
  6104. // int idx = res.IndexOf("waybill_code");
  6105. // int idx2 = res.IndexOf("}]}");
  6106. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6107. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6108. // ReturnSuccess(res);
  6109. // }
  6110. //}
  6111. public void cancel_erp_aftersale()
  6112. {
  6113. if (UrlPostParmsCheck("ctid"))
  6114. {
  6115. string eid = GetPostString("ctid");
  6116. CeErpTradeCell entity = null;
  6117. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6118. if (entity != null)
  6119. {
  6120. //有过处理的售后,取消也不能删除 售 字,保留
  6121. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6122. {
  6123. entity.AfterSaleState = 4;
  6124. }
  6125. else
  6126. entity.AfterSaleState = 0;
  6127. entity.UpdateTime = DateTime.Now;
  6128. entity.Update();
  6129. returnSuccessMsg("操作成功!");
  6130. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6131. return;
  6132. }
  6133. returnErrorMsg("找不到订单记录");
  6134. }
  6135. }
  6136. public void get_erp_aftersalelist()
  6137. {
  6138. DataStruct dStruct = GetPostStruct();
  6139. List<string> lw = new List<string>();
  6140. int st = GetInt("st");
  6141. string tid = GetPostString("ctid");
  6142. if (st == 3)
  6143. {
  6144. if (tid.Length > 0)
  6145. {
  6146. string select_tid = getTidByCtid(tid);
  6147. lw.Add(string.Format("tid='{0}'", select_tid));
  6148. }
  6149. }
  6150. else
  6151. {
  6152. if (tid.Length > 0)
  6153. {
  6154. string select_tid = getTidByCtid(tid);
  6155. lw.Add(string.Format("tid='{0}'", select_tid));
  6156. }
  6157. }
  6158. string shopname = GetPostString("shopname");
  6159. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6160. string buyernick = GetPostString("buyer_nick");
  6161. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6162. string sellermemo = GetPostString("seller_memo");
  6163. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6164. string orderState = GetPostString("orderState");
  6165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6166. string afterState = GetPostString("afterstate");
  6167. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6168. string date1 = GetPostString("date1");
  6169. string date2 = GetPostString("date2");
  6170. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6171. if (dw.Length > 0) lw.Add(dw);
  6172. string price1 = GetPostString("price1");
  6173. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6174. string price2 = GetPostString("price2");
  6175. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6176. //lw.Add(string.Format("IsRefund!={0}", 1));
  6177. string reason = GetPostString("reason");
  6178. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6179. string method = GetPostString("method");
  6180. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6181. string handler = GetPostString("handler");
  6182. if (handler.Length > 0)
  6183. {
  6184. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6185. }
  6186. string handledate1 = GetPostString("handledate1");
  6187. string handledate2 = GetPostString("handledate2");
  6188. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6189. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6190. string finish1 = GetPostString("finishdate1");
  6191. string finish2 = GetPostString("finishdate2");
  6192. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6193. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6194. string afterdate1 = GetPostString("afterdate1");
  6195. string afterdate2 = GetPostString("afterdate2");
  6196. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6197. if (afterDate.Length > 0) lw.Add(afterDate);
  6198. string supplier = GetPostString("supplier");
  6199. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6200. string responsible = GetPostString("responsibleman");
  6201. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6202. string customer = GetPostString("customer");
  6203. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6204. string design = GetPostString("design");
  6205. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6206. string afterMemoType = GetPostString("aftermemotype");
  6207. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6208. string posCode = CurrentUser.UserPost.Post.Code;
  6209. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6210. //{
  6211. // string vstate = GetPostString("vstate");
  6212. // if (vstate.Length > 0)
  6213. // {
  6214. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6215. // }
  6216. // if (posCode == "Supplier")
  6217. // {
  6218. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6219. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6220. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6221. // }
  6222. // else
  6223. // {
  6224. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6225. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6226. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6227. // {
  6228. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6229. // }
  6230. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6231. // {
  6232. // int orgid = CurrentUser.UserPost.OrgID;
  6233. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6234. // }
  6235. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6236. // {
  6237. // string shopid = CurrentUser.User.pemShop;
  6238. // lw.Add(string.Format("shopId in ({0})", shopid));
  6239. // }
  6240. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6241. // //{
  6242. // // int org_id = CurrentUser.UserPost.OrgID;
  6243. // // lw.Add(string.Format("OrgID={0}", org_id));
  6244. // //}
  6245. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6246. // }
  6247. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6248. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6249. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6250. //}
  6251. if (st == 5)
  6252. {
  6253. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6254. {
  6255. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6256. {
  6257. string shopid = CurrentUser.User.pemShop;
  6258. lw.Add(string.Format("shopId in ({0})", shopid));
  6259. }
  6260. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6261. {
  6262. int mrOrgid = CurrentUser.UserPost.OrgID;
  6263. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6264. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6265. }
  6266. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6267. //{
  6268. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6269. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6270. //}
  6271. else
  6272. {
  6273. string userIdStr = "";
  6274. if (posCode == "CustomerService")
  6275. {
  6276. userIdStr = CurrentUser.UserID + "_k";
  6277. }
  6278. else if (posCode == "Designer" || posCode == "wxDesigner")
  6279. {
  6280. userIdStr = CurrentUser.UserID + "_s";
  6281. }
  6282. else if (posCode == "Place")
  6283. {
  6284. userIdStr = CurrentUser.UserID + "_x";
  6285. }
  6286. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6287. }
  6288. }
  6289. string placedate1 = GetPostString("placedate1");
  6290. string placedate2 = GetPostString("placedate2");
  6291. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6292. if (dwplace.Length > 0) lw.Add(dwplace);
  6293. string supState = GetPostString("supState");
  6294. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6295. string searchType = GetPostString("searchType");
  6296. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6297. {
  6298. lw.Add(string.Format("BackNum>1"));
  6299. }
  6300. lw.Add(string.Format("AfterSaleState>0"));
  6301. if (ex_psize > 0)
  6302. {
  6303. if (CurrentUser.UserPost.Post.Code == "Finance")
  6304. dStruct.Order = "pay_time desc";
  6305. else
  6306. dStruct.Order = "HandleTime desc";
  6307. }
  6308. else
  6309. dStruct.Order = "HandleTime desc";
  6310. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6311. DataTable dt = WebCache.GetData("view_test", dStruct);
  6312. writeGridDataTableJson(dStruct.TotalCount, dt);
  6313. }
  6314. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6315. //{
  6316. // lw.Add(string.Format("AfterSaleState=4"));
  6317. // string code = CurrentUser.UserPost.Post.Code;
  6318. // if (code == "CustomerService")
  6319. // {
  6320. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6321. // }
  6322. // else if (code == "Designer" || code == "DesignerMr")
  6323. // {
  6324. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6325. // }
  6326. // else if (code == "Place" || code == "PlaceMr")
  6327. // {
  6328. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6329. // }
  6330. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6331. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6332. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6333. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6334. //}
  6335. //else //处理中的售后,待处理和处理中合并
  6336. //{
  6337. // if (afterState.Length <= 0)
  6338. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6339. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6340. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6341. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6342. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6343. //}
  6344. }
  6345. public void get_erp_disagreeftersalelist()
  6346. {
  6347. DataStruct dStruct = GetPostStruct();
  6348. List<string> lw = new List<string>();
  6349. int st = 2;
  6350. string tid = GetPostString("ctid");
  6351. if (tid.Length > 0)
  6352. {
  6353. string select_tid = getTidByCtid(tid);
  6354. lw.Add(string.Format("tid='{0}'", select_tid));
  6355. }
  6356. string shopname = GetPostString("shopname");
  6357. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6358. string buyernick = GetPostString("buyer_nick");
  6359. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6360. string sellermemo = GetPostString("seller_memo");
  6361. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6362. string orderState = GetPostString("orderState");
  6363. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6364. string afterState = GetPostString("afterstate");
  6365. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6366. string date1 = GetPostString("date1");
  6367. string date2 = GetPostString("date2");
  6368. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6369. if (dw.Length > 0) lw.Add(dw);
  6370. string price1 = GetPostString("price1");
  6371. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6372. string price2 = GetPostString("price2");
  6373. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6374. //lw.Add(string.Format("IsRefund!={0}", 1));
  6375. string reason = GetPostString("reason");
  6376. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6377. string method = GetPostString("method");
  6378. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6379. string handler = GetPostString("handler");
  6380. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6381. string handledate1 = GetPostString("handledate1");
  6382. string handledate2 = GetPostString("handledate2");
  6383. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6384. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6385. string afterdate1 = GetPostString("afterdate1");
  6386. string afterdate2 = GetPostString("afterdate2");
  6387. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6388. if (afterDate.Length > 0) lw.Add(afterDate);
  6389. string backdate1 = GetPostString("backdate1");
  6390. string backdate2 = GetPostString("backdate2");
  6391. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6392. if (backDate.Length > 0) lw.Add(backDate);
  6393. string supplier = GetPostString("supplier");
  6394. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6395. string responsible = GetPostString("responsibleman");
  6396. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6397. string customer = GetPostString("customer");
  6398. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6399. string design = GetPostString("design");
  6400. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6401. string afterSaleMemo = GetPostString("afterSaleMemo");
  6402. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6403. string afterMemoType = GetPostString("aftermemotype");
  6404. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6405. string aftersakereason = GetPostString("aftersakereason");
  6406. if (aftersakereason.Length > 0)
  6407. {
  6408. if (aftersakereason == "1")
  6409. {
  6410. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6411. }
  6412. if (aftersakereason == "2")
  6413. {
  6414. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6415. }
  6416. }
  6417. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6418. string poscode = CurrentUser.UserPost.Post.Code;
  6419. if (poscode != "SysAdmin")
  6420. {
  6421. string shopid = CurrentUser.User.pemShop;
  6422. lw.Add(string.Format("shopId in ({0})", shopid));
  6423. }
  6424. string searchType = GetPostString("searchType");
  6425. if (searchType == "wait")
  6426. {
  6427. lw.Add(string.Format("HandleTime is null"));
  6428. }
  6429. if (searchType == "handling")
  6430. {
  6431. lw.Add(string.Format("HandleTime is not null "));
  6432. }
  6433. if (searchType == "back" || searchType == "puBack")
  6434. {
  6435. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6436. }
  6437. if (searchType == "reBack")
  6438. {
  6439. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6440. }
  6441. if (searchType == "moreBack")
  6442. {
  6443. lw.Add(string.Format("backNum > 1"));
  6444. }
  6445. lw.Add(string.Format("(AfterSaleState=5)"));
  6446. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6447. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6448. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6449. writeGridDataTableJson(dStruct.TotalCount, dt);
  6450. }
  6451. public void get_erp_handlingaftersalelist()
  6452. {
  6453. DataStruct dStruct = GetPostStruct();
  6454. List<string> lw = new List<string>();
  6455. int st = 2;
  6456. string tid = GetPostString("ctid");
  6457. if (tid.Length > 0)
  6458. {
  6459. string select_tid = getTidByCtid(tid);
  6460. lw.Add(string.Format("tid='{0}'", select_tid));
  6461. }
  6462. string shopname = GetPostString("shopname");
  6463. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6464. string buyernick = GetPostString("buyer_nick");
  6465. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6466. string sellermemo = GetPostString("seller_memo");
  6467. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6468. string orderState = GetPostString("orderState");
  6469. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6470. string afterState = GetPostString("afterstate");
  6471. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6472. string date1 = GetPostString("date1");
  6473. string date2 = GetPostString("date2");
  6474. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6475. if (dw.Length > 0) lw.Add(dw);
  6476. string price1 = GetPostString("price1");
  6477. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6478. string price2 = GetPostString("price2");
  6479. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6480. //lw.Add(string.Format("IsRefund!={0}", 1));
  6481. string reason = GetPostString("reason");
  6482. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6483. string method = GetPostString("method");
  6484. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6485. string handler = GetPostString("handler");
  6486. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6487. string handledate1 = GetPostString("handledate1");
  6488. string handledate2 = GetPostString("handledate2");
  6489. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6490. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6491. string afterdate1 = GetPostString("afterdate1");
  6492. string afterdate2 = GetPostString("afterdate2");
  6493. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6494. if (afterDate.Length > 0) lw.Add(afterDate);
  6495. string supplier = GetPostString("supplier");
  6496. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6497. string responsible = GetPostString("responsibleman");
  6498. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6499. string customer = GetPostString("customer");
  6500. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6501. string design = GetPostString("design");
  6502. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6503. string afterSaleMemo = GetPostString("afterSaleMemo");
  6504. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6505. string afterMemoType = GetPostString("aftermemotype");
  6506. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6507. string afterresult = GetPostString("afterresult");
  6508. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6509. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6510. string poscode = CurrentUser.UserPost.Post.Code;
  6511. if (poscode != "SysAdmin")
  6512. {
  6513. string shopid = CurrentUser.User.pemShop;
  6514. lw.Add(string.Format("shopId in ({0})", shopid));
  6515. }
  6516. string searchType = GetPostString("searchType");
  6517. if (searchType == "wait")
  6518. {
  6519. lw.Add(string.Format("HandleTime is null"));
  6520. }
  6521. if (searchType == "documentary")
  6522. {
  6523. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6524. }
  6525. if (searchType == "handling")
  6526. {
  6527. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6528. }
  6529. if (searchType == "back" || searchType == "puBack")
  6530. {
  6531. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6532. }
  6533. if (searchType == "reBack")
  6534. {
  6535. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6536. }
  6537. if (afterState.Length <= 0)
  6538. {
  6539. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6540. }
  6541. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6542. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6543. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6544. writeGridDataTableJson(dStruct.TotalCount, dt);
  6545. }
  6546. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6547. //public void get_erp_back_handlingaftersalelist()
  6548. //{
  6549. // DataStruct dStruct = GetPostStruct();
  6550. // List<string> lw = new List<string>();
  6551. // string tid = GetPostString("ctid");
  6552. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6553. // string shopname = GetPostString("shopname");
  6554. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6555. // string buyernick = GetPostString("buyer_nick");
  6556. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6557. // string sellermemo = GetPostString("seller_memo");
  6558. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6559. // string orderState = GetPostString("orderState");
  6560. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6561. // string afterState = GetPostString("afterstate");
  6562. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6563. // string date1 = GetPostString("date1");
  6564. // string date2 = GetPostString("date2");
  6565. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6566. // if (dw.Length > 0) lw.Add(dw);
  6567. // string price1 = GetPostString("price1");
  6568. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6569. // string price2 = GetPostString("price2");
  6570. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6571. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6572. // string reason = GetPostString("reason");
  6573. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6574. // string method = GetPostString("method");
  6575. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6576. // string handler = GetPostString("handler");
  6577. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6578. // string handledate1 = GetPostString("handledate1");
  6579. // string handledate2 = GetPostString("handledate2");
  6580. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6581. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6582. // string afterdate1 = GetPostString("afterdate1");
  6583. // string afterdate2 = GetPostString("afterdate2");
  6584. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6585. // if (afterDate.Length > 0) lw.Add(afterDate);
  6586. // string supplier = GetPostString("supplier");
  6587. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6588. // string responsible = GetPostString("responsibleman");
  6589. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6590. // string customer = GetPostString("customer");
  6591. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6592. // string design = GetPostString("design");
  6593. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6594. // string afterMemoType = GetPostString("aftermemotype");
  6595. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6596. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6597. // if (afterState.Length <= 0)
  6598. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6599. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6600. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6601. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6602. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6603. //}
  6604. public void get_erp_aftersaleverifylist()
  6605. {
  6606. DataStruct dStruct = GetPostStruct();
  6607. List<string> lw = new List<string>();
  6608. string tid = GetPostString("ctid");
  6609. if (tid.Length > 0)
  6610. {
  6611. string select_tid = getTidByCtid(tid);
  6612. lw.Add(string.Format("otid='{0}'", select_tid));
  6613. }
  6614. string shopname = GetPostString("shopname");
  6615. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6616. string buyernick = GetPostString("buyer_nick");
  6617. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6618. string sellermemo = GetPostString("seller_memo");
  6619. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6620. string orderState = GetPostString("orderState");
  6621. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6622. //lw.Add(string.Format("IsRefund!={0}", 1));
  6623. string reason = GetPostString("reason");
  6624. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6625. string method = GetPostString("method");
  6626. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6627. string handler = GetPostString("handler");
  6628. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6629. string handledate1 = GetPostString("handledate1");
  6630. string handledate2 = GetPostString("handledate2");
  6631. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6632. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6633. string finish1 = GetPostString("finishdate1");
  6634. string finish2 = GetPostString("finishdate2");
  6635. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6636. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6637. string supplier = GetPostString("supplier");
  6638. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6639. string responsible = GetPostString("responsibleman");
  6640. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6641. string posCode = CurrentUser.UserPost.Post.Code;
  6642. string vstate = GetPostString("vstate");
  6643. if (vstate.Length > 0)
  6644. {
  6645. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6646. }
  6647. if (posCode == "Supplier")
  6648. {
  6649. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6650. lw.Add(string.Format("VerifyState = 0"));
  6651. lw.Add("type = 1");
  6652. lw.Add(string.Format("AfterSaleState={0}", 3));
  6653. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6654. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6655. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6656. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6657. writeGridDataTableJson(dStruct.TotalCount, dt);
  6658. }
  6659. else if (posCode == "logistics")
  6660. {
  6661. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6662. lw.Add(string.Format("VerifyState = 0"));
  6663. lw.Add("type = 2");
  6664. lw.Add(string.Format("AfterSaleState={0}", 3));
  6665. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6666. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6667. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6668. writeGridDataTableJson(dStruct.TotalCount, dt);
  6669. }
  6670. else
  6671. {
  6672. lw.Add(string.Format("(AfterSaleState = 3)"));
  6673. lw.Add("type = 0");
  6674. string reasonState = GetPostString("reasonState");
  6675. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6676. {
  6677. if (reasonState == "2")
  6678. {
  6679. lw.Add("VerifyState = 3");
  6680. }
  6681. else if (reasonState == "1")
  6682. {
  6683. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6684. }
  6685. else
  6686. {
  6687. lw.Add("VerifyState in (0,3)");
  6688. }
  6689. //不加条件,可以看全部
  6690. }
  6691. 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")
  6692. {
  6693. int orgid = CurrentUser.UserPost.OrgID;
  6694. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6695. if (string.IsNullOrEmpty(manageOrgId))
  6696. {
  6697. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6698. }
  6699. else
  6700. {
  6701. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6702. }
  6703. if (reasonState == "1")
  6704. {
  6705. lw.Add("VerifyState = 3");
  6706. }
  6707. else if (reasonState == "2")
  6708. {
  6709. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6710. }
  6711. else
  6712. {
  6713. }
  6714. }
  6715. else
  6716. {
  6717. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6718. }
  6719. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6720. //{
  6721. // int org_id = CurrentUser.UserPost.OrgID;
  6722. // lw.Add(string.Format("OrgID={0}", org_id));
  6723. //}
  6724. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6725. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6726. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6727. writeGridDataTableJson(dStruct.TotalCount, dt);
  6728. }
  6729. }
  6730. public void get_erp_finishaftersalelist()
  6731. {
  6732. DataStruct dStruct = GetPostStruct();
  6733. List<string> lw = new List<string>();
  6734. int st = 4;
  6735. string tid = GetPostString("ctid");
  6736. if (tid.Length > 0)
  6737. {
  6738. string select_tid = getTidByCtid(tid);
  6739. lw.Add(string.Format("otid='{0}'", select_tid));
  6740. }
  6741. string shopname = GetPostString("shopname");
  6742. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6743. //lw.Add(string.Format("IsRefund!={0}", 1));
  6744. string reason = GetPostString("reason");
  6745. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6746. string method = GetPostString("method");
  6747. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6748. string buyernick = GetPostString("buyer_nick");
  6749. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6750. string handler = GetPostString("handler");
  6751. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6752. string handledate1 = GetPostString("handledate1");
  6753. string handledate2 = GetPostString("handledate2");
  6754. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6755. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6756. string finish1 = GetPostString("finishdate1");
  6757. string finish2 = GetPostString("finishdate2");
  6758. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6759. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6760. string supplier = GetPostString("supplier");
  6761. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6762. string responsible = GetPostString("responsibleman");
  6763. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6764. string vstate = GetPostString("vstate");
  6765. if (vstate.Length > 0)
  6766. {
  6767. if ("3".Equals(vstate))
  6768. {
  6769. lw.Add(string.Format("IsTem=1"));
  6770. }
  6771. else
  6772. {
  6773. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6774. }
  6775. }
  6776. lw.Add(string.Format("AfterSaleState=4"));
  6777. string code = CurrentUser.UserPost.Post.Code;
  6778. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6779. {
  6780. //不加条件,可以看全部
  6781. }
  6782. else if (code == "Supplier")
  6783. {
  6784. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6785. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6786. lw.Add("type = 1");
  6787. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6788. }
  6789. else if (code == "logistics")
  6790. {
  6791. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6792. lw.Add("type = 2");
  6793. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6794. }
  6795. 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")
  6796. {
  6797. lw.Add("type = 0");
  6798. int orgid = CurrentUser.UserPost.OrgID;
  6799. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6800. if (string.IsNullOrEmpty(manageOrgIds))
  6801. {
  6802. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6803. }
  6804. else
  6805. {
  6806. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6807. }
  6808. }
  6809. else
  6810. {
  6811. lw.Add("type = 0");
  6812. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6813. }
  6814. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6815. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6816. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6817. writeGridDataTableJson(dStruct.TotalCount, dt);
  6818. }
  6819. public void handle_erp_aftersale()
  6820. {
  6821. if (UrlPostParmsCheck("ctid"))
  6822. {
  6823. string eid = GetPostString("ctid");
  6824. string responStr = GetPostString("AfterSaleResponsible");
  6825. if (responStr.Length <= 0)
  6826. {
  6827. returnErrorMsg("售后责任人不能为空");
  6828. return;
  6829. }
  6830. bool isDesign = false;
  6831. double designFree = 0.00;
  6832. int responsibleId = 0;
  6833. CeErpTradeCell entity = null;
  6834. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6835. if (entity != null)
  6836. {
  6837. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6838. string afterMethod = GetPostString("AfterSaleMethod");
  6839. if (isNeedNewOrder == 1)
  6840. {
  6841. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6842. bool ishav = true;
  6843. if (newentity == null)
  6844. {
  6845. newentity = entity.Clone() as CeErpTradeCell;
  6846. ishav = false;
  6847. newentity.ctid = "S_" + entity.ctid;
  6848. newentity.OrderState = 0;
  6849. //唯一标识
  6850. newentity.OrderSn = newentity.ctid;
  6851. string orderSn = commonHelper.generateDateTimeRandomNos();
  6852. if (orderSn != "")
  6853. {
  6854. newentity.OrderSn = orderSn;
  6855. }
  6856. }
  6857. newentity.UpdateTime = DateTime.Now;
  6858. newentity.AfterSaleState = 0;
  6859. newentity.AfterSaleMethod = afterMethod;
  6860. if (!ishav)
  6861. {
  6862. string memo_str = newentity.seller_memo;
  6863. memo_str = memo_str.Replace("(", "(");
  6864. memo_str = memo_str.Replace(")", ")");
  6865. int sIndex = memo_str.IndexOf("(");
  6866. int eIndex = memo_str.IndexOf(")");
  6867. if (sIndex == -1 || eIndex == -1)
  6868. {
  6869. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6870. return;
  6871. }
  6872. string first = memo_str.Substring(0, sIndex + 1);
  6873. string memoCtid = newentity.OrderSn;
  6874. //if (memoCtid.IndexOf("C") != -1)
  6875. //{
  6876. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6877. //if (CIdx.IndexOf("+") != -1)
  6878. //{
  6879. //CIdx = "C" + CIdx.Split('+')[1];
  6880. //}
  6881. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6882. //}
  6883. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6884. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6885. string newMemo = first + memoCtid + last;
  6886. newentity.seller_memo = newMemo;
  6887. newentity.FinishPlaceTime = null;
  6888. newentity.UnusualTag = 0;
  6889. newentity.UnusualCon = "";
  6890. newentity.UnusualTime = null;
  6891. newentity.AfterSaleMemo = "";
  6892. newentity.AfterSaleMethod = afterMethod;
  6893. newentity.AfterSalePreTime = null;
  6894. newentity.AfterSaleReason = "";
  6895. newentity.AfterSaleResponsible = "";
  6896. newentity.AfterSaleState = 0;
  6897. newentity.AfterSaleTime = null;
  6898. newentity.AfterSaleUserId = 0;
  6899. newentity.AfterSaleSupplierState = 0;
  6900. newentity.LastBillWaybillCode = "";
  6901. newentity.LastBillCpCode = "";
  6902. newentity.FinishAfterSaleTime = null;
  6903. newentity.HandleTime = null;
  6904. newentity.IsSF = 0;
  6905. newentity.IsOldCustomer = 0;
  6906. newentity.UrgencyTime = null;
  6907. newentity.ResponsibleUserId = "";
  6908. newentity.IsVerifyToSupplier = false;
  6909. newentity.payment = 0;
  6910. newentity.CheckMemo = "";
  6911. newentity.OutSid = "";
  6912. newentity.CheckOrderTime = null;
  6913. newentity.MemoOpt = 0;
  6914. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6915. }
  6916. newentity.isAfterSaleOrder = 1;
  6917. newentity.IsRefund = 0;
  6918. string receiveMobile = GetPostString("receiver_mobile");
  6919. if (receiveMobile.Length > 0)
  6920. {
  6921. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6922. if (trade != null)
  6923. {
  6924. trade.receiver_name = GetPostString("receiver_name");
  6925. trade.receiver_mobile = receiveMobile;
  6926. trade.receiver_state = GetPostString("receiver_state");
  6927. trade.receiver_city = GetPostString("receiver_city");
  6928. trade.receiver_district = GetPostString("receiver_district");
  6929. trade.receiver_address = GetPostString("receiver_address");
  6930. newentity.IsOffLineOrder = 1;
  6931. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6932. }
  6933. }
  6934. string st = GetPostString("ToState");
  6935. if (st.Length > 0)
  6936. {
  6937. if (newentity.OrderState <= 3)
  6938. {
  6939. newentity.WaitDesignTime = DateTime.Now;
  6940. newentity.StartDesignTime = null;
  6941. newentity.FinishDesignTime = null;
  6942. newentity.OrderState = 3;
  6943. if (st == "下单员")
  6944. {
  6945. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6946. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6947. {
  6948. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6949. }
  6950. }
  6951. else
  6952. {
  6953. newentity.WaitDesignTime = DateTime.Now;
  6954. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6955. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6956. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6957. {
  6958. DataRow user = dt1.Rows[0];
  6959. //找主管
  6960. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6961. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6962. if (dt != null && dt.Rows.Count > 0)
  6963. {
  6964. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6965. newentity.DesignUserId = designMr;
  6966. string key = "aftersale_order_" + designMr;
  6967. if (RedisHelper.HasKey(key))
  6968. {
  6969. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6970. list.Add(newentity.ctid);
  6971. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6972. }
  6973. }
  6974. //账号正常
  6975. if (user["State"].ToString() == "0")
  6976. {
  6977. newentity.DesignUserId = entity.DesignUserId;
  6978. string key = "aftersale_order_" + entity.DesignUserId;
  6979. if (RedisHelper.HasKey(key))
  6980. {
  6981. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6982. list.Add(newentity.ctid);
  6983. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6984. }
  6985. }
  6986. }
  6987. }
  6988. }
  6989. if (entity.IsXianHuo == 1)
  6990. {
  6991. newentity.OrderState = 6;
  6992. entity.FinishPlaceTime = DateTime.Now;
  6993. }
  6994. }
  6995. if (ishav)
  6996. {
  6997. newentity.Update();
  6998. }
  6999. else
  7000. {
  7001. newentity.Create();
  7002. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  7003. newCellExtend.ctid = newentity.ctid;
  7004. newCellExtend.orderFrom = 20;
  7005. newCellExtend.orderType = 30;
  7006. if (st == "下单员")
  7007. {
  7008. }
  7009. else
  7010. {
  7011. newCellExtend.ReprintTime = DateTime.Now;
  7012. }
  7013. newCellExtend.Create();
  7014. }
  7015. if (st != "下单员")
  7016. {
  7017. if (entity.DispatchSort == 2)
  7018. {
  7019. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  7020. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  7021. }
  7022. }
  7023. }
  7024. //处理售后扩展
  7025. string resIdStr = GetPostString("ResponsibleUserId");
  7026. string refundFees = GetPostString("refundFrees");
  7027. int IsComplain = GetPostInt("isComplain");
  7028. int IsBad = GetPostInt("isBad");
  7029. string IsOriginal = GetPostString("isOriginal");
  7030. double diffResultPrice = GetPostDouble("diffResultPrice");
  7031. string textResult = GetPostString("textResult");
  7032. string supplierResponsible = GetPostString("supplierResponsible");
  7033. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  7034. if (ceErpTradeAfterSaleExtend == null)
  7035. {
  7036. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7037. ceErpTradeAfterSaleExtend.tid = eid;
  7038. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7039. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7040. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7041. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7042. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7043. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7044. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7045. ceErpTradeAfterSaleExtend.Create();
  7046. }
  7047. else
  7048. {
  7049. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  7050. {
  7051. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  7052. }
  7053. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7054. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7055. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7056. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7057. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7058. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7059. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7060. ceErpTradeAfterSaleExtend.Update();
  7061. }
  7062. int gysid = GetPostInt("ResponsibleSupId");
  7063. if (entity.AfterSaleUserId == 0)
  7064. {
  7065. entity.AfterSaleUserId = CurrentUser.UserID;
  7066. }
  7067. entity.ResponsibleUserId = resIdStr;
  7068. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7069. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7070. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7071. {
  7072. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7073. int backNum = 0;
  7074. if (number != null)
  7075. {
  7076. backNum = number.BackNum;
  7077. }
  7078. char[] separator = { ',' };
  7079. string[] sArray = resIdStr.Split(separator);
  7080. string[] refundFreeList = { };
  7081. if (refundFees.Length > 0)
  7082. {
  7083. refundFreeList = refundFees.Split(separator);
  7084. }
  7085. int index = -1;
  7086. List<int> responsibleIds = new List<int>();
  7087. foreach (string i in sArray)
  7088. {
  7089. index++;
  7090. if (i.Length <= 0) continue;
  7091. char[] separator2 = { '_' };
  7092. string idstr = i.Split(separator2)[0];
  7093. string idtype = i.Split(separator2)[1];
  7094. double refudFree = 0;
  7095. if (refundFreeList.Length > 0)
  7096. {
  7097. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7098. }
  7099. if (idtype == "s")
  7100. {
  7101. isDesign = true;
  7102. designFree = refudFree;
  7103. }
  7104. int userId = Convert.ToInt32(idstr);
  7105. int type = 0;
  7106. if (idtype == "g")
  7107. {
  7108. type = 1;
  7109. }
  7110. if (idtype == "w")
  7111. {
  7112. type = 2;
  7113. }
  7114. if (idtype == "t")
  7115. {
  7116. type = 3;
  7117. }
  7118. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7119. if (ceErpTradeResponsible == null)
  7120. {
  7121. ceErpTradeResponsible = new CeErpTradeResponsible();
  7122. ceErpTradeResponsible.tid = eid;
  7123. ceErpTradeResponsible.UserId = userId;
  7124. ceErpTradeResponsible.createdTime = DateTime.Now;
  7125. ceErpTradeResponsible.type = type;
  7126. if (type == 1)
  7127. {
  7128. ceErpTradeResponsible.IsSup = 1;
  7129. }
  7130. if (type == 2)
  7131. {
  7132. ceErpTradeResponsible.IsFlow = 1;
  7133. }
  7134. }
  7135. int state = 0;
  7136. //已认可的不需要再次认可
  7137. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7138. {
  7139. state = 1;
  7140. }
  7141. ceErpTradeResponsible.RefundFee = refudFree;
  7142. ceErpTradeResponsible.VerifyState = state;
  7143. if (userId == 2125 || idtype == "w")
  7144. {
  7145. ceErpTradeResponsible.VerifyState = 1;
  7146. }
  7147. if (idtype == "w" && userId == 101)
  7148. {
  7149. ceErpTradeResponsible.VerifyState = state;
  7150. }
  7151. if (ceErpTradeResponsible.ID > 0)
  7152. {
  7153. ceErpTradeResponsible.Update();
  7154. }
  7155. else
  7156. {
  7157. ceErpTradeResponsible.Create();
  7158. }
  7159. if (isDesign)
  7160. {
  7161. responsibleId = ceErpTradeResponsible.ID;
  7162. }
  7163. responsibleIds.Add(ceErpTradeResponsible.ID);
  7164. }
  7165. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7166. CeErpTradeResponsible.NumByTid(backNum, eid);
  7167. }
  7168. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7169. if (ceErpTradeCellExtend != null)
  7170. {
  7171. ceErpTradeCellExtend.returnVisit = 0;
  7172. ceErpTradeCellExtend.Update();
  7173. }
  7174. if (entity.HandleTime != null)
  7175. {
  7176. if (entity.AfterSaleState == 1)
  7177. {
  7178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7179. }
  7180. else
  7181. {
  7182. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7183. }
  7184. }
  7185. else
  7186. {
  7187. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7188. entity.HandleTime = DateTime.Now;
  7189. }
  7190. bool isCompale = false;
  7191. if (entity.AfterSaleState == 5)
  7192. {
  7193. isCompale = true;
  7194. entity.AfterSaleState = 3;
  7195. }
  7196. entity.AfterSaleSupplierState = 0;
  7197. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7198. {
  7199. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7200. }
  7201. string sImgs = GetPostString("img");
  7202. entity.AfterSaleSupplierImg = sImgs;
  7203. entity.supRefundType = GetPostString("supRefundType");
  7204. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7205. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7206. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7207. entity.AfterSaleMemoType = GetPostString("MemoType");
  7208. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7209. {
  7210. //entity.AfterSaleSupplierState = 2;
  7211. }
  7212. string df = GetPostString("DeductFee");
  7213. if (df == "")
  7214. {
  7215. df = "0";
  7216. }
  7217. string rf = GetPostString("RefundFee");
  7218. if (rf == "")
  7219. {
  7220. rf = "0";
  7221. }
  7222. string pm = GetPostString("AfterSalePayment");
  7223. if (pm == "")
  7224. {
  7225. pm = "0";
  7226. }
  7227. entity.AfterSalePayment = Convert.ToDouble(pm);
  7228. entity.DeductFee = Convert.ToDouble(df);
  7229. entity.RefundFee = Convert.ToDouble(rf);
  7230. entity.UpdateTime = DateTime.Now;
  7231. entity.Update();
  7232. string toState = GetPostString("ToState");
  7233. string original = GetPostString("isOriginal");
  7234. ApiVo apiVo = new ApiVo();
  7235. apiVo.orderNumber = entity.ctid;
  7236. apiVo.actionName = "afterDesign";
  7237. apiVo.orderRemarks = entity.AfterSaleMethod;
  7238. apiVo.reasonRemarks = entity.AfterSaleReason;
  7239. apiVo.isDesign = isDesign;
  7240. apiVo.designFree = designFree;
  7241. apiVo.responsibleId = responsibleId;
  7242. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7243. if (toState == "设计师")
  7244. {
  7245. apiVo.isOriginal = Convert.ToBoolean(original);
  7246. }
  7247. designHelper.API_WorkCore(apiVo);//afterDesign
  7248. CeErpMethod methodSql = new CeErpMethod();
  7249. methodSql.con = entity.AfterSaleMethod;
  7250. methodSql.addTime = DateTime.Now;
  7251. methodSql.Create();
  7252. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7253. CeErpMethod.ExecuteNonQuery(delsql);
  7254. if (isCompale)
  7255. {
  7256. aftersale_data_change(entity.ctid);
  7257. }
  7258. returnSuccessMsg("操作成功!");
  7259. return;
  7260. }
  7261. returnErrorMsg("找不到订单记录");
  7262. }
  7263. }
  7264. public void ins_erp_toresponsible()
  7265. {
  7266. if (UrlPostParmsCheck("ctid"))
  7267. {
  7268. string eid = GetPostString("ctid");
  7269. CeErpTradeCell entity = null;
  7270. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7271. if (entity != null)
  7272. {
  7273. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7274. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7275. {
  7276. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7277. return;
  7278. }
  7279. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7280. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7281. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7282. if (entity.AfterSalePreTime == null)
  7283. {
  7284. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7285. {
  7286. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7287. }
  7288. }
  7289. entity.AfterSalePreTime = DateTime.Now;
  7290. //预完成给售后主管审核客户问题直接完成
  7291. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7292. {
  7293. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7294. {
  7295. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7296. }
  7297. }
  7298. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7299. ceErpTradeAfterSaleExtend.Update();
  7300. entity.AfterSaleState = 2;
  7301. entity.UpdateTime = DateTime.Now;
  7302. entity.Update();
  7303. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7304. aftersale_data_change(entity.ctid);
  7305. returnSuccessMsg("操作成功!");
  7306. return;
  7307. }
  7308. returnErrorMsg("找不到订单记录");
  7309. }
  7310. }
  7311. public void cancel_erp_aftersaleanddelnew()
  7312. {
  7313. if (UrlPostParmsCheck("ctid"))
  7314. {
  7315. string eid = GetPostString("ctid");
  7316. CeErpTradeCell entity = null;
  7317. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7318. if (entity != null)
  7319. {
  7320. entity.AfterSaleState = 0;
  7321. entity.AfterSaleReason = "";
  7322. entity.AfterSaleMethod = "";
  7323. entity.AfterSaleMemo = "";
  7324. entity.AfterSaleResponsible = "";
  7325. entity.ResponsibleUserId = "";
  7326. entity.DeductFee = 0;
  7327. entity.RefundFee = 0;
  7328. entity.IsArbitrate = 0;
  7329. CeErpTradeResponsible.DelByTid(eid, -1);
  7330. entity.Update();
  7331. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7332. if (after != null)
  7333. {
  7334. if (after.OrderState < 5)
  7335. CeErpTradeCell.DelByCtid("S_" + eid);
  7336. }
  7337. returnSuccessMsg("操作成功!");
  7338. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7339. return;
  7340. }
  7341. returnErrorMsg("找不到订单记录");
  7342. }
  7343. }
  7344. public void get_erp_aftersale_pregather()
  7345. {
  7346. List<string> lw = new List<string>();
  7347. int st = GetInt("st");
  7348. string tid = GetPostString("ctid");
  7349. if (tid.Length > 0)
  7350. {
  7351. string select_tid = getTidByCtid(tid);
  7352. lw.Add(string.Format("tid='{0}'", select_tid));
  7353. }
  7354. string shopname = GetPostString("shopname");
  7355. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7356. string buyernick = GetPostString("buyer_nick");
  7357. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7358. string sellermemo = GetPostString("seller_memo");
  7359. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7360. string orderState = GetPostString("orderState");
  7361. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7362. string reason = GetPostString("reason");
  7363. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7364. string method = GetPostString("method");
  7365. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7366. string handler = GetPostString("handler");
  7367. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7368. string handledate1 = GetPostString("handledate1");
  7369. string handledate2 = GetPostString("handledate2");
  7370. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7371. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7372. string supplier = GetPostString("supplier");
  7373. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7374. string responsible = GetPostString("responsibleman");
  7375. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7376. string customer = GetPostString("customer");
  7377. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7378. string design = GetPostString("design");
  7379. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7380. string afterMemoType = GetPostString("aftermemotype");
  7381. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7382. string afterSaleMemo = GetPostString("afterSaleMemo");
  7383. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7384. string afterresult = GetPostString("afterresult");
  7385. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7386. string poscode = CurrentUser.UserPost.Post.Code;
  7387. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7388. {
  7389. string shopid = CurrentUser.User.pemShop;
  7390. lw.Add(string.Format("shopId in ({0})", shopid));
  7391. }
  7392. var mainwhere = string.Join(" and ", lw.ToArray());
  7393. string ro_json = "";
  7394. string type = GetPostString("gather_type");
  7395. int number = 0;
  7396. if (poscode == "AfterSale")
  7397. {
  7398. //处理中
  7399. if (type == "Handling")
  7400. {
  7401. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7402. DataTable dt = null;
  7403. try
  7404. {
  7405. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7406. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7407. }
  7408. catch (Exception e)
  7409. {
  7410. dt = new DataTable();
  7411. }
  7412. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7413. return;
  7414. }
  7415. if (type == "Wait")
  7416. {
  7417. //待处理
  7418. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7419. DataTable dt1 = null;
  7420. try
  7421. {
  7422. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7423. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7424. }
  7425. catch (Exception e)
  7426. {
  7427. dt1 = new DataTable();
  7428. }
  7429. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7430. return;
  7431. }
  7432. if (type == "back")
  7433. {
  7434. //打回
  7435. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7436. DataTable dt2 = null;
  7437. try
  7438. {
  7439. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7440. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7441. }
  7442. catch (Exception e)
  7443. {
  7444. dt2 = new DataTable();
  7445. }
  7446. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7447. return;
  7448. }
  7449. if (type == "preCompletion")
  7450. {
  7451. //预完成
  7452. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7453. DataTable dt3 = null;
  7454. try
  7455. {
  7456. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7457. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7458. }
  7459. catch (Exception e)
  7460. {
  7461. dt3 = new DataTable();
  7462. }
  7463. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7464. return;
  7465. }
  7466. if (type == "documentary")
  7467. {
  7468. //跟单中
  7469. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('重印-转设计师','重印-转下单员') " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7470. DataTable dt4 = null;
  7471. try
  7472. {
  7473. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7474. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7475. }
  7476. catch (Exception e)
  7477. {
  7478. dt4 = new DataTable();
  7479. }
  7480. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7481. return;
  7482. }
  7483. if (type == "reBack")
  7484. {
  7485. //被打回
  7486. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7487. DataTable dt1 = null;
  7488. try
  7489. {
  7490. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7491. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7492. }
  7493. catch (Exception e)
  7494. {
  7495. dt1 = new DataTable();
  7496. }
  7497. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7498. return;
  7499. }
  7500. }
  7501. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7502. {
  7503. if (type == "puBack")
  7504. {
  7505. //退回
  7506. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7507. DataTable dt = null;
  7508. try
  7509. {
  7510. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7511. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7512. }
  7513. catch (Exception e)
  7514. {
  7515. dt = new DataTable();
  7516. }
  7517. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7518. return;
  7519. }
  7520. if (type == "reBack")
  7521. {
  7522. //打回
  7523. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7524. DataTable dt1 = null;
  7525. try
  7526. {
  7527. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7528. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7529. }
  7530. catch (Exception e)
  7531. {
  7532. dt1 = new DataTable();
  7533. }
  7534. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7535. return;
  7536. }
  7537. if (type == "examEd")
  7538. {
  7539. //已审核
  7540. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7541. DataTable dt2 = null;
  7542. try
  7543. {
  7544. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7545. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7546. }
  7547. catch (Exception e)
  7548. {
  7549. dt2 = new DataTable();
  7550. }
  7551. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7552. return;
  7553. }
  7554. if (type == "waitExam")
  7555. {
  7556. //待审核
  7557. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7558. DataTable dt3 = null;
  7559. try
  7560. {
  7561. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7562. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7563. }
  7564. catch (Exception e)
  7565. {
  7566. dt3 = new DataTable();
  7567. }
  7568. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7569. return;
  7570. }
  7571. if (type == "Handling")
  7572. {
  7573. //处理中
  7574. string sql4 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7575. DataTable dt4 = null;
  7576. try
  7577. {
  7578. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7579. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7580. }
  7581. catch (Exception e)
  7582. {
  7583. dt4 = new DataTable();
  7584. }
  7585. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7586. return;
  7587. }
  7588. if (type == "Wait")
  7589. {
  7590. //待处理
  7591. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7592. DataTable dt5 = null;
  7593. try
  7594. {
  7595. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7596. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7597. }
  7598. catch (Exception e)
  7599. {
  7600. dt5 = new DataTable();
  7601. }
  7602. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7603. return;
  7604. }
  7605. if (type == "documentary")
  7606. {
  7607. //跟单中
  7608. string sql6 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7609. DataTable dt6 = null;
  7610. try
  7611. {
  7612. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7613. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7614. }
  7615. catch (Exception e)
  7616. {
  7617. dt6 = new DataTable();
  7618. }
  7619. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7620. return;
  7621. }
  7622. }
  7623. returnSuccess(ro_json);
  7624. }
  7625. public void end_erp_aftersale()
  7626. {
  7627. if (UrlPostParmsCheck("ctid"))
  7628. {
  7629. string eid = GetPostString("ctid");
  7630. CeErpTradeCell entity = null;
  7631. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7632. if (entity != null)
  7633. {
  7634. string stype = GetPostString("stype");
  7635. string typeStr = stype;
  7636. entity.AfterSaleState = 4;
  7637. entity.FinishAfterSaleTime = DateTime.Now;
  7638. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7639. entity.Update();
  7640. ApiVo apiVo = new ApiVo();
  7641. apiVo.orderNumber = entity.ctid;
  7642. apiVo.actionName = "afterOver";
  7643. designHelper.API_WorkCore(apiVo); //afterOver
  7644. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7645. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7646. CeErpSukuraData.createInfo(entity.ctid, 8);
  7647. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7648. returnSuccessMsg("操作成功!");
  7649. return;
  7650. }
  7651. returnErrorMsg("找不到订单记录");
  7652. }
  7653. }
  7654. public void ins_erp_finishaftersale()
  7655. {
  7656. if (UrlPostParmsCheck("id"))
  7657. {
  7658. string eid = GetPostString("id");
  7659. CeErpTradeResponsible entity = null;
  7660. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7661. if (entity != null)
  7662. {
  7663. entity.VerifyState = 1;
  7664. entity.VerifyTime = DateTime.Now;
  7665. entity.Update();
  7666. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7667. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7668. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7669. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7670. if (dt.Rows.Count <= 0)
  7671. {
  7672. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7673. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7674. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7675. CeErpSukuraData.createInfo(entity.tid, 8);
  7676. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7677. {
  7678. CeErpDesignerBill.Del(entity.tid);
  7679. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7680. }
  7681. }
  7682. returnSuccessMsg("操作成功!");
  7683. return;
  7684. }
  7685. returnErrorMsg("找不到订单记录");
  7686. }
  7687. }
  7688. public void upd_erp_arbitrateaftersale()
  7689. {
  7690. if (UrlPostParmsCheck("id"))
  7691. {
  7692. string eid = GetPostString("id");
  7693. CeErpTradeResponsible entity = null;
  7694. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7695. if (entity != null)
  7696. {
  7697. entity.IsArbitrate = 1;
  7698. entity.ArbitradeMemo = GetPostString("reason");
  7699. entity.VerifyState = 2;
  7700. entity.Update();
  7701. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7702. if (tradecell != null)
  7703. {
  7704. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7705. tradecell.IsArbitrate = 1;
  7706. tradecell.Update();
  7707. }
  7708. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7709. returnSuccessMsg("操作成功!");
  7710. return;
  7711. }
  7712. returnErrorMsg("找不到订单记录");
  7713. }
  7714. }
  7715. public void upd_erp_backaftersale()
  7716. {
  7717. if (UrlPostParmsCheck("tid"))
  7718. {
  7719. string eid = GetPostString("tid");
  7720. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7721. int backNum = 0;
  7722. if (number != null)
  7723. {
  7724. backNum = number.BackNum;
  7725. }
  7726. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7727. CeErpTradeCell entity = null;
  7728. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7729. if (entity != null)
  7730. {
  7731. entity.AfterSaleBackReason = GetPostString("backreason");
  7732. entity.AfterSaleState = 1;
  7733. entity.AfterSaleSupplierState = 0;
  7734. entity.UpdateTime = DateTime.Now;
  7735. entity.Update();
  7736. returnSuccessMsg("操作成功!");
  7737. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7738. return;
  7739. }
  7740. returnErrorMsg("找不到订单记录");
  7741. }
  7742. }
  7743. public void get_erp_supplieraftersalelist()
  7744. {
  7745. DataStruct dStruct = GetPostStruct();
  7746. List<string> lw = new List<string>();
  7747. string tid = GetPostString("ctid");
  7748. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7749. string shopname = GetPostString("shopname");
  7750. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7751. string buyernick = GetPostString("buyer_nick");
  7752. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7753. string sellermemo = GetPostString("seller_memo");
  7754. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7755. string orderState = GetPostString("orderState");
  7756. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7757. string afterState = GetPostString("afterstate");
  7758. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7759. string date1 = GetPostString("date1");
  7760. string date2 = GetPostString("date2");
  7761. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7762. if (dw.Length > 0) lw.Add(dw);
  7763. string price1 = GetPostString("price1");
  7764. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7765. string price2 = GetPostString("price2");
  7766. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7767. string reason = GetPostString("reason");
  7768. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7769. string method = GetPostString("method");
  7770. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7771. string handledate1 = GetPostString("handledate1");
  7772. string handledate2 = GetPostString("handledate2");
  7773. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7774. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7775. string handler = GetPostString("handler");
  7776. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7777. string afterdate1 = GetPostString("afterdate1");
  7778. string afterdate2 = GetPostString("afterdate2");
  7779. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7780. if (afterDate.Length > 0) lw.Add(afterDate);
  7781. string customer = GetPostString("customer");
  7782. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7783. string design = GetPostString("design");
  7784. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7785. string afterMemoType = GetPostString("aftermemotype");
  7786. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7787. string vstate = GetPostString("vstate");
  7788. if (vstate.Length > 0)
  7789. {
  7790. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7791. }
  7792. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7793. string supplier = GetPostString("supplier");
  7794. int supid = commonHelper.getSupplierIDByName(supplier);
  7795. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7796. string posCode = CurrentUser.UserPost.Post.Code;
  7797. if (posCode == "Supplier")
  7798. {
  7799. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7800. }
  7801. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7802. {
  7803. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7804. }
  7805. else
  7806. {
  7807. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7808. }
  7809. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7810. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7811. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7812. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7813. writeGridDataTableJson(dStruct.TotalCount, dt);
  7814. }
  7815. public void upd_erp_supverifyaftersale()
  7816. {
  7817. if (UrlPostParmsCheck("id"))
  7818. {
  7819. string id = GetPostString("id");
  7820. int st = GetPostInt("afterstate");
  7821. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7822. CeErpTradeCell entity = null;
  7823. if (ceErpTradeResponsible != null)
  7824. {
  7825. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7826. }
  7827. string afmemo = GetPostString("supmemo");
  7828. string image = GetPostString("image");
  7829. if (entity != null)
  7830. {
  7831. entity.AfterSaleSupplierState = st;
  7832. entity.AfterSaleSupplierMemo = afmemo;
  7833. if (st == 1)
  7834. {
  7835. ceErpTradeResponsible.VerifyState = 1;
  7836. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7837. ceErpTradeResponsible.Update();
  7838. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7839. if (isAll)
  7840. {
  7841. entity.AfterSaleState = 4;
  7842. entity.FinishAfterSaleTime = DateTime.Now;
  7843. }
  7844. }
  7845. else
  7846. {
  7847. CeErpTradeResponsible.dateByTid(entity.ctid);
  7848. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7849. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7850. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7851. if (num <= 1)
  7852. {
  7853. entity.AfterSaleState = 1;
  7854. }
  7855. else
  7856. {
  7857. entity.AfterSaleState = 5;
  7858. }
  7859. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7860. if (ceErpTradeAfterSaleExtend != null)
  7861. {
  7862. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7863. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7864. ceErpTradeAfterSaleExtend.Update();
  7865. }
  7866. else
  7867. {
  7868. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7869. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7870. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7871. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7872. ceErpTradeAfterSaleExtend.Create();
  7873. }
  7874. }
  7875. if (entity.AfterSaleState == 4)
  7876. {
  7877. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7878. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7879. {
  7880. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7881. }
  7882. ApiVo apiVo = new ApiVo();
  7883. apiVo.orderNumber = entity.ctid;
  7884. apiVo.actionName = "afterOver";
  7885. designHelper.API_WorkCore(apiVo); //afterOver
  7886. }
  7887. entity.UpdateTime = DateTime.Now;
  7888. entity.Update();
  7889. returnSuccessMsg("操作成功!");
  7890. CeErpSukuraData.createInfo(entity.ctid, 8);
  7891. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7892. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7893. return;
  7894. }
  7895. returnErrorMsg("找不到订单记录");
  7896. }
  7897. }
  7898. public void upd_erp_masteraftersale()
  7899. {
  7900. if (UrlPostParmsCheck("id"))
  7901. {
  7902. string id = GetPostString("id");
  7903. int st = GetPostInt("afterstate");
  7904. string afmemo = GetPostString("supmemo");
  7905. string image = GetPostString("image");
  7906. string textResult = GetPostString("textResult");
  7907. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7908. if (ceErpTradeResponsible != null)
  7909. {
  7910. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7911. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7912. ceErpTradeResponsible.Update();
  7913. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7914. if (entity != null)
  7915. {
  7916. entity.AfterSaleSupplierState = st;
  7917. entity.AfterSaleSupplierMemo = afmemo;
  7918. if (st == 1)
  7919. {
  7920. }
  7921. else
  7922. {
  7923. CeErpTradeResponsible.dateByTid(entity.ctid);
  7924. //退回到售后
  7925. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7926. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7927. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7928. if (num <= 1)
  7929. {
  7930. entity.AfterSaleState = 1;
  7931. }
  7932. else
  7933. {
  7934. entity.AfterSaleState = 5;
  7935. }
  7936. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7937. if (ceErpTradeAfterSaleExtend != null)
  7938. {
  7939. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7940. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7941. ceErpTradeAfterSaleExtend.Update();
  7942. }
  7943. else
  7944. {
  7945. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7946. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7947. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7948. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7949. ceErpTradeAfterSaleExtend.Create();
  7950. }
  7951. }
  7952. entity.UpdateTime = DateTime.Now;
  7953. entity.Update();
  7954. returnSuccessMsg("操作成功!");
  7955. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7956. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7957. return;
  7958. }
  7959. }
  7960. returnErrorMsg("找不到订单记录");
  7961. }
  7962. }
  7963. public void upd_erp_personaftersale()
  7964. {
  7965. if (UrlPostParmsCheck("id"))
  7966. {
  7967. //林小连
  7968. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7969. {
  7970. upd_erp_masteraftersale();
  7971. return;
  7972. }
  7973. string id = GetPostString("id");
  7974. int st = GetPostInt("afterstate");
  7975. string afmemo = GetPostString("supmemo");
  7976. string image = GetPostString("image");
  7977. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7978. if (ceErpTradeResponsible != null)
  7979. {
  7980. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7981. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7982. ceErpTradeResponsible.Update();
  7983. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7984. if (entity != null)
  7985. {
  7986. entity.AfterSaleSupplierMemo = afmemo;
  7987. entity.AfterSaleSupplierState = st;
  7988. if (st == 1)
  7989. {
  7990. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7991. if (isAll)
  7992. {
  7993. entity.AfterSaleState = 4;
  7994. entity.FinishAfterSaleTime = DateTime.Now;
  7995. }
  7996. }
  7997. else
  7998. {
  7999. CeErpTradeResponsible.dateByTid(entity.ctid);
  8000. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  8001. if (ceErpTradeAfterSaleExtend != null)
  8002. {
  8003. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8004. ceErpTradeAfterSaleExtend.Update();
  8005. }
  8006. else
  8007. {
  8008. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8009. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8010. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8011. ceErpTradeAfterSaleExtend.Create();
  8012. }
  8013. //退回到主管
  8014. //entity.AfterSaleState = 2;
  8015. }
  8016. if (entity.AfterSaleState == 4)
  8017. {
  8018. ApiVo apiVo = new ApiVo();
  8019. apiVo.orderNumber = entity.ctid;
  8020. apiVo.actionName = "afterOver";
  8021. designHelper.API_WorkCore(apiVo); //afterOver
  8022. }
  8023. entity.UpdateTime = DateTime.Now;
  8024. entity.Update();
  8025. returnSuccessMsg("操作成功!");
  8026. CeErpSukuraData.createInfo(entity.ctid, 8);
  8027. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8028. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8029. return;
  8030. }
  8031. }
  8032. returnErrorMsg("找不到订单记录");
  8033. }
  8034. }
  8035. public void set_erp_supplierrefundtag()
  8036. {
  8037. if (UrlPostParmsCheck("ctid"))
  8038. {
  8039. string eid = GetPostString("ctid");
  8040. CeErpTradeCell entity = null;
  8041. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8042. if (entity != null)
  8043. {
  8044. entity.IsSupplierRefund = GetPostInt("tag");
  8045. entity.Update();
  8046. returnSuccessMsg("操作成功!");
  8047. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  8048. return;
  8049. }
  8050. returnErrorMsg("找不到订单记录");
  8051. }
  8052. }
  8053. public void get_erp_refundlist()
  8054. {
  8055. DataStruct dStruct = GetPostStruct();
  8056. List<string> lw = new List<string>();
  8057. string tid = GetPostString("tid");
  8058. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8059. //string rid = GetPostString("refund_id");
  8060. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  8061. string shopname = GetPostString("shopname");
  8062. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8063. string buyernick = GetPostString("buyer_nick");
  8064. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8065. string customer = GetPostString("customer");
  8066. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8067. string design = GetPostString("design");
  8068. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8069. string sellermemo = GetPostString("seller_memo");
  8070. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8071. //string date1 = GetPostString("date1");
  8072. //string date2 = GetPostString("date2");
  8073. //string dateType = GetPostString("dateType");
  8074. //if (dateType.Length > 0)
  8075. //{
  8076. // if (dateType == "1001") dateType = "0";
  8077. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8078. // if (searchDT.Count == 2)
  8079. // {
  8080. // date1 = searchDT[0].ToString();
  8081. // date2 = searchDT[1].ToString();
  8082. // }
  8083. //}
  8084. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8085. //if (dw.Length > 0) lw.Add(dw);
  8086. string redate1 = GetPostString("refunddate1");
  8087. string redate2 = GetPostString("refunddate2");
  8088. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8089. if (dwdate.Length > 0) lw.Add(dwdate);
  8090. string price1 = GetPostString("price1");
  8091. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8092. string price2 = GetPostString("price2");
  8093. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8094. string ispartrefund = GetPostString("ispartrefund");
  8095. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8096. string refundState = GetPostString("refundvstate");
  8097. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8098. int st = GetInt("st");
  8099. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8100. {
  8101. string responsible = GetPostString("responsibleman");
  8102. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8103. lw.Add(string.Format("RefundState>={0}", st));
  8104. string code = CurrentUser.UserPost.Post.Code;
  8105. if (code == "CustomerService")
  8106. {
  8107. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8108. }
  8109. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8110. {
  8111. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8112. }
  8113. else if (code == "Place" || code == "PlaceMr")
  8114. {
  8115. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8116. }
  8117. dStruct.Order = "RefundState asc,created desc";
  8118. }
  8119. else if (st == 10)
  8120. {
  8121. string responsible = GetPostString("responsibleman");
  8122. if (responsible == "空白")
  8123. {
  8124. lw.Add(string.Format("ResponsibleUserName = ''"));
  8125. }
  8126. else if (responsible.Length > 0)
  8127. {
  8128. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8129. }
  8130. lw.Add(string.Format("RefundState>=0"));
  8131. dStruct.Order = "created desc";
  8132. }
  8133. else
  8134. {
  8135. string responsible = GetPostString("responsibleman");
  8136. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8137. lw.Add(string.Format("RefundState={0}", st));
  8138. dStruct.Order = "created desc";
  8139. }
  8140. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8141. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8142. dt.Columns.Add("refund_fees");
  8143. foreach (DataRow dr in dt.Rows)
  8144. {
  8145. String status = dr["status"].ToString();
  8146. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8147. {
  8148. dr["refund_fees"] = dr["refund_fee"];
  8149. }
  8150. else
  8151. {
  8152. dr["refund_fees"] = "0.0";
  8153. }
  8154. }
  8155. writeGridDataTableJson(dStruct.TotalCount, dt);
  8156. }
  8157. public void get_erp_refunddesignlist()
  8158. {
  8159. DataStruct dStruct = GetPostStruct();
  8160. List<string> lw = new List<string>();
  8161. string tid = GetPostString("tid");
  8162. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8163. string shopname = GetPostString("shopname");
  8164. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8165. string buyernick = GetPostString("buyer_nick");
  8166. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8167. string customer = GetPostString("customer");
  8168. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8169. string design = GetPostString("design");
  8170. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8171. string sellermemo = GetPostString("seller_memo");
  8172. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8173. string redate1 = GetPostString("refunddate1");
  8174. string redate2 = GetPostString("refunddate2");
  8175. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8176. if (dwdate.Length > 0) lw.Add(dwdate);
  8177. string price1 = GetPostString("price1");
  8178. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8179. string price2 = GetPostString("price2");
  8180. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8181. string ispartrefund = GetPostString("ispartrefund");
  8182. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8183. string designerorg = GetPostString("designerorg");
  8184. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8185. string refundState = GetPostString("refundState");
  8186. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8187. int myOrgid = CurrentUser.UserPost.OrgID;
  8188. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8189. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8190. {
  8191. if (CurrentUser.User.TeamIds.Length > 0)
  8192. {
  8193. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8194. }
  8195. else
  8196. {
  8197. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8198. }
  8199. }
  8200. else if ("SysAdmin".Equals(myOrgCode))
  8201. {
  8202. }
  8203. else
  8204. {
  8205. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8206. {
  8207. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8208. }
  8209. else
  8210. {
  8211. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8212. }
  8213. }
  8214. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8215. dStruct.Order = "created desc";
  8216. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8217. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8218. dt.Columns.Add("refund_fees");
  8219. foreach (DataRow dr in dt.Rows)
  8220. {
  8221. String status = dr["status"].ToString();
  8222. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8223. {
  8224. dr["refund_fees"] = dr["refund_fee"];
  8225. }
  8226. else
  8227. {
  8228. dr["refund_fees"] = "0.0";
  8229. }
  8230. }
  8231. writeGridDataTableJson(dStruct.TotalCount, dt);
  8232. }
  8233. public void handle_erp_refundtag()
  8234. {
  8235. if (UrlPostParmsCheck("refund_id"))
  8236. {
  8237. string eid = GetPostString("refund_id");
  8238. string respMan = GetPostString("ResponsibleName");
  8239. if (respMan.Length <= 0)
  8240. {
  8241. returnErrorMsg("责任人不能为空");
  8242. return;
  8243. }
  8244. CeErpTradeRefund entity = null;
  8245. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8246. if (entity != null)
  8247. {
  8248. entity.ResponsibleUserName = respMan;
  8249. string userid = GetPostString("ResponsibleUserId");
  8250. if (userid.Length > 0)
  8251. {
  8252. entity.ResponsibleUserId = userid;
  8253. }
  8254. entity.Memo = GetPostString("Memo");
  8255. if (respMan.IndexOf("客服") != -1 ||
  8256. respMan.IndexOf("设计师") != -1 ||
  8257. respMan.IndexOf("下单员") != -1)
  8258. {
  8259. entity.RefundState = 2;
  8260. }
  8261. else
  8262. {
  8263. entity.RefundState = 3;
  8264. }
  8265. entity.modified = DateTime.Now;
  8266. entity.Update();
  8267. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8268. returnSuccessMsg("操作成功!");
  8269. return;
  8270. }
  8271. returnErrorMsg("找不到订单记录");
  8272. }
  8273. }
  8274. public void handle_erp_designrefundtag()
  8275. {
  8276. if (UrlPostParmsCheck("refund_id"))
  8277. {
  8278. string eid = GetPostString("refund_id");
  8279. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8280. if (ceErpTradeCellExtend == null)
  8281. {
  8282. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8283. ceErpTradeCellExtend.ctid = eid;
  8284. }
  8285. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8286. if (ceErpTradeCellExtend.ID > 0)
  8287. {
  8288. ceErpTradeCellExtend.Update();
  8289. }
  8290. else
  8291. {
  8292. ceErpTradeCellExtend.Create();
  8293. }
  8294. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8295. returnSuccessMsg("操作成功!");
  8296. return;
  8297. }
  8298. returnErrorMsg("找不到订单记录");
  8299. }
  8300. public void upd_erp_refundverify()
  8301. {
  8302. if (UrlPostParmsCheck("refund_id"))
  8303. {
  8304. string eid = GetPostString("refund_id");
  8305. CeErpTradeRefund entity = null;
  8306. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8307. if (entity != null)
  8308. {
  8309. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8310. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8311. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8312. {
  8313. entity.RefundState = 2;
  8314. }
  8315. else
  8316. {
  8317. entity.RefundState = 3;
  8318. }
  8319. entity.Update();
  8320. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8321. returnSuccessMsg("操作成功!");
  8322. return;
  8323. }
  8324. returnErrorMsg("找不到订单记录");
  8325. }
  8326. }
  8327. public void upd_erp_refundapprove()
  8328. {
  8329. if (UrlPostParmsCheck("refund_id"))
  8330. {
  8331. string eid = GetPostString("refund_id");
  8332. CeErpTradeRefund entity = null;
  8333. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8334. if (entity != null)
  8335. {
  8336. int apr = GetPostInt("approve");
  8337. if (apr == 0)
  8338. {
  8339. entity.RefundState = 1;
  8340. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8341. }
  8342. else if (apr == 1)
  8343. {
  8344. entity.RefundState = 3;
  8345. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8346. }
  8347. entity.modified = DateTime.Now;
  8348. entity.Update();
  8349. returnSuccessMsg("操作成功!");
  8350. return;
  8351. }
  8352. returnErrorMsg("找不到订单记录");
  8353. }
  8354. }
  8355. public void get_erp_billlist()
  8356. {
  8357. DataStruct dStruct = GetPostStruct();
  8358. List<string> lw = new List<string>();
  8359. string title = GetPostString("title");
  8360. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8361. string tid = GetPostString("tid");
  8362. string tids = GetPostString("tids");
  8363. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8364. if (tids.Length > 0)
  8365. {
  8366. tids = "'" + tids + "'";
  8367. tids = tids.Replace(",", "','");
  8368. lw.Add(string.Format("tid in ({0})", tids));
  8369. }
  8370. string shopname = GetPostString("shopname");
  8371. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8372. string buyernick = GetPostString("buyer_nick");
  8373. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8374. string customer = GetPostString("customer");
  8375. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8376. string date1 = GetPostString("date1");
  8377. string date2 = GetPostString("date2");
  8378. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8379. if (dw.Length > 0) lw.Add(dw);
  8380. string price1 = GetPostString("price1");
  8381. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8382. string price2 = GetPostString("price2");
  8383. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8384. string returndate1 = GetPostString("returndate1");
  8385. string returndate2 = GetPostString("returndate2");
  8386. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8387. if (dw1.Length > 0) lw.Add(dw1);
  8388. string billtype = GetPostString("billtype");
  8389. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8390. string billstate = GetPostString("billstate");
  8391. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8392. string usershop = CurrentUser.User.pemShop;
  8393. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8394. dStruct.Order = "createTime desc";
  8395. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8396. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8397. //foreach (DataRow dr in dt.Rows)
  8398. //{
  8399. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8400. //}
  8401. writeGridDataTableJson(dStruct.TotalCount, dt);
  8402. }
  8403. public void modify_erp_billinfo()
  8404. {
  8405. if (UrlPostParmsCheck("ID"))
  8406. {
  8407. string eid = GetPostString("ID");
  8408. CeErpBill bill_entity = null;
  8409. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8410. if (bill_entity != null)
  8411. {
  8412. bill_entity.tid = GetPostString("tid");
  8413. bill_entity.title = GetPostString("title");
  8414. bill_entity.tax = GetPostString("tax");
  8415. bill_entity.bank = GetPostString("bank");
  8416. bill_entity.bankac = GetPostString("bankac");
  8417. bill_entity.address = GetPostString("address");
  8418. bill_entity.phone = GetPostString("phone");
  8419. bill_entity.price = GetPostString("price");
  8420. bill_entity.productId = GetPostInt("ProductName");
  8421. bill_entity.num = GetPostInt("num");
  8422. bill_entity.unit = GetPostString("unit");
  8423. bill_entity.type = GetPostString("type");
  8424. bill_entity.sendType = GetPostString("SendType");
  8425. bill_entity.email = GetPostString("email");
  8426. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8427. bill_entity.shopName = GetPostString("ShopName");
  8428. bill_entity.applymemo = GetPostString("applymemo");
  8429. bill_entity.modifyTime = DateTime.Now;
  8430. bill_entity.createTime = DateTime.Now;
  8431. bill_entity.state = 0;
  8432. bill_entity.Update();
  8433. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8434. returnSuccessMsg("发票修改成功!");
  8435. return;
  8436. }
  8437. returnErrorMsg("找不到对应记录");
  8438. }
  8439. }
  8440. public void set_erp_invoicing()
  8441. {
  8442. if (UrlPostParmsCheck("id"))
  8443. {
  8444. try
  8445. {
  8446. string eid = GetPostString("id");
  8447. CeErpBill bill_entity = null;
  8448. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8449. if (bill_entity != null)
  8450. {
  8451. int ComId = GetPostInt("ComId");
  8452. //string memo = GetPostString("Memo");
  8453. int allInfo = GetPostInt("allinfo");
  8454. string clert = CurrentUser.User.Name;
  8455. //string detailValue = GetPostString("detailvalue");
  8456. string billId = bill_entity.billOrderId;
  8457. string[] billIdList = billId.Split(',');
  8458. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8459. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8460. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8461. {
  8462. billCount += 1;
  8463. }
  8464. if (billId.Length <= 0 || billIdList.Length != billCount)
  8465. {
  8466. bill_entity.billOrderId = "";
  8467. string prebill = "ltb";
  8468. for (int idx = 1; idx <= billCount; idx++)
  8469. {
  8470. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8471. string billoid = prebill + idx + dtstr;
  8472. bill_entity.billOrderId += billoid;
  8473. if (idx < billCount)
  8474. {
  8475. bill_entity.billOrderId += ",";
  8476. }
  8477. }
  8478. }
  8479. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8480. if (bill_entity.state == 5)
  8481. {
  8482. string errMsg = bill_entity.failerror;
  8483. string[] errlist = errMsg.Split('|');
  8484. string[] errTags = new string[errlist.Length];
  8485. for (int itag = 0; itag < errlist.Length; itag++)
  8486. {
  8487. if (errlist[itag].Length <= 0) continue;
  8488. errTags[itag] = errlist[itag].Split('&')[0];
  8489. }
  8490. for (int iii = 0; iii < errTags.Length; iii++)
  8491. {
  8492. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8493. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8494. if (billOrderList.Length >= erroBillOrderTag)
  8495. {
  8496. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8497. if (needModifyBillId.Length <= 19)
  8498. {
  8499. needModifyBillId = needModifyBillId + "1";
  8500. }
  8501. else
  8502. {
  8503. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8504. last = last + 1;
  8505. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8506. }
  8507. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8508. }
  8509. }
  8510. }
  8511. bool isHaveBillSucces = false;
  8512. string totalRes = "";
  8513. bill_entity.failerror = "";
  8514. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8515. {
  8516. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8517. totalRes += res;
  8518. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8519. {
  8520. isHaveBillSucces = true;
  8521. bill_entity.comId = ComId;
  8522. bill_entity.state = 1;
  8523. bill_entity.executeTime = DateTime.Now;
  8524. bill_entity.executeUser = clert;
  8525. }
  8526. else
  8527. {
  8528. bill_entity.state = 5;
  8529. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8530. }
  8531. }
  8532. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8533. bill_entity.Update();
  8534. if (isHaveBillSucces)
  8535. {
  8536. StringBuilder sql = new StringBuilder();
  8537. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8538. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8539. }
  8540. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8541. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8542. {
  8543. returnErrorMsg("开票失败");
  8544. }
  8545. else
  8546. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8547. return;
  8548. }
  8549. returnErrorMsg("找不到对应记录");
  8550. }
  8551. catch (Exception ex)
  8552. {
  8553. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8554. returnErrorMsg("操作失败");
  8555. }
  8556. }
  8557. }
  8558. public void get_erp_invoicing_back()
  8559. {
  8560. if (UrlPostParmsCheck("id"))
  8561. {
  8562. try
  8563. {
  8564. string id = GetPostString("id");
  8565. CeErpBill entiy = CeErpBill.Get(id);
  8566. if (entiy != null)
  8567. {
  8568. if (entiy.state == 0)
  8569. {
  8570. returnErrorMsg("发票还未开具");
  8571. return;
  8572. }
  8573. string[] billOrderList = entiy.billOrderId.Split(',');
  8574. int iTag = 0;
  8575. entiy.fplsh = "";
  8576. entiy.fpdm = "";
  8577. entiy.fphm = "";
  8578. foreach (string billOrderId in billOrderList)
  8579. {
  8580. iTag++;
  8581. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8582. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8583. {
  8584. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8585. try
  8586. {
  8587. Invoicing_get_response_Obj iObj = null;
  8588. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8589. if (iObj != null)
  8590. {
  8591. entiy.state = 2;
  8592. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8593. entiy.fpdm += iObj.list[0].c_fpdm;
  8594. entiy.fphm += iObj.list[0].c_fphm;
  8595. if (iTag < billOrderList.Length)
  8596. {
  8597. entiy.fplsh += ",";
  8598. entiy.fpdm += ",";
  8599. entiy.fphm += ",";
  8600. }
  8601. entiy.Update();
  8602. }
  8603. StringBuilder sql = new StringBuilder();
  8604. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8605. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8606. returnSuccessMsg("开票成功");
  8607. }
  8608. catch (Exception ex)
  8609. {
  8610. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8611. }
  8612. return;
  8613. }
  8614. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8615. {
  8616. var res_obj = new
  8617. {
  8618. data = "开票中"
  8619. };
  8620. string ro_json = JsonConvert.SerializeObject(res_obj);
  8621. returnSuccess(ro_json);
  8622. return;
  8623. }
  8624. else
  8625. {
  8626. int eidx = res.IndexOf("c_resultmsg");
  8627. int lidx = res.IndexOf("c_status");
  8628. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8629. entiy.state = 5;
  8630. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8631. entiy.Update();
  8632. returnErrorMsg("开票失败");
  8633. return;
  8634. }
  8635. }
  8636. }
  8637. }
  8638. catch (Exception ex)
  8639. {
  8640. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8641. }
  8642. return;
  8643. }
  8644. }
  8645. public void get_erp_invoicing()
  8646. {
  8647. if (UrlPostParmsCheck("id"))
  8648. {
  8649. try
  8650. {
  8651. string id = GetPostString("id");
  8652. CeErpBill entiy = CeErpBill.Get(id);
  8653. if (entiy != null)
  8654. {
  8655. if (entiy.state == 0)
  8656. {
  8657. returnErrorMsg("发票还未开具");
  8658. return;
  8659. }
  8660. if (entiy.sendType == "纸质发票")
  8661. {
  8662. if (entiy.img.Length <= 0)
  8663. {
  8664. returnErrorMsg("查无纸质发票");
  8665. return;
  8666. }
  8667. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8668. returnSuccess(returnres);
  8669. return;
  8670. }
  8671. string[] billOrderList = entiy.billOrderId.Split(',');
  8672. int iTag = 0;
  8673. string fpUrl = "";
  8674. entiy.fplsh = "";
  8675. entiy.fpdm = "";
  8676. entiy.fphm = "";
  8677. foreach (string billOrderId in billOrderList)
  8678. {
  8679. iTag++;
  8680. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8681. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8682. {
  8683. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8684. Invoicing_get_response_Obj iObj = null;
  8685. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8686. if (iObj != null)
  8687. {
  8688. //entiy.state = 2;
  8689. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8690. entiy.fpdm += iObj.list[0].c_fpdm;
  8691. entiy.fphm += iObj.list[0].c_fphm;
  8692. if (iTag < billOrderList.Length)
  8693. {
  8694. entiy.fplsh += ",";
  8695. entiy.fpdm += ",";
  8696. entiy.fphm += ",";
  8697. }
  8698. entiy.Update();
  8699. fpUrl += iObj.list[0].c_url + ",";
  8700. }
  8701. //returnSuccess(res);
  8702. StringBuilder sql = new StringBuilder();
  8703. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8704. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8705. }
  8706. else
  8707. {
  8708. int eidx = res.IndexOf("c_resultmsg");
  8709. //int lidx = res.IndexOf("c_status");
  8710. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8711. //开票失败
  8712. entiy.state = 5;
  8713. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8714. entiy.Update();
  8715. returnErrorMsg("开票失败");
  8716. return;
  8717. }
  8718. }
  8719. var returnObj = new
  8720. {
  8721. data = fpUrl
  8722. };
  8723. string ro_json = JsonConvert.SerializeObject(returnObj);
  8724. returnSuccess(ro_json);
  8725. }
  8726. }
  8727. catch (Exception ex)
  8728. {
  8729. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8730. }
  8731. return;
  8732. }
  8733. }
  8734. public void save_erp_billimg()
  8735. {
  8736. if (UrlPostParmsCheck("id"))
  8737. {
  8738. string eid = GetPostString("id");
  8739. CeErpBill bill_entity = null;
  8740. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8741. if (bill_entity != null)
  8742. {
  8743. bill_entity.img = GetPostString("img");
  8744. bill_entity.executeTime = DateTime.Now;
  8745. bill_entity.state = 2;
  8746. bill_entity.Update();
  8747. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8748. returnSuccessMsg("保存成功");
  8749. }
  8750. return;
  8751. }
  8752. }
  8753. public void upd_erp_billreturnback()
  8754. {
  8755. if (UrlPostParmsCheck("id"))
  8756. {
  8757. int eid = GetPostInt("id");
  8758. CeErpBill bill_entity = null;
  8759. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8760. if (bill_entity != null)
  8761. {
  8762. bill_entity.state = 3;
  8763. bill_entity.returnReason = GetPostString("reason");
  8764. bill_entity.Update();
  8765. returnSuccessMsg("驳回成功!");
  8766. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8767. }
  8768. return;
  8769. }
  8770. }
  8771. public void cancel_erp_bill()
  8772. {
  8773. if (UrlPostParmsCheck("id"))
  8774. {
  8775. int eid = GetPostInt("id");
  8776. int detailValue = GetPostInt("detailvalue");
  8777. CeErpBill bill_entity = null;
  8778. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8779. string cres = "";
  8780. string gres = "";
  8781. if (bill_entity != null)
  8782. {
  8783. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8784. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8785. {
  8786. int iTag = 0;
  8787. bill_entity.fplsh = "";
  8788. bill_entity.fpdm = "";
  8789. bill_entity.fphm = "";
  8790. foreach (string billOrderId in billOrderList)
  8791. {
  8792. iTag++;
  8793. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8794. if (gres.IndexOf("success") != -1)
  8795. {
  8796. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8797. Invoicing_get_response_Obj iObj = null;
  8798. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8799. if (iObj != null)
  8800. {
  8801. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8802. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8803. bill_entity.fphm += iObj.list[0].c_fphm;
  8804. if (iTag < billOrderList.Length)
  8805. {
  8806. bill_entity.fplsh += ",";
  8807. bill_entity.fpdm += ",";
  8808. bill_entity.fphm += ",";
  8809. }
  8810. bill_entity.Update();
  8811. }
  8812. }
  8813. else
  8814. {
  8815. returnErrorMsg(gres);
  8816. return;
  8817. }
  8818. }
  8819. }
  8820. if (bill_entity.sendType == "纸质发票")
  8821. {
  8822. //作废
  8823. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8824. //if (DateTime.Now.Month == extime.Month)
  8825. //{
  8826. //cres = taobaoHelper.cancel_invoicing(eid);
  8827. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8828. //{
  8829. bill_entity.state = 4;//已作废
  8830. bill_entity.Update();
  8831. returnSuccessMsg("发票已作废");
  8832. return;
  8833. //}
  8834. //else
  8835. //{
  8836. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8837. // bill_entity.Update();
  8838. // returnErrorMsg(cres);
  8839. // return;
  8840. //}
  8841. //}
  8842. //else
  8843. //{
  8844. // returnErrorMsg("纸质发票只能作废本月的发票");
  8845. // return;
  8846. //}
  8847. }
  8848. //红冲
  8849. int redTag = 0;
  8850. string[] fpdmList = bill_entity.fpdm.Split(',');
  8851. string[] fphmList = bill_entity.fphm.Split(',');
  8852. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8853. {
  8854. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8855. return;
  8856. }
  8857. foreach (string billOrderId in billOrderList)
  8858. {
  8859. redTag++;
  8860. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8861. cres += onecres;
  8862. cres += ",";
  8863. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8864. {
  8865. bill_entity.state = 4;//已作废
  8866. //bill_entity.Update();
  8867. //returnSuccessMsg("发票已红冲");
  8868. }
  8869. else if (onecres.IndexOf("重复冲红") != -1)
  8870. {
  8871. bill_entity.state = 4;//已作废
  8872. //bill_entity.Update();
  8873. //returnSuccessMsg("发票已红冲");
  8874. }
  8875. else
  8876. {
  8877. string errmsg = commonHelper.KeepChinese(onecres);
  8878. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8879. }
  8880. }
  8881. bill_entity.Update();
  8882. if (cres.IndexOf("失败") != -1)
  8883. returnErrorMsg("红冲失败");
  8884. else
  8885. returnSuccessMsg("发票已红冲");
  8886. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8887. return;
  8888. }
  8889. return;
  8890. }
  8891. }
  8892. public void del_erp_billorder()
  8893. {
  8894. if (UrlPostParmsCheck("id"))
  8895. {
  8896. string eid = GetPostString("id");
  8897. CeErpBill.Del(eid);
  8898. CeErpBill bill = CeErpBill.Get(eid);
  8899. if (bill != null)
  8900. {
  8901. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8902. }
  8903. returnSuccessMsg("删除成功");
  8904. }
  8905. }
  8906. public void finish_erp_bill()
  8907. {
  8908. if (UrlPostParmsCheck("ids"))
  8909. {
  8910. string eids = GetPostString("ids");
  8911. string[] list = eids.Split(',');
  8912. foreach (string eid in list)
  8913. {
  8914. CeErpBill bill = CeErpBill.Get(eid);
  8915. if (bill != null)
  8916. {
  8917. bill.state = 2;
  8918. bill.Update();
  8919. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8920. }
  8921. }
  8922. returnSuccessMsg("操作成功");
  8923. }
  8924. }
  8925. public void get_erp_returncash()
  8926. {
  8927. DataStruct dStruct = GetPostStruct();
  8928. List<string> lw = new List<string>();
  8929. string tid = GetPostString("tid");
  8930. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8931. string shopname = GetPostString("shopname");
  8932. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8933. string buyernick = GetPostString("buyer_nick");
  8934. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8935. string customer = GetPostString("customer");
  8936. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8937. string returndate1 = GetPostString("returndate1");
  8938. string returndate2 = GetPostString("returndate2");
  8939. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8940. if (dw.Length > 0) lw.Add(dw);
  8941. string finishDate1 = GetPostString("finishdate1");
  8942. string finishDate2 = GetPostString("finishdate2");
  8943. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8944. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8945. string returntype = GetPostString("returntype");
  8946. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8947. string returnvstate = GetPostString("returnvstate");
  8948. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8949. dStruct.Order = "created desc";
  8950. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8951. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8952. writeGridDataTableJson(dStruct.TotalCount, dt);
  8953. }
  8954. public void get_erp_staygoods()
  8955. {
  8956. DataStruct dStruct = GetPostStruct();
  8957. List<string> lw = new List<string>();
  8958. string tid = GetPostString("tid");
  8959. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8960. string shopname = GetPostString("shopname");
  8961. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8962. string wangwang = GetPostString("wangwang");
  8963. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8964. string customer = GetPostString("customer");
  8965. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8966. string returndate1 = GetPostString("returndate1");
  8967. string returndate2 = GetPostString("returndate2");
  8968. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8969. if (dw.Length > 0) lw.Add(dw);
  8970. string finishDate1 = GetPostString("finishdate1");
  8971. string finishDate2 = GetPostString("finishdate2");
  8972. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8973. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8974. string returnvstate = GetPostString("returnvstate");
  8975. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8976. string persuadetype = GetPostString("persuadetype");
  8977. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8978. string customerOrg = GetPostString("customerOrg");
  8979. if (customerOrg.Length > 0)
  8980. {
  8981. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8982. }
  8983. string designerorg = GetPostString("designerorg");
  8984. if (designerorg.Length > 0)
  8985. {
  8986. lw.Add(string.Format("OrgID = {0}", designerorg));
  8987. }
  8988. dStruct.Order = "creata_time desc";
  8989. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8990. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8991. writeGridDataTableJson(dStruct.TotalCount, dt);
  8992. }
  8993. public void upd_erp_staygoods()
  8994. {
  8995. if (UrlPostParmsCheck("id"))
  8996. {
  8997. int eid = GetPostInt("id");
  8998. CeErpStayGoods entity = null;
  8999. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9000. if (entity != null)
  9001. {
  9002. entity.audit_type = 1;
  9003. entity.audit_time = DateTime.Now;
  9004. entity.audit_u_id = CurrentUser.UserID;
  9005. entity.audit_u_name = CurrentUser.UserName;
  9006. entity.Update();
  9007. returnSuccessMsg("审核成功!");
  9008. return;
  9009. }
  9010. returnErrorMsg("找不到订单记录");
  9011. }
  9012. }
  9013. public void upd_erp_stayGoodsback()
  9014. {
  9015. if (UrlPostParmsCheck("id"))
  9016. {
  9017. int eid = GetPostInt("id");
  9018. CeErpStayGoods entity = null;
  9019. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9020. if (entity != null)
  9021. {
  9022. entity.audit_text = GetPostString("reason");
  9023. entity.audit_type = 2;
  9024. entity.audit_time = DateTime.Now;
  9025. entity.audit_u_id = CurrentUser.UserID;
  9026. entity.audit_u_name = CurrentUser.UserName;
  9027. entity.Update();
  9028. returnSuccessMsg("退回成功!");
  9029. return;
  9030. }
  9031. returnErrorMsg("找不到订单记录");
  9032. }
  9033. }
  9034. public void upd_erp_returncashverify()
  9035. {
  9036. if (UrlPostParmsCheck("ID"))
  9037. {
  9038. int eid = GetPostInt("ID");
  9039. CeErpReturnCash entity = null;
  9040. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9041. if (entity != null)
  9042. {
  9043. entity.cashstate = 1;
  9044. entity.verifytime = DateTime.Now;
  9045. entity.verifyuserid = CurrentUser.UserID;
  9046. entity.Update();
  9047. returnSuccessMsg("审核成功!");
  9048. return;
  9049. }
  9050. returnErrorMsg("找不到订单记录");
  9051. }
  9052. }
  9053. public void upd_all_erp_returncashverify()
  9054. {
  9055. if (UrlPostParmsCheck("ID"))
  9056. {
  9057. String[] list = GetPostString("ID").Split(',');
  9058. CeErpReturnCash entity = null;
  9059. for (int i = 0; i < list.Length; i++)
  9060. {
  9061. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9062. if (entity != null)
  9063. {
  9064. if (entity.cashstate == 1)
  9065. {
  9066. returnErrorMsg("已审核过的订单不需要在审核!");
  9067. return;
  9068. }
  9069. entity.cashstate = 1;
  9070. entity.verifytime = DateTime.Now;
  9071. entity.verifyuserid = CurrentUser.UserID;
  9072. entity.Update();
  9073. }
  9074. }
  9075. returnSuccessMsg("审核成功!");
  9076. return;
  9077. }
  9078. }
  9079. public void upd_erp_returncashback()
  9080. {
  9081. if (UrlPostParmsCheck("ID"))
  9082. {
  9083. int eid = GetPostInt("ID");
  9084. CeErpReturnCash entity = null;
  9085. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9086. if (entity != null)
  9087. {
  9088. entity.backreason = GetPostString("reason");
  9089. entity.cashstate = 2;
  9090. entity.verifytime = DateTime.Now;
  9091. entity.verifyuserid = CurrentUser.UserID;
  9092. entity.Update();
  9093. returnSuccessMsg("退回成功!");
  9094. return;
  9095. }
  9096. returnErrorMsg("找不到订单记录");
  9097. }
  9098. }
  9099. public void upd_erp_returnprice()
  9100. {
  9101. if (UrlPostParmsCheck("ID"))
  9102. {
  9103. int eid = GetPostInt("ID");
  9104. CeErpReturnCash entity = null;
  9105. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9106. if (entity != null)
  9107. {
  9108. if (entity.cashstate == 1)
  9109. {
  9110. returnErrorMsg("审核通过了不能改");
  9111. return;
  9112. }
  9113. entity.returnprice = GetPostDouble("returnprice");
  9114. entity.Update();
  9115. returnSuccessMsg("修改成功!");
  9116. return;
  9117. }
  9118. returnErrorMsg("找不到订单记录");
  9119. }
  9120. }
  9121. public void del_erp_returncash()
  9122. {
  9123. if (UrlPostParmsCheck("ID"))
  9124. {
  9125. int eid = GetPostInt("ID");
  9126. CeErpReturnCash.Del(eid);
  9127. returnSuccessMsg("操作成功");
  9128. return;
  9129. }
  9130. }
  9131. public void test_for_do_sql()
  9132. {
  9133. string sql = GetPostString("sqlstr");
  9134. if (sql.Length > 0)
  9135. {
  9136. try
  9137. {
  9138. DbHelper.DbConn.ExecuteNonQuery(sql);
  9139. var res_obj = new
  9140. {
  9141. data = "成功",
  9142. };
  9143. string ro_json = JsonConvert.SerializeObject(res_obj);
  9144. returnSuccess(ro_json);
  9145. }
  9146. catch (Exception ex)
  9147. {
  9148. var res_obj = new
  9149. {
  9150. data = ex.Message,
  9151. };
  9152. string ro_json = JsonConvert.SerializeObject(res_obj);
  9153. returnSuccess(ro_json);
  9154. }
  9155. }
  9156. }
  9157. public void get_user_info()
  9158. {
  9159. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9160. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9161. }
  9162. public void get_total_data()
  9163. {
  9164. int userId = CurrentUser.UserID;
  9165. string sql = "";
  9166. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9167. {
  9168. 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);
  9169. }
  9170. else
  9171. {
  9172. 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 " +
  9173. "(select ID from CE_ErpUser where ID = {0}) d " +
  9174. "left join " +
  9175. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9176. ") a on d.ID = a.id left join " +
  9177. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9178. ") b on a.id = b.id1 left join" +
  9179. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9180. ") c on a.id = c.id2;", userId);
  9181. }
  9182. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9183. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9184. }
  9185. public void get_date_area_total_data2()
  9186. {
  9187. int userId = CurrentUser.UserID;
  9188. string date_type = GetPostString("timetype");
  9189. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9190. string sql = "";
  9191. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9192. {
  9193. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9194. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9195. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9196. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9197. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9198. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9199. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9200. ") a on e.ID = a.id left join " +
  9201. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9202. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9203. ") b on a.id = b.id1 " +
  9204. "left join " +
  9205. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9206. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9207. ") c on a.id = c.id2 " +
  9208. "left join " +
  9209. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9210. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9211. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9212. }
  9213. else
  9214. {
  9215. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9216. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9217. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9218. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9219. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9220. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9221. ") a on e.ID = a.id left join " +
  9222. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9223. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9224. ") c on a.id = c.id2 " +
  9225. "left join " +
  9226. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9227. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9228. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9229. }
  9230. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9231. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9232. }
  9233. public void get_date_area_total_data()
  9234. {
  9235. int userId = CurrentUser.UserID;
  9236. string date_type = GetPostString("timetype");
  9237. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9238. string date1 = searchDT[0].ToString();
  9239. string date2 = searchDT[1].ToString();
  9240. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9241. {
  9242. SqlParameter[] sqlParameter ={
  9243. new SqlParameter("@userId", SqlDbType.Int,4),
  9244. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9245. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9246. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9247. };
  9248. sqlParameter[0].Value = userId;
  9249. sqlParameter[1].Value = date1;
  9250. sqlParameter[2].Value = date2;
  9251. sqlParameter[3].Direction = ParameterDirection.Output;
  9252. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9253. string res = sqlParameter[3].Value.ToString();
  9254. var res_obj = new
  9255. {
  9256. data = res
  9257. };
  9258. string ro_json = JsonConvert.SerializeObject(res_obj);
  9259. returnSuccess(ro_json);
  9260. }
  9261. else
  9262. {
  9263. SqlParameter[] sqlParameter ={
  9264. new SqlParameter("@userId", SqlDbType.Int,4),
  9265. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9266. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9267. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9268. };
  9269. sqlParameter[0].Value = userId;
  9270. sqlParameter[1].Value = date1;
  9271. sqlParameter[2].Value = date2;
  9272. sqlParameter[3].Direction = ParameterDirection.Output;
  9273. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9274. string res = sqlParameter[3].Value.ToString();
  9275. var res_obj = new
  9276. {
  9277. data = res
  9278. };
  9279. string ro_json = JsonConvert.SerializeObject(res_obj);
  9280. returnSuccess(ro_json);
  9281. }
  9282. //writeGridDataViewJson(dt.Rows.Count, dv);
  9283. }
  9284. public void get_order_list()
  9285. {
  9286. string strFields = GetPostString("paraFields");
  9287. string strOrder = GetPostString("paraOrder");
  9288. string strWhere = GetPostString("paraWhere");
  9289. string strPageSize = GetPostString("paraPageSize");
  9290. DataStruct dStruct = GetPostStruct();
  9291. dStruct.PageSize = int.Parse(strPageSize);
  9292. dStruct.Fileds = strFields;
  9293. dStruct.Order = strOrder;
  9294. dStruct.MainWhere = strWhere;
  9295. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9296. writeGridDataTableJson(dStruct.TotalCount, dt);
  9297. }
  9298. ////获取待开始订单列表
  9299. //public void get_wait_design_order_list()
  9300. //{
  9301. // string date_type = GetPostString("date_type");
  9302. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9303. // DataStruct dStruct = GetPostStruct();
  9304. // dStruct.PageSize = 1000;
  9305. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9306. // List<string> lw = new List<string>();
  9307. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9308. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9309. // dStruct.Order = "WaitDesignTime asc";
  9310. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9311. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9312. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9313. //}
  9314. //获取完成单量排名
  9315. public void get_finish_order_count_ranking()
  9316. {
  9317. /* string date_type = GetPostString("date_type");
  9318. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9319. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9320. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9321. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9322. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9323. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9324. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9325. writeGridDataTableJson(0, new DataTable());
  9326. }
  9327. public void get_finish_order_amount_ranking()
  9328. {
  9329. /*string date_type = GetPostString("date_type");
  9330. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9331. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9332. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9333. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9334. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9335. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9337. writeGridDataTableJson(0, new DataTable());
  9338. }
  9339. public void get_finish_refund_count_ranking()
  9340. {
  9341. string date_type = GetPostString("date_type");
  9342. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9343. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9344. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9345. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9346. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9347. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9348. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9349. writeGridDataTableJson(dt.Rows.Count, dt);
  9350. }
  9351. public void get_finish_refund_amount_ranking()
  9352. {
  9353. string date_type = GetPostString("date_type");
  9354. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9355. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9356. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9357. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9358. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9359. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9360. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9361. writeGridDataTableJson(dt.Rows.Count, dt);
  9362. }
  9363. public void set_erp_finishorder_director()
  9364. {
  9365. if (UrlPostParmsCheck("ctid"))
  9366. {
  9367. string eid = GetPostString("ctid");
  9368. CeErpTradeCell entity = null;
  9369. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9370. if (entity != null)
  9371. {
  9372. entity.OrderState = 8;
  9373. entity.Update();
  9374. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9375. returnSuccessMsg("操作成功!");
  9376. return;
  9377. }
  9378. returnErrorMsg("找不到记录");
  9379. }
  9380. }
  9381. public void get_erp_placeregistlist()
  9382. {
  9383. DataStruct dStruct = GetPostStruct();
  9384. List<string> lw = new List<string>();
  9385. string outsid = GetPostString("outsid");
  9386. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9387. string memo = GetPostString("memo");
  9388. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9389. string filename = GetPostString("filename");
  9390. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9391. string islate = GetPostString("islate");
  9392. if (islate.Length > 0)
  9393. {
  9394. if (islate == "1")
  9395. lw.Add(string.Format("OutLate>0"));
  9396. else
  9397. lw.Add(string.Format("OutLate=0"));
  9398. }
  9399. string placedate1 = GetPostString("placedate1");
  9400. string placedate2 = GetPostString("placedate2");
  9401. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9402. if (dw.Length > 0) lw.Add(dw);
  9403. string deliveryDate1 = GetPostString("deliverydate1");
  9404. string deliveryDate2 = GetPostString("deliverydate2");
  9405. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9406. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9407. dStruct.Order = "ID desc";
  9408. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9409. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9410. writeGridDataTableJson(dStruct.TotalCount, dt);
  9411. }
  9412. public void ins_erp_placeregist()
  9413. {
  9414. if (UrlPostParmsCheck("id"))
  9415. {
  9416. string eid = GetPostString("id");
  9417. CeErpPlaceRegister entity = null;
  9418. if (eid == "0")//新增
  9419. {
  9420. entity = new CeErpPlaceRegister();
  9421. string xdTime = GetPostString("placeTime");
  9422. if (xdTime.Length > 0)
  9423. {
  9424. entity.PlactTime = Convert.ToDateTime(xdTime);
  9425. }
  9426. string fhTime = GetPostString("deliveryTime");
  9427. if (fhTime.Length > 0)
  9428. {
  9429. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9430. }
  9431. string preTime = GetPostString("preOutTime");
  9432. if (preTime.Length > 0)
  9433. {
  9434. entity.PreOutTime = Convert.ToDateTime(preTime);
  9435. }
  9436. entity.DeliveryCount = GetPostInt("deliveryCount");
  9437. entity.ReceiveCount = GetPostInt("receiveCount");
  9438. entity.OutSid = GetPostString("outSid");
  9439. entity.FileName = GetPostString("fileName");
  9440. entity.Memo = GetPostString("memo");
  9441. entity.AddUserId = CurrentUser.UserID;
  9442. entity.CreateTime = DateTime.Now;
  9443. entity.Img = GetPostString("img");
  9444. entity.Supplier = GetPostInt("supplier");
  9445. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9446. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9447. {
  9448. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9449. DateTime dt2 = (DateTime)entity.PreOutTime;
  9450. TimeSpan span = dt1.Subtract(dt2);
  9451. if (span.Days > 0)
  9452. {
  9453. entity.OutLate = span.Days;
  9454. }
  9455. }
  9456. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9457. entity.Create();
  9458. returnSuccessMsg("添加成功!");
  9459. return;
  9460. }
  9461. else //修改
  9462. {
  9463. entity = CeErpPlaceRegister.Get(eid);
  9464. if (entity != null)
  9465. {
  9466. string xdTime = GetPostString("placeTime");
  9467. if (xdTime.Length > 0)
  9468. {
  9469. entity.PlactTime = Convert.ToDateTime(xdTime);
  9470. }
  9471. string fhTime = GetPostString("deliveryTime");
  9472. if (fhTime.Length > 0)
  9473. {
  9474. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9475. }
  9476. string preTime = GetPostString("preOutTime");
  9477. if (preTime.Length > 0)
  9478. {
  9479. entity.PreOutTime = Convert.ToDateTime(preTime);
  9480. }
  9481. entity.DeliveryCount = GetPostInt("deliveryCount");
  9482. entity.ReceiveCount = GetPostInt("receiveCount");
  9483. if (entity.DeliveryCount == entity.ReceiveCount)
  9484. {
  9485. entity.CurState = "已完成";
  9486. }
  9487. else
  9488. {
  9489. entity.CurState = "未完成";
  9490. }
  9491. entity.OutSid = GetPostString("outSid");
  9492. entity.FileName = GetPostString("fileName");
  9493. entity.Memo = GetPostString("memo");
  9494. entity.Img = GetPostString("img");
  9495. entity.Supplier = GetPostInt("supplier");
  9496. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9497. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9498. {
  9499. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9500. DateTime dt2 = (DateTime)entity.PreOutTime;
  9501. TimeSpan span = dt1.Subtract(dt2);
  9502. if (span.Days > 0)
  9503. {
  9504. entity.OutLate = span.Days;
  9505. }
  9506. }
  9507. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9508. entity.Update();
  9509. returnSuccessMsg("修改成功");
  9510. return;
  9511. }
  9512. returnErrorMsg("找不到对应的记录");
  9513. return;
  9514. }
  9515. }
  9516. returnErrorMsg("缺少必要参数");
  9517. }
  9518. public void del_erp_placeregist()
  9519. {
  9520. string eid = GetPostString("id");
  9521. CeErpPlaceRegister.Del(eid);
  9522. returnSuccessMsg("删除成功!");
  9523. return;
  9524. }
  9525. public void ins_erp_placeregistbyorder()
  9526. {
  9527. string ctid = GetPostString("ctid");
  9528. if (ctid.Length > 0)
  9529. {
  9530. StringBuilder sql = new StringBuilder();
  9531. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9532. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9533. if (dt.Rows.Count > 0)
  9534. {
  9535. foreach (DataRow dr in dt.Rows)
  9536. {
  9537. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9538. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9539. entity.AddUserId = CurrentUser.UserID;
  9540. entity.tid = dr["tid"].ToString();
  9541. entity.Did = Convert.ToString(dr["ctid"]);
  9542. entity.splitTag = dr["SplitTag"].ToString();
  9543. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9544. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9545. if (pre_ctid.Length > 0)
  9546. {
  9547. sellmemo = sellmemo.Replace(pre_ctid, "");
  9548. }
  9549. sellmemo = sellmemo.Replace("[", "");
  9550. sellmemo = sellmemo.Replace("]", "");
  9551. entity.FileName = sellmemo;
  9552. string count = dr["ProductCount"].ToString();
  9553. int usecount = commonHelper.getIntCountFromString(count);
  9554. entity.DeliveryCount = usecount;
  9555. entity.CurState = "未完成";
  9556. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9557. {
  9558. entity.Supplier = 24;//dl手提袋定制
  9559. }
  9560. else
  9561. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9562. entity.CreateTime = DateTime.Now;
  9563. entity.Create();
  9564. }
  9565. returnSuccessMsg("操作成功");
  9566. return;
  9567. }
  9568. returnErrorMsg("没有找到对应订单");
  9569. return;
  9570. }
  9571. returnErrorMsg("缺少订单编号");
  9572. return;
  9573. }
  9574. public void get_erp_persuadelist()
  9575. {
  9576. DataStruct dStruct = GetPostStruct();
  9577. List<string> lw = new List<string>();
  9578. string ctid = GetPostString("ctid");
  9579. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9580. string shopname = GetPostString("shopname");
  9581. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9582. string buyernick = GetPostString("buyer_nick");
  9583. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9584. string customer = GetPostString("customer");
  9585. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9586. string returndate1 = GetPostString("returndate1");
  9587. string returndate2 = GetPostString("returndate2");
  9588. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9589. if (dw.Length > 0) lw.Add(dw);
  9590. string finishDate1 = GetPostString("finishdate1");
  9591. string finishDate2 = GetPostString("finishdate2");
  9592. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9593. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9594. string persuadetype = GetPostString("persuadetype");
  9595. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9596. string returnvstate = GetPostString("returnvstate");
  9597. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9598. dStruct.Order = "created desc";
  9599. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9600. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9601. writeGridDataTableJson(dStruct.TotalCount, dt);
  9602. }
  9603. public void upd_erp_returnpersuadeback()
  9604. {
  9605. if (UrlPostParmsCheck("ID"))
  9606. {
  9607. int eid = GetPostInt("ID");
  9608. CeErpPersuade entity = null;
  9609. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9610. if (entity != null)
  9611. {
  9612. entity.backreason = GetPostString("reason");
  9613. entity.pstate = 2;
  9614. entity.verifytime = DateTime.Now;
  9615. entity.verifyuserid = CurrentUser.UserID;
  9616. entity.Update();
  9617. returnSuccessMsg("退回成功!");
  9618. return;
  9619. }
  9620. returnErrorMsg("找不到订单记录");
  9621. }
  9622. }
  9623. public void upd_erp_returnpersuadeverify()
  9624. {
  9625. if (UrlPostParmsCheck("ID"))
  9626. {
  9627. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9628. {
  9629. returnErrorMsg("暂无权限审核");
  9630. return;
  9631. }
  9632. int eid = GetPostInt("ID");
  9633. CeErpPersuade entity = null;
  9634. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9635. if (entity != null)
  9636. {
  9637. entity.pstate = 1;
  9638. entity.verifytime = DateTime.Now;
  9639. entity.verifyuserid = CurrentUser.UserID;
  9640. entity.Update();
  9641. returnSuccessMsg("审核成功!");
  9642. return;
  9643. }
  9644. returnErrorMsg("找不到订单记录");
  9645. }
  9646. }
  9647. public void del_erp_persuade()
  9648. {
  9649. if (UrlPostParmsCheck("ID"))
  9650. {
  9651. int eid = GetPostInt("ID");
  9652. CeErpPersuade.Del(eid);
  9653. returnSuccessMsg("操作成功");
  9654. return;
  9655. }
  9656. }
  9657. public void get_erp_oldcustoupload()
  9658. {
  9659. DataStruct dStruct = GetPostStruct();
  9660. List<string> lw = new List<string>();
  9661. string buyernick = GetPostString("buyer_nick");
  9662. if (buyernick.Length > 0)
  9663. {
  9664. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9665. }
  9666. else
  9667. return;
  9668. dStruct.Order = "pay_time desc";
  9669. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9670. DataTable dt = null;
  9671. dt = WebCache.GetData("view_erptradecell", dStruct);
  9672. writeGridDataTableJson(dStruct.TotalCount, dt);
  9673. }
  9674. public void get_erp_checkorderlist()
  9675. {
  9676. DataStruct dStruct = GetPostStruct();
  9677. List<string> lw = new List<string>();
  9678. string tid = GetPostString("ctid");
  9679. if (tid.Length > 0)
  9680. {
  9681. string select_tid = getTidByCtid(tid);
  9682. lw.Add(string.Format("tid='{0}'", select_tid));
  9683. }
  9684. string shopname = GetPostString("shopname");
  9685. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9686. string buyernick = GetPostString("buyer_nick");
  9687. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9688. string customer = GetPostString("customer");
  9689. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9690. string design = GetPostString("design");
  9691. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9692. string orderState = GetPostString("orderState");
  9693. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9694. string address = GetPostString("address");
  9695. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9696. string sellermemo = GetPostString("seller_memo");
  9697. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9698. string supplier = GetPostString("supplier");
  9699. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9700. {
  9701. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9702. }
  9703. else
  9704. {
  9705. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9706. }
  9707. string date1 = GetPostString("date1");
  9708. string date2 = GetPostString("date2");
  9709. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9710. if (dw.Length > 0) lw.Add(dw);
  9711. string placedate1 = GetPostString("placedate1");
  9712. string placedate2 = GetPostString("placedate2");
  9713. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9714. if (fdw.Length > 0) lw.Add(fdw);
  9715. string price1 = GetPostString("price1");
  9716. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9717. string price2 = GetPostString("price2");
  9718. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9719. string checkst = GetPostString("checkstate");
  9720. if (checkst.Length > 0 && "10".Equals(checkst))
  9721. {
  9722. lw.Add(string.Format("CheckOut>0"));
  9723. }
  9724. else
  9725. {
  9726. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9727. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9728. }
  9729. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9730. {
  9731. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9732. }
  9733. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9734. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9735. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9736. writeGridDataTableJson(dStruct.TotalCount, dt);
  9737. }
  9738. public void ins_erp_startCheck()
  9739. {
  9740. if (UrlPostParmsCheck("ctid"))
  9741. {
  9742. string eid = GetPostString("ctid");
  9743. CeErpTradeCell entity = null;
  9744. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9745. if (entity != null)
  9746. {
  9747. entity.MemoOpt = 4;
  9748. entity.UpdateTime = DateTime.Now;
  9749. entity.Update();
  9750. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9751. CeErpSukuraData.createInfo(entity.ctid, 6);
  9752. returnSuccessMsg("操作成功!");
  9753. return;
  9754. }
  9755. returnErrorMsg("找不到记录");
  9756. }
  9757. }
  9758. public void upd_erp_sendXlw()
  9759. {
  9760. if (UrlPostParmsCheck("ctid"))
  9761. {
  9762. string eid = GetPostString("ctid");
  9763. CeErpTradeCell entity = null;
  9764. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9765. if (entity != null)
  9766. {
  9767. if (entity.IsSendGift == 1)
  9768. {
  9769. returnErrorMsg("请勿重复标记");
  9770. return;
  9771. }
  9772. entity.IsSendGift = 1;
  9773. entity.Update();
  9774. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9775. returnSuccessMsg("操作成功!");
  9776. return;
  9777. }
  9778. returnErrorMsg("找不到记录");
  9779. }
  9780. }
  9781. public void cancel_sendXlw()
  9782. {
  9783. if (UrlPostParmsCheck("ctid"))
  9784. {
  9785. string eid = GetPostString("ctid");
  9786. CeErpTradeCell entity = null;
  9787. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9788. if (entity != null)
  9789. {
  9790. if (entity.IsSendGift == 0)
  9791. {
  9792. returnErrorMsg("未标记小礼物");
  9793. return;
  9794. }
  9795. entity.IsSendGift = 0;
  9796. entity.Update();
  9797. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9798. returnSuccessMsg("操作成功!");
  9799. return;
  9800. }
  9801. returnErrorMsg("找不到记录");
  9802. }
  9803. }
  9804. public void get_erp_designbill()
  9805. {
  9806. DataStruct dStruct = GetPostStruct();
  9807. List<string> lw = new List<string>();
  9808. int isMy = GetInt("my");
  9809. if (isMy == 1)
  9810. {
  9811. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9812. }
  9813. string tid = GetPostString("tid");
  9814. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9815. string userName = GetPostString("design");
  9816. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9817. string price1 = GetPostString("price1");
  9818. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9819. string price2 = GetPostString("price2");
  9820. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9821. string rePrice1 = GetPostString("rePrice1");
  9822. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9823. string rePrice2 = GetPostString("rePrice2");
  9824. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9825. string designerType = GetPostString("designerType");
  9826. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9827. string orderState = GetPostString("orderState");
  9828. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9829. string endTime1 = GetPostString("endTime1");
  9830. string endTime2 = GetPostString("endTime2");
  9831. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9832. if (dw.Length > 0) lw.Add(dw);
  9833. string isDk = GetPostString("isDk");
  9834. if (isDk == "1")
  9835. {
  9836. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9837. }
  9838. else if (isDk == "0")
  9839. {
  9840. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9841. }
  9842. dStruct.Order = "oid, create_time desc";
  9843. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9844. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9845. writeGridDataTableJson(dStruct.TotalCount, dt);
  9846. }
  9847. public void upd_erp_designerbill()
  9848. {
  9849. if (UrlPostParmsCheck("ID"))
  9850. {
  9851. string eid = GetPostString("ID");
  9852. CeErpDesignerBill entity = null;
  9853. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9854. if (entity != null)
  9855. {
  9856. if (GetPostDouble("designerpirce") > 0)
  9857. {
  9858. entity.realPrice = GetPostDouble("designerpirce");
  9859. entity.update_time = DateTime.Now;
  9860. entity.update_u_id = CurrentUser.UserID;
  9861. entity.update_u_name = CurrentUser.UserName;
  9862. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9863. entity.Update();
  9864. returnSuccessMsg("操作成功!");
  9865. return;
  9866. }
  9867. else
  9868. {
  9869. entity.price = GetPostDouble("price");
  9870. entity.update_time = DateTime.Now;
  9871. entity.update_u_id = CurrentUser.UserID;
  9872. entity.update_u_name = CurrentUser.UserName;
  9873. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9874. entity.Update();
  9875. returnSuccessMsg("操作成功!");
  9876. return;
  9877. }
  9878. }
  9879. returnErrorMsg("找不到记录");
  9880. }
  9881. }
  9882. public void audit_erp_designerbill()
  9883. {
  9884. if (UrlPostParmsCheck("ID"))
  9885. {
  9886. string eid = GetPostString("ID");
  9887. CeErpDesignerBill entity = null;
  9888. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9889. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9890. if (entity != null)
  9891. {
  9892. entity.realPrice = GetPostDouble("designerpirce");
  9893. entity.update_time = DateTime.Now;
  9894. entity.update_u_id = CurrentUser.UserID;
  9895. entity.update_u_name = CurrentUser.UserName;
  9896. entity.isAudit = 1;
  9897. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9898. entity.Update();
  9899. if (orderEntity != null)
  9900. {
  9901. orderEntity.IsReadTag = 3;
  9902. orderEntity.Update();
  9903. }
  9904. returnSuccessMsg("操作成功!");
  9905. return;
  9906. }
  9907. returnErrorMsg("找不到记录");
  9908. }
  9909. }
  9910. public void all_audit_erp_designerbill()
  9911. {
  9912. if (UrlPostParmsCheck("idList"))
  9913. {
  9914. string[] list = GetPostString("idList").Split(',');
  9915. CeErpDesignerBill entity = null;
  9916. for (int i = 0; i < list.Length; i++)
  9917. {
  9918. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9919. if (entity == null) return;
  9920. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9921. if (orderEntity == null) return;
  9922. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9923. entity.update_time = DateTime.Now;
  9924. entity.update_u_id = CurrentUser.UserID;
  9925. entity.update_u_name = CurrentUser.UserName;
  9926. entity.isAudit = 1;
  9927. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9928. entity.Update();
  9929. orderEntity.IsReadTag = 3;
  9930. orderEntity.Update();
  9931. }
  9932. returnSuccessMsg("操作成功!");
  9933. return;
  9934. }
  9935. }
  9936. public void get_erp_sameorders()
  9937. {
  9938. if (UrlPostParmsCheck("ctid"))
  9939. {
  9940. string eid = GetPostString("ctid");
  9941. CeErpTradeCell entity = null;
  9942. entity = CeErpTradeCell.GetByCtid(eid);
  9943. if (entity != null)
  9944. {
  9945. StringBuilder sql = new StringBuilder();
  9946. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9947. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9948. var res = new
  9949. {
  9950. data = dt.Rows.Count
  9951. };
  9952. string ro_jsond = JsonConvert.SerializeObject(res);
  9953. returnSuccess(ro_jsond);
  9954. return;
  9955. }
  9956. returnErrorMsg("未找到订单");
  9957. return;
  9958. }
  9959. returnErrorMsg("缺少必要的参数");
  9960. }
  9961. public void get_erp_islasthavesameorder()
  9962. {
  9963. if (UrlPostParmsCheck("ctid"))
  9964. {
  9965. string eid = GetPostString("ctid");
  9966. string[] ctidList = eid.Split(',');
  9967. StringBuilder sql = new StringBuilder();
  9968. string tisCtid = "";
  9969. foreach (string ctid in ctidList)
  9970. {
  9971. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9972. if (entity != null)
  9973. {
  9974. sql = new StringBuilder();
  9975. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9976. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9977. if (dth.Rows.Count > 0)
  9978. {
  9979. tisCtid += entity.ctid;
  9980. tisCtid += ",";
  9981. }
  9982. }
  9983. }
  9984. if (tisCtid.Length > 0)
  9985. {
  9986. var res = new
  9987. {
  9988. data = tisCtid
  9989. };
  9990. string ro_jsond = JsonConvert.SerializeObject(res);
  9991. returnSuccess(ro_jsond);
  9992. }
  9993. else
  9994. {
  9995. var res = new
  9996. {
  9997. data = ""
  9998. };
  9999. string ro_jsond = JsonConvert.SerializeObject(res);
  10000. returnSuccess(ro_jsond);
  10001. }
  10002. return;
  10003. }
  10004. returnErrorMsg("缺少必要的参数");
  10005. }
  10006. public void file_client_down_url()
  10007. {
  10008. if (!UrlPostParmsCheck("userId"))
  10009. {
  10010. returnErrorMsg("缺少必要的参数");
  10011. }
  10012. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  10013. }
  10014. public void checkout_form_data()
  10015. {
  10016. if (!UrlPostParmsCheck("tid"))
  10017. {
  10018. returnErrorMsg("缺少必要的参数");
  10019. }
  10020. string tid = GetPostString("tid");
  10021. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  10022. if (ceErpOrderFormData != null)
  10023. {
  10024. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  10025. returnSuccess(ro_jsond);
  10026. return;
  10027. }
  10028. returnErrorMsg("尚未有文件!");
  10029. }
  10030. public void back_supplier_audit()
  10031. {
  10032. int userId = CurrentUser.UserID;
  10033. StringBuilder sql = new StringBuilder();
  10034. 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);
  10035. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10036. if (dt.Rows.Count > 0)
  10037. {
  10038. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10039. }
  10040. else
  10041. {
  10042. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10043. }
  10044. }
  10045. public void back_supplier_query()
  10046. {
  10047. string eid = GetPostString("ctid");
  10048. if (eid != "")
  10049. {
  10050. StringBuilder sql = new StringBuilder();
  10051. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  10052. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10053. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10054. }
  10055. else
  10056. {
  10057. returnErrorMsg("找不到订单记录");
  10058. return;
  10059. }
  10060. }
  10061. public void verified_to_order()
  10062. {
  10063. int userId = CurrentUser.UserID;
  10064. StringBuilder sql = new StringBuilder();
  10065. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10066. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10067. if (dt.Rows.Count > 0)
  10068. {
  10069. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10070. }
  10071. else
  10072. {
  10073. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10074. }
  10075. }
  10076. public void upd_supplier_audit()
  10077. {
  10078. if (UrlPostParmsCheck("ctid"))
  10079. {
  10080. string eid = GetPostString("ctid");
  10081. string reason = GetPostString("returnreason");
  10082. CeErpTradeCell entity = null;
  10083. CeWithdraw withdraw = null;
  10084. withdraw = CeWithdraw.GetByTid(eid);
  10085. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10086. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10087. {
  10088. if (withdraw != null)
  10089. {
  10090. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10091. {
  10092. returnSuccessMsg("您没有权限操作!");
  10093. return;
  10094. }
  10095. else
  10096. {
  10097. if (reason.Equals("1"))
  10098. {
  10099. if (entity.OrderState == -1)
  10100. {
  10101. if (entity.FinishPlaceTime == null)
  10102. {
  10103. entity.OrderState = 2;
  10104. }
  10105. else
  10106. {
  10107. entity.OrderState = 6;
  10108. }
  10109. }
  10110. entity.Update();
  10111. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10112. if (withdraw != null)
  10113. {
  10114. withdraw.status = int.Parse(reason);
  10115. withdraw.Update();
  10116. }
  10117. returnSuccessMsg("操作成功!");
  10118. return;
  10119. }
  10120. else
  10121. {
  10122. withdraw.status = int.Parse(reason);
  10123. withdraw.acknowledgingtime = DateTime.Now;
  10124. withdraw.Update();
  10125. returnSuccessMsg("查看详细请点击线下订单查询");
  10126. return;
  10127. }
  10128. }
  10129. }
  10130. // 第一个字符是 'N'
  10131. }
  10132. if (eid[0] != 'N')
  10133. {
  10134. }
  10135. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10136. {
  10137. entity.IsVerifyToSupplier = false;
  10138. entity.IsReturn = 1;
  10139. entity.ReturnTime = DateTime.Now;
  10140. entity.ReturnReason = reason;
  10141. if (entity.OrderState == 6)
  10142. {
  10143. entity.OrderState = 5;
  10144. }
  10145. entity.Update();
  10146. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10147. if (withdraw != null)
  10148. {
  10149. withdraw.status = int.Parse(reason);
  10150. withdraw.Update();
  10151. }
  10152. returnSuccessMsg("操作成功!");
  10153. return;
  10154. }
  10155. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10156. {
  10157. ;
  10158. if (withdraw != null)
  10159. {
  10160. withdraw.status = int.Parse(reason);
  10161. withdraw.acknowledgingtime = DateTime.Now;
  10162. withdraw.Update();
  10163. returnSuccessMsg("供应商取消撤回!");
  10164. return;
  10165. }
  10166. }
  10167. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10168. {
  10169. if (entity.OrderState == -1)
  10170. {
  10171. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10172. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10173. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10174. {
  10175. returnErrorMsg("台湾客户需填写身份证!");
  10176. return;
  10177. }
  10178. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10179. {
  10180. returnErrorMsg("偏远地区需要填写物流费!");
  10181. return;
  10182. }
  10183. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10184. {
  10185. returnErrorMsg("订单spu没有确认无法通过审核!");
  10186. return;
  10187. }
  10188. if (entity.FinishPlaceTime == null)
  10189. {
  10190. entity.OrderState = 2;
  10191. }
  10192. else
  10193. {
  10194. entity.OrderState = 3;
  10195. }
  10196. commonHelper.getCytPrice(entity);
  10197. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10198. {
  10199. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10200. }
  10201. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10202. {
  10203. entity.OrderState = 6;
  10204. }
  10205. }
  10206. entity.Update();
  10207. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10208. if (withdraw != null)
  10209. {
  10210. withdraw.status = int.Parse(reason);
  10211. withdraw.Update();
  10212. }
  10213. returnSuccessMsg("操作成功!");
  10214. return;
  10215. }
  10216. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10217. {
  10218. if (withdraw == null)
  10219. {
  10220. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10221. return;
  10222. }
  10223. }
  10224. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10225. {
  10226. if (withdraw != null)
  10227. {
  10228. withdraw.status = int.Parse(reason);
  10229. withdraw.acknowledgingtime = DateTime.Now;
  10230. withdraw.Update();
  10231. returnSuccessMsg("查看详细请点击线下订单查询");
  10232. return;
  10233. }
  10234. }
  10235. return;
  10236. }
  10237. }
  10238. //校验报价
  10239. public void refund_order_tip()
  10240. {
  10241. int userid = CurrentUser.UserID;
  10242. int sectionId = CurrentUser.UserPost.OrgID;
  10243. StringBuilder sql = new StringBuilder();
  10244. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10245. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10246. List<string> ids = new List<string>();
  10247. if (dth.Rows.Count > 0)
  10248. {
  10249. foreach (DataRow dr in dth.Rows)
  10250. {
  10251. ids.Add(dr["ID"].ToString());
  10252. }
  10253. try
  10254. {
  10255. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10256. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10257. }
  10258. catch (Exception ex)
  10259. {
  10260. }
  10261. }
  10262. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10263. }
  10264. public void refund_order_Design()
  10265. {
  10266. int userid = CurrentUser.UserID;
  10267. int sectionId = CurrentUser.UserPost.OrgID;
  10268. StringBuilder sql = new StringBuilder();
  10269. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10270. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10271. List<string> ids = new List<string>();
  10272. if (dth.Rows.Count > 0)
  10273. {
  10274. foreach (DataRow dr in dth.Rows)
  10275. {
  10276. ids.Add(dr["ID"].ToString());
  10277. }
  10278. try
  10279. {
  10280. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10281. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10282. }
  10283. catch (Exception ex)
  10284. {
  10285. }
  10286. }
  10287. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10288. }
  10289. public void change_order_info()
  10290. {
  10291. int userid = CurrentUser.UserID;
  10292. StringBuilder sql = new StringBuilder();
  10293. 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);
  10294. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10295. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10296. }
  10297. public void size_order_tip()
  10298. {
  10299. int userid = CurrentUser.UserID;
  10300. StringBuilder sql = new StringBuilder();
  10301. sql.AppendFormat("select top 1 * from CE_ErpMessageTip c where (c.userId = '{0}' ) and c.isVisit = 0 and c.type = 3;", userid);
  10302. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10303. List<string> ids = new List<string>();
  10304. if (dth.Rows.Count > 0)
  10305. {
  10306. foreach (DataRow dr in dth.Rows)
  10307. {
  10308. ids.Add(dr["ID"].ToString());
  10309. }
  10310. try
  10311. {
  10312. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10313. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10314. }
  10315. catch (Exception ex)
  10316. {
  10317. }
  10318. }
  10319. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10320. }
  10321. public void change_win_mome()
  10322. {
  10323. if (UrlPostParmsCheck("id,ctid"))
  10324. {
  10325. string id = GetPostString("id");
  10326. string ctid = GetPostString("ctid");
  10327. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10328. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10329. if (ce == null || ceErpMessageTip == null)
  10330. {
  10331. returnSuccessMsg("未找到对应的订单!");
  10332. return;
  10333. }
  10334. if (ce.OrderState >= 5)
  10335. {
  10336. ceErpMessageTip.isVisit = true;
  10337. ceErpMessageTip.Update();
  10338. returnSuccessMsg("已上传文件无法修改!");
  10339. return;
  10340. }
  10341. int type = GetPostInt("type");
  10342. string content = GetPostString("content");
  10343. if (type == 0)
  10344. {
  10345. content = content.Replace("(", "(");
  10346. content = content.Replace(")", ")");
  10347. string check = MidStrEx(content, "(", ")").Trim();
  10348. if (string.IsNullOrEmpty(check))
  10349. {
  10350. returnSuccessMsg("文件名格式不正确");
  10351. return;
  10352. }
  10353. }
  10354. ce.seller_memo = content;
  10355. ce.Update();
  10356. ceErpMessageTip.isVisit = true;
  10357. ceErpMessageTip.Update();
  10358. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10359. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10360. ApiVo apiVo = new ApiVo();
  10361. apiVo.orderNumber = ce.ctid;
  10362. apiVo.actionName = "demandDesign";
  10363. apiVo.orderRemarks = content;
  10364. apiVo.demandExamine = type + 1;
  10365. designHelper.API_WorkCore(apiVo);//demandDesign
  10366. returnSuccessMsg("修改成功!");
  10367. }
  10368. }
  10369. public static string MidStrEx(string sourse, string startstr, string endstr)
  10370. {
  10371. string result = string.Empty;
  10372. int startindex, endindex;
  10373. try
  10374. {
  10375. startindex = sourse.IndexOf(startstr);
  10376. if (startindex == -1)
  10377. return result;
  10378. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10379. endindex = tmpstr.IndexOf(endstr);
  10380. if (endindex == -1)
  10381. return result;
  10382. result = tmpstr.Remove(endindex);
  10383. }
  10384. catch (Exception ex)
  10385. {
  10386. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10387. }
  10388. return result;
  10389. }
  10390. public void refund_order_list()
  10391. {
  10392. int userid = CurrentUser.UserID;
  10393. int sectionId = CurrentUser.UserPost.OrgID;
  10394. StringBuilder sql = new StringBuilder();
  10395. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10396. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10397. DataStruct dStruct = GetPostStruct();
  10398. DataTable dt = null;
  10399. List<string> ids = new List<string>();
  10400. List<string> tids = new List<string>();
  10401. if (dth.Rows.Count > 0)
  10402. {
  10403. foreach (DataRow dr in dth.Rows)
  10404. {
  10405. tids.Add("'" + dr["tid"].ToString() + "'");
  10406. ids.Add(dr["id"].ToString());
  10407. }
  10408. try
  10409. {
  10410. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10411. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10412. List<string> lw = new List<string>();
  10413. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10414. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10415. dt = WebCache.GetData("view_orderlist", dStruct);
  10416. }
  10417. catch (Exception ex)
  10418. {
  10419. }
  10420. }
  10421. writeGridDataTableJson(dStruct.TotalCount, dt);
  10422. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10423. }
  10424. //新增
  10425. public void order_batch_downloads()
  10426. {
  10427. string ceid = GetPostString("tid");
  10428. String[] tid = ceid.Split(',');
  10429. order_batch_caiyingtong(tid);
  10430. /* (string success, string errors) = UploadFiles(tid);
  10431. returnSuccessMsg(success + errors);*/
  10432. return;
  10433. }
  10434. //报价接口
  10435. public void Get_To_Quote()
  10436. {
  10437. string ceid = GetPostString("ctid");
  10438. if (ceid != null)
  10439. {
  10440. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10441. if (entity != null)
  10442. {
  10443. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10444. {
  10445. return;
  10446. }
  10447. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10448. double price = 0;
  10449. if (cp == null)
  10450. {
  10451. JObject jsonObject12 = new JObject
  10452. {
  10453. { "UserId", "77886" },
  10454. { "Pwd", "lt666888" },
  10455. { "Filename", entity.seller_memo }
  10456. };
  10457. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10458. JObject jsonObjects1 = JObject.Parse(response1);
  10459. string ms1g = (string)jsonObjects1["msg"];
  10460. if (ms1g == "报价成功")
  10461. {
  10462. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10463. string data = (string)jsonObject1["price"];
  10464. 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 + "');";
  10465. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10466. returnSuccessMsg("获取报价成功:" + data);
  10467. price = Convert.ToDouble(data);
  10468. }
  10469. else
  10470. {
  10471. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10472. return;
  10473. }
  10474. }
  10475. String[] beizhu = entity.seller_memo.Split('-');
  10476. String chanp = "";
  10477. if (beizhu.Length > 0)
  10478. {
  10479. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10480. }
  10481. else
  10482. {
  10483. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10484. }
  10485. JObject jsonObject = new JObject
  10486. {
  10487. { "UserId", "77886" },
  10488. { "Pwd", "lt666888" },
  10489. { "Filename", chanp }
  10490. };
  10491. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10492. JObject jsonObjects = JObject.Parse(response);
  10493. string msg = (string)jsonObjects["msg"];
  10494. if (msg == "报价成功")
  10495. {
  10496. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10497. string data = (string)jsonObject1["price"];
  10498. 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 + "');";
  10499. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10500. returnSuccessMsg("获取报价成功:" + data);
  10501. price = Convert.ToDouble(data);
  10502. }
  10503. else
  10504. {
  10505. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10506. return;
  10507. }
  10508. if (price > 0)
  10509. {
  10510. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10511. if (ceErpTradeCellExtend == null)
  10512. {
  10513. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10514. ceErpTradeCellExtend.ctid = entity.ctid;
  10515. ceErpTradeCellExtend.payment_cyt = price;
  10516. ceErpTradeCellExtend.Create();
  10517. }
  10518. else
  10519. {
  10520. ceErpTradeCellExtend.payment_cyt = price;
  10521. ceErpTradeCellExtend.Update();
  10522. }
  10523. }
  10524. return;
  10525. }
  10526. }
  10527. else
  10528. {
  10529. returnErrorMsg("请至少选择一条数据");
  10530. return;
  10531. }
  10532. }
  10533. //新增
  10534. public void order_To_Supplier()
  10535. {
  10536. string ceid = GetPostString("tid");
  10537. String[] tid = ceid.Split(',');
  10538. if (tid.Length > 0)
  10539. {
  10540. try
  10541. {
  10542. for (int i = 0; i < tid.Length; i++)
  10543. {
  10544. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10545. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10546. entity.SupplierId = suid;
  10547. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10548. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10549. entity.Update();
  10550. }
  10551. }
  10552. catch (Exception ex)
  10553. {
  10554. returnErrorMsg("自动匹配供应商失败");
  10555. return;
  10556. }
  10557. }
  10558. else
  10559. {
  10560. returnErrorMsg("请至少选择一条数据");
  10561. return;
  10562. }
  10563. returnSuccessMsg("自动匹配供应商成功");
  10564. return;
  10565. }
  10566. public (string, string) UploadFiles(string[] urls)
  10567. {
  10568. string success = "";
  10569. string errors = "";
  10570. int userid = CurrentUser.UserID;
  10571. foreach (string url in urls)
  10572. {
  10573. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10574. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10575. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10576. {
  10577. JObject jsonObject = new JObject
  10578. {
  10579. { "Userid", "77886" },
  10580. { "pwd", "cyt86435015" },
  10581. { "content", base64FileContent },
  10582. { "ext", Path.GetExtension(fileName) }
  10583. };
  10584. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10585. JObject jsonObjects = JObject.Parse(response);
  10586. string msg = (string)jsonObjects["msg"];
  10587. if (msg.Equals("上传成功"))
  10588. {
  10589. success += url + " 上传成功";
  10590. }
  10591. else
  10592. {
  10593. errors += url + " 上传失败";
  10594. }
  10595. }
  10596. else
  10597. {
  10598. errors += url + " 格式出现问题";
  10599. }
  10600. }
  10601. if (urls.Length == 0)
  10602. {
  10603. return (success, errors);
  10604. }
  10605. return (success, errors);
  10606. }
  10607. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10608. {
  10609. return true; //总是接受
  10610. }
  10611. public static string HttpPost(string url, string param = null)
  10612. {
  10613. HttpWebRequest request;
  10614. //如果是发送HTTPS请求
  10615. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10616. {
  10617. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10618. request = WebRequest.Create(url) as HttpWebRequest;
  10619. request.ProtocolVersion = HttpVersion.Version10;
  10620. }
  10621. else
  10622. {
  10623. request = WebRequest.Create(url) as HttpWebRequest;
  10624. }
  10625. request.Method = "POST";
  10626. request.ContentType = "application/json";
  10627. request.Accept = "*/*";
  10628. request.Timeout = 120000;
  10629. request.AllowAutoRedirect = false;
  10630. StreamWriter requestStream = null;
  10631. WebResponse response = null;
  10632. string responseStr = null;
  10633. try
  10634. {
  10635. requestStream = new StreamWriter(request.GetRequestStream());
  10636. requestStream.Write(param);
  10637. requestStream.Close();
  10638. response = request.GetResponse();
  10639. if (response != null)
  10640. {
  10641. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10642. responseStr = reader.ReadToEnd();
  10643. reader.Close();
  10644. }
  10645. }
  10646. catch (Exception ex)
  10647. {
  10648. return ex.Message;
  10649. }
  10650. finally
  10651. {
  10652. request = null;
  10653. requestStream = null;
  10654. response = null;
  10655. }
  10656. return responseStr;
  10657. }
  10658. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10659. {
  10660. string base64FileContent;
  10661. string fileName;
  10662. using (WebClient webClient = new WebClient())
  10663. {
  10664. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10665. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10666. {
  10667. using (Stream stream = response.GetResponseStream())
  10668. {
  10669. using (MemoryStream memoryStream = new MemoryStream())
  10670. {
  10671. stream.CopyTo(memoryStream);
  10672. byte[] fileBytes = memoryStream.ToArray();
  10673. base64FileContent = Convert.ToBase64String(fileBytes);
  10674. fileName = response.Headers["Content-Disposition"];
  10675. if (!string.IsNullOrEmpty(fileName))
  10676. {
  10677. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10678. if (index >= 0)
  10679. {
  10680. fileName = fileName.Substring(index + 9).Trim('\"');
  10681. }
  10682. }
  10683. else
  10684. {
  10685. fileName = Path.GetFileName(downloadUrl);
  10686. }
  10687. }
  10688. }
  10689. }
  10690. }
  10691. return (fileName, base64FileContent);
  10692. }
  10693. //新增
  10694. public void order_batch_caiyingtong(string[] downloadUrls)
  10695. {
  10696. try
  10697. {
  10698. //遍历文件
  10699. DataStruct dStruct = GetPostStruct();
  10700. DataTable dt = null;
  10701. int userid = CurrentUser.UserID;
  10702. List<string> ids = new List<string>();//失败组
  10703. List<string> tids = new List<string>();
  10704. using (WebClient webClient = new WebClient())
  10705. {
  10706. foreach (var url in downloadUrls)
  10707. {
  10708. try
  10709. {
  10710. tids.Add("'" + url + "'");
  10711. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10712. if (entity != null)
  10713. {
  10714. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10715. if (cp == null)
  10716. {
  10717. JObject jsonObject = new JObject
  10718. {
  10719. { "Userid", "77886" },
  10720. { "pwd", "lt666888" },
  10721. { "Filename",entity.seller_memo }
  10722. };
  10723. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10724. JObject jsonObjects = JObject.Parse(response);
  10725. string msg = (string)jsonObjects["msg"];
  10726. if (msg == "报价成功")
  10727. {
  10728. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10729. DownloadAndConvertToBase64(url1);
  10730. }
  10731. else
  10732. {
  10733. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10734. }
  10735. }
  10736. else
  10737. {
  10738. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10739. JObject jsonObject = new JObject
  10740. {
  10741. { "Userid", "77886" },
  10742. { "pwd", "lt666888" },
  10743. { "Filename",chanp }
  10744. };
  10745. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10746. JObject jsonObjects = JObject.Parse(response);
  10747. string msg = (string)jsonObjects["msg"];
  10748. if (msg == "报价成功")
  10749. {
  10750. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10751. DownloadAndConvertToBase64(url1);
  10752. }
  10753. else
  10754. {
  10755. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10756. }
  10757. }
  10758. }
  10759. // 上传文件到FTP
  10760. }
  10761. catch (Exception ex)
  10762. {
  10763. Console.WriteLine($"An error occurred: {ex.Message}");
  10764. }
  10765. }
  10766. List<string> lw = new List<string>();
  10767. lw.Add(string.Format("( OrderState < 6 )"));
  10768. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10769. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10770. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10771. if (dt.Rows.Count > 0)
  10772. {
  10773. foreach (DataRow dr in dt.Rows)
  10774. {
  10775. ids.Add(dr["ctid"].ToString());
  10776. }
  10777. }
  10778. String ErrorMsgs = "";
  10779. foreach (String id in ids)
  10780. {
  10781. ErrorMsgs += id + ",";
  10782. }
  10783. if (ErrorMsgs.Length > 1)
  10784. {
  10785. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10786. }
  10787. if (ErrorMsgs.Length < 1)
  10788. {
  10789. ErrorMsgs = "上传成功";
  10790. returnSuccessMsg(ErrorMsgs);
  10791. }
  10792. else
  10793. {
  10794. returnErrorMsg("以下订单" + ErrorMsgs);
  10795. }
  10796. }
  10797. // 删除文件夹及其内容
  10798. /* Directory.Delete(localDirectory, true);*/
  10799. }
  10800. catch { }
  10801. }
  10802. public void get_center_data()
  10803. {
  10804. int userId = CurrentUser.UserID;
  10805. string postCode = CurrentUser.UserPost.Post.Code;
  10806. List<string> lw = new List<string>();
  10807. List<string> ww = new List<string>();
  10808. DateTime currentTime = DateTime.Now;
  10809. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10810. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10811. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10812. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10813. string sql = " SELECT ";
  10814. string startTime = "2023-10-01 11:22:31";
  10815. //设计
  10816. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10817. {
  10818. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10819. 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));
  10820. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10821. 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));
  10822. }
  10823. //客服
  10824. else if (postCode == "CustomerService" || postCode == "Director")
  10825. {
  10826. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10827. 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));
  10828. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10829. 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));
  10830. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10831. 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));
  10832. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10833. 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));
  10834. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10835. 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));
  10836. }
  10837. //售后
  10838. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10839. {
  10840. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10841. 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));
  10842. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10843. 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));
  10844. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10845. 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));
  10846. }
  10847. //下单部
  10848. else if (postCode == "Place" || postCode == "PlaceMr")
  10849. {
  10850. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10851. 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));
  10852. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10853. 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));
  10854. }
  10855. //车间
  10856. else if (postCode == "Supplier")
  10857. {
  10858. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10859. 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));
  10860. }
  10861. DataTable dt = new DataTable();
  10862. if (lw.Count > 0)
  10863. {
  10864. sql += string.Join(" , ", lw);
  10865. sql += " FROM ";
  10866. sql += string.Join(" , ", ww);
  10867. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10868. }
  10869. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10870. }
  10871. public void get_center_data_list()
  10872. {
  10873. int userId = CurrentUser.UserID;
  10874. string postCode = CurrentUser.UserPost.Post.Code;
  10875. string shopIds = CurrentUser.User.pemShop;
  10876. DataStruct dStruct = GetPostStruct();
  10877. List<string> lw = new List<string>();
  10878. DateTime currentTime = DateTime.Now;
  10879. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10880. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10881. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10882. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10883. string startTime = "2023-10-01 11:22:31";
  10884. int order_type = GetPostInt("order_type");
  10885. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10886. {
  10887. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10888. if (order_type == 0)
  10889. {
  10890. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10891. }
  10892. else if (order_type == 3)
  10893. {
  10894. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10895. }
  10896. else
  10897. {
  10898. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10899. }
  10900. }
  10901. //客服
  10902. if (postCode == "CustomerService" || postCode == "Director")
  10903. {
  10904. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10905. if (order_type == 0)
  10906. {
  10907. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10908. }
  10909. else if (order_type == 1)
  10910. {
  10911. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10912. }
  10913. else if (order_type == 2)
  10914. {
  10915. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10916. }
  10917. else if (order_type == 3)
  10918. {
  10919. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10920. }
  10921. else if (order_type == 4)
  10922. {
  10923. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10924. }
  10925. else
  10926. {
  10927. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10928. }
  10929. }
  10930. //售后
  10931. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10932. {
  10933. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10934. if (shopIds != "")
  10935. {
  10936. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10937. }
  10938. if (order_type == 2)
  10939. {
  10940. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10941. }
  10942. else if (order_type == 4)
  10943. {
  10944. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10945. }
  10946. else if (order_type == 5)
  10947. {
  10948. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10949. }
  10950. else
  10951. {
  10952. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10953. }
  10954. }
  10955. //下单部
  10956. if (postCode == "Place" || postCode == "PlaceMr")
  10957. {
  10958. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10959. if (shopIds != "")
  10960. {
  10961. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10962. }
  10963. else if (order_type == 1)
  10964. {
  10965. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10966. }
  10967. else if (order_type == 2)
  10968. {
  10969. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10970. }
  10971. else
  10972. {
  10973. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10974. }
  10975. }
  10976. //车间
  10977. if (postCode == "Supplier")
  10978. {
  10979. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10980. if (order_type == 5)
  10981. {
  10982. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10983. }
  10984. else
  10985. {
  10986. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10987. }
  10988. }
  10989. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10990. dStruct.Fileds = "tid,ctid";
  10991. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10992. writeGridDataTableJson(dStruct.TotalCount, dt);
  10993. }
  10994. public void aftersale_audit_master()
  10995. {
  10996. if (UrlPostParmsCheck("ctid"))
  10997. {
  10998. string ctid = GetPostString("ctid");
  10999. if (ctid.Length > 0)
  11000. {
  11001. bool result = aftersale_data_change(ctid);
  11002. if (result)
  11003. {
  11004. returnSuccessMsg("修改成功!");
  11005. return;
  11006. }
  11007. }
  11008. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11009. }
  11010. }
  11011. public void aftersale_batch_audit_master()
  11012. {
  11013. if (UrlPostParmsCheck("ctids"))
  11014. {
  11015. string ctids = GetPostString("ctids");
  11016. if (ctids.Length > 0)
  11017. {
  11018. List<string> list = new List<string>();
  11019. string[] ctid_list = ctids.Split(',');
  11020. foreach (var item in ctid_list)
  11021. {
  11022. bool result = aftersale_data_change(item);
  11023. if (!result)
  11024. {
  11025. list.Add(item);
  11026. }
  11027. }
  11028. if (list.Count > 0)
  11029. {
  11030. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  11031. return;
  11032. }
  11033. returnSuccessMsg("修改成功!");
  11034. return;
  11035. }
  11036. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11037. }
  11038. }
  11039. public bool aftersale_data_change(string ctid)
  11040. {
  11041. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11042. if (ceErpTradeCell != null)
  11043. {
  11044. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  11045. ceErpTradeCell.AfterSaleSupplierState = 0;
  11046. StringBuilder sql = new StringBuilder();
  11047. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  11048. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11049. CeErpTradeResponsible.DelByTid(ctid, 0);
  11050. 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 == "不理赔")
  11051. {
  11052. CeErpTradeResponsible.DelByTid(ctid, -1);
  11053. ceErpTradeCell.AfterSaleSupplierState = 1;
  11054. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11055. ceErpTradeCell.AfterSaleState = 4;
  11056. }
  11057. else
  11058. {
  11059. ceErpTradeCell.AfterSaleState = 3;
  11060. }
  11061. bool needCyt = false;
  11062. if (dt != null)
  11063. {
  11064. if (dt.Rows.Count == 1)
  11065. {
  11066. bool isEnd = false;
  11067. foreach (DataRow dr in dt.Rows)
  11068. {
  11069. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11070. {
  11071. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11072. isEnd = true;
  11073. }
  11074. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  11075. {
  11076. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11077. isEnd = true;
  11078. }
  11079. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11080. {
  11081. needCyt = true;
  11082. }
  11083. }
  11084. if (isEnd)
  11085. {
  11086. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11087. ceErpTradeCell.AfterSaleState = 4;
  11088. ceErpTradeCell.AfterSaleSupplierState = 1;
  11089. }
  11090. }
  11091. else
  11092. {
  11093. bool isAll = true;
  11094. foreach (DataRow dr in dt.Rows)
  11095. {
  11096. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11097. {
  11098. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11099. continue;
  11100. }
  11101. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11102. {
  11103. string path = "";
  11104. int OrgID = 0;
  11105. if (!Convert.IsDBNull(dr["OrgPath"]))
  11106. {
  11107. path = dr["OrgPath"].ToString();
  11108. }
  11109. if (!Convert.IsDBNull(dr["OrgID"]))
  11110. {
  11111. OrgID = Convert.ToInt32(dr["OrgID"]);
  11112. }
  11113. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11114. {
  11115. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11116. continue;
  11117. }
  11118. }
  11119. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11120. {
  11121. needCyt = true;
  11122. }
  11123. isAll = false;
  11124. }
  11125. if (isAll)
  11126. {
  11127. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11128. ceErpTradeCell.AfterSaleState = 4;
  11129. ceErpTradeCell.AfterSaleSupplierState = 1;
  11130. }
  11131. }
  11132. }
  11133. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11134. {
  11135. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11136. }
  11137. if (ceErpTradeCell.AfterSaleState == 4)
  11138. {
  11139. ApiVo apiVo = new ApiVo();
  11140. apiVo.orderNumber = ceErpTradeCell.ctid;
  11141. apiVo.actionName = "afterOver";
  11142. designHelper.API_WorkCore(apiVo); //afterOver
  11143. }
  11144. ceErpTradeCell.Update();
  11145. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11146. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11147. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11148. return true;
  11149. }
  11150. return false;
  11151. }
  11152. public void get_erp_wechatorder()
  11153. {
  11154. DataStruct dStruct = GetPostStruct();
  11155. List<string> lw = new List<string>();
  11156. string tid = GetPostString("tid");
  11157. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11158. string shopname = GetPostString("shopname");
  11159. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11160. string buyernick = GetPostString("buyer_nick");
  11161. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11162. string customer = GetPostString("customer");
  11163. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11164. string returndate1 = GetPostString("returndate1");
  11165. string returndate2 = GetPostString("returndate2");
  11166. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11167. if (dw.Length > 0) lw.Add(dw);
  11168. string finishDate1 = GetPostString("finishdate1");
  11169. string finishDate2 = GetPostString("finishdate2");
  11170. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11171. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11172. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11173. dStruct.Order = "created desc";
  11174. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11175. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11176. writeGridDataTableJson(dStruct.TotalCount, dt);
  11177. }
  11178. public void get_erp_wechatlist_sumprice()
  11179. {
  11180. DataStruct dStruct = GetPostStruct();
  11181. List<string> lw = new List<string>();
  11182. string tid = GetPostString("tid");
  11183. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11184. string shopname = GetPostString("shopname");
  11185. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11186. string buyernick = GetPostString("buyer_nick");
  11187. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11188. string customer = GetPostString("customer");
  11189. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11190. string returndate1 = GetPostString("returndate1");
  11191. string returndate2 = GetPostString("returndate2");
  11192. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11193. if (dw.Length > 0) lw.Add(dw);
  11194. string finishDate1 = GetPostString("finishdate1");
  11195. string finishDate2 = GetPostString("finishdate2");
  11196. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11197. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11198. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11199. string mainWhere = string.Join(" and ", lw.ToArray());
  11200. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11201. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11202. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11203. decimal total = 0;
  11204. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11205. {
  11206. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11207. }
  11208. var res = new
  11209. {
  11210. data = total
  11211. };
  11212. string ro_jsond = JsonConvert.SerializeObject(res);
  11213. returnSuccess(ro_jsond);
  11214. return;
  11215. }
  11216. public void get_erp_qr_waitdeliverylist()
  11217. {
  11218. DataStruct dStruct = GetPostStruct();
  11219. List<string> lw = new List<string>();
  11220. string tid = GetPostString("ctid");
  11221. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11222. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11223. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11224. var res_objz = new
  11225. {
  11226. restype = 1,
  11227. data = dt
  11228. };
  11229. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11230. returnSuccess(ro_jsonz);
  11231. }
  11232. public void get_erp_yield_list()
  11233. {
  11234. DataStruct dStruct = GetPostStruct();
  11235. List<string> lw = new List<string>();
  11236. string tid = GetPostString("ctid");
  11237. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11238. string shopname = GetPostString("shopname");
  11239. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11240. string buyernick = GetPostString("buyer_nick");
  11241. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11242. //if (tid.Length == 0 && buyernick.Length == 0)
  11243. //{
  11244. // lw.Add(string.Format("IsRefund<={0}", 1));
  11245. //}
  11246. string customer = GetPostString("customer");
  11247. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11248. string design = GetPostString("design");
  11249. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11250. string orderState = GetPostString("orderState");
  11251. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11252. string address = GetPostString("address");
  11253. 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));
  11254. string sellermemo = GetPostString("seller_memo");
  11255. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11256. string supplier = GetPostString("supplier");
  11257. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11258. string OrderArea = GetPostString("order_area");
  11259. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11260. string placedate1 = GetPostString("placedate1");
  11261. string placedate2 = GetPostString("placedate2");
  11262. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11263. if (fdw.Length > 0) lw.Add(fdw);
  11264. string price1 = GetPostString("price1");
  11265. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11266. string price2 = GetPostString("price2");
  11267. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11268. string unusualCon = GetPostString("unusualcon");
  11269. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11270. string posTag = CurrentUser.UserPost.Post.Code;
  11271. if (posTag == "Supplier")
  11272. {
  11273. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11274. }
  11275. lw.Add(string.Format("OrderState = 6 "));
  11276. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11277. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11278. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11279. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11280. writeGridDataTableJson(dStruct.TotalCount, dt);
  11281. }
  11282. public void change_erp_sup_state()
  11283. {
  11284. if (UrlPostParmsCheck("ctid"))
  11285. {
  11286. string ctid = GetPostString("ctid");
  11287. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11288. if (ceErpTradeCell != null)
  11289. {
  11290. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11291. if (ceErpTradeCellExtend == null)
  11292. {
  11293. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11294. ceErpTradeCellExtend.ctid = ctid;
  11295. ceErpTradeCellExtend.SupState = 1;
  11296. ceErpTradeCellExtend.Create();
  11297. }
  11298. else
  11299. {
  11300. ceErpTradeCellExtend.SupState = 1;
  11301. ceErpTradeCellExtend.Update();
  11302. }
  11303. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11304. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11305. return;
  11306. }
  11307. returnErrorMsg("找不到订单");
  11308. }
  11309. }
  11310. public void supplier_all_downs()
  11311. {
  11312. if (UrlPostParmsCheck("tids"))
  11313. {
  11314. string tids = GetPostString("tids");
  11315. if (tids != null && tids.Length > 0)
  11316. {
  11317. StringBuilder sql = new StringBuilder();
  11318. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11319. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11320. sql = new StringBuilder();
  11321. 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, "下载设计文件");
  11322. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11323. string[] list = tids.Split(',');
  11324. foreach (string ctid in list)
  11325. {
  11326. CeErpSukuraData.createInfo(ctid, 3);
  11327. }
  11328. designHelper.api_approveDesign(tids); //approveDesign
  11329. returnSuccessMsg("下载成功!");
  11330. return;
  11331. }
  11332. returnErrorMsg("下载订单更新失败");
  11333. }
  11334. }
  11335. public void uploaderFileSuccess()
  11336. {
  11337. if (UrlPostParmsCheck("fileName"))
  11338. {
  11339. string fileName = GetPostString("fileName");
  11340. ApiVo apiVo = new ApiVo();
  11341. apiVo.orderNumber = fileName;
  11342. apiVo.actionName = "finishDesign";
  11343. designHelper.API_WorkCore(apiVo);//finishDesign
  11344. returnSuccessMsg("");
  11345. }
  11346. }
  11347. public void get_sample2_order()
  11348. {
  11349. if (UrlPostParmsCheck("ctid"))
  11350. {
  11351. string ctid = GetPostString("ctid");
  11352. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11353. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11354. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11355. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11356. double total = 0.0;
  11357. double order_price = 0.0;
  11358. if (dt_bu.Rows.Count > 0)
  11359. {
  11360. foreach (DataRow dr in dt_bu.Rows)
  11361. {
  11362. total += Convert.ToDouble(dr["payment"]);
  11363. }
  11364. }
  11365. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11366. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11367. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11368. string tid = ctid.Replace("S_", "");
  11369. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11370. double paymant = 0.0;
  11371. if (entity != null)
  11372. {
  11373. paymant = entity.payment;
  11374. }
  11375. string return_reason = "";
  11376. if (dt_after != null && dt_after.Rows.Count > 0)
  11377. {
  11378. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11379. }
  11380. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11381. }
  11382. }
  11383. public void get_erp_design_status()
  11384. {
  11385. string designName = GetPostString("designName");
  11386. DataStruct dStruct = GetPostStruct();
  11387. if (designName.Length > 0)
  11388. {
  11389. 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";
  11390. sql_user += " and Name like '%" + designName + "%'";
  11391. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11392. List<string> ids_list = new List<string>();
  11393. if (user_table.Rows.Count > 0)
  11394. {
  11395. foreach (DataRow item in user_table.Rows)
  11396. {
  11397. ids_list.Add(item["id"].ToString());
  11398. string ids_s = item["TeamIds"].ToString();
  11399. if (ids_s.Length > 0)
  11400. {
  11401. ids_list.AddRange(ids_s.Split(','));
  11402. }
  11403. }
  11404. }
  11405. HashSet<string> set = new HashSet<string>(ids_list);
  11406. ids_list = set.ToList();
  11407. if (ids_list.Count > 0)
  11408. {
  11409. 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));
  11410. dStruct.MainWhere = sql;
  11411. DataTable dt = null;
  11412. dt = WebCache.GetData("view_ErpUser", dStruct);
  11413. writeGridDataTableJson(dStruct.TotalCount, dt);
  11414. }
  11415. }
  11416. }
  11417. public void change_erp_order_price()
  11418. {
  11419. string ctid = GetPostString("ctid");
  11420. double price = GetPostDouble("price");
  11421. if (ctid.Length > 0)
  11422. {
  11423. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11424. if (ceErpTradeCellExtend == null)
  11425. {
  11426. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11427. ceErpTradeCellExtend.ctid = ctid;
  11428. ceErpTradeCellExtend.payment_cyt = price;
  11429. ceErpTradeCellExtend.Create();
  11430. }
  11431. else
  11432. {
  11433. ceErpTradeCellExtend.payment_cyt = price;
  11434. ceErpTradeCellExtend.Update();
  11435. }
  11436. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11437. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11438. {
  11439. ceErpDataSendOrderInfo.isSync = false;
  11440. ceErpDataSendOrderInfo.Update();
  11441. }
  11442. if (ceErpDataSendOrderInfo == null)
  11443. {
  11444. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11445. ceErpDataSendOrderInfo.isSync = false;
  11446. ceErpDataSendOrderInfo.ctid = ctid;
  11447. ceErpDataSendOrderInfo.Create();
  11448. }
  11449. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11450. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11451. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11452. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11453. {
  11454. dataSendOrderBean dataSendOrderBean = null;
  11455. foreach (DataRow item in dth.Rows)
  11456. {
  11457. try
  11458. {
  11459. dataSendOrderBean = new dataSendOrderBean();
  11460. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11461. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11462. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11463. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11464. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11465. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11466. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11467. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11468. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11469. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11470. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11471. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11472. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11473. if (result != null)
  11474. {
  11475. if ("0".Equals(result.errcode))
  11476. {
  11477. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11478. }
  11479. else
  11480. {
  11481. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11482. }
  11483. }
  11484. }
  11485. catch (Exception ex)
  11486. {
  11487. }
  11488. }
  11489. }
  11490. returnSuccessMsg("修改成功!");
  11491. return;
  11492. }
  11493. returnErrorMsg("找不到订单");
  11494. }
  11495. public void find_he_together()
  11496. {
  11497. string ctid = GetPostString("ctid");
  11498. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11499. List<string> list = new List<string>();
  11500. if (ceErpTradeCell != null)
  11501. {
  11502. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11503. {
  11504. 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);
  11505. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11506. if (table != null && table.Rows.Count > 0)
  11507. {
  11508. foreach (TableRow row in table.Rows)
  11509. {
  11510. }
  11511. }
  11512. }
  11513. }
  11514. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11515. }
  11516. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11517. {
  11518. //chy----19
  11519. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11520. //GD-CYT-----64
  11521. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11522. //ZHX----3
  11523. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11524. //JK----97
  11525. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11526. //ZT----70
  11527. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11528. //GD-CYTUV---126
  11529. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11530. //LHCY-----98
  11531. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11532. //XD-----90
  11533. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11534. //CYCY-----14
  11535. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}},
  11536. //THLZY----122
  11537. {122, new Dictionary<string, string> {{ "烫画", "烫画" }, { "冷转印", "冷转印" }}}
  11538. };
  11539. //其他改名
  11540. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11541. {
  11542. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11543. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11544. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11545. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11546. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11547. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11548. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11549. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" },{ 129,"种子纸"},{ 125,"胶带"},{ 127,"PET透卡"}
  11550. };
  11551. //不统计
  11552. List<int> no_suppliers = new List<int>()
  11553. {
  11554. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11555. };
  11556. //配件单
  11557. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11558. {
  11559. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11560. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11561. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11562. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11563. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11564. {"旗杆",new List<string>(){ "班旗" } },
  11565. {"牙签",new List<string>(){ "不干胶" } }
  11566. };
  11567. public void get_place_order_data()
  11568. {
  11569. string date1 = GetPostString("date1");
  11570. string date2 = GetPostString("date2");
  11571. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11572. DateTime start = DateTime.Parse(starttime);
  11573. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11574. DateTime end = DateTime.Parse(endtime);
  11575. if (date1 != null && date1.Length > 0)
  11576. {
  11577. DateTime dateTime = DateTime.Parse(date1);
  11578. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11579. start = DateTime.Parse(starttime);
  11580. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11581. end = DateTime.Parse(endtime);
  11582. }
  11583. if (date2 != null && date2.Length > 0)
  11584. {
  11585. DateTime dateTime = DateTime.Parse(date2);
  11586. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11587. end = DateTime.Parse(endtime);
  11588. }
  11589. List<int> smSupplier = new List<int>() { 97, 121, 119, 80 };
  11590. string startMonthDate = commonHelper.FirstDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 00:00:00");
  11591. string endMonthDate = commonHelper.LastDayOfMonth(DateTime.Now).ToString("yyyy-MM-dd 23:59:59");
  11592. string sql = string.Format("select SupplierId,ProductId,seller_memo,ProductCount,ProductName,payment,SupplierName,UnusualTime,FinishPlaceTime,OrderState,FinishDeliveryTime,AfterSaleState=0,AfterSaleReason = '',delivery=0 from view_ErpTradeCell where ( ( FinishPlaceTime BETWEEN '{0}' AND '{1}' ) OR ( OrderState = 6 AND UnusualTag = 5 AND IsRefund <= 1 ) ) AND IsSample = 0 and SupplierId > 0 ", starttime, endtime);
  11593. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11594. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState,AfterSaleReason,delivery=0 FROM view_ErpTradeCell WHERE ( AfterSalePreTime BETWEEN '{0}' AND '{1}' ) AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime IS NOT NULL", startMonthDate, endMonthDate);
  11595. DataTable afterSaleData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11596. data.Merge(afterSaleData);
  11597. sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState=0,AfterSaleReason = '',delivery=1 FROM view_ErpTradeCell WHERE orderstate = 6 AND IsSample = 0 AND SupplierId > 0 AND FinishPlaceTime > '2025-11-01 00:00:31.000' AND IsRefund <= 1 AND status = 'NOT_SHIPPED' AND LEN( ProductName ) > 0 AND SupplierId not in (86,10,105,86)", startMonthDate, endMonthDate);
  11598. DataTable deliveryData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11599. data.Merge(deliveryData);
  11600. //不干胶-----1,卡片-----29
  11601. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11602. foreach (DataRow row in data.Rows)
  11603. {
  11604. int productId = Convert.ToInt32(row["ProductId"]);
  11605. string ProductName = row["ProductName"].ToString();
  11606. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11607. if (no_suppliers.Contains(supplierId))
  11608. {
  11609. continue;
  11610. }
  11611. string seller_memo = row["seller_memo"].ToString();
  11612. bool ispj = false;//是否配件单
  11613. bool isfirst = true;//第一个配
  11614. maps.Keys.ForEach(key =>
  11615. {
  11616. //备注包含配件
  11617. if (seller_memo.Contains(key) && isfirst)
  11618. {
  11619. List<string> list = maps[key];
  11620. ispj = true;
  11621. isfirst = false;
  11622. for (int i = 0; i < list.Count; i++)
  11623. {
  11624. if (seller_memo.Contains(list[i]))
  11625. {
  11626. ispj = false;
  11627. break;
  11628. }
  11629. }
  11630. }
  11631. });
  11632. if (ispj)
  11633. {
  11634. continue;
  11635. }
  11636. seller_memo = seller_memo.Replace("UV", "uv");
  11637. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11638. //吊牌归到卡片
  11639. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11640. seller_memo = seller_memo.Replace("卡套", "卡片");
  11641. seller_memo = seller_memo.Replace("封套", "卡片");
  11642. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11643. seller_memo = seller_memo.Replace("腰封", "卡片");
  11644. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11645. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11646. seller_memo = seller_memo.Replace("横幅", "条幅");
  11647. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11648. string map_key = "";
  11649. string type = "";
  11650. if (supplierMap.ContainsKey(supplierId))
  11651. {
  11652. foreach (var kvp in supplierMap[supplierId])
  11653. {
  11654. if (seller_memo.Contains(kvp.Key))
  11655. {
  11656. map_key = kvp.Value;
  11657. type = kvp.Value;
  11658. break;
  11659. }
  11660. }
  11661. }
  11662. if (map_key == "")
  11663. {
  11664. type = ProductName;
  11665. map_key = ProductName;
  11666. if (smSupplier.Contains(supplierId))
  11667. {
  11668. type = "数码";
  11669. map_key = "数码";
  11670. }
  11671. }
  11672. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11673. {
  11674. map_key = suppliers[supplierId];
  11675. }
  11676. map_key += "_" + row["SupplierName"].ToString();
  11677. Dictionary<string, int> map = null;
  11678. if (other_map.ContainsKey(map_key))
  11679. {
  11680. other_map.TryGetValue(map_key, out map);
  11681. }
  11682. else
  11683. {
  11684. map = new Dictionary<string, int>();
  11685. map.Add("dayDev", 0);//当天出货
  11686. map.Add("dayTotal", 0);//下单总数
  11687. map.Add("payTotal", 0);//500以上
  11688. map.Add("today", 0);//当天出货数量
  11689. map.Add("unusua", 0);//异常数
  11690. map.Add("aftersale", 0);//异常数
  11691. map.Add("deliveryNum", 0);//待发货数
  11692. other_map.Add(map_key, map);
  11693. other_map.TryGetValue(map_key, out map);
  11694. }
  11695. int afterSaleState = Convert.ToInt32(row["AfterSaleState"]);
  11696. int delivery = Convert.ToInt32(row["delivery"]);
  11697. if (afterSaleState == 0 && delivery == 0)
  11698. {
  11699. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11700. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11701. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11702. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11703. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11704. {
  11705. map["dayTotal"]++;
  11706. if (supplierId == 97)
  11707. {
  11708. supplierId = 97;
  11709. }
  11710. }
  11711. if (Convert.ToDecimal(row["payment"]) >= 500)
  11712. {
  11713. map["payTotal"]++;
  11714. }
  11715. bool istoday = false;
  11716. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11717. {
  11718. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11719. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11720. {
  11721. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11722. {
  11723. map["today"]++;
  11724. }
  11725. }
  11726. else
  11727. {
  11728. if (supplierId == 80 || supplierId == 126)
  11729. {
  11730. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11731. {
  11732. map["today"]++;
  11733. }
  11734. }
  11735. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11736. {
  11737. map["today"]++;
  11738. istoday = true;
  11739. }
  11740. }
  11741. }
  11742. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11743. {
  11744. map["unusua"]++;
  11745. }
  11746. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11747. //GD-CYT-----64
  11748. DateTime two = palceTimeStart.AddHours(14);
  11749. DateTime three = palceTimeStart.AddHours(15);
  11750. DateTime four = palceTimeStart.AddHours(16);
  11751. DateTime six = palceTimeStart.AddHours(18);
  11752. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11753. {
  11754. //下午四点前 500-1000
  11755. string count = row["ProductCount"].ToString();
  11756. if (count != null && count.Length > 0)
  11757. {
  11758. int productCount = commonHelper.getPlaceProductCount(count);
  11759. if (productCount >= 500 && productCount <= 1000)
  11760. {
  11761. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11762. {
  11763. map["dayDev"]++;
  11764. }
  11765. }
  11766. }
  11767. }
  11768. //UV
  11769. else if ("uv".Equals(type))
  11770. {
  11771. //ZT----70
  11772. //ZHX----3
  11773. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11774. {
  11775. map["dayDev"]++;
  11776. }
  11777. //JK----97
  11778. //HZX----105
  11779. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11780. {
  11781. map["dayDev"]++;
  11782. }
  11783. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11784. {
  11785. map["dayDev"]++;
  11786. }
  11787. }
  11788. //帆布---52|条幅---27
  11789. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11790. {
  11791. //LHCY-----98
  11792. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11793. {
  11794. map["dayDev"]++;
  11795. }
  11796. }
  11797. //条幅
  11798. else if ("条幅".Equals(type))
  11799. {
  11800. //XD-----90
  11801. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11802. {
  11803. map["dayDev"]++;
  11804. }
  11805. }
  11806. //桌布
  11807. else if ("桌布".Equals(type))
  11808. {
  11809. //XD-----90
  11810. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11811. {
  11812. map["dayDev"]++;
  11813. }
  11814. }
  11815. //DL---10
  11816. //AYTW---119
  11817. //FS-CYT-DY ----80
  11818. //JK----97
  11819. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11820. {
  11821. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11822. {
  11823. map["dayDev"]++;
  11824. if (supplierId == 80 && istoday)
  11825. {
  11826. Debug.WriteLine(seller_memo);
  11827. }
  11828. }
  11829. }
  11830. // QC---121
  11831. else if (supplierId == 121)
  11832. {
  11833. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11834. {
  11835. map["dayDev"]++;
  11836. }
  11837. }
  11838. }
  11839. else if (delivery == 0)
  11840. {
  11841. if (row["AfterSaleReason"].ToString().Contains("车间责任"))
  11842. {
  11843. map["aftersale"]++;
  11844. }
  11845. }
  11846. else
  11847. {
  11848. map["deliveryNum"]++;
  11849. }
  11850. }
  11851. DataTable dt = new DataTable();
  11852. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11853. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11854. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11855. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11856. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11857. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11858. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11859. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11860. dt.Columns.Add(new DataColumn("aftersale", typeof(string)));
  11861. dt.Columns.Add(new DataColumn("deliveryNum", typeof(string)));
  11862. other_map.Keys.ForEach(key =>
  11863. {
  11864. DataRow dr = dt.NewRow();
  11865. Dictionary<string, int> map = other_map[key];
  11866. string[] key_list = key.Split('_');
  11867. dr[0] = key_list[0];
  11868. dr[1] = key_list[1];
  11869. if (key_list.Length > 2)
  11870. {
  11871. dr[1] += "(" + key_list[2] + ")";
  11872. }
  11873. dr[2] = map["dayTotal"];
  11874. dr[3] = map["payTotal"];
  11875. dr[4] = map["today"];
  11876. dr[5] = map["unusua"];
  11877. dr[6] = map["dayDev"];
  11878. double rate = 0.00;
  11879. if (map["dayDev"] > 0)
  11880. {
  11881. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11882. }
  11883. dr[7] = rate.ToString();
  11884. dr[8] = map["aftersale"];
  11885. dr[9] = map["deliveryNum"];
  11886. dt.Rows.Add(dr);
  11887. });
  11888. DataView dv = new DataView(dt);
  11889. dv.Sort = "SupplierName";
  11890. //dv.Sort = "ProductName desc";
  11891. DataTable dtNew = dv.ToTable();
  11892. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11893. }
  11894. public void check_order_desing_info()
  11895. {
  11896. string ctid = GetPostString("ctid");
  11897. if (!string.IsNullOrEmpty(ctid))
  11898. {
  11899. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11900. if (ceErpTradeCell != null)
  11901. {
  11902. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11903. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11904. return;
  11905. }
  11906. returnErrorMsg("找不到订单");
  11907. return;
  11908. }
  11909. returnErrorMsg("找不到订单");
  11910. }
  11911. public void get_timeout_detail()
  11912. {
  11913. string poscode = CurrentUser.UserPost.Post.Code;
  11914. DataStruct dStruct = GetPostStruct();
  11915. List<string> lw = new List<string>();
  11916. string id = GetPostString("id");
  11917. string pay_date1 = GetPostString("pay_date1");
  11918. string pay_date2 = GetPostString("pay_date2");
  11919. int type = GetPostInt("type");
  11920. if (type == 0)
  11921. {
  11922. if (pay_date1.Length > 0)
  11923. {
  11924. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11925. }
  11926. if (pay_date2.Length > 0)
  11927. {
  11928. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11929. }
  11930. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11931. }
  11932. if (type == 1)
  11933. {
  11934. if (pay_date1.Length > 0)
  11935. {
  11936. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11937. }
  11938. if (pay_date2.Length > 0)
  11939. {
  11940. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11941. }
  11942. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11943. }
  11944. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11945. DataTable dt = null;
  11946. dt = WebCache.GetData("view_orderlist", dStruct);
  11947. writeGridDataTableJson(dStruct.TotalCount, dt);
  11948. }
  11949. public void saveUrgentChargePrice()
  11950. {
  11951. string ctid = GetPostString("ctid");
  11952. if (!string.IsNullOrEmpty(ctid))
  11953. {
  11954. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11955. if (ceErpTradeCell != null)
  11956. {
  11957. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11958. if (prices <= 100)
  11959. {
  11960. returnErrorMsg("此订单金额不足100元,无法加急。");
  11961. return;
  11962. }
  11963. double price = GetPostDouble("price");
  11964. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11965. if (ceErpTradeCellExtend == null)
  11966. {
  11967. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11968. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11969. }
  11970. ceErpTradeCellExtend.urgentCharge = price;
  11971. if (ceErpTradeCellExtend.ID > 0)
  11972. {
  11973. ceErpTradeCellExtend.Update();
  11974. }
  11975. else
  11976. {
  11977. ceErpTradeCellExtend.Save();
  11978. }
  11979. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11980. returnSuccessMsg("修改成功!");
  11981. return;
  11982. }
  11983. returnErrorMsg("找不到订单");
  11984. return;
  11985. }
  11986. returnErrorMsg("找不到订单");
  11987. }
  11988. public void finish_erp_order()
  11989. {
  11990. string ctid = GetPostString("ctid");
  11991. if (!string.IsNullOrEmpty(ctid))
  11992. {
  11993. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11994. {
  11995. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11996. if (ceErpTradeCell != null)
  11997. {
  11998. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11999. ceErpTradeCell.Update();
  12000. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  12001. returnSuccessMsg("修改成功!");
  12002. return;
  12003. }
  12004. }
  12005. }
  12006. returnErrorMsg("找不到订单");
  12007. }
  12008. public void get_trade_order_list()
  12009. {
  12010. string tid = GetPostString("tid");
  12011. if (!string.IsNullOrEmpty(tid))
  12012. {
  12013. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  12014. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12015. writeGridDataTableJson(data.Rows.Count, data);
  12016. return;
  12017. }
  12018. returnErrorMsg("找不到订单");
  12019. }
  12020. public void save_cell_spu()
  12021. {
  12022. string ctid = GetPostString("ctid");
  12023. string spu_id = GetPostString("spu_id");
  12024. if (!string.IsNullOrEmpty(ctid))
  12025. {
  12026. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12027. if (ceErpTradeCellExtend == null)
  12028. {
  12029. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12030. ceErpTradeCellExtend.ctid = ctid;
  12031. }
  12032. ceErpTradeCellExtend.spu_id = spu_id;
  12033. if (!string.IsNullOrEmpty(spu_id))
  12034. {
  12035. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12036. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  12037. }
  12038. if (ceErpTradeCellExtend.ID == 0)
  12039. {
  12040. ceErpTradeCellExtend.Create();
  12041. }
  12042. else
  12043. {
  12044. ceErpTradeCellExtend.Update();
  12045. }
  12046. returnSuccessMsg("修改成功!");
  12047. return;
  12048. }
  12049. returnErrorMsg("找不到订单");
  12050. }
  12051. public void change_express_info()
  12052. {
  12053. string ctid = GetPostString("ctid");
  12054. string transNo = GetPostString("transNo");
  12055. string transCom = GetPostString("transCom");
  12056. if (!string.IsNullOrEmpty(ctid))
  12057. {
  12058. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12059. if (ceErpTradeCellExtend == null)
  12060. {
  12061. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12062. ceErpTradeCellExtend.ctid = ctid;
  12063. }
  12064. ceErpTradeCellExtend.modExpressNo = transNo;
  12065. ceErpTradeCellExtend.modExpressCom = transCom;
  12066. ceErpTradeCellExtend.readMod = 2;
  12067. if (ceErpTradeCellExtend.ID == 0)
  12068. {
  12069. ceErpTradeCellExtend.Create();
  12070. }
  12071. else
  12072. {
  12073. ceErpTradeCellExtend.Update();
  12074. }
  12075. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  12076. returnSuccessMsg("修改成功!");
  12077. return;
  12078. }
  12079. returnErrorMsg("找不到订单");
  12080. }
  12081. public void get_change_express_list()
  12082. {
  12083. DataStruct dStruct = GetPostStruct();
  12084. List<string> lw = new List<string>();
  12085. int st = 2;
  12086. string tid = GetPostString("ctid");
  12087. if (tid.Length > 0)
  12088. {
  12089. string select_tid = getTidByCtid(tid);
  12090. lw.Add(string.Format("tid='{0}'", select_tid));
  12091. }
  12092. string shopname = GetPostString("shopname");
  12093. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12094. string buyernick = GetPostString("buyer_nick");
  12095. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12096. string sellermemo = GetPostString("seller_memo");
  12097. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12098. string supplier = GetPostString("supplier");
  12099. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12100. string customer = GetPostString("customer");
  12101. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12102. string design = GetPostString("design");
  12103. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12104. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12105. string poscode = CurrentUser.UserPost.Post.Code;
  12106. if (poscode != "SysAdmin")
  12107. {
  12108. string shopid = CurrentUser.User.pemShop;
  12109. lw.Add(string.Format("shopId in ({0})", shopid));
  12110. }
  12111. lw.Add("readMod = 2");
  12112. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12113. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  12114. writeGridDataTableJson(dStruct.TotalCount, dt);
  12115. }
  12116. public void deal_express_complete()
  12117. {
  12118. string ctid = GetPostString("ctid");
  12119. if (!string.IsNullOrEmpty(ctid))
  12120. {
  12121. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12122. if (ceErpTradeCellExtend == null)
  12123. {
  12124. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12125. ceErpTradeCellExtend.ctid = ctid;
  12126. }
  12127. ceErpTradeCellExtend.readMod = 1;
  12128. if (ceErpTradeCellExtend.ID == 0)
  12129. {
  12130. ceErpTradeCellExtend.Create();
  12131. }
  12132. else
  12133. {
  12134. ceErpTradeCellExtend.Update();
  12135. }
  12136. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12137. returnSuccessMsg("修改成功!");
  12138. return;
  12139. }
  12140. returnErrorMsg("找不到订单");
  12141. }
  12142. public void aftersale_return_visit()
  12143. {
  12144. string ctid = GetPostString("ctid");
  12145. if (!string.IsNullOrEmpty(ctid))
  12146. {
  12147. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12148. if (ceErpTradeCellExtend == null)
  12149. {
  12150. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12151. ceErpTradeCellExtend.ctid = ctid;
  12152. }
  12153. ceErpTradeCellExtend.returnVisit = 1;
  12154. if (ceErpTradeCellExtend.ID == 0)
  12155. {
  12156. ceErpTradeCellExtend.Create();
  12157. }
  12158. else
  12159. {
  12160. ceErpTradeCellExtend.Update();
  12161. }
  12162. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12163. if (ceErpTradeAfterSaleExtend != null)
  12164. {
  12165. ceErpTradeAfterSaleExtend.TextResult = "";
  12166. ceErpTradeAfterSaleExtend.Update();
  12167. }
  12168. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12169. returnSuccessMsg("修改成功!");
  12170. return;
  12171. }
  12172. returnErrorMsg("找不到订单");
  12173. }
  12174. public void orderPlaceInfo()
  12175. {
  12176. string ctids = GetPostString("ctids");
  12177. string[] list = ctids.Split(',');
  12178. foreach (string ctid in list)
  12179. {
  12180. CeErpSukuraData.createInfo(ctid, 3);
  12181. }
  12182. StringBuilder sql = new StringBuilder();
  12183. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12184. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12185. designHelper.api_approveDesign(ctids); //approveDesign
  12186. returnSuccessMsg("");
  12187. }
  12188. public void get_issue_list()
  12189. {
  12190. DataStruct dStruct = GetPostStruct();
  12191. List<string> lw = new List<string>();
  12192. int st = 2;
  12193. string tid = GetPostString("ctid");
  12194. if (tid.Length > 0)
  12195. {
  12196. string select_tid = getTidByCtid(tid);
  12197. lw.Add(string.Format("tid='{0}'", select_tid));
  12198. }
  12199. string shopname = GetPostString("shopname");
  12200. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12201. string buyernick = GetPostString("buyer_nick");
  12202. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12203. string sellermemo = GetPostString("seller_memo");
  12204. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12205. string supplier = GetPostString("supplier");
  12206. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12207. string customer = GetPostString("customer");
  12208. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12209. string design = GetPostString("design");
  12210. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12211. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12212. string poscode = CurrentUser.UserPost.Post.Code;
  12213. if (poscode != "SysAdmin")
  12214. {
  12215. string shopid = CurrentUser.User.pemShop;
  12216. lw.Add(string.Format("shopId in ({0})", shopid));
  12217. }
  12218. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12219. {
  12220. lw.Add("IssueState = 1");
  12221. }
  12222. else
  12223. {
  12224. string iisstate = GetPostString("iisstate");
  12225. if ("1".Equals(iisstate))
  12226. {
  12227. lw.Add("IssueState =1");
  12228. }
  12229. else if ("2".Equals(iisstate))
  12230. {
  12231. lw.Add("IssueState = 2");
  12232. }
  12233. else
  12234. {
  12235. lw.Add("IssueState > 0");
  12236. }
  12237. }
  12238. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12239. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12240. writeGridDataTableJson(dStruct.TotalCount, dt);
  12241. }
  12242. public void saveIssueContent()
  12243. {
  12244. string ctid = GetPostString("ctid");
  12245. if (!string.IsNullOrEmpty(ctid))
  12246. {
  12247. string content = GetPostString("content");
  12248. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12249. if (ceErpTradeAfterSaleExtend == null)
  12250. {
  12251. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12252. ceErpTradeAfterSaleExtend.tid = ctid;
  12253. }
  12254. ceErpTradeAfterSaleExtend.IssueContent = content;
  12255. ceErpTradeAfterSaleExtend.IssueState = 1;
  12256. if (ceErpTradeAfterSaleExtend.ID > 0)
  12257. {
  12258. ceErpTradeAfterSaleExtend.Update();
  12259. }
  12260. else
  12261. {
  12262. ceErpTradeAfterSaleExtend.Create();
  12263. }
  12264. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12265. returnSuccessMsg("添加成功!");
  12266. return;
  12267. }
  12268. returnErrorMsg("找不到订单");
  12269. }
  12270. public void dealIssueContent()
  12271. {
  12272. string ctid = GetPostString("ctid");
  12273. if (!string.IsNullOrEmpty(ctid))
  12274. {
  12275. string content = GetPostString("content");
  12276. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12277. if (ceErpTradeAfterSaleExtend != null)
  12278. {
  12279. ceErpTradeAfterSaleExtend.IssueState = 2;
  12280. ceErpTradeAfterSaleExtend.Update();
  12281. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12282. returnSuccessMsg("修改完成!");
  12283. return;
  12284. }
  12285. }
  12286. returnErrorMsg("找不到订单");
  12287. }
  12288. public void set_tid_attachments()
  12289. {
  12290. string tid = GetPostString("tid");
  12291. string atta = GetPostString("atta");
  12292. if (!string.IsNullOrEmpty(tid))
  12293. {
  12294. if (string.IsNullOrEmpty(atta))
  12295. {
  12296. returnErrorMsg("文件地址为空");
  12297. return;
  12298. }
  12299. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12300. if (ceErpTradeCell != null)
  12301. {
  12302. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12303. if (ceErpTrade == null)
  12304. {
  12305. returnErrorMsg("找不到订单");
  12306. return;
  12307. }
  12308. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12309. bool isSend = false;
  12310. if (dt != null && dt.Rows.Count > 0)
  12311. {
  12312. foreach (DataRow row in dt.Rows)
  12313. {
  12314. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12315. {
  12316. isSend = true;
  12317. }
  12318. }
  12319. if (isSend)
  12320. {
  12321. returnErrorMsg("已发货无法修改");
  12322. return;
  12323. }
  12324. ceErpTrade.Attachments = atta;
  12325. ceErpTrade.Update();
  12326. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12327. returnSuccessMsg("上传成功!");
  12328. return;
  12329. }
  12330. }
  12331. }
  12332. returnErrorMsg("找不到订单");
  12333. }
  12334. public void get_tid_attachments()
  12335. {
  12336. string tid = GetPostString("tid");
  12337. if (!string.IsNullOrEmpty(tid))
  12338. {
  12339. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12340. if (ceErpTradeCell != null)
  12341. {
  12342. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12343. if (ceErpTrade == null)
  12344. {
  12345. returnErrorMsg("找不到订单");
  12346. return;
  12347. }
  12348. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12349. return;
  12350. }
  12351. }
  12352. returnErrorMsg("找不到订单");
  12353. }
  12354. public void check_erp_sameorders()
  12355. {
  12356. if (UrlPostParmsCheck("ctid"))
  12357. {
  12358. string eid = GetPostString("ctid");
  12359. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12360. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12361. if (entity != null && ceErpTrade != null)
  12362. {
  12363. if (entity.OrderState > 6)
  12364. {
  12365. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12366. return;
  12367. }
  12368. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12369. List<string> ids = new List<string>();
  12370. if (dt != null && dt.Rows.Count > 1)
  12371. {
  12372. bool needhe = true;
  12373. foreach (DataRow dr in dt.Rows)
  12374. {
  12375. ids.Add("'" + dr["ctid"] + "'");
  12376. /* //备注有合包
  12377. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12378. {
  12379. needhe = true;
  12380. }
  12381. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12382. {
  12383. needhe = true;
  12384. }
  12385. //顺丰快递
  12386. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12387. {
  12388. needhe = true;
  12389. }*/
  12390. }
  12391. if (!needhe)
  12392. {
  12393. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12394. return;
  12395. }
  12396. StringBuilder sql = new StringBuilder();
  12397. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12398. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12399. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12400. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12401. foreach (DataRow dr in dt.Rows)
  12402. {
  12403. dr["dstate"] = 0;
  12404. dr["dnumber"] = 0;
  12405. foreach (DataRow row in dt1.Rows)
  12406. {
  12407. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12408. {
  12409. dr["dstate"] = 2;
  12410. dr["default"] = 1;
  12411. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12412. }
  12413. }
  12414. if (eid.Equals(dr["ctid"].ToString()))
  12415. {
  12416. dr["dstate"] = 1;
  12417. dr["default"] = 1;
  12418. }
  12419. }
  12420. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12421. return;
  12422. }
  12423. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12424. return;
  12425. }
  12426. returnErrorMsg("未找到订单");
  12427. return;
  12428. }
  12429. returnErrorMsg("缺少必要的参数");
  12430. }
  12431. public void get_mark_number()
  12432. {
  12433. string eid = GetPostString("ctid");
  12434. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12435. if (entity != null)
  12436. {
  12437. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12438. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12439. int current = 1;
  12440. if (ceErpDeliverMark == null)
  12441. {
  12442. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12443. List<string> ids = new List<string>();
  12444. if (dt != null && dt.Rows.Count > 1)
  12445. {
  12446. foreach (DataRow dr in dt.Rows)
  12447. {
  12448. ids.Add("'" + dr["ctid"] + "'");
  12449. }
  12450. //查询已有的编号
  12451. StringBuilder sql = new StringBuilder();
  12452. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12453. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12454. if (dt1 == null || dt1.Rows.Count == 0)
  12455. {
  12456. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12457. List<int> list_number = new List<int>();
  12458. foreach (DataRow row in numbers.Rows)
  12459. {
  12460. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12461. }
  12462. //查询空余编号
  12463. for (int i = 0; i < list_number.Count + 2; i++)
  12464. {
  12465. if (!list_number.Contains(current))
  12466. {
  12467. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12468. //防止查询过程中有新数据生成
  12469. if (ceErpDeliverMark1 == null)
  12470. {
  12471. break;
  12472. }
  12473. }
  12474. current++;
  12475. }
  12476. }
  12477. else
  12478. {
  12479. foreach (DataRow row in dt1.Rows)
  12480. {
  12481. current = Convert.ToInt32(row["markNumber"]);
  12482. }
  12483. }
  12484. ceErpDeliverMark = new CeErpDeliverMark();
  12485. ceErpDeliverMark.ctid = eid;
  12486. ceErpDeliverMark.createtime = DateTime.Now;
  12487. if (ceErpTrade != null)
  12488. {
  12489. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12490. }
  12491. ceErpDeliverMark.markNumber = current;
  12492. ceErpDeliverMark.Create();
  12493. }
  12494. }
  12495. else
  12496. {
  12497. current = ceErpDeliverMark.markNumber;
  12498. }
  12499. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12500. return;
  12501. }
  12502. }
  12503. public void aftersaleCytSend()
  12504. {
  12505. string ctid = GetPostString("ctid");
  12506. if (!string.IsNullOrEmpty(ctid))
  12507. {
  12508. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12509. if (ceErpTradeCell != null)
  12510. {
  12511. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12512. }
  12513. returnSuccessMsg("推送成功");
  12514. return;
  12515. }
  12516. returnErrorMsg("缺少必要的参数");
  12517. }
  12518. public void packOrderInfo()
  12519. {
  12520. string ctids = GetPostString("ctids");
  12521. if (!string.IsNullOrEmpty(ctids))
  12522. {
  12523. string[] ctid_list = ctids.Split(',');
  12524. if (ctid_list.Length > 20)
  12525. {
  12526. returnErrorMsg("单次下载次数不能超过20个");
  12527. return;
  12528. }
  12529. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12530. StringBuilder sql = new StringBuilder();
  12531. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12532. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12533. int supplierId = 0;
  12534. StringBuilder insterSql = new StringBuilder();
  12535. for (int i = 0; i < dt.Rows.Count; i++)
  12536. {
  12537. DataRow row = dt.Rows[i];
  12538. if (i == 0)
  12539. {
  12540. supplierId = Convert.ToInt32(row["SupplierId"]);
  12541. }
  12542. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12543. {
  12544. returnErrorMsg("同车间的订单才能一起打包");
  12545. return;
  12546. }
  12547. int orderState = Convert.ToInt32(row["OrderState"]);
  12548. if (orderState != 5)
  12549. {
  12550. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12551. return;
  12552. }
  12553. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12554. }
  12555. CeErpPackData ceErpPackData = new CeErpPackData();
  12556. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12557. ceErpPackData.supplierId = supplierId;
  12558. ceErpPackData.createtime = DateTime.Now;
  12559. ceErpPackData.createBy = CurrentUser.UserID;
  12560. ceErpPackData.createName = CurrentUser.UserName;
  12561. ceErpPackData.Create();
  12562. if (ceErpPackData.ID > 0)
  12563. {
  12564. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12565. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12566. }
  12567. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12568. returnSuccessMsg("打包成功");
  12569. return;
  12570. }
  12571. returnErrorMsg("缺少必要的参数");
  12572. }
  12573. public void rePackOrderInfo()
  12574. {
  12575. string id = GetPostString("id");
  12576. if (!string.IsNullOrEmpty(id))
  12577. {
  12578. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12579. if (ceErpPackData == null)
  12580. {
  12581. returnSuccessMsg("查无数据");
  12582. return;
  12583. }
  12584. ceErpPackData.upStatus = 0;
  12585. ceErpPackData.message = "";
  12586. ceErpPackData.Update();
  12587. returnSuccessMsg("打包成功");
  12588. return;
  12589. }
  12590. returnErrorMsg("缺少必要的参数");
  12591. }
  12592. public void backPackOrderInfo()
  12593. {
  12594. string id = GetPostString("id");
  12595. if (!string.IsNullOrEmpty(id))
  12596. {
  12597. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12598. if (ceErpPackData == null)
  12599. {
  12600. returnSuccessMsg("查无数据");
  12601. return;
  12602. }
  12603. ceErpPackData.upStatus = 4;
  12604. ceErpPackData.Update();
  12605. List<string> list = new List<string>();
  12606. StringBuilder sql = new StringBuilder();
  12607. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12608. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12609. for (int i = 0; i < dt.Rows.Count; i++)
  12610. {
  12611. DataRow row = dt.Rows[i];
  12612. list.Add("'" + row["ctid"].ToString() + "'");
  12613. }
  12614. string textCtids = string.Join(",", list);
  12615. 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));
  12616. 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, "无法打包退回"));
  12617. returnSuccessMsg("退回成功");
  12618. return;
  12619. }
  12620. returnErrorMsg("缺少必要的参数");
  12621. }
  12622. public void addPackDownNum()
  12623. {
  12624. string id = GetPostString("id");
  12625. if (!string.IsNullOrEmpty(id))
  12626. {
  12627. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12628. returnSuccessMsg("下载成功");
  12629. return;
  12630. }
  12631. returnErrorMsg("缺少必要的参数");
  12632. }
  12633. public void get_pack_list()
  12634. {
  12635. DataStruct dStruct = GetPostStruct();
  12636. List<string> lw = new List<string>();
  12637. string supplier = GetPostString("supplier");
  12638. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12639. string posTag = CurrentUser.UserPost.Post.Code;
  12640. if (posTag == "Supplier")
  12641. {
  12642. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12643. }
  12644. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12645. dStruct.Order = "createtime desc";
  12646. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12647. writeGridDataTableJson(dStruct.TotalCount, dt);
  12648. }
  12649. public void get_pack_order_list()
  12650. {
  12651. string packId = GetPostString("packId");
  12652. if (string.IsNullOrEmpty(packId))
  12653. {
  12654. returnErrorMsg("缺少必要的参数");
  12655. return;
  12656. }
  12657. StringBuilder sql = new StringBuilder();
  12658. 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);
  12659. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12660. if (dt == null || dt.Rows.Count == 0)
  12661. {
  12662. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12663. return;
  12664. }
  12665. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12666. return;
  12667. }
  12668. public void get_supplier_product_time_list()
  12669. {
  12670. DataStruct dStruct = GetPostStruct();
  12671. List<string> lw = new List<string>();
  12672. string txtKey = GetPostString("txtKey");
  12673. if (txtKey.Length > 0)
  12674. {
  12675. lw.Add(string.Format("(supplierName = '{0}' or productName like '%{0}%')", txtKey));
  12676. }
  12677. string posTag = CurrentUser.UserPost.Post.Code;
  12678. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12679. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12680. writeGridDataTableJson(dStruct.TotalCount, dt);
  12681. }
  12682. public void saveSupplierProductTime()
  12683. {
  12684. string productId = GetPostString("productId");
  12685. if (string.IsNullOrEmpty(productId))
  12686. {
  12687. returnErrorMsg("缺少必要的参数");
  12688. return;
  12689. }
  12690. string productName = GetPostString("productName");
  12691. int supplierId = GetPostInt("supplierId");
  12692. if (supplierId == 0)
  12693. {
  12694. returnErrorMsg("缺少必要的参数");
  12695. return;
  12696. }
  12697. int quantity = GetPostInt("quantity");
  12698. int sendDay = GetPostInt("sendTime");
  12699. string supplierName = GetPostString("supplierName");
  12700. string craft = GetPostString("craft");
  12701. string deadLine = GetPostString("deadLine");
  12702. string dayDeadLine = GetPostString("dayDeadLine");
  12703. try
  12704. {
  12705. int eid = GetPostInt("eid");
  12706. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12707. if (ceErpSupplierProductTime == null)
  12708. {
  12709. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12710. }
  12711. ceErpSupplierProductTime.productId = productId;
  12712. ceErpSupplierProductTime.productName = productName;
  12713. ceErpSupplierProductTime.supplierId = supplierId;
  12714. ceErpSupplierProductTime.supplierName = supplierName;
  12715. ceErpSupplierProductTime.craft = craft;
  12716. ceErpSupplierProductTime.sendDay = sendDay;
  12717. ceErpSupplierProductTime.quantity = quantity;
  12718. if (!string.IsNullOrEmpty(deadLine))
  12719. {
  12720. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12721. }
  12722. if (!string.IsNullOrEmpty(dayDeadLine))
  12723. {
  12724. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12725. }
  12726. if (ceErpSupplierProductTime.ID == 0)
  12727. {
  12728. ceErpSupplierProductTime.Save();
  12729. }
  12730. else
  12731. {
  12732. ceErpSupplierProductTime.Update();
  12733. }
  12734. }
  12735. catch (Exception e)
  12736. {
  12737. }
  12738. returnSuccessMsg("保存成功");
  12739. return;
  12740. }
  12741. public void delSupplierProductTime()
  12742. {
  12743. int eid = GetPostInt("eid");
  12744. if (eid > 0)
  12745. {
  12746. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12747. if (ceErpSupplierProductTime == null)
  12748. {
  12749. returnErrorMsg("查无数据");
  12750. return;
  12751. }
  12752. ceErpSupplierProductTime.Delete();
  12753. returnSuccessMsg("保存成功");
  12754. return;
  12755. }
  12756. returnErrorMsg("缺少必要的参数");
  12757. }
  12758. public void getExpressInfo()
  12759. {
  12760. string ctid = GetPostString("ctid");
  12761. if (!string.IsNullOrEmpty(ctid))
  12762. {
  12763. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12764. if (ceErpTradeCell != null)
  12765. {
  12766. string outSid = ceErpTradeCell.OutSid;
  12767. if (outSid.Length > 0)
  12768. {
  12769. 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);
  12770. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12771. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12772. return;
  12773. }
  12774. }
  12775. returnErrorMsg("查无记录");
  12776. return;
  12777. }
  12778. returnErrorMsg("缺少必要的参数");
  12779. }
  12780. public void getExpressPostData()
  12781. {
  12782. string express = GetPostString("express");
  12783. if (!string.IsNullOrEmpty(express))
  12784. {
  12785. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12786. if (ceErpExpressInfo != null)
  12787. {
  12788. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12789. return;
  12790. }
  12791. }
  12792. returnErrorMsg("缺少必要的参数");
  12793. }
  12794. public void checkSupplierOrder()
  12795. {
  12796. string ctids = GetPostString("ctids");
  12797. if (ctids != null)
  12798. {
  12799. List<string> list = new List<string>();
  12800. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12801. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12802. for (int i = 0; i < dt.Rows.Count; i++)
  12803. {
  12804. DataRow row = dt.Rows[i];
  12805. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12806. {
  12807. continue;
  12808. }
  12809. list.Add(row["seller_memo"].ToString());
  12810. }
  12811. if (list.Count > 0)
  12812. {
  12813. 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, "点击下载按钮"));
  12814. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12815. return;
  12816. }
  12817. }
  12818. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12819. return;
  12820. }
  12821. public void addPersonId()
  12822. {
  12823. string tid = GetPostString("tid");
  12824. string personId = GetPostString("personId");
  12825. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12826. if (ceErpTrade != null)
  12827. {
  12828. ceErpTrade.receiver_zip = personId;
  12829. ceErpTrade.Update();
  12830. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12831. returnSuccessMsg("保存成功");
  12832. return;
  12833. }
  12834. returnErrorMsg("缺少必要的参数");
  12835. }
  12836. public void addDeliveryPaymant()
  12837. {
  12838. string tid = GetPostString("tid");
  12839. string paymant = GetPostString("paymant");
  12840. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12841. if (ceErpTrade != null)
  12842. {
  12843. if (!string.IsNullOrEmpty(paymant))
  12844. {
  12845. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12846. }
  12847. ceErpTrade.Update();
  12848. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12849. returnSuccessMsg("保存成功");
  12850. return;
  12851. }
  12852. returnErrorMsg("缺少必要的参数");
  12853. }
  12854. public void saveCellFile()
  12855. {
  12856. string tid = GetPostString("tid");
  12857. string ctid = GetPostString("ctid");
  12858. string urls = GetPostString("urls");
  12859. string type = GetPostString("type");
  12860. string del = GetPostString("del");
  12861. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12862. {
  12863. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  12864. {
  12865. ctid = tid;
  12866. }
  12867. if ("1".Equals(del))
  12868. {
  12869. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12870. }
  12871. string[] list = urls.Split(',');
  12872. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12873. {
  12874. foreach (string item in list)
  12875. {
  12876. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12877. ceErpTradeCellFile.Create();
  12878. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12879. }
  12880. }
  12881. returnSuccessMsg("保存成功");
  12882. return;
  12883. }
  12884. returnErrorMsg("缺少必要的参数");
  12885. }
  12886. public void getCellFile()
  12887. {
  12888. string tid = GetPostString("tid");
  12889. string ctid = GetPostString("ctid");
  12890. string type = GetPostString("type");
  12891. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12892. {
  12893. if (tradeCellFile == TradeCellFile.AUTH_FILE)
  12894. {
  12895. ctid = tid;
  12896. }
  12897. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12898. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12899. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12900. return;
  12901. }
  12902. returnErrorMsg("缺少必要的参数");
  12903. }
  12904. public void delCellFile()
  12905. {
  12906. string id = GetPostString("id");
  12907. if (string.IsNullOrEmpty(id))
  12908. {
  12909. returnErrorMsg("缺少必要的参数");
  12910. return;
  12911. }
  12912. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12913. CeErpTradeCellFile.delByID(id);
  12914. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12915. returnSuccessMsg("保存成功");
  12916. }
  12917. public void getInvoiceOrder()
  12918. {
  12919. string tid = GetPostString("tid");
  12920. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12921. List<string> tids = new List<string>();
  12922. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  12923. {
  12924. 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);
  12925. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12926. foreach (DataRow dr in dt.Rows)
  12927. {
  12928. tids.Add("'" + dr["tid"].ToString() + "'");
  12929. }
  12930. }
  12931. else
  12932. {
  12933. tids.Add("'" + ceErpTrade.tid + "'");
  12934. }
  12935. DataTable cell_dt = new DataTable();
  12936. if (tids.Count > 0)
  12937. {
  12938. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  12939. }
  12940. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  12941. return;
  12942. }
  12943. public void getOrderLogInfo()
  12944. {
  12945. string ctid = GetPostString("ctid");
  12946. if (!string.IsNullOrEmpty(ctid))
  12947. {
  12948. StringBuilder sql = new StringBuilder();
  12949. sql.AppendFormat("select * from view_erptradelog where tid='{0}' order by id;", ctid);
  12950. DataSet ds = DbHelper.DbConn.ExecuteDataset(sql.ToString());
  12951. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(ds.Tables[0])) + "}");
  12952. return;
  12953. }
  12954. returnErrorMsg("缺少必要的参数");
  12955. }
  12956. public void setCellTeampId()
  12957. {
  12958. string ctid = GetPostString("ctid");
  12959. string tempId = GetPostString("tempId");
  12960. if (!string.IsNullOrEmpty(ctid))
  12961. {
  12962. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12963. if (ceErpTradeCellExtend == null)
  12964. {
  12965. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12966. ceErpTradeCellExtend.ctid = ctid;
  12967. }
  12968. ceErpTradeCellExtend.tempId = tempId;
  12969. if (ceErpTradeCellExtend.ID > 0)
  12970. {
  12971. ceErpTradeCellExtend.Update();
  12972. }
  12973. else
  12974. {
  12975. ceErpTradeCellExtend.Create();
  12976. }
  12977. designHelper.API_sendTempInfo(ctid, tempId);
  12978. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "修改模板id" + tempId, 6);
  12979. returnSuccessMsg("保存成功");
  12980. return;
  12981. }
  12982. returnErrorMsg("缺少必要的参数");
  12983. }
  12984. }
  12985. }